2001-02-02 10:14:37 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 12:52:02 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-02-02 10:14:37 +00:00
|
|
|
*
|
2005-09-09 12:52:02 +00:00
|
|
|
* $RCSfile: shapeexport3.cxx,v $
|
2001-02-02 10:14:37 +00:00
|
|
|
*
|
2006-06-19 17:12:33 +00:00
|
|
|
* $Revision: 1.14 $
|
2001-02-02 10:14:37 +00:00
|
|
|
*
|
2006-06-19 17:12:33 +00:00
|
|
|
* last change: $Author: hr $ $Date: 2006-06-19 18:12:33 $
|
2001-02-02 10:14:37 +00:00
|
|
|
*
|
2005-09-09 12:52:02 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2001-02-02 10:14:37 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 12:52:02 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2001-02-02 10:14:37 +00:00
|
|
|
*
|
2005-09-09 12:52:02 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2001-02-02 10:14:37 +00:00
|
|
|
*
|
2005-09-09 12:52:02 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2001-02-02 10:14:37 +00:00
|
|
|
*
|
2005-09-09 12:52:02 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2001-02-02 10:14:37 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _B3D_HMATRIX_HXX
|
|
|
|
#include <goodies/hmatrix.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_DRAWING_HOMOGENMATRIX_HPP_
|
|
|
|
#include <com/sun/star/drawing/HomogenMatrix.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_DRAWING_POLYPOLYGONSHAPE3D_HPP_
|
|
|
|
#include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_DRAWING_PROJECTIONMODE_HPP_
|
|
|
|
#include <com/sun/star/drawing/ProjectionMode.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_DRAWING_SHADEMODE_HPP_
|
|
|
|
#include <com/sun/star/drawing/ShadeMode.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_DRAWING_DIRECTION3D_HPP_
|
|
|
|
#include <com/sun/star/drawing/Direction3D.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_DRAWING_POSITION3D_HPP_
|
|
|
|
#include <com/sun/star/drawing/Position3D.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_DRAWING_CAMERAGEOMETRY_HPP_
|
|
|
|
#include <com/sun/star/drawing/CameraGeometry.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_DRAWING_DOUBLESEQUENCE_HPP_
|
|
|
|
#include <com/sun/star/drawing/DoubleSequence.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_SHAPEEXPORT_HXX
|
|
|
|
#include "shapeexport.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _SDPROPLS_HXX
|
|
|
|
#include "sdpropls.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _RTL_USTRBUF_HXX_
|
|
|
|
#include <rtl/ustrbuf.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLEXP_HXX
|
|
|
|
#include "xmlexp.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLUCONV_HXX
|
|
|
|
#include "xmluconv.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XEXPTRANSFORM_HXX
|
|
|
|
#include "xexptran.hxx"
|
|
|
|
#endif
|
|
|
|
|
2001-06-29 20:07:26 +00:00
|
|
|
#ifndef _XMLOFF_XMLTOKEN_HXX
|
|
|
|
#include "xmltoken.hxx"
|
|
|
|
#endif
|
|
|
|
|
2001-02-02 10:14:37 +00:00
|
|
|
#include "xmlnmspe.hxx"
|
|
|
|
|
|
|
|
using namespace ::rtl;
|
|
|
|
using namespace ::com::sun::star;
|
2001-06-29 20:07:26 +00:00
|
|
|
using namespace ::xmloff::token;
|
2001-02-02 10:14:37 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
inline sal_Int32 FRound( double fVal )
|
|
|
|
{
|
|
|
|
return( fVal > 0.0 ? (sal_Int32) ( fVal + 0.5 ) : -(sal_Int32) ( -fVal + 0.5 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-06-19 17:12:33 +00:00
|
|
|
void XMLShapeExport::ImpExport3DSceneShape( const uno::Reference< drawing::XShape >& xShape, XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
|
2001-02-02 10:14:37 +00:00
|
|
|
{
|
|
|
|
uno::Reference< drawing::XShapes > xShapes(xShape, uno::UNO_QUERY);
|
|
|
|
if(xShapes.is() && xShapes->getCount())
|
|
|
|
{
|
|
|
|
uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
|
2001-03-28 08:47:01 +00:00
|
|
|
DBG_ASSERT( xPropSet.is(), "XMLShapeExport::ImpExport3DSceneShape can't export a scene without a propertyset" );
|
2001-02-02 10:14:37 +00:00
|
|
|
if( xPropSet.is() )
|
|
|
|
{
|
2001-03-28 08:47:01 +00:00
|
|
|
// Transformation
|
|
|
|
ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
|
|
|
|
|
|
|
|
// 3d attributes
|
|
|
|
export3DSceneAttributes( xPropSet );
|
|
|
|
|
|
|
|
// write 3DScene shape
|
2001-09-20 13:20:24 +00:00
|
|
|
sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
|
2006-06-19 17:12:33 +00:00
|
|
|
SvXMLElementExport aOBJ( mrExport, XML_NAMESPACE_DR3D, XML_SCENE, bCreateNewline, sal_True);
|
2001-03-28 08:47:01 +00:00
|
|
|
|
|
|
|
ImpExportEvents( xShape );
|
|
|
|
|
2001-02-02 10:14:37 +00:00
|
|
|
// write 3DSceneLights
|
2001-03-28 08:47:01 +00:00
|
|
|
export3DLamps( xPropSet );
|
2001-02-02 10:14:37 +00:00
|
|
|
|
2001-07-24 14:53:45 +00:00
|
|
|
// #89764# if export of position is supressed for group shape,
|
|
|
|
// positions of contained objects should be written relative to
|
|
|
|
// the upper left edge of the group.
|
|
|
|
awt::Point aUpperLeft;
|
|
|
|
|
|
|
|
if(!(nFeatures & SEF_EXPORT_POSITION))
|
|
|
|
{
|
|
|
|
nFeatures |= SEF_EXPORT_POSITION;
|
|
|
|
aUpperLeft = xShape->getPosition();
|
|
|
|
pRefPoint = &aUpperLeft;
|
|
|
|
}
|
|
|
|
|
2001-03-28 10:19:11 +00:00
|
|
|
// write members
|
|
|
|
exportShapes( xShapes, nFeatures, pRefPoint );
|
|
|
|
}
|
2001-02-02 10:14:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void XMLShapeExport::ImpExport3DShape(
|
|
|
|
const uno::Reference< drawing::XShape >& xShape,
|
2006-06-19 17:12:33 +00:00
|
|
|
XmlShapeType eShapeType, sal_Int32 /* nFeatures = SEF_DEFAULT */, awt::Point* /*pRefPoint = NULL */)
|
2001-02-02 10:14:37 +00:00
|
|
|
{
|
|
|
|
const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
|
|
|
|
if(xPropSet.is())
|
|
|
|
{
|
|
|
|
OUString aStr;
|
|
|
|
OUStringBuffer sStringBuffer;
|
|
|
|
|
|
|
|
// transformation (UNO_NAME_3D_TRANSFORM_MATRIX == "D3DTransformMatrix")
|
|
|
|
uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DTransformMatrix")));
|
|
|
|
drawing::HomogenMatrix xHomMat;
|
|
|
|
aAny >>= xHomMat;
|
|
|
|
SdXMLImExTransform3D aTransform;
|
|
|
|
aTransform.AddHomogenMatrix(xHomMat);
|
|
|
|
if(aTransform.NeedsAction())
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_TRANSFORM, aTransform.GetExportString(mrExport.GetMM100UnitConverter()));
|
2001-02-02 10:14:37 +00:00
|
|
|
|
|
|
|
switch(eShapeType)
|
|
|
|
{
|
|
|
|
case XmlShapeTypeDraw3DCubeObject:
|
|
|
|
{
|
|
|
|
// write 3DCube shape
|
2006-06-19 17:12:33 +00:00
|
|
|
SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_CUBE, sal_True, sal_True);
|
2001-02-02 10:14:37 +00:00
|
|
|
|
|
|
|
// minEdge
|
|
|
|
aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition")));
|
|
|
|
drawing::Position3D aPosition3D;
|
|
|
|
aAny >>= aPosition3D;
|
|
|
|
Vector3D aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ);
|
|
|
|
|
|
|
|
// maxEdge
|
|
|
|
aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSize")));
|
|
|
|
drawing::Direction3D aDirection3D;
|
|
|
|
aAny >>= aDirection3D;
|
|
|
|
Vector3D aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ);
|
|
|
|
|
|
|
|
// transform maxEdge from distance to pos
|
|
|
|
aDir3D = aPos3D + aDir3D;
|
|
|
|
|
|
|
|
// write minEdge
|
|
|
|
if(aPos3D != Vector3D(-2500.0, -2500.0, -2500.0)) // write only when not default
|
|
|
|
{
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aPos3D);
|
2001-02-02 10:14:37 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_MIN_EDGE, aStr);
|
2001-02-02 10:14:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// write maxEdge
|
|
|
|
if(aDir3D != Vector3D(2500.0, 2500.0, 2500.0)) // write only when not default
|
|
|
|
{
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aDir3D);
|
2001-02-02 10:14:37 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_MAX_EDGE, aStr);
|
2001-02-02 10:14:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case XmlShapeTypeDraw3DSphereObject:
|
|
|
|
{
|
|
|
|
// write 3DSphere shape
|
2006-06-19 17:12:33 +00:00
|
|
|
SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_SPHERE, sal_True, sal_True);
|
2001-02-02 10:14:37 +00:00
|
|
|
|
|
|
|
// Center
|
|
|
|
aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition")));
|
|
|
|
drawing::Position3D aPosition3D;
|
|
|
|
aAny >>= aPosition3D;
|
|
|
|
Vector3D aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ);
|
|
|
|
|
|
|
|
// Size
|
|
|
|
aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSize")));
|
|
|
|
drawing::Direction3D aDirection3D;
|
|
|
|
aAny >>= aDirection3D;
|
|
|
|
Vector3D aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ);
|
|
|
|
|
|
|
|
// write Center
|
|
|
|
if(aPos3D != Vector3D(0.0, 0.0, 0.0)) // write only when not default
|
|
|
|
{
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aPos3D);
|
2001-02-02 10:14:37 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_CENTER, aStr);
|
2001-02-02 10:14:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// write Size
|
|
|
|
if(aDir3D != Vector3D(5000.0, 5000.0, 5000.0)) // write only when not default
|
|
|
|
{
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aDir3D);
|
2001-02-02 10:14:37 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SIZE, aStr);
|
2001-02-02 10:14:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case XmlShapeTypeDraw3DLatheObject:
|
|
|
|
case XmlShapeTypeDraw3DExtrudeObject:
|
|
|
|
{
|
|
|
|
// write special 3DLathe/3DExtrude attributes
|
2006-06-19 17:12:33 +00:00
|
|
|
aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPolyPolygon3D")));
|
2001-02-02 10:14:37 +00:00
|
|
|
drawing::PolyPolygonShape3D xPolyPolygon3D;
|
|
|
|
aAny >>= xPolyPolygon3D;
|
|
|
|
|
|
|
|
// look for maximal values
|
2004-09-08 13:58:19 +00:00
|
|
|
double fXMin = 0;
|
|
|
|
double fXMax = 0;
|
|
|
|
double fYMin = 0;
|
|
|
|
double fYMax = 0;
|
2001-02-02 10:14:37 +00:00
|
|
|
BOOL bInit(FALSE);
|
|
|
|
sal_Int32 nOuterSequenceCount(xPolyPolygon3D.SequenceX.getLength());
|
|
|
|
drawing::DoubleSequence* pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray();
|
|
|
|
drawing::DoubleSequence* pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray();
|
|
|
|
|
2003-12-01 15:22:16 +00:00
|
|
|
sal_Int32 a;
|
|
|
|
for( a= 0L; a < nOuterSequenceCount; a++)
|
2001-02-02 10:14:37 +00:00
|
|
|
{
|
|
|
|
sal_Int32 nInnerSequenceCount(pInnerSequenceX->getLength());
|
|
|
|
double* pArrayX = pInnerSequenceX->getArray();
|
|
|
|
double* pArrayY = pInnerSequenceY->getArray();
|
|
|
|
|
|
|
|
for(sal_Int32 b(0L); b < nInnerSequenceCount; b++)
|
|
|
|
{
|
|
|
|
double fX = *pArrayX++;
|
|
|
|
double fY = *pArrayY++;
|
|
|
|
|
|
|
|
if(bInit)
|
|
|
|
{
|
|
|
|
if(fX > fXMax)
|
|
|
|
fXMax = fX;
|
|
|
|
|
|
|
|
if(fX < fXMin)
|
|
|
|
fXMin = fX;
|
|
|
|
|
|
|
|
if(fY > fYMax)
|
|
|
|
fYMax = fY;
|
|
|
|
|
|
|
|
if(fY < fYMin)
|
|
|
|
fYMin = fY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fXMin = fXMax = fX;
|
|
|
|
fYMin = fYMax = fY;
|
|
|
|
bInit = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pInnerSequenceX++;
|
|
|
|
pInnerSequenceY++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// export ViewBox
|
|
|
|
awt::Point aMinPoint(FRound(fXMin), FRound(fYMin));
|
|
|
|
awt::Size aMaxSize(FRound(fXMax) - aMinPoint.X, FRound(fYMax) - aMinPoint.Y);
|
|
|
|
SdXMLImExViewBox aViewBox(
|
|
|
|
aMinPoint.X, aMinPoint.Y, aMaxSize.Width, aMaxSize.Height);
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX,
|
|
|
|
aViewBox.GetExportString(mrExport.GetMM100UnitConverter()));
|
2001-02-02 10:14:37 +00:00
|
|
|
|
|
|
|
// prepare svx:d element export
|
|
|
|
SdXMLImExSvgDElement aSvgDElement(aViewBox);
|
|
|
|
pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray();
|
|
|
|
pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray();
|
|
|
|
|
|
|
|
for(a = 0L; a < nOuterSequenceCount; a++)
|
|
|
|
{
|
|
|
|
sal_Int32 nInnerSequenceCount(pInnerSequenceX->getLength());
|
|
|
|
double* pArrayX = pInnerSequenceX->getArray();
|
|
|
|
double* pArrayY = pInnerSequenceY->getArray();
|
|
|
|
drawing::PointSequence aPoly(nInnerSequenceCount);
|
|
|
|
awt::Point* pInnerSequence = aPoly.getArray();
|
|
|
|
|
|
|
|
for(sal_Int32 b(0L); b < nInnerSequenceCount; b++)
|
|
|
|
{
|
|
|
|
double fX = *pArrayX++;
|
|
|
|
double fY = *pArrayY++;
|
|
|
|
|
|
|
|
*pInnerSequence = awt::Point(FRound(fX), FRound(fY));
|
|
|
|
pInnerSequence++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculate closed flag
|
|
|
|
awt::Point* pFirst = aPoly.getArray();
|
|
|
|
awt::Point* pLast = pFirst + (nInnerSequenceCount - 1);
|
|
|
|
BOOL bClosed = (pFirst->X == pLast->X && pFirst->Y == pLast->Y);
|
|
|
|
|
|
|
|
aSvgDElement.AddPolygon(&aPoly, 0L, aMinPoint,
|
2006-06-19 17:12:33 +00:00
|
|
|
aMaxSize, mrExport.GetMM100UnitConverter(), bClosed);
|
2001-02-02 10:14:37 +00:00
|
|
|
|
|
|
|
// #80594# corrected error in PolyPolygon3D export for 3D XML
|
|
|
|
pInnerSequenceX++;
|
|
|
|
pInnerSequenceY++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// write point array
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aSvgDElement.GetExportString());
|
2001-02-02 10:14:37 +00:00
|
|
|
|
|
|
|
if(eShapeType == XmlShapeTypeDraw3DLatheObject)
|
|
|
|
{
|
|
|
|
// write 3DLathe shape
|
2006-06-19 17:12:33 +00:00
|
|
|
SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_ROTATE, sal_True, sal_True);
|
2001-02-02 10:14:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// write 3DExtrude shape
|
2006-06-19 17:12:33 +00:00
|
|
|
SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_EXTRUDE, sal_True, sal_True);
|
2001-02-02 10:14:37 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2006-06-19 17:12:33 +00:00
|
|
|
default:
|
|
|
|
break;
|
2001-02-02 10:14:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-03-28 08:47:01 +00:00
|
|
|
/** helper for chart that adds all attributes of a 3d scene element to the export */
|
|
|
|
void XMLShapeExport::export3DSceneAttributes( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet )
|
2001-02-02 10:14:37 +00:00
|
|
|
{
|
2001-03-28 08:47:01 +00:00
|
|
|
OUString aStr;
|
|
|
|
OUStringBuffer sStringBuffer;
|
2001-02-02 10:14:37 +00:00
|
|
|
|
2001-03-28 08:47:01 +00:00
|
|
|
// world transformation (UNO_NAME_3D_TRANSFORM_MATRIX == "D3DTransformMatrix")
|
|
|
|
uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DTransformMatrix")));
|
|
|
|
drawing::HomogenMatrix xHomMat;
|
|
|
|
aAny >>= xHomMat;
|
|
|
|
SdXMLImExTransform3D aTransform;
|
|
|
|
aTransform.AddHomogenMatrix(xHomMat);
|
|
|
|
if(aTransform.NeedsAction())
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_TRANSFORM, aTransform.GetExportString(mrExport.GetMM100UnitConverter()));
|
2001-03-28 08:47:01 +00:00
|
|
|
|
|
|
|
// VRP, VPN, VUP
|
|
|
|
aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DCameraGeometry")));
|
|
|
|
drawing::CameraGeometry aCamGeo;
|
|
|
|
aAny >>= aCamGeo;
|
|
|
|
|
|
|
|
Vector3D aVRP(aCamGeo.vrp.PositionX, aCamGeo.vrp.PositionY, aCamGeo.vrp.PositionZ);
|
|
|
|
if(aVRP != Vector3D(0.0, 0.0, 1.0)) // write only when not default
|
|
|
|
{
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aVRP);
|
2001-02-02 10:14:37 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_VRP, aStr);
|
2001-03-28 08:47:01 +00:00
|
|
|
}
|
2001-02-02 10:14:37 +00:00
|
|
|
|
2001-03-28 08:47:01 +00:00
|
|
|
Vector3D aVPN(aCamGeo.vpn.DirectionX, aCamGeo.vpn.DirectionY, aCamGeo.vpn.DirectionZ);
|
|
|
|
if(aVPN != Vector3D(0.0, 0.0, 1.0)) // write only when not default
|
|
|
|
{
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aVPN);
|
2001-02-02 10:14:37 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_VPN, aStr);
|
2001-03-28 08:47:01 +00:00
|
|
|
}
|
2001-02-02 10:14:37 +00:00
|
|
|
|
2001-03-28 08:47:01 +00:00
|
|
|
Vector3D aVUP(aCamGeo.vup.DirectionX, aCamGeo.vup.DirectionY, aCamGeo.vup.DirectionZ);
|
|
|
|
if(aVUP != Vector3D(0.0, 1.0, 0.0)) // write only when not default
|
|
|
|
{
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aVUP);
|
2001-02-02 10:14:37 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_VUP, aStr);
|
2001-03-28 08:47:01 +00:00
|
|
|
}
|
2001-02-02 10:14:37 +00:00
|
|
|
|
2001-03-28 08:47:01 +00:00
|
|
|
// projection "D3DScenePerspective" drawing::ProjectionMode
|
|
|
|
aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DScenePerspective")));
|
|
|
|
drawing::ProjectionMode xPrjMode;
|
|
|
|
aAny >>= xPrjMode;
|
|
|
|
if(xPrjMode == drawing::ProjectionMode_PARALLEL)
|
2001-06-29 20:07:26 +00:00
|
|
|
aStr = GetXMLToken(XML_PARALLEL);
|
2001-03-28 08:47:01 +00:00
|
|
|
else
|
2001-06-29 20:07:26 +00:00
|
|
|
aStr = GetXMLToken(XML_PERSPECTIVE);
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_PROJECTION, aStr);
|
2001-03-28 08:47:01 +00:00
|
|
|
|
|
|
|
// distance
|
|
|
|
aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneDistance")));
|
|
|
|
sal_Int32 nDistance;
|
|
|
|
aAny >>= nDistance;
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDistance);
|
2001-03-28 08:47:01 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_DISTANCE, aStr);
|
2001-03-28 08:47:01 +00:00
|
|
|
|
|
|
|
// focalLength
|
|
|
|
aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneFocalLength")));
|
|
|
|
sal_Int32 nFocalLength;
|
|
|
|
aAny >>= nFocalLength;
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nFocalLength);
|
2001-03-28 08:47:01 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_FOCAL_LENGTH, aStr);
|
2001-03-28 08:47:01 +00:00
|
|
|
|
|
|
|
// shadowSlant
|
|
|
|
aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadowSlant")));
|
|
|
|
sal_Int16 nShadowSlant;
|
|
|
|
aAny >>= nShadowSlant;
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertNumber(sStringBuffer, (sal_Int32)nShadowSlant);
|
2001-03-28 08:47:01 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SHADOW_SLANT, aStr);
|
2001-03-28 08:47:01 +00:00
|
|
|
|
|
|
|
// shadeMode
|
|
|
|
aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadeMode")));
|
|
|
|
drawing::ShadeMode xShadeMode;
|
|
|
|
if(aAny >>= xShadeMode)
|
|
|
|
{
|
|
|
|
if(xShadeMode == drawing::ShadeMode_FLAT)
|
2001-06-29 20:07:26 +00:00
|
|
|
aStr = GetXMLToken(XML_FLAT);
|
2001-03-28 08:47:01 +00:00
|
|
|
else if(xShadeMode == drawing::ShadeMode_PHONG)
|
2001-06-29 20:07:26 +00:00
|
|
|
aStr = GetXMLToken(XML_PHONG);
|
2001-03-28 08:47:01 +00:00
|
|
|
else if(xShadeMode == drawing::ShadeMode_SMOOTH)
|
2001-06-29 20:07:26 +00:00
|
|
|
aStr = GetXMLToken(XML_GOURAUD);
|
2001-03-28 08:47:01 +00:00
|
|
|
else
|
2001-06-29 20:07:26 +00:00
|
|
|
aStr = GetXMLToken(XML_DRAFT);
|
2001-03-28 08:47:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// ShadeMode enum not there, write default
|
2001-06-29 20:07:26 +00:00
|
|
|
aStr = GetXMLToken(XML_GOURAUD);
|
2001-02-02 10:14:37 +00:00
|
|
|
}
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SHADE_MODE, aStr);
|
2001-03-28 08:47:01 +00:00
|
|
|
|
|
|
|
// ambientColor
|
|
|
|
aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor")));
|
|
|
|
sal_Int32 aColTemp;
|
|
|
|
Color aAmbientColor;
|
|
|
|
aAny >>= aColTemp; aAmbientColor.SetColor(aColTemp);
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertColor(sStringBuffer, aAmbientColor);
|
2001-03-28 08:47:01 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_AMBIENT_COLOR, aStr);
|
2001-03-28 08:47:01 +00:00
|
|
|
|
|
|
|
// lightingMode
|
|
|
|
aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneTwoSidedLighting")));
|
|
|
|
sal_Bool bTwoSidedLighting;
|
|
|
|
aAny >>= bTwoSidedLighting;
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertBool(sStringBuffer, bTwoSidedLighting);
|
2001-03-28 08:47:01 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_LIGHTING_MODE, aStr);
|
2001-02-02 10:14:37 +00:00
|
|
|
}
|
|
|
|
|
2001-03-28 08:47:01 +00:00
|
|
|
/** helper for chart that exports all lamps from the propertyset */
|
|
|
|
void XMLShapeExport::export3DLamps( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet )
|
2001-02-02 10:14:37 +00:00
|
|
|
{
|
|
|
|
// write lamps 1..8 as content
|
|
|
|
OUString aStr;
|
|
|
|
OUStringBuffer sStringBuffer;
|
|
|
|
|
|
|
|
const OUString aColorPropName(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor") );
|
|
|
|
const OUString aDirectionPropName(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection") );
|
|
|
|
const OUString aLightOnPropName(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn") );
|
|
|
|
|
|
|
|
OUString aPropName;
|
|
|
|
OUString aIndexStr;
|
|
|
|
sal_Int32 aColTemp;
|
|
|
|
Color aLightColor;
|
|
|
|
Vector3D aLightDirection;
|
|
|
|
drawing::Direction3D xLightDir;
|
|
|
|
sal_Bool bLightOnOff;
|
2001-02-13 14:00:56 +00:00
|
|
|
for(sal_Int32 nLamp = 1; nLamp <= 8; nLamp++)
|
2001-02-02 10:14:37 +00:00
|
|
|
{
|
|
|
|
aIndexStr = OUString::valueOf( nLamp );
|
|
|
|
|
|
|
|
// lightcolor
|
|
|
|
aPropName = aColorPropName;
|
|
|
|
aPropName += aIndexStr;
|
|
|
|
xPropSet->getPropertyValue( aPropName ) >>= aColTemp;
|
|
|
|
aLightColor.SetColor(aColTemp);
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertColor(sStringBuffer, aLightColor);
|
2001-02-02 10:14:37 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_DIFFUSE_COLOR, aStr);
|
2001-02-02 10:14:37 +00:00
|
|
|
|
|
|
|
// lightdirection
|
|
|
|
aPropName = aDirectionPropName;
|
|
|
|
aPropName += aIndexStr;
|
|
|
|
xPropSet->getPropertyValue(aPropName) >>= xLightDir;
|
|
|
|
aLightDirection = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ);
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aLightDirection);
|
2001-02-02 10:14:37 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_DIRECTION, aStr);
|
2001-02-02 10:14:37 +00:00
|
|
|
|
|
|
|
// lighton
|
|
|
|
aPropName = aLightOnPropName;
|
|
|
|
aPropName += aIndexStr;
|
|
|
|
xPropSet->getPropertyValue(aPropName) >>= bLightOnOff;
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.GetMM100UnitConverter().convertBool(sStringBuffer, bLightOnOff);
|
2001-02-02 10:14:37 +00:00
|
|
|
aStr = sStringBuffer.makeStringAndClear();
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_ENABLED, aStr);
|
2001-02-02 10:14:37 +00:00
|
|
|
|
|
|
|
// specular
|
2006-06-19 17:12:33 +00:00
|
|
|
mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SPECULAR,
|
2001-06-29 20:07:26 +00:00
|
|
|
nLamp == 1 ? XML_TRUE : XML_FALSE);
|
2001-02-02 10:14:37 +00:00
|
|
|
|
|
|
|
// write light entry
|
2006-06-19 17:12:33 +00:00
|
|
|
SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_LIGHT, sal_True, sal_True);
|
2001-02-02 10:14:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|