Beispiel #1
0
static void _css_length (const char *str,GR_Graphics* pG,
			 UT_sint32 *iDisplayLength,UT_sint32 *iLayoutLength)
{
   	UT_sint32 dim = UT_determineDimension(static_cast<const char*>(str), DIM_PX);

   	if (dim != DIM_PX && dim != DIM_none)
	{
		if (pG == 0)
		{
			*iDisplayLength = static_cast<UT_sint32>((UT_convertToInches(str) * 72.0) + 0.05);
		}
		else
		{
			*iDisplayLength = UT_convertToLogicalUnits(str);
		}
		*iLayoutLength = UT_convertToLogicalUnits(str);
	}
	else
	{
		double iImageLength = UT_convertDimensionless(str);

		double fScale = pG ? (pG->getResolution() / 72.0) : 1;
		*iDisplayLength = static_cast<UT_sint32>(iImageLength * fScale);

		fScale = 1440.0 / 72.0;
		*iLayoutLength = static_cast<UT_sint32>(iImageLength * fScale);
	}
}
bool GR_Graphics::scaleDimensions(const char * szLeftIn, const char * szWidthIn,
									 UT_uint32 iWidthAvail,
									 UT_sint32 * piLeft, UT_uint32 * piWidth) const
{
	/* Scale the given left-offset and width using the width available.
	** Compute the actual left-offset and actual width used.
	** We allow the given left-offset to be a number.
	** We allow the given width to be a number or "*"; where "*" indicates
	** we take all remaining space available.
	**
	** NOTE: This routine can also be used for vertical calculations.
	*/

	UT_ASSERT(szLeftIn);
	UT_ASSERT(szWidthIn);

	UT_sint32 iLeft = UT_convertToLogicalUnits(szLeftIn);
	UT_uint32 iWidth;

	if (szWidthIn[0] == '*')
		iWidth = iWidthAvail - iLeft;
	else
		iWidth = UT_convertToLogicalUnits(szWidthIn);

	if (piLeft)
		*piLeft = iLeft;
	if (piWidth)
		*piWidth = iWidth;

	return true;
}
Beispiel #3
0
static void s_border_properties (const gchar * border_color, const gchar * border_style, const gchar * border_width,
								 const gchar * color, PP_PropertyMap::Line & line)
{
	/* frame-border properties:
	 * 
	 * (1) color      - defaults to value of "color" property
	 * (2) line-style - defaults to solid (in contrast to "none" in CSS)
	 * (3) thickness  - defaults to 1 layout unit (??, vs "medium" in CSS)
	 */
	line.reset ();

	PP_PropertyMap::TypeColor t_border_color = PP_PropertyMap::color_type (border_color);
	if (t_border_color)
		{
			line.m_t_color = t_border_color;
			if (t_border_color == PP_PropertyMap::color_color)
				UT_parseColor (border_color, line.m_color);
		}
	else if (color)
		{
			PP_PropertyMap::TypeColor t_color = PP_PropertyMap::color_type (color);

			line.m_t_color = t_color;
			if (t_color == PP_PropertyMap::color_color)
				UT_parseColor (color, line.m_color);
		}

	line.m_t_linestyle = PP_PropertyMap::linestyle_type (border_style);
	if (!line.m_t_linestyle)
		line.m_t_linestyle = PP_PropertyMap::linestyle_solid;

	line.m_t_thickness = PP_PropertyMap::thickness_type (border_width);
	if (line.m_t_thickness == PP_PropertyMap::thickness_length)
		{
			if (UT_determineDimension (border_width, (UT_Dimension)-1) == DIM_PX)
				{
					double thickness = UT_LAYOUT_RESOLUTION * UT_convertDimensionless (border_width);
					line.m_thickness = static_cast<UT_sint32>(thickness / UT_PAPER_UNITS_PER_INCH);
				}
			else
				line.m_thickness = UT_convertToLogicalUnits (border_width);

			if (!line.m_thickness)
				{
					double thickness = UT_LAYOUT_RESOLUTION;
					line.m_thickness = static_cast<UT_sint32>(thickness / UT_PAPER_UNITS_PER_INCH);
				}
		}
	else // ??
		{
			double thickness = UT_LAYOUT_RESOLUTION;
			line.m_thickness = static_cast<UT_sint32>(thickness / UT_PAPER_UNITS_PER_INCH);
		}
}
/*!
 * This method is used to determine the value of the layout properties
 * of the embed runs. The values returned are in logical units.
 * The properties are "height","width","ascent","decent".
 * If the propeties are not defined return -1
 */
