コード例 #1
0
STDMETHODIMP CESVGRectElement::Move(ISVGView* view, double dx, double dy)
{
	ATLASSERT(0);
#if 0
	CComQIPtr<ILSVGRectElement> rect = m_domElement;

	CComPtr<ILHTMLWindow> window;
	view->GetHTMLWindow(&window);

	CComPtr<ILSVGElement> viewportElement;
	rect->get_viewportElement(&viewportElement);

// TODO, this can't be correct
	CComPtr<ILSVGRect> _rect;
	window->svgGetRBBox(viewportElement, &_rect);
	SVGRect viewBox = _rect;

	// x
	{
		CComPtr<ILSVGAnimatedLength> alength;
		rect->get_x(&alength);

		SVGLength length;
		alength->get_baseVal(&length);

		if (length.GetUnitType() == SVG_LENGTHTYPE_PERCENTAGE)
		{
			double dx_pcnt = dx*100/viewBox.Width;

			double value;
			length->get_valueInSpecifiedUnits(&value);
			length->put_valueInSpecifiedUnits(value+dx_pcnt);
		}
		else
		{
			double value;
			length->get_value(&value);
			length->put_value(value + dx);
		}
	}

	// y
	{
		CComPtr<ILSVGAnimatedLength> alength;
		rect->get_y(&alength);

		SVGLength length;
		alength->get_baseVal(&length);

		if (length.GetUnitType() == SVG_LENGTHTYPE_PERCENTAGE)
		{
			double dy_pcnt = dy*100/viewBox.Height;

			double value;
			length->get_valueInSpecifiedUnits(&value);
			length->put_valueInSpecifiedUnits(value+dy_pcnt);
		}
		else
		{
			double value;
			length->get_value(&value);
			length->put_value(value + dy);
		}
	}
#endif

	return S_OK;
}
コード例 #2
0
STDMETHODIMP CESVGRectElement::Resize(ISVGView* view, double x, double y, double width, double height)
{
	ATLASSERT(0);
#if 0
	CComQIPtr<ILSVGRectElement> rect = m_domElement;

	CComPtr<ILHTMLWindow> window;
	view->GetHTMLWindow(&window);

	CComPtr<ILSVGElement> viewportElement;
	rect->get_viewportElement(&viewportElement);

// TODO, this can't be correct
	CComPtr<ILSVGRect> _rect;
	window->svgGetRBBox(viewportElement, &_rect);
	SVGRect viewBox = _rect;

	// x
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_x(&alength);

		SVGLength length;
		alength->get_baseVal(&length);

		if (length.GetUnitType() == SVG_LENGTHTYPE_PERCENTAGE)
		{
			double x_pcnt = x*100/viewBox.Width;
			length->set_valueInSpecifiedUnits(x_pcnt);
		}
		else
		{
			length->put_value(x);
		}
	}

	// y
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_y(&alength);

		SVGLength length;
		alength->get_baseVal(&length);

		if (length.GetUnitType() == SVG_LENGTHTYPE_PERCENTAGE)
		{
			double y_pcnt = y*100/viewBox.Height;
			length->set_valueInSpecifiedUnits(y_pcnt);
		}
		else
		{
			length->put_value(y);
		}
	}

	// width
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_width(&alength);

		SVGLength length;
		alength->get_baseVal(&length);

		if (length.GetUnitType() == SVG_LENGTHTYPE_PERCENTAGE)
		{
			double width_pcnt = width*100/viewBox.Width;
			length->set_valueInSpecifiedUnits(width_pcnt);
		}
		else
		{
			length->put_value(width);
		}
	}

	// height
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_height(&alength);

		SVGLength length;
		alength->get_baseVal(&length);

		if (length.GetUnitType() == SVG_LENGTHTYPE_PERCENTAGE)
		{
			double height_pcnt = height*100/viewBox.Height;
			length->set_valueInSpecifiedUnits(height_pcnt);
		}
		else
		{
			length->put_value(height);
		}
	}
#endif

	return S_OK;
}