void s_RTF_ListenerGetProps::_compute_span_properties(const PP_AttrProp * pSpanAP, const PP_AttrProp * pBlockAP, const PP_AttrProp * pSectionAP) { // see if we have a previously unused color reference. const gchar * szColor = PP_evalProperty("color",pSpanAP,pBlockAP,pSectionAP,m_pDocument,true); UT_sint32 ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); szColor = PP_evalProperty("bgcolor",pSpanAP,pBlockAP,pSectionAP,m_pDocument,true); if (g_ascii_strcasecmp (szColor, "transparent") != 0) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } // also check the revision attribute _check_revs_for_color(pSpanAP, pBlockAP, pSectionAP); // convert our font properties into an item for the rtf font table. // in this pass thru the document we are just collecting all the // info that we need to put into the rtf header, so we can't just // write it out now. so, we build a vector of the stuff we want // to write (and make sure it's unique). UT_sint32 ndxFont; { _rtf_font_info fi; if (fi.init(s_RTF_AttrPropAdapter_AP(pSpanAP,pBlockAP,pSectionAP,m_pDocument))) { ndxFont = m_pie->_findFont(&fi); if (ndxFont == -1) m_pie->_addFont(&fi); } } // // Look in field-font too // { _rtf_font_info fii; if (fii.init(s_RTF_AttrPropAdapter_AP(pSpanAP,pBlockAP,pSectionAP,m_pDocument),true)) { ndxFont = m_pie->_findFont(&fii); if (ndxFont == -1) m_pie->_addFont(&fii); } } // also check the revision attribute _check_revs_for_font(pSpanAP, pBlockAP, pSectionAP); }
void s_XSL_FO_Listener::_handlePageSize(PT_AttrPropIndex api) { // // Code to write out the PageSize Definitions to disk // const PP_AttrProp * pAP = NULL; bool bHaveProp = m_pDocument->getAttrProp(api,&pAP); UT_LocaleTransactor t(LC_NUMERIC, "C"); UT_UTF8String master = "simple-page-master"; _tagOpen(TT_LAYOUT_MASTER_SET, "layout-master-set"); // query and output properties // todo - validate these and make sure they all make sense if (bHaveProp && pAP) { const gchar * szValue = NULL; szValue = PP_evalProperty("page-margin-top", NULL, NULL, pAP, m_pDocument, true); if(szValue) { master += " margin-top=\""; master += szValue; master += "\""; } szValue = PP_evalProperty("page-margin-bottom", NULL, NULL, pAP, m_pDocument, true); if(szValue) { master += " margin-bottom=\""; master += szValue; master += "\""; } szValue = PP_evalProperty("page-margin-left", NULL, NULL, pAP, m_pDocument, true); if(szValue) { master += " margin-left=\""; master += szValue; master += "\""; } szValue = PP_evalProperty("page-margin-right", NULL, NULL, pAP, m_pDocument, true); if(szValue) { master += " margin-right=\""; master += szValue; master += "\""; } UT_Dimension docUnit = m_pDocument->m_docPageSize.getDims(); UT_UTF8String buf; // page-width, page-height UT_UTF8String_sprintf(buf, " page-width=\"%f%s\"", m_pDocument->m_docPageSize.Width(docUnit), UT_dimensionName(docUnit)); master += buf; buf.clear(); UT_UTF8String_sprintf(buf, " page-height=\"%f%s\"", m_pDocument->m_docPageSize.Height(docUnit), UT_dimensionName(docUnit)); master += buf; } master += " master-name=\"first\""; _tagOpen(TT_SIMPLE_PAGE_MASTER, master); m_pie->write("\t"); _tagOpenClose("region-body"); _tagClose(TT_SIMPLE_PAGE_MASTER, "simple-page-master"); _tagClose(TT_LAYOUT_MASTER_SET, "layout-master-set"); m_pie->write("\n"); m_bFirstWrite = false; }
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(); }
void s_RTF_ListenerGetProps::_searchCellAPI(PT_AttrPropIndex api) { const PP_AttrProp * pCellAP = NULL; m_pDocument->getAttrProp(api,&pCellAP); const gchar * szColor = NULL; UT_sint32 ndxColor; // top szColor = PP_evalProperty("top-color",pCellAP,NULL,NULL,m_pDocument,true); if (szColor && (g_ascii_strcasecmp (szColor, "transparent") != 0) && (g_ascii_strcasecmp (szColor, "inherit") != 0) ) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } // left szColor = PP_evalProperty("left-color",pCellAP,NULL,NULL,m_pDocument,true); if (szColor && (g_ascii_strcasecmp (szColor, "transparent") != 0) && (g_ascii_strcasecmp (szColor, "inherit") != 0) ) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } // right szColor = PP_evalProperty("right-color",pCellAP,NULL,NULL,m_pDocument,true); if (szColor && (g_ascii_strcasecmp (szColor, "transparent") != 0) && (g_ascii_strcasecmp (szColor, "inherit") != 0) ) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } // Bottom szColor = PP_evalProperty("bot-color",pCellAP,NULL,NULL,m_pDocument,true); if (szColor && (g_ascii_strcasecmp (szColor, "transparent") != 0) && (g_ascii_strcasecmp (szColor, "inherit") != 0) ) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } // Background szColor = PP_evalProperty("background-color",pCellAP,NULL,NULL,m_pDocument,true); if (szColor && (g_ascii_strcasecmp (szColor, "transparent") != 0) && (g_ascii_strcasecmp (szColor, "inherit") != 0) ) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } }
bool s_RTF_ListenerGetProps::populateStrux(PL_StruxDocHandle /*sdh*/, const PX_ChangeRecord * pcr, PL_StruxFmtHandle * psfh) { UT_return_val_if_fail(pcr->getType() == PX_ChangeRecord::PXT_InsertStrux, false); const PX_ChangeRecord_Strux * pcrx = static_cast<const PX_ChangeRecord_Strux *> (pcr); *psfh = 0; // we don't need it. switch (pcrx->getStruxType()) { case PTX_Section: { _closeSpan(); _closeBlock(); _closeSection(); m_bInSection = true; m_apiThisSection = pcr->getIndexAP(); return true; } case PTX_SectionHdrFtr: { _closeSpan(); _closeBlock(); _closeSection(); m_bInSection = true; m_apiThisSection = pcr->getIndexAP(); return true; } case PTX_SectionTable: { _closeSpan(); _searchTableAPI(pcr->getIndexAP()); return true; } case PTX_SectionFootnote: { _closeSpan(); m_apiSavedBlock = m_apiThisBlock; return true; } case PTX_EndFootnote: { _closeSpan(); _closeBlock(); m_apiThisBlock = m_apiSavedBlock; return true; } case PTX_SectionAnnotation: { _closeSpan(); m_apiSavedBlock = m_apiThisBlock; return true; } case PTX_EndAnnotation: { _closeSpan(); _closeBlock(); m_apiThisBlock = m_apiSavedBlock; return true; } case PTX_SectionEndnote: { _closeSpan(); m_apiSavedBlock = m_apiThisBlock; return true; } case PTX_SectionTOC: { _closeSpan(); return true; } case PTX_EndTOC: { _closeSpan(); return true; } case PTX_SectionFrame: { _closeSpan(); return true; } case PTX_EndFrame: { _closeSpan(); return true; } case PTX_EndEndnote: { _closeSpan(); _closeBlock(); m_apiThisBlock = m_apiSavedBlock; return true; } case PTX_SectionCell: { _closeSpan(); _searchCellAPI(pcr->getIndexAP()); return true; } case PTX_EndTable: { _closeSpan(); return true; } case PTX_EndCell: { _closeSpan(); return true; } case PTX_Block: { _closeSpan(); _closeBlock(); m_bInBlock = true; m_bHasBlock = true; m_apiThisBlock = pcr->getIndexAP(); // Find colours of the Paragraph borders and shading const PP_AttrProp * pBlockAP = NULL; m_pDocument->getAttrProp(m_apiThisBlock,&pBlockAP); const gchar * szColor = PP_evalProperty("bot-color",pBlockAP,NULL,NULL,m_pDocument,true); UT_sint32 ndxColor = 0; if (szColor) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } szColor = PP_evalProperty("left-color",pBlockAP,NULL,NULL,m_pDocument,true); if (szColor) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } szColor = PP_evalProperty("right-color",pBlockAP,NULL,NULL,m_pDocument,true); if (szColor) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } szColor = PP_evalProperty("top-color",pBlockAP,NULL,NULL,m_pDocument,true); if (szColor) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } szColor = PP_evalProperty("shading-foreground-color",pBlockAP,NULL,NULL,m_pDocument,true); if (szColor) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } szColor = PP_evalProperty("shading-background-color",pBlockAP,NULL,NULL,m_pDocument,true); if (szColor) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } return true; } default: UT_ASSERT_NOT_REACHED(); return false; } }
bool Text_Listener::populateStrux(PL_StruxDocHandle /*sdh*/, const PX_ChangeRecord * pcr, PL_StruxFmtHandle * psfh) { UT_return_val_if_fail(pcr->getType() == PX_ChangeRecord::PXT_InsertStrux, false); const PX_ChangeRecord_Strux * pcrx = static_cast<const PX_ChangeRecord_Strux *>(pcr); *psfh = 0; // we don't need it. switch (pcrx->getStruxType()) { case PTX_SectionEndnote: case PTX_SectionHdrFtr: case PTX_Section: { _closeBlock(); PT_AttrPropIndex api = pcr->getIndexAP(); const PP_AttrProp * pAP = NULL; bool bHaveProp = m_pDocument->getAttrProp (api, &pAP); if (bHaveProp && pAP) { const gchar *szValue = NULL; if(pAP->getProperty("dom-dir", szValue)) { if(!g_ascii_strcasecmp("rtl",szValue)) { m_eSectionDir = DO_RTL; } else { m_eSectionDir = DO_LTR; } } else { m_eSectionDir = DO_UNSET; } } return true; } case PTX_Block: { _closeBlock(); m_bInBlock = true; const gchar * szValue = NULL; PT_AttrPropIndex api = pcr->getIndexAP(); const PP_AttrProp * pAP = NULL; bool bHaveProp = m_pDocument->getAttrProp (api, &pAP); m_bBreakExtra = false; if (bHaveProp && pAP) { szValue = PP_evalProperty ("margin-top", 0, pAP, 0, m_pDocument, true); if(szValue) { double inches = UT_convertToInches(szValue); if (!m_bFirstWrite && (inches > 0.01)) m_pie->write(static_cast<const char *>(m_mbLineBreak),m_iLineBreakLen); } szValue = PP_evalProperty ("margin-bottom", 0, pAP, 0, m_pDocument, true); if(szValue) { double inches = UT_convertToInches(szValue); if (inches > 0.01) m_bBreakExtra = true; } } // in 16-bit encodings we sometimes have to issue LRM or // RLM to indicate the dominant direction of the block // (the actual insertion will be done in the subsequent // call to _outputData(), since most often the marker is // unnecessary if(m_bUnicode) { if (bHaveProp && pAP) { szValue = NULL; if(pAP->getProperty("dom-dir", szValue)) { if(!g_ascii_strcasecmp("rtl",szValue)) { m_eDirMarkerPending = DO_RTL; } else { m_eDirMarkerPending = DO_LTR; } } else if(m_eSectionDir != DO_UNSET) { m_eDirMarkerPending = m_eSectionDir; } else { m_eDirMarkerPending = m_eDocDir; } } } return true; } // Be nice about these until we figure out what to do with 'em case PTX_SectionTable: case PTX_SectionCell: case PTX_EndTable: case PTX_EndCell: case PTX_EndFrame: case PTX_EndMarginnote: case PTX_EndFootnote: case PTX_SectionFrame: case PTX_SectionMarginnote: case PTX_SectionFootnote: case PTX_EndEndnote: case PTX_SectionTOC: case PTX_EndTOC: case PTX_SectionAnnotation: case PTX_EndAnnotation: return true ; default: UT_ASSERT_HARMLESS(UT_TODO); return true; } }
const gchar * s_RTF_AttrPropAdapter_AP::getProperty(const gchar * szName) const { return PP_evalProperty(szName, m_pSpanAP, m_pBlockAP, m_pSectionAP, m_pDoc, true); }