UT_sint32  fp_EmbedRun::_getLayoutPropFromObject(const char * szProp) const
{
  PT_AttrPropIndex api = getBlock()->getDocument()->getAPIFromSOH(m_OH);
  const PP_AttrProp * pAP = NULL;
  const char * szPropVal = NULL;
  getBlock()->getDocument()->getAttrProp(api, &pAP);
  if(pAP)
    {
      bool bFound = pAP->getProperty(szProp, szPropVal);
      if(bFound)
	{
	  return UT_convertToLogicalUnits(szPropVal);
	}
    }
  return -1;
}
Beispiel #5
0
ap_RulerTicks::ap_RulerTicks(GR_Graphics * pG, UT_Dimension dim)
{
	char Buffer[30];

	m_pG = pG;
	dimType = dim;
	
	UT_LocaleTransactor t(LC_NUMERIC, "C");

	// we scale the units up by UnitScale to avoid round-off problems.
	
	switch (dimType)
	{
	case DIM_IN:
		// For english, we draw numbers on the inches, long ticks 
		// on the half inches and short ticks on the eighth inches.  
		// We round up/down mouse actions to the nearest 1/16th.

		// On a 75 dpi screen, a 1/32 inch is 2.34375, so i set the scale to 100000.
		
		dBasicUnit = 0.125;
		tickUnitScale = SCALE_IN;
		sprintf(Buffer, "%fin", dBasicUnit * (double)tickUnitScale);
		tickUnit = UT_convertToLogicalUnits(Buffer); // 1/8th inch is our basic unit
		tickLong = 4;					// draw long ticks every 4 units (1/2 inch)
		tickLabel = 8;					// draw labeled ticks every 8 units (1 inch)
		tickScale = 1;					// label increment
		sprintf(Buffer, "%fin", (dBasicUnit / 2 * (double)tickUnitScale));
		dragDelta = UT_convertToLogicalUnits(Buffer); // 1/16th inch is mouse resolution
		break;

	case DIM_CM:
		dBasicUnit = 0.25;
		tickUnitScale = SCALE_CM;
		sprintf(Buffer, "%fcm", (dBasicUnit * (double)tickUnitScale));
		tickUnit = UT_convertToLogicalUnits(Buffer);
		tickLong = 2;
		tickLabel = 4;
		tickScale = 1;
		sprintf(Buffer, "%fcm", (dBasicUnit / 2 * (double)tickUnitScale));
		dragDelta = UT_convertToLogicalUnits(Buffer);
		break;

	case DIM_MM:
		dBasicUnit = 2.5;
		tickUnitScale = SCALE_MM;
		sprintf(Buffer, "%fmm", (dBasicUnit * (double)tickUnitScale));
		tickUnit = UT_convertToLogicalUnits(Buffer);
		tickLong = 2;
		tickLabel = 4;
		tickScale = 10;
		sprintf(Buffer, "%fmm", (dBasicUnit / 2 * (double)tickUnitScale));
		dragDelta = UT_convertToLogicalUnits(Buffer);
		break;

	case DIM_PI:						// picas
		dBasicUnit = 1.0;
		tickUnitScale = SCALE_PT;
		sprintf(Buffer, "%fpi", (dBasicUnit * (double)tickUnitScale));
		tickUnit = UT_convertToLogicalUnits(Buffer);
		tickLong = 6;
		tickLabel = 6;
		tickScale = 6;
		sprintf(Buffer, "%fpi", (dBasicUnit / 2 * (double)tickUnitScale));
		dragDelta = UT_convertToLogicalUnits(Buffer);
		break;
		
	case DIM_PT:						// points
		dBasicUnit = 6.0;
		tickUnitScale = SCALE_PT;
		sprintf(Buffer, "%fpt", (dBasicUnit * (double)tickUnitScale));
		tickUnit = UT_convertToLogicalUnits(Buffer);
		tickLong = 6;
		tickLabel = 6;
		tickScale = 36;
		sprintf(Buffer, "%fpt", (dBasicUnit / 2 * (double)tickUnitScale));
		dragDelta = UT_convertToLogicalUnits(Buffer);
		break;

	default:
		UT_ASSERT_HARMLESS(UT_NOT_IMPLEMENTED);
		break;
	}
}
Beispiel #6
0
void AP_FormatFrame_preview::draw(void)
{
	GR_Painter painter(m_gc);
	
	UT_sint32 iWidth = m_gc->tlu (getWindowWidth());
	UT_sint32 iHeight = m_gc->tlu (getWindowHeight());
	UT_Rect pageRect(m_gc->tlu(7), m_gc->tlu(7), iWidth - m_gc->tlu(14), iHeight - m_gc->tlu(14));	
	
	painter.fillRect(GR_Graphics::CLR3D_Background, 0, 0, iWidth, iHeight);
	painter.clearArea(pageRect.left, pageRect.top, pageRect.width, pageRect.height);	
	
	
	UT_RGBColor tmpCol;
	
	UT_RGBColor black(0, 0, 0);
	m_gc->setLineWidth(m_gc->tlu(1));
	
	int border = m_gc->tlu(20);
	int cornerLength = m_gc->tlu(5);

//
//  Draw the cell background
//
	
	const gchar * pszBGCol = NULL;
	if(m_pFormatFrame->getImage())
	{
		GR_Image * pImg = m_pFormatFrame->getImage();
		FG_Graphic * pFG = m_pFormatFrame->getGraphic();
		const char * szName = pFG->getDataId();
        const UT_ByteBuf * pBB = static_cast<FG_GraphicRaster *>(pFG)->getBuffer();
		if(pFG->getType() == FGT_Raster)
		{
			pImg = static_cast<GR_Image *>(
				m_gc->createNewImage( szName,
									pBB, pFG->getMimeType(),
									pageRect.width - 2*border,
									pageRect.height - 2*border,
									GR_Image::GRT_Raster));
		}
		else
		{
			pImg = static_cast<GR_Image *>(
				m_gc->createNewImage( szName,
                                      pBB, pFG->getMimeType(),
									pageRect.width - 2*border,
									pageRect.height - 2*border,
									GR_Image::GRT_Vector));
		}

		UT_Rect rec(pageRect.left + border, pageRect.top + border, 
					pageRect.width - 2*border, pageRect.height - 2*border);
		painter.drawImage(pImg,pageRect.left + border, pageRect.top + border);
		delete pImg;
	}
	else
	{
		m_pFormatFrame->getPropVector().getProp(static_cast<const gchar *>("background-color"), pszBGCol);
		if (pszBGCol && *pszBGCol)
		{
			UT_parseColor(pszBGCol, tmpCol);
			painter.fillRect(tmpCol, pageRect.left + border, pageRect.top + border, pageRect.width - 2*border, pageRect.height - 2*border);
		}
	}

//
//  Draw the cell corners
//
	
	m_gc->setColor(UT_RGBColor(127,127,127));
	
	// top left corner
	painter.drawLine(pageRect.left + border - cornerLength, pageRect.top + border,
				   pageRect.left + border, pageRect.top + border);
	painter.drawLine(pageRect.left + border, pageRect.top + border  - cornerLength,
				   pageRect.left + border, pageRect.top + border);

	// top right corner
	painter.drawLine(pageRect.left + pageRect.width - border + cornerLength, pageRect.top + border,
				   pageRect.left + pageRect.width - border, pageRect.top + border);
	painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + border - cornerLength,
				   pageRect.left + pageRect.width - border, pageRect.top + border);

	// bottom left corner
	painter.drawLine(pageRect.left + border - cornerLength, pageRect.top + pageRect.height - border,
				   pageRect.left + border, pageRect.top + pageRect.height - border);
	painter.drawLine(pageRect.left + border, pageRect.top + pageRect.height - border + cornerLength,
				   pageRect.left + border, pageRect.top + pageRect.height - border);

	// bottom right corner
	painter.drawLine(pageRect.left + pageRect.width - border + cornerLength, pageRect.top + pageRect.height - border,
				   pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);
	painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border + cornerLength,
				   pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);

//
//  Draw the cell borders
//
	// right border
	if (m_pFormatFrame->getRightToggled())
	{
		UT_sint32 linestyle = m_pFormatFrame->borderLineStyleRight();
		if (linestyle == LS_DOTTED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_DOTTED);
		else if (linestyle == LS_DASHED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_ON_OFF_DASH);
		else
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_SOLID);

		m_gc->setColor(m_pFormatFrame->borderColorRight());

		UT_sint32 iRightThickness = UT_convertToLogicalUnits(m_pFormatFrame->getBorderThicknessRight().utf8_str());
		m_gc->setLineWidth(iRightThickness);

		painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + border,
						 pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);
	}

	// left border
	if (m_pFormatFrame->getLeftToggled())
	{
		UT_sint32 linestyle = m_pFormatFrame->borderLineStyleLeft();
		if (linestyle == LS_DOTTED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_DOTTED);
		else if (linestyle == LS_DASHED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_ON_OFF_DASH);
		else
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_SOLID);

		m_gc->setColor(m_pFormatFrame->borderColorLeft());

		UT_sint32 iLeftThickness = UT_convertToLogicalUnits(m_pFormatFrame->getBorderThicknessLeft().utf8_str());
		m_gc->setLineWidth(iLeftThickness);

		painter.drawLine(pageRect.left + border, pageRect.top + border,
						 pageRect.left + border, pageRect.top + pageRect.height - border);
	}

	// top border
	if (m_pFormatFrame->getTopToggled())
	{
		UT_sint32 linestyle = m_pFormatFrame->borderLineStyleTop();
		if (linestyle == LS_DOTTED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_DOTTED);
		else if (linestyle == LS_DASHED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_ON_OFF_DASH);
		else
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_SOLID);

		m_gc->setColor(m_pFormatFrame->borderColorTop());		
		UT_sint32 iTopThickness = UT_convertToLogicalUnits(m_pFormatFrame->getBorderThicknessTop().utf8_str());
		m_gc->setLineWidth(iTopThickness);

		painter.drawLine(pageRect.left + border, pageRect.top + border,
						 pageRect.left + pageRect.width - border, pageRect.top + border);
	}

	// bottom border
	if (m_pFormatFrame->getBottomToggled())
	{
		UT_sint32 linestyle = m_pFormatFrame->borderLineStyleBottom();
		if (linestyle == LS_DOTTED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_DOTTED);
		else if (linestyle == LS_DASHED)
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_ON_OFF_DASH);
		else
			m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_SOLID);

		m_gc->setColor(m_pFormatFrame->borderColorBottom());

		UT_sint32 iBottomThickness = UT_convertToLogicalUnits(m_pFormatFrame->getBorderThicknessBottom().utf8_str());
		m_gc->setLineWidth(iBottomThickness);

		painter.drawLine(pageRect.left + border, pageRect.top + pageRect.height - border,
						 pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);
	}
}
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();
}
/*!
 * Returns true if the properties are changed in the document.
 */
bool fp_EmbedRun::_updatePropValuesIfNeeded(void)
{
  UT_sint32 iVal = 0;
  if(getEmbedManager()->isDefault())
    {
      return false;
    }
  PT_AttrPropIndex api = getBlock()->getDocument()->getAPIFromSOH(m_OH);
  const PP_AttrProp * pAP = NULL;
  const char * szPropVal = NULL;
  getBlock()->getDocument()->getAttrProp(api, &pAP);
  UT_return_val_if_fail(pAP,false);
  bool bFound = pAP->getProperty("height", szPropVal);
  bool bDoUpdate = false;
  if(bFound)
    {
      iVal = UT_convertToLogicalUnits(szPropVal);
      bDoUpdate = (iVal != getHeight());
    }
  else
    {
      bDoUpdate = true;
    }
  bFound = pAP->getProperty("width", szPropVal);
  if(bFound && !bDoUpdate)
    {
      iVal = UT_convertToLogicalUnits(szPropVal);
      bDoUpdate = (iVal != getWidth());
    }
  else
    {
      bDoUpdate = true;
    }
  bFound = pAP->getProperty("ascent", szPropVal);
  if(bFound && !bDoUpdate)
    {
      iVal = UT_convertToLogicalUnits(szPropVal);
      bDoUpdate = (iVal != static_cast<UT_sint32>(getAscent()));
    }
  else
    {
      bDoUpdate = true;
    }
  bFound = pAP->getProperty("descent", szPropVal);
  if(bFound && !bDoUpdate)
    {
      iVal = UT_convertToLogicalUnits(szPropVal);
      bDoUpdate = (iVal != static_cast<UT_sint32>(getDescent()));
    }
  else
    {
      bDoUpdate = true;
    }
  if(bDoUpdate)
    {
      const char * pProps[10] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
	  UT_LocaleTransactor t(LC_NUMERIC, "C");
	  UT_UTF8String sHeight,sWidth,sAscent,sDescent;
      UT_UTF8String_sprintf(sHeight,"%fin",static_cast<double>(getHeight())/1440.);
      pProps[0] = "height";
      pProps[1] = sHeight.utf8_str();
      UT_UTF8String_sprintf(sWidth,"%fin",static_cast<double>(getWidth())/1440.);
      pProps[2] = "width";
      pProps[3] = sWidth.utf8_str();
      UT_UTF8String_sprintf(sAscent,"%fin",static_cast<double>(getAscent())/1440.);
      pProps[4] = "ascent";
      pProps[5] = sAscent.utf8_str();
      UT_UTF8String_sprintf(sDescent,"%fin",static_cast<double>(getDescent())/1440.);
      pProps[6] = "descent";
      pProps[7] = sDescent.utf8_str();
      getBlock()->getDocument()->changeObjectFormatNoUpdate(PTC_AddFmt,m_OH,
							    NULL,
							    pProps);
      return true;
    }
  return false;
}
Beispiel #9
0
/*!
    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;
		}
	}

}
Beispiel #10
0
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();
	}
}
void AP_FormatTable_preview::draw(const UT_Rect *clip)
{
    UT_UNUSED(clip);
    GR_Painter painter(m_gc);

    UT_sint32 iWidth = m_gc->tlu (getWindowWidth());
    UT_sint32 iHeight = m_gc->tlu (getWindowHeight());
    UT_Rect pageRect(m_gc->tlu(7), m_gc->tlu(7), iWidth - m_gc->tlu(14), iHeight - m_gc->tlu(14));

    painter.fillRect(GR_Graphics::CLR3D_Background, 0, 0, iWidth, iHeight);
    painter.clearArea(pageRect.left, pageRect.top, pageRect.width, pageRect.height);


    UT_RGBColor tmpCol;

    UT_RGBColor black(0, 0, 0);
    m_gc->setLineWidth(m_gc->tlu(1));

    int border = m_gc->tlu(20);
    int cornerLength = m_gc->tlu(5);

//
//  Draw the cell background
//

    const gchar * pszBGCol = NULL;
    if(m_pFormatTable->getImage())
    {
        GR_Image * pImg = m_pFormatTable->getImage();
        FG_Graphic * pFG = m_pFormatTable->getGraphic();
        const char * szName = pFG->getDataId();
        const UT_ByteBuf * pBB = pFG->getBuffer();
        if(pFG->getType() == FGT_Raster)
        {
            pImg = static_cast<GR_Image *>(
                       m_gc->createNewImage( szName,
                                             pBB, pFG->getMimeType(),
                                             pageRect.width - 2*border,
                                             pageRect.height - 2*border,
                                             GR_Image::GRT_Raster));
        }
        else
        {
            pImg = static_cast<GR_Image *>(
                       m_gc->createNewImage( szName,
                                             pBB, pFG->getMimeType(),
                                             pageRect.width - 2*border,
                                             pageRect.height - 2*border,
                                             GR_Image::GRT_Vector));
        }

        UT_Rect rec(pageRect.left + border, pageRect.top + border,
                    pageRect.width - 2*border, pageRect.height - 2*border);
        painter.drawImage(pImg,pageRect.left + border, pageRect.top + border);
        delete pImg;
    }
    else
    {
        m_pFormatTable->getPropVector().getProp(static_cast<const gchar *>("background-color"), pszBGCol);
        if (pszBGCol && *pszBGCol)
        {
            UT_parseColor(pszBGCol, tmpCol);
            painter.fillRect(tmpCol, pageRect.left + border, pageRect.top + border, pageRect.width - 2*border, pageRect.height - 2*border);
        }
    }

//
//  Draw the cell corners
//

    m_gc->setColor(UT_RGBColor(127,127,127));

    // top left corner
    painter.drawLine(pageRect.left + border - cornerLength, pageRect.top + border,
                     pageRect.left + border, pageRect.top + border);
    painter.drawLine(pageRect.left + border, pageRect.top + border  - cornerLength,
                     pageRect.left + border, pageRect.top + border);

    // top right corner
    painter.drawLine(pageRect.left + pageRect.width - border + cornerLength, pageRect.top + border,
                     pageRect.left + pageRect.width - border, pageRect.top + border);
    painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + border - cornerLength,
                     pageRect.left + pageRect.width - border, pageRect.top + border);

    // bottom left corner
    painter.drawLine(pageRect.left + border - cornerLength, pageRect.top + pageRect.height - border,
                     pageRect.left + border, pageRect.top + pageRect.height - border);
    painter.drawLine(pageRect.left + border, pageRect.top + pageRect.height - border + cornerLength,
                     pageRect.left + border, pageRect.top + pageRect.height - border);

    // bottom right corner
    painter.drawLine(pageRect.left + pageRect.width - border + cornerLength, pageRect.top + pageRect.height - border,
                     pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);
    painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border + cornerLength,
                     pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);

//
//  Draw the cell borders
//

    // top border
    if (m_pFormatTable->getTopToggled())
    {
        const gchar * pszTopColor = NULL;
        m_pFormatTable->getPropVector().getProp("top-color", pszTopColor);
        if (pszTopColor)
        {
            UT_parseColor(pszTopColor, tmpCol);
            m_gc->setColor(tmpCol);
        }
        else
            m_gc->setColor(black);
        const gchar * pszTopThickness = NULL;
        m_pFormatTable->getPropVector().getProp("top-thickness", pszTopThickness);
        if(pszTopThickness)
        {
            UT_sint32 iTopThickness = UT_convertToLogicalUnits(pszTopThickness);
            m_gc->setLineWidth(iTopThickness);
        }
        else
        {
            m_gc->setLineWidth(m_gc->tlu(1));
        }

        painter.drawLine(pageRect.left + border, pageRect.top + border,
                         pageRect.left + pageRect.width - border, pageRect.top + border);
    }

    // left border
    if (m_pFormatTable->getLeftToggled())
    {
        const gchar * pszLeftColor = NULL;
        m_pFormatTable->getPropVector().getProp("left-color", pszLeftColor);
        if (pszLeftColor)
        {
            UT_parseColor(pszLeftColor, tmpCol);
            m_gc->setColor(tmpCol);
        }
        else
            m_gc->setColor(black);
        const gchar * pszLeftThickness = NULL;
        m_pFormatTable->getPropVector().getProp("left-thickness", pszLeftThickness);
        if(pszLeftThickness)
        {
            UT_sint32 iLeftThickness = UT_convertToLogicalUnits(pszLeftThickness);
            m_gc->setLineWidth(iLeftThickness);
        }
        else
        {
            m_gc->setLineWidth(m_gc->tlu(1));
        }
        painter.drawLine(pageRect.left + border, pageRect.top + border,
                         pageRect.left + border, pageRect.top + pageRect.height - border);
    }

    // right border
    if (m_pFormatTable->getRightToggled())
    {
        const gchar * pszRightColor = NULL;
        m_pFormatTable->getPropVector().getProp("right-color", pszRightColor);
        if (pszRightColor)
        {
            UT_parseColor(pszRightColor, tmpCol);
            m_gc->setColor(tmpCol);
        }
        else
            m_gc->setColor(black);
        const gchar * pszRightThickness = NULL;
        m_pFormatTable->getPropVector().getProp("right-thickness", pszRightThickness);
        if(pszRightThickness)
        {
            UT_sint32 iRightThickness = UT_convertToLogicalUnits(pszRightThickness);
            m_gc->setLineWidth(iRightThickness);
        }
        else
        {
            m_gc->setLineWidth(m_gc->tlu(1));
        }
        painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + border,
                         pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);
    }

    // bottom border
    if (m_pFormatTable->getBottomToggled())
    {
        const gchar * pszBottomColor = NULL;
        m_pFormatTable->getPropVector().getProp("bot-color", pszBottomColor);
        if (pszBottomColor)
        {
            UT_parseColor(pszBottomColor, tmpCol);
            m_gc->setColor(tmpCol);
        }
        else
            m_gc->setColor(black);
        const gchar * pszBotThickness = NULL;
        m_pFormatTable->getPropVector().getProp("bot-thickness", pszBotThickness);
        if(pszBotThickness)
        {
            UT_sint32 iBotThickness = UT_convertToLogicalUnits(pszBotThickness);
            m_gc->setLineWidth(iBotThickness);
        }
        else
        {
            m_gc->setLineWidth(m_gc->tlu(1));
        }
        painter.drawLine(pageRect.left + border, pageRect.top + pageRect.height - border,
                         pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border);
    }
}