diff options
author | Christian Lippka <cl@openoffice.org> | 2001-02-02 10:14:37 +0000 |
---|---|---|
committer | Christian Lippka <cl@openoffice.org> | 2001-02-02 10:14:37 +0000 |
commit | 72e5b4abc4d1dc521aad285ec63530efe620cb59 (patch) | |
tree | 25977562b66d361f6d8bfee7a4339eb5a47a61ab /xmloff | |
parent | f920ae3e7d17ca1adacfc8d33462408a5aa8ba6a (diff) |
#83254# moved shape export implementation to shape exporter
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/draw/makefile.mk | 6 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlexp.cxx | 2437 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlexp_impl.hxx | 108 | ||||
-rw-r--r-- | xmloff/source/draw/shapeexport.cxx | 480 | ||||
-rw-r--r-- | xmloff/source/draw/shapeexport2.cxx | 1088 | ||||
-rw-r--r-- | xmloff/source/draw/shapeexport3.cxx | 561 |
6 files changed, 2118 insertions, 2562 deletions
diff --git a/xmloff/source/draw/makefile.mk b/xmloff/source/draw/makefile.mk index 830f1e847a57..41737344c574 100644 --- a/xmloff/source/draw/makefile.mk +++ b/xmloff/source/draw/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.7 $ +# $Revision: 1.8 $ # -# last change: $Author: cl $ $Date: 2001-01-19 16:25:18 $ +# last change: $Author: cl $ $Date: 2001-02-02 11:14:37 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -94,6 +94,8 @@ SLOFILES = \ $(SLO)$/propimp0.obj \ $(SLO)$/xexptran.obj \ $(SLO)$/shapeexport.obj \ + $(SLO)$/shapeexport2.obj \ + $(SLO)$/shapeexport3.obj \ $(SLO)$/shapeimport.obj \ $(SLO)$/XMLShapePropertySetContext.obj \ $(SLO)$/XMLShapeStyleContext.obj \ diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index d3f507e31259..31ddff1e0ad9 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sdxmlexp.cxx,v $ * - * $Revision: 1.44 $ + * $Revision: 1.45 $ * - * last change: $Author: cl $ $Date: 2001-02-01 19:06:28 $ + * last change: $Author: cl $ $Date: 2001-02-02 11:14:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -113,10 +113,6 @@ #include "sdxmlexp_impl.hxx" #endif -#ifndef _COM_SUN_STAR_DRAWING_CIRCLEKIND_HPP_ -#include <com/sun/star/drawing/CircleKind.hpp> -#endif - #ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESSUPPLIER_HPP_ #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #endif @@ -149,14 +145,6 @@ #include <com/sun/star/drawing/XMasterPageTarget.hpp> #endif -#ifndef _COM_SUN_STAR_DRAWING_CONNECTORTYPE_HPP_ -#include <com/sun/star/drawing/ConnectorType.hpp> -#endif - -#ifndef _COM_SUN_STAR_DRAWING_XCONTROLSHAPE_HPP_ -#include <com/sun/star/drawing/XControlShape.hpp> -#endif - #ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_ #include <com/sun/star/text/XText.hpp> #endif @@ -209,10 +197,6 @@ #include "xexptran.hxx" #endif -#ifndef _COM_SUN_STAR_DRAWING_POLYPOLYGONBEZIERCOORDS_HPP_ -#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> -#endif - #ifndef _ISOLANG_HXX #include <tools/isolang.hxx> #endif @@ -229,42 +213,10 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #endif -#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_DOUBLESEQUENCE_HPP_ -#include <com/sun/star/drawing/DoubleSequence.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 _XMLOFF_PROPERTYSETMERGER_HXX_ #include "PropertySetMerger.hxx" #endif -#ifndef _COM_SUN_STAR_DRAWING_CAMERAGEOMETRY_HPP_ -#include <com/sun/star/drawing/CameraGeometry.hpp> -#endif - #ifndef _XMLOFF_LAYEREXP_HXX #include "layerexp.hxx" #endif @@ -280,40 +232,6 @@ using namespace ::com::sun::star::presentation; ////////////////////////////////////////////////////////////////////////////// -inline sal_Int32 FRound( double fVal ) -{ - return( fVal > 0.0 ? (sal_Int32) ( fVal + 0.5 ) : -(sal_Int32) ( -fVal + 0.5 ) ); -} - -////////////////////////////////////////////////////////////////////////////// - -class ImpXMLShapeStyleInfo -{ - OUString msStyleName; - sal_Int32 mnFamily; - -public: - ImpXMLShapeStyleInfo( - const OUString& rStyStr, - sal_Int32 nFam); - - const OUString& GetStyleName() const { return msStyleName; } - sal_Int32 GetFamily() const { return mnFamily; } -}; - -ImpXMLShapeStyleInfo::ImpXMLShapeStyleInfo( - const OUString& rStyStr, - sal_Int32 nFam) -: msStyleName(rStyStr), - mnFamily(nFam) -{ -} - - -DECLARE_LIST(ImpXMLShapeStyleInfoList, ImpXMLShapeStyleInfo*); - -////////////////////////////////////////////////////////////////////////////// - class ImpXMLEXPPageMasterInfo { sal_Int32 mnBorderBottom; @@ -559,7 +477,6 @@ SdXMLExport::SdXMLExport( sal_Bool bIsDraw) : SvXMLExport( MAP_CM, bIsDraw ? sXML_drawing : sXML_presentation ), mpPageMasterInfoList(new ImpXMLEXPPageMasterList(1, 4, 4)), mpPageMaterUsageList(new ImpXMLEXPPageMasterList(1, 4, 4)), - mpShapeStyleInfoList(new ImpXMLShapeStyleInfoList(16, 64, 64)), mpAutoLayoutInfoList(new ImpXMLAutoLayoutInfoList(1, 4, 4)), mpPropertySetMapper(0L), mpPresPagePropsMapper(0L), @@ -716,15 +633,6 @@ __EXPORT SdXMLExport::~SdXMLExport() mpPageMaterUsageList = 0L; } - // clear shape style infos - if(mpShapeStyleInfoList) - { - while(mpShapeStyleInfoList->Count()) - delete mpShapeStyleInfoList->Remove(mpShapeStyleInfoList->Count() - 1L); - delete mpShapeStyleInfoList; - mpShapeStyleInfoList = 0L; - } - // clear auto-layout infos if(mpAutoLayoutInfoList) { @@ -1646,12 +1554,9 @@ void SdXMLExport::_ExportContent() } // write graphic objects on this page (if any) - uno::Reference< container::XIndexAccess > xShapes(xDrawPage, uno::UNO_QUERY); + uno::Reference< drawing::XShapes > xShapes(xDrawPage, uno::UNO_QUERY); if(xShapes.is() && xShapes->getCount()) - { - // write shapes per se - ImpWriteSingleShapeStyleInfos(xShapes); - } + GetShapeExport()->exportShapes( xShapes ); // write animations and presentation notes (ONLY if presentation) if(IsImpress()) @@ -1671,7 +1576,7 @@ void SdXMLExport::_ExportContent() uno::Reference< drawing::XDrawPage > xNotesPage(xPresPage->getNotesPage()); if(xNotesPage.is()) { - uno::Reference< container::XIndexAccess > xShapes(xNotesPage, uno::UNO_QUERY); + uno::Reference< drawing::XShapes > xShapes(xNotesPage, uno::UNO_QUERY); if(xShapes.is() && xShapes->getCount()) { // write presentation notes @@ -1681,7 +1586,7 @@ void SdXMLExport::_ExportContent() exportFormsElement( xNotesPage ); // write shapes per se - ImpWriteSingleShapeStyleInfos(xShapes); + GetShapeExport()->exportShapes( xShapes ); } } } @@ -1746,2310 +1651,7 @@ void SdXMLExport::_ExportContent() ////////////////////////////////////////////////////////////////////////////// -void SdXMLExport::ImpExportTextBoxShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ ) -{ - const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); - - SdXMLImExTransform2D aTransform; - OUString aStr; - OUStringBuffer sStringBuffer; - - // presentation attribute (if presentation) - sal_Bool bIsPresShape(FALSE); - sal_Bool bIsEmptyPresObj(FALSE); - sal_Bool bIsPlaceholderDependant(TRUE); - - switch(eShapeType) - { - case XmlShapeTypePresSubtitleShape: - { - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_subtitle)); - bIsPresShape = TRUE; - break; - } - case XmlShapeTypePresTitleTextShape: - { - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_title)); - bIsPresShape = TRUE; - break; - } - case XmlShapeTypePresOutlinerShape: - { - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_outline)); - bIsPresShape = TRUE; - break; - } - case XmlShapeTypePresNotesShape: - { - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_notes)); - bIsPresShape = TRUE; - break; - } - } - - if(bIsPresShape) - { - // is empty pes shape? - if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject")))) - { - uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))) ); - aAny >>= bIsEmptyPresObj; - } - - // is user-transformed? - if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent")))) - { - uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent"))) ); - aAny >>= bIsPlaceholderDependant; - } - - // write presentation class entry - rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class, aStr); - - // write presentation placeholder entry - if(bIsEmptyPresObj) - rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_placeholder, - OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true))); - - // write user-transformed entry - if(!bIsPlaceholderDependant) - rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_user_transformed, - OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true))); - } - - // text shape, prepare parameters - awt::Point aPoint( xShape->getPosition() ); - if( pRefPoint ) - { - aPoint.X -= pRefPoint->X; - aPoint.Y -= pRefPoint->Y; - } - - awt::Size aSize( xShape->getSize() ); - - if( nFeatures & SEF_EXPORT_X ) - { - // svg: x - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr); - } - - if( nFeatures & SEF_EXPORT_Y ) - { - // svg: y - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr); - } - - if( nFeatures & SEF_EXPORT_WIDTH ) - { - // svg: width - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr); - } - - if( nFeatures & SEF_EXPORT_HEIGHT ) - { - // svg: height - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr); - } - - // evtl. rotation (100'th degree, part of transformation)? - sal_Int32 nRotAngle(0L); - uno::Any aAny = xPropSet->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("RotateAngle"))); - aAny >>= nRotAngle; - if(nRotAngle) - aTransform.AddRotate(nRotAngle / 100.0); - - // does transformation need to be exported? - if(aTransform.NeedsAction()) - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter())); - - // write text-box - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_text_box, sal_True, sal_True); - - // export text - if(!bIsEmptyPresObj) - { - uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); - if( xText.is() && xText->getString().getLength() ) - rExp.GetTextParagraphExport()->exportText( xText ); - } - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExportRectangleShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /*= SEF_DEFAULT */, com::sun::star::awt::Point* pRefPoint /* = NULL */ ) -{ - const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - SdXMLImExTransform2D aTransform; - OUString aStr; - OUStringBuffer sStringBuffer; - - // rectangle, prepare parameters - awt::Point aPoint = xShape->getPosition(); - if( pRefPoint ) - { - aPoint.X -= pRefPoint->X; - aPoint.Y -= pRefPoint->Y; - } - - awt::Size aSize = xShape->getSize(); - - if( nFeatures & SEF_EXPORT_X ) - { - // svg: x - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr); - } - - if( nFeatures & SEF_EXPORT_Y ) - { - // svg: y - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr); - } - - if( nFeatures & SEF_EXPORT_WIDTH ) - { - // svg: width - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr); - } - - if( nFeatures & SEF_EXPORT_HEIGHT ) - { - // svg: height - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr); - } - - // evtl. rotation (100'th degree, part of transformation)? - sal_Int32 nRotAngle(0L); - uno::Any aAny = xPropSet->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("RotateAngle"))); - aAny >>= nRotAngle; - if(nRotAngle) - aTransform.AddRotate(nRotAngle / 100.0); - - // does transformation need to be exported? - if(aTransform.NeedsAction()) - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter())); - - // evtl. corner radius? - sal_Int32 nCornerRadius(0L); - aAny = xPropSet->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius"))); - aAny >>= nCornerRadius; - if(nCornerRadius) - { - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nCornerRadius); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_corner_radius, aStr); - } - - // write rectangle - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_rect, sal_True, sal_True); - - // export text - uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); - if( xText.is() && xText->getString().getLength() ) - rExp.GetTextParagraphExport()->exportText( xText ); - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExportLineShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ ) -{ - const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - SdXMLImExTransform2D aTransform; - OUString aStr; - OUStringBuffer sStringBuffer; - awt::Point aStart(0,0); - awt::Point aEnd(1,1); - - drawing::PointSequenceSequence* pSourcePolyPolygon = 0L; - uno::Any aAny = xPropSet->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygon"))); - pSourcePolyPolygon = (drawing::PointSequenceSequence*)aAny.getValue(); - - if(pSourcePolyPolygon) - { - drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->getArray(); - if(pOuterSequence) - { - drawing::PointSequence* pInnerSequence = pOuterSequence++; - if(pInnerSequence) - { - awt::Point* pArray = pInnerSequence->getArray(); - if(pArray) - { - if(pInnerSequence->getLength() > 0) - { - aStart = awt::Point(pArray->X, pArray->Y); - pArray++; - } - - if(pInnerSequence->getLength() > 1) - { - aEnd = awt::Point(pArray->X, pArray->Y); - } - } - } - } - } - - if( pRefPoint ) - { - aStart.X -= pRefPoint->X; - aStart.Y -= pRefPoint->Y; - aEnd.X -= pRefPoint->X; - aEnd.Y -= pRefPoint->Y; - } - - // svg: x1 - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x1, aStr); - - // svg: y1 - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y1, aStr); - - // svg: x2 - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x2, aStr); - - // svg: y2 - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y2, aStr); - - // evtl. rotation (100'th degree, part of transformation)? - sal_Int32 nRotAngle(0L); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("RotateAngle"))); - aAny >>= nRotAngle; - if(nRotAngle) - aTransform.AddRotate(nRotAngle / 100.0); - - // does transformation need to be exported? - if(aTransform.NeedsAction()) - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter())); - - // write line - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_line, sal_True, sal_True); - - // export text - uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); - if( xText.is() && xText->getString().getLength() ) - rExp.GetTextParagraphExport()->exportText( xText ); - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExportEllipseShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) -{ - const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - SdXMLImExTransform2D aTransform; - // get size to decide between Circle and Ellipse - awt::Point aPoint = xShape->getPosition(); - if( pRefPoint ) - { - aPoint.X -= pRefPoint->X; - aPoint.Y -= pRefPoint->Y; - } - awt::Size aSize = xShape->getSize(); - sal_Int32 nRx((aSize.Width + 1) / 2); - sal_Int32 nRy((aSize.Height + 1) / 2); - BOOL bCircle(nRx == nRy); - OUString aStr; - OUStringBuffer sStringBuffer; - - if( nFeatures & SEF_EXPORT_X ) - { - // svg: cx - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X + nRx); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_cx, aStr); - } - - if( nFeatures & SEF_EXPORT_Y ) - { - // svg: cy - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y + nRy); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_cy, aStr); - } - - // evtl. rotation (100'th degree, part of transformation)? - sal_Int32 nRotAngle(0L); - uno::Any aAny = xPropSet->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("RotateAngle"))); - aAny >>= nRotAngle; - if(nRotAngle) - aTransform.AddRotate(nRotAngle / 100.0); - - // does transformation need to be exported? - if(aTransform.NeedsAction()) - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter())); - - drawing::CircleKind eKind = drawing::CircleKind_FULL; - xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleKind")) ) >>= eKind; - if( eKind != drawing::CircleKind_FULL ) - { - sal_Int32 nStartAngle; - sal_Int32 nEndAngle; - xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleStartAngle")) ) >>= nStartAngle; - xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleEndAngle")) ) >>= nEndAngle; - - const double dStartAngle = nStartAngle / 100.0; - const double dEndAngle = nEndAngle / 100.0; - - SvXMLUnitConverter::convertEnum( sStringBuffer, (USHORT)eKind, aXML_CircleKind_EnumMap ); - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_kind, sStringBuffer.makeStringAndClear() ); - - SvXMLUnitConverter::convertNumber( sStringBuffer, dStartAngle ); - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_start_angle, sStringBuffer.makeStringAndClear() ); - - SvXMLUnitConverter::convertNumber( sStringBuffer, dEndAngle ); - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_end_angle, sStringBuffer.makeStringAndClear() ); - } - - if(bCircle) - { - // svg: r - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nRx); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_r, aStr); - - // write circle - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_circle, sal_True, sal_True); - - // export text - uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); - if( xText.is() && xText->getString().getLength() ) - rExp.GetTextParagraphExport()->exportText( xText ); - } - else - { - // svg: rx - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nRx); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_rx, aStr); - - // svg: ry - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nRy); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_ry, aStr); - - // write ellipse - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_ellipse, sal_True, sal_True); - - // export text - uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); - if( xText.is() && xText->getString().getLength() ) - rExp.GetTextParagraphExport()->exportText( xText ); - } - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExportPolygonShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) -{ - const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - BOOL bClosed(eShapeType == XmlShapeTypeDrawPolyPolygonShape - || eShapeType == XmlShapeTypeDrawClosedBezierShape); - BOOL bBezier(eShapeType == XmlShapeTypeDrawClosedBezierShape - || eShapeType == XmlShapeTypeDrawOpenBezierShape); - SdXMLImExTransform2D aTransform; - OUString aStr; - OUStringBuffer sStringBuffer; - - // prepare posistion and size parameters - awt::Point aPoint = xShape->getPosition(); - if( pRefPoint ) - { - aPoint.X -= pRefPoint->X; - aPoint.Y -= pRefPoint->Y; - } - - awt::Size aSize = xShape->getSize(); - - if( nFeatures & SEF_EXPORT_X ) - { - // svg: x - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr); - } - - if( nFeatures & SEF_EXPORT_Y ) - { - // svg: y - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr); - } - - // svg: width - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr); - - // svg: height - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr); - - // evtl. rotation (100'th degree, part of transformation)? - sal_Int32 nRotAngle(0L); - uno::Any aAny = xPropSet->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("RotateAngle"))); - aAny >>= nRotAngle; - if(nRotAngle) - aTransform.AddRotate(nRotAngle / 100.0); - - // does transformation need to be exported? - if(aTransform.NeedsAction()) - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter())); - - // create and export ViewBox - SdXMLImExViewBox aViewBox(0, 0, aSize.Width, aSize.Height); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_viewBox, aViewBox.GetExportString(rExp.GetMM100UnitConverter())); - - - if(bBezier) - { - // get PolygonBezier - aAny = xPropSet->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier"))); - drawing::PolyPolygonBezierCoords* pSourcePolyPolygon = - (drawing::PolyPolygonBezierCoords*)aAny.getValue(); - - if(pSourcePolyPolygon && pSourcePolyPolygon->Coordinates.getLength()) - { - sal_Int32 nOuterCnt(pSourcePolyPolygon->Coordinates.getLength()); - drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->Coordinates.getArray(); - drawing::FlagSequence* pOuterFlags = pSourcePolyPolygon->Flags.getArray(); - - if(pOuterSequence && pOuterFlags) - { - // prepare svx:d element export - SdXMLImExSvgDElement aSvgDElement(aViewBox); - - for(sal_Int32 a(0L); a < nOuterCnt; a++) - { - drawing::PointSequence* pSequence = pOuterSequence++; - drawing::FlagSequence* pFlags = pOuterFlags++; - - if(pSequence && pFlags) - { - aSvgDElement.AddPolygon(pSequence, pFlags, - aPoint, aSize, rExp.GetMM100UnitConverter(), bClosed); - } - } - - // write point array - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_d, aSvgDElement.GetExportString()); - } - - // write object now - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_path, sal_True, sal_True); - - // export text - uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); - if( xText.is() && xText->getString().getLength() ) - rExp.GetTextParagraphExport()->exportText( xText ); - } - } - else - { - // get non-bezier polygon - aAny = xPropSet->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygon"))); - drawing::PointSequenceSequence* pSourcePolyPolygon = - (drawing::PointSequenceSequence*)aAny.getValue(); - - if(pSourcePolyPolygon && pSourcePolyPolygon->getLength()) - { - sal_Int32 nOuterCnt(pSourcePolyPolygon->getLength()); - - if(1L == nOuterCnt && !bBezier) - { - // simple polygon shape, can be written as svg:points sequence - drawing::PointSequence* pSequence = pSourcePolyPolygon->getArray(); - if(pSequence) - { - SdXMLImExPointsElement aPoints(pSequence, aViewBox, aPoint, aSize, rExp.GetMM100UnitConverter()); - - // write point array - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_points, aPoints.GetExportString()); - } - - // write object now - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, - bClosed ? sXML_polygon : sXML_polyline , sal_True, sal_True); - - // export text - uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); - if( xText.is() && xText->getString().getLength() ) - rExp.GetTextParagraphExport()->exportText( xText ); - } - else - { - // polypolygon or bezier, needs to be written as a svg:path sequence - drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->getArray(); - if(pOuterSequence) - { - // prepare svx:d element export - SdXMLImExSvgDElement aSvgDElement(aViewBox); - - for(sal_Int32 a(0L); a < nOuterCnt; a++) - { - drawing::PointSequence* pSequence = pOuterSequence++; - if(pSequence) - { - aSvgDElement.AddPolygon(pSequence, 0L, aPoint, - aSize, rExp.GetMM100UnitConverter(), bClosed); - } - } - - // write point array - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_d, aSvgDElement.GetExportString()); - } - - // write object now - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_path, sal_True, sal_True); - - // export text - uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); - if( xText.is() && xText->getString().getLength() ) - rExp.GetTextParagraphExport()->exportText( xText ); - } - } - } - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExportGraphicObjectShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) -{ - const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - SdXMLImExTransform2D aTransform; - OUString aStr; - OUStringBuffer sStringBuffer; - - sal_Bool bIsEmptyPresObj = sal_False; - uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); - - // prepare posistion and size parameters - awt::Point aPoint = xShape->getPosition(); - if( pRefPoint ) - { - aPoint.X -= pRefPoint->X; - aPoint.Y -= pRefPoint->Y; - } - - awt::Size aSize = xShape->getSize(); - - if( nFeatures & SEF_EXPORT_X ) - { - // svg: x - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr); - } - - if( nFeatures & SEF_EXPORT_Y ) - { - // svg: y - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr); - } - - // svg: width - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr); - - // svg: height - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr); - - // evtl. rotation (100'th degree, part of transformation)? - sal_Int32 nRotAngle(0L); - uno::Any aAny = xPropSet->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("RotateAngle"))); - aAny >>= nRotAngle; - if(nRotAngle) - aTransform.AddRotate(nRotAngle / 100.0); - - // does transformation need to be exported? - if(aTransform.NeedsAction()) - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter())); - - if(eShapeType == XmlShapeTypePresGraphicObjectShape) - { - if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject")))) - { - uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))); - aAny >>= bIsEmptyPresObj; - } - - // write presentation class entry - rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class, - OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_graphic))); - - // write presentation placeholder entry - if(bIsEmptyPresObj) - rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_placeholder, - OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true))); - } - - if( !bIsEmptyPresObj ) - { - OUString aStreamURL; - - aAny = xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))); - aAny >>= aStr; - rExp.AddAttribute(XML_NAMESPACE_XLINK, sXML_href, aStr = rExp.AddEmbeddedGraphicObject( aStr ) ); - - if( aStr.getLength() && aStr[ 0 ] == '#' ) - { - aStreamURL = OUString::createFromAscii( "vnd.sun.star.Package:" ); - aStreamURL = aStreamURL.concat( aStr.copy( 1, aStr.getLength() - 1 ) ); - } - - // update stream URL for load on demand - aAny <<= aStreamURL; - xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL")), aAny ); - - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_simple)); - rExp.AddAttribute(XML_NAMESPACE_XLINK, sXML_type, aStr ); - - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_embed)); - rExp.AddAttribute(XML_NAMESPACE_XLINK, sXML_show, aStr ); - - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_onLoad)); - rExp.AddAttribute(XML_NAMESPACE_XLINK, sXML_actuate, aStr ); - } - // write graphic object - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_image, sal_True, sal_True); - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExportChartShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) -{ - const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); - - sal_Bool bIsEmptyPresObj = sal_False; - if(eShapeType == XmlShapeTypePresChartShape) - { - if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject")))) - { - uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))); - aAny >>= bIsEmptyPresObj; - } - - // write presentation class entry - rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class, - OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_chart))); - - // write presentation placeholder entry - if(bIsEmptyPresObj) - rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_placeholder, - OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true))); - } - - OUString aStr; - OUStringBuffer sStringBuffer; - - // rectangle, prepare parameters - awt::Point aPoint( xShape->getPosition()); - if( pRefPoint ) - { - aPoint.X -= pRefPoint->X; - aPoint.Y -= pRefPoint->Y; - } - - awt::Size aSize( xShape->getSize()); - - if( nFeatures & SEF_EXPORT_X ) - { - // svg: x - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr); - } - - if( nFeatures & SEF_EXPORT_Y ) - { - // svg: y - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr); - } - - // svg: width - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr); - - // svg: height - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr); - - uno::Reference< chart::XChartDocument > xChartDoc; - if( !bIsEmptyPresObj ) - { - uno::Any aAny( xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ) ); - aAny >>= xChartDoc; - } - - if( xChartDoc.is() ) - { - // export chart data if the flag is not set (default) - sal_Bool bExportOwnData = (( nFeatures & SEF_EXPORT_NO_CHART_DATA ) == 0 ); - rExp.GetChartExport()->exportChart( xChartDoc, bExportOwnData ); - } - else - { - // write chart object (fake for now, replace later) - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_CHART, sXML_chart, sal_True, sal_True); - } - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExportSpreadsheetShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) -{ - const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); - - if(eShapeType == XmlShapeTypePresTableShape) - { - sal_Bool bIsEmptyPresObj = sal_False; - - if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject")))) - { - uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))); - aAny >>= bIsEmptyPresObj; - } - - // write presentation class entry - rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class, - OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_table))); - - // write presentation placeholder entry - if(bIsEmptyPresObj) - rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_placeholder, - OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true))); - } - - // write spreadsheet object (fake for now, replace later) - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML__unknown_, sal_True, sal_True); - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExportControlShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) -{ - OUString aStr; - OUStringBuffer sStringBuffer; - - // rectangle, prepare parameters - awt::Point aPoint = xShape->getPosition(); - if( pRefPoint ) - { - aPoint.X -= pRefPoint->X; - aPoint.Y -= pRefPoint->Y; - } - - awt::Size aSize = xShape->getSize(); - - if( nFeatures & SEF_EXPORT_X ) - { - // svg: x - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr); - } - - if( nFeatures & SEF_EXPORT_Y ) - { - // svg: y - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr); - } - - if( nFeatures & SEF_EXPORT_WIDTH ) - { - // svg: width - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr); - } - - if( nFeatures & SEF_EXPORT_HEIGHT ) - { - // svg: height - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr); - } - - uno::Reference< drawing::XControlShape > xControl( xShape, uno::UNO_QUERY ); - DBG_ASSERT( xControl.is(), "Control shape is not supporting XControlShape" ); - if( xControl.is() ) - { - uno::Reference< beans::XPropertySet > xControlModel( xControl->getControl(), uno::UNO_QUERY ); - DBG_ASSERT( xControlModel.is(), "Control shape has not XControlModel" ); - if( xControlModel.is() ) - { - rExp.AddAttribute( XML_NAMESPACE_FORM, sXML_id, rExp.GetFormExport()->getControlId( xControlModel ) ); - } - } - - // this is a control shape, in this place the database team - // would have to export the control abilities. Add Export later - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_control, sal_True, sal_True); -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExportConnectorShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) -{ - uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY ); - - OUString aStr; - OUStringBuffer sStringBuffer; - - // export connection kind - drawing::ConnectorType eType = drawing::ConnectorType_STANDARD; - uno::Any aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeKind"))); - aAny >>= eType; - - if( eType != drawing::ConnectorType_STANDARD ) - { - SvXMLUnitConverter::convertEnum( sStringBuffer, (sal_uInt16)eType, aXML_ConnectionKind_EnumMap ); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_type, aStr); - } - - // export line skew - sal_Int32 nDelta1 = 0, nDelta2 = 0, nDelta3 = 0; - - aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine1Delta"))); - aAny >>= nDelta1; - aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine2Delta"))); - aAny >>= nDelta2; - aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine3Delta"))); - aAny >>= nDelta3; - - if( nDelta1 != 0 || nDelta2 != 0 || nDelta3 != 0 ) - { - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta1); - if( nDelta2 != 0 || nDelta3 != 0 ) - { - const char aSpace = ' '; - sStringBuffer.appendAscii( &aSpace, 1 ); - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta2); - if( nDelta3 != 0 ) - { - sStringBuffer.appendAscii( &aSpace, 1 ); - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta3); - } - } - - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_line_skew, aStr); - } - - // export start and end point - awt::Point aStart(0,0); - awt::Point aEnd(1,1); - - aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition"))); - aAny >>= aStart; - - aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition"))); - aAny >>= aEnd; - - if( pRefPoint ) - { - aStart.X -= pRefPoint->X; - aStart.Y -= pRefPoint->Y; - aEnd.X -= pRefPoint->X; - aEnd.Y -= pRefPoint->Y; - } - - // svg: x1 - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x1, aStr); - - // svg: y1 - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y1, aStr); - - // svg: x2 - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x2, aStr); - - // svg: y2 - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y2, aStr); - - uno::Reference< drawing::XShape > xTempShape; - - // export start connection - aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartShape") ) ); - if( aAny >>= xTempShape ) - { - sal_Int32 nShapeId = rExp.GetShapeExport()->getShapeId( xTempShape ); - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_start_shape, OUString::valueOf( nShapeId )); - - aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartGluePointIndex")) ); - sal_Int32 nGluePointId; - if( aAny >>= nGluePointId ) - { - if( nGluePointId != -1 ) - { - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_start_glue_point, OUString::valueOf( nGluePointId )); - } - } - } - - // export end connection - aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndShape")) ); - if( aAny >>= xTempShape ) - { - sal_Int32 nShapeId = rExp.GetShapeExport()->getShapeId( xTempShape ); - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_end_shape, OUString::valueOf( nShapeId )); - - aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndGluePointIndex")) ); - sal_Int32 nGluePointId; - if( aAny >>= nGluePointId ) - { - if( nGluePointId != -1 ) - { - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_end_glue_point, OUString::valueOf( nGluePointId )); - } - } - } - - // write connector shape. Add Export later. - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_connector, sal_True, sal_True); - - // export text - uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); - if( xText.is() && xText->getString().getLength() ) - rExp.GetTextParagraphExport()->exportText( xText ); -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExportMeasureShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) -{ - uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY ); - - OUString aStr; - OUStringBuffer sStringBuffer; - - // export start and end point - awt::Point aStart(0,0); - awt::Point aEnd(1,1); - - uno::Any aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition"))); - aAny >>= aStart; - - aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition"))); - aAny >>= aEnd; - - if( pRefPoint ) - { - aStart.X -= pRefPoint->X; - aStart.Y -= pRefPoint->Y; - aEnd.X -= pRefPoint->X; - aEnd.Y -= pRefPoint->Y; - } - - // svg: x1 - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x1, aStr); - - // svg: y1 - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y1, aStr); - - // svg: x2 - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x2, aStr); - - // svg: y2 - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y2, aStr); - - // write measure shape. Add Export later. - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_measure, sal_True, sal_True); - - // export text - uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); - if( xText.is() ) - rExp.GetTextParagraphExport()->exportText( xText ); -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExportOLE2Shape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) -{ - const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); - - if(eShapeType == XmlShapeTypePresOLE2Shape) - { - sal_Bool bIsEmptyPresObj = sal_False; - - if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject")))) - { - uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))); - aAny >>= bIsEmptyPresObj; - } - - // write presentation class entry - rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class, - OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_object))); - - // write presentation placeholder entry - if(bIsEmptyPresObj) - rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_placeholder, - OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true))); - } - - // write spreadsheet object (fake for now, replace later) - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML__unknown_, sal_True, sal_True); - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExportPageShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) -{ - OUString aStr; - - // a presentation page shape, normally used on notes pages only. If - // it is used not as presentation shape, it may have been created with - // copy-paste exchange between draw and impress (this IS possible...) - if(eShapeType == XmlShapeTypePresPageShape) - { - rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class, - OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_page))); - } - - // write Page shape - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_page_thumbnail, sal_True, sal_True); -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExportCaptionShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) -{ - // write Caption shape. Add export later. - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_caption, sal_True, sal_True); - - // export text - uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); - if( xText.is() && xText->getString().getLength() ) - rExp.GetTextParagraphExport()->exportText( xText ); -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExport3DShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) -{ - 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()) - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter())); - - switch(eShapeType) - { - case XmlShapeTypeDraw3DCubeObject: - { - // write 3DCube shape - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DR3D, sXML_cube, sal_True, sal_True); - - // 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 - { - rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aPos3D); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_min_edge, aStr); - } - - // write maxEdge - if(aDir3D != Vector3D(2500.0, 2500.0, 2500.0)) // write only when not default - { - rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aDir3D); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_max_edge, aStr); - } - - break; - } - case XmlShapeTypeDraw3DSphereObject: - { - // write 3DSphere shape - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DR3D, sXML_sphere, sal_True, sal_True); - - // 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 - { - rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aPos3D); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_center, aStr); - } - - // write Size - if(aDir3D != Vector3D(5000.0, 5000.0, 5000.0)) // write only when not default - { - rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aDir3D); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_size, aStr); - } - - break; - } - case XmlShapeTypeDraw3DLatheObject: - case XmlShapeTypeDraw3DExtrudeObject: - { - // write special 3DLathe/3DExtrude attributes - uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPolyPolygon3D"))); - drawing::PolyPolygonShape3D xPolyPolygon3D; - aAny >>= xPolyPolygon3D; - - // look for maximal values - double fXMin, fXMax, fYMin, fYMax; - BOOL bInit(FALSE); - sal_Int32 nOuterSequenceCount(xPolyPolygon3D.SequenceX.getLength()); - drawing::DoubleSequence* pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray(); - drawing::DoubleSequence* pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray(); - - for(sal_Int32 a(0L); a < nOuterSequenceCount; a++) - { - 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); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_viewBox, - aViewBox.GetExportString(rExp.GetMM100UnitConverter())); - - // 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, - aMaxSize, rExp.GetMM100UnitConverter(), bClosed); - - // #80594# corrected error in PolyPolygon3D export for 3D XML - pInnerSequenceX++; - pInnerSequenceY++; - } - - // write point array - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_d, aSvgDElement.GetExportString()); - - if(eShapeType == XmlShapeTypeDraw3DLatheObject) - { - // write 3DLathe shape - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DR3D, sXML_rotate, sal_True, sal_True); - } - else - { - // write 3DExtrude shape - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DR3D, sXML_extrude, sal_True, sal_True); - } - break; - } - } - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpPrepareExport3DScene(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint) -{ - // write 3DScene attributes - const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - OUString aStr; - OUStringBuffer sStringBuffer; - - // rectangle, prepare parameters - awt::Point aPoint = xShape->getPosition(); - awt::Size aSize = xShape->getSize(); - if( pRefPoint ) - { - aPoint.X -= pRefPoint->X; - aPoint.Y -= pRefPoint->Y; - } - - // svg: x - if( nFeatures & SEF_EXPORT_X ) - { - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr); - } - - // svg: y - if( nFeatures & SEF_EXPORT_Y ) - { - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr); - } - - // svg: width - if( nFeatures & SEF_EXPORT_WIDTH ) - { - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr); - } - - // svg: height - if( nFeatures & SEF_EXPORT_HEIGHT ) - { - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr); - } - - // 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()) - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter())); - - // 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 - { - rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aVRP); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_vrp, aStr); - } - - 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 - { - rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aVPN); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_vpn, aStr); - } - - 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 - { - rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aVUP); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_vup, aStr); - } - - // projection "D3DScenePerspective" drawing::ProjectionMode - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DScenePerspective"))); - drawing::ProjectionMode xPrjMode; - aAny >>= xPrjMode; - if(xPrjMode == drawing::ProjectionMode_PARALLEL) - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_parallel)); - else - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_perspective)); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_projection, aStr); - - // distance - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneDistance"))); - sal_Int32 nDistance; - aAny >>= nDistance; - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDistance); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_distance, aStr); - - // focalLength - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneFocalLength"))); - sal_Int32 nFocalLength; - aAny >>= nFocalLength; - rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nFocalLength); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_focal_length, aStr); - - // shadowSlant - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadowSlant"))); - sal_Int16 nShadowSlant; - aAny >>= nShadowSlant; - rExp.GetMM100UnitConverter().convertNumber(sStringBuffer, (sal_Int32)nShadowSlant); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_shadow_slant, aStr); - - // shadeMode - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadeMode"))); - drawing::ShadeMode xShadeMode; - if(aAny >>= xShadeMode) - { - if(xShadeMode == drawing::ShadeMode_FLAT) - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_flat)); - else if(xShadeMode == drawing::ShadeMode_PHONG) - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_phong)); - else if(xShadeMode == drawing::ShadeMode_SMOOTH) - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_gouraud)); - else - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_draft)); - } - else - { - // ShadeMode enum not there, write default - aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_gouraud)); - } - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_shade_mode, aStr); - - // ambientColor - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor"))); - sal_Int32 aColTemp; - Color aAmbientColor; - aAny >>= aColTemp; aAmbientColor.SetColor(aColTemp); - rExp.GetMM100UnitConverter().convertColor(sStringBuffer, aAmbientColor); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_ambient_color, aStr); - - // lightingMode - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneTwoSidedLighting"))); - sal_Bool bTwoSidedLighting; - aAny >>= bTwoSidedLighting; - rExp.GetMM100UnitConverter().convertBool(sStringBuffer, bTwoSidedLighting); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_lighting_mode, aStr); - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpExport3DLamps(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint) -{ - const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - // write lamps 1..8 as content - uno::Any aAny; - OUString aStr; - OUStringBuffer sStringBuffer; - - // lightcolor - Color aLightColor[8]; - sal_Int32 aColTemp; - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor1"))); - aAny >>= aColTemp; aLightColor[0].SetColor(aColTemp); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor2"))); - aAny >>= aColTemp; aLightColor[1].SetColor(aColTemp); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor3"))); - aAny >>= aColTemp; aLightColor[2].SetColor(aColTemp); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor4"))); - aAny >>= aColTemp; aLightColor[3].SetColor(aColTemp); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor5"))); - aAny >>= aColTemp; aLightColor[4].SetColor(aColTemp); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor6"))); - aAny >>= aColTemp; aLightColor[5].SetColor(aColTemp); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor7"))); - aAny >>= aColTemp; aLightColor[6].SetColor(aColTemp); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor8"))); - aAny >>= aColTemp; aLightColor[7].SetColor(aColTemp); - - // lightdirection - Vector3D aLightDirection[8]; - drawing::Direction3D xLightDir; - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection1"))); - aAny >>= xLightDir; aLightDirection[0] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection2"))); - aAny >>= xLightDir; aLightDirection[1] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection3"))); - aAny >>= xLightDir; aLightDirection[2] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection4"))); - aAny >>= xLightDir; aLightDirection[3] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection5"))); - aAny >>= xLightDir; aLightDirection[4] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection6"))); - aAny >>= xLightDir; aLightDirection[5] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection7"))); - aAny >>= xLightDir; aLightDirection[6] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ); - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection8"))); - aAny >>= xLightDir; aLightDirection[7] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ); - - // lighton - sal_Bool bLightOnOff[8]; - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn1"))); - aAny >>= bLightOnOff[0]; - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn2"))); - aAny >>= bLightOnOff[1]; - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn3"))); - aAny >>= bLightOnOff[2]; - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn4"))); - aAny >>= bLightOnOff[3]; - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn5"))); - aAny >>= bLightOnOff[4]; - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn6"))); - aAny >>= bLightOnOff[5]; - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn7"))); - aAny >>= bLightOnOff[6]; - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn8"))); - aAny >>= bLightOnOff[7]; - - for(sal_uInt32 a(0L); a < 8; a++) - { - // lightcolor - rExp.GetMM100UnitConverter().convertColor(sStringBuffer, aLightColor[a]); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_diffuse_color, aStr); - - // lightdirection - rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aLightDirection[a]); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_direction, aStr); - - // lighton - rExp.GetMM100UnitConverter().convertBool(sStringBuffer, bLightOnOff[a]); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_enabled, aStr); - - // specular - rExp.GetMM100UnitConverter().convertBool(sStringBuffer, (BOOL)(a == 0L)); - aStr = sStringBuffer.makeStringAndClear(); - rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_specular, aStr); - - // write light entry - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DR3D, sXML_light, sal_True, sal_True); - } - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpWriteSingleShapeStyleInfo(const uno::Reference< drawing::XShape >& xShape, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ ) -{ - // get correct shape-style info - ImpXMLShapeStyleInfo* pInfo = - (mnShapeStyleInfoIndex < mpShapeStyleInfoList->Count()) ? - mpShapeStyleInfoList->GetObject(mnShapeStyleInfoIndex) : 0L; - mnShapeStyleInfoIndex++; - - if(pInfo && pInfo->GetStyleName().getLength()) - { - XmlShapeType eShapeType(XmlShapeTypeNotYetSet); - - ImpCalcShapeType(xShape, eShapeType); - ImpWriteSingleShapeStyleInfo(*this, xShape, - pInfo->GetFamily(), pInfo->GetStyleName(), eShapeType, nFeatures, pRefPoint ); - } -} - -////////////////////////////////////////////////////////////////////////////// - -// static version of ImpWriteSingleShapeStyleInfos() for external export -// used by XMLShapeExport::exportShape(...) -void SdXMLExport::ImpWriteSingleShapeStyleInfos(SvXMLExport& rExp, - uno::Reference< container::XIndexAccess >& xShapes, - sal_Int32 nFeatures, awt::Point* pRefPoint) -{ - const sal_Int32 nShapeCount(xShapes->getCount()); - sal_Int32 nShapeId; - - // loop over shapes - for(nShapeId = 0L; nShapeId < nShapeCount; nShapeId++) - { - uno::Any aAny(xShapes->getByIndex(nShapeId)); - uno::Reference< drawing::XShape > xShape; - - if(aAny >>= xShape) - { - uno::Reference< container::XIndexAccess > xShapes(xShape, uno::UNO_QUERY); - if(xShapes.is() && xShapes->getCount()) - { - // group shape - ImpStartWriteGroupShape(rExp, xShape, nFeatures, pRefPoint); - } - else - { - // single shape - rExp.GetShapeExport()->exportShape(xShape, nFeatures, pRefPoint); - } - } - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpStartWriteGroupShape(SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - sal_Int32 nFeatures, awt::Point* pRefPoint) -{ - uno::Reference< container::XIndexAccess > xShapes(xShape, uno::UNO_QUERY); - if(xShapes.is() && xShapes->getCount()) - { - // export shape id if needed - sal_Int32 nShapeId = rExp.GetShapeExport()->getShapeId( xShape ); - if( nShapeId != -1 ) - { - const OUString sId( OUString::valueOf( nShapeId ) ); - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_id, sId ); - } - - // group shape or 3Dscene? - sal_Bool bIsScene(FALSE); - uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xShape, uno::UNO_QUERY); - if(xShapeDescriptor.is()) - { - String aType((OUString)xShapeDescriptor->getShapeType()); - if(aType.EqualsAscii((const sal_Char*)"com.sun.star.drawing.Shape3DSceneObject")) - { - bIsScene = TRUE; - } - } - - if(bIsScene) - { - // prepare write 3DScene - ImpPrepareExport3DScene(rExp, xShape, XmlShapeTypeDraw3DSceneObject, nFeatures, pRefPoint); - - // write 3DScene shape - SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DR3D, sXML_scene, sal_True, sal_True); - - // write 3DSceneLights - ImpExport3DLamps(rExp, xShape, XmlShapeTypeDraw3DSceneObject, nFeatures, pRefPoint); - - // write members - ImpWriteSingleShapeStyleInfos(rExp, xShapes, nFeatures, pRefPoint); - } - else - { - // write group shape - SvXMLElementExport aPGR(rExp, XML_NAMESPACE_DRAW, sXML_g, sal_True, sal_True); - - // write members - ImpWriteSingleShapeStyleInfos(rExp, xShapes, nFeatures, pRefPoint); - } - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpCalcShapeType(const uno::Reference< drawing::XShape >& xShape, - XmlShapeType& eShapeType) -{ - // set in every case, so init here - eShapeType = XmlShapeTypeUnknown; - - uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xShape, uno::UNO_QUERY); - if(xShapeDescriptor.is()) - { - String aType((OUString)xShapeDescriptor->getShapeType()); - - if(aType.EqualsAscii((const sal_Char*)"com.sun.star.", 0, 13)) - { - if(aType.EqualsAscii("drawing.", 13, 8)) - { - // drawing shapes - if (aType.EqualsAscii("Rectangle", 21, 9)) { eShapeType = XmlShapeTypeDrawRectangleShape; } - else if(aType.EqualsAscii("Ellipse", 21, 7)) { eShapeType = XmlShapeTypeDrawEllipseShape; } - else if(aType.EqualsAscii("Control", 21, 7)) { eShapeType = XmlShapeTypeDrawControlShape; } - else if(aType.EqualsAscii("Connector", 21, 9)) { eShapeType = XmlShapeTypeDrawConnectorShape; } - else if(aType.EqualsAscii("Measure", 21, 7)) { eShapeType = XmlShapeTypeDrawMeasureShape; } - else if(aType.EqualsAscii("Line", 21, 4)) { eShapeType = XmlShapeTypeDrawLineShape; } - else if(aType.EqualsAscii("PolyPolygon", 21, 11)) { eShapeType = XmlShapeTypeDrawPolyPolygonShape; } - else if(aType.EqualsAscii("PolyLine", 21, 8)) { eShapeType = XmlShapeTypeDrawPolyLineShape; } - else if(aType.EqualsAscii("OpenBezier", 21, 10)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; } - else if(aType.EqualsAscii("ClosedBezier", 21, 12)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; } - else if(aType.EqualsAscii("GraphicObject", 21, 13)) { eShapeType = XmlShapeTypeDrawGraphicObjectShape; } - else if(aType.EqualsAscii("Group", 21, 5)) { eShapeType = XmlShapeTypeDrawGroupShape; } - else if(aType.EqualsAscii("Text", 21, 4)) { eShapeType = XmlShapeTypeDrawTextShape; } - else if(aType.EqualsAscii("OLE2", 21, 4)) - { - eShapeType = XmlShapeTypeDrawOLE2Shape; - - // get info about presentation shape - uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY); - - if(xPropSet.is()) - { - uno::Any aAny; - aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Model"))); - uno::Reference <lang::XServiceInfo> xObjectInfo; - - if(aAny >>= xObjectInfo) - { - if(xObjectInfo->supportsService(OUString(RTL_CONSTASCII_USTRINGPARAM - ("com.sun.star.chart.ChartDocument")))) - { - eShapeType = XmlShapeTypeDrawChartShape; - } - else if(xObjectInfo->supportsService(OUString(RTL_CONSTASCII_USTRINGPARAM - ("com.sun.star.sheet.SpreadsheetDocument")))) - { - eShapeType = XmlShapeTypeDrawTableShape; - } - else - { - // general OLE2 Object - } - } - } - } - else if(aType.EqualsAscii("Page", 21, 4)) { eShapeType = XmlShapeTypeDrawPageShape; } - else if(aType.EqualsAscii("Frame", 21, 5)) { eShapeType = XmlShapeTypeDrawFrameShape; } - else if(aType.EqualsAscii("Caption", 21, 6)) { eShapeType = XmlShapeTypeDrawCaptionShape; } - - // 3D shapes - else if(aType.EqualsAscii("Scene", 21 + 7, 5)) { eShapeType = XmlShapeTypeDraw3DSceneObject; } - else if(aType.EqualsAscii("Cube", 21 + 7, 4)) { eShapeType = XmlShapeTypeDraw3DCubeObject; } - else if(aType.EqualsAscii("Sphere", 21 + 7, 6)) { eShapeType = XmlShapeTypeDraw3DSphereObject; } - else if(aType.EqualsAscii("Lathe", 21 + 7, 5)) { eShapeType = XmlShapeTypeDraw3DLatheObject; } - else if(aType.EqualsAscii("Extrude", 21 + 7, 7)) { eShapeType = XmlShapeTypeDraw3DExtrudeObject; } - } - else if(aType.EqualsAscii("presentation.", 13, 13)) - { - // presentation shapes - if (aType.EqualsAscii("TitleText", 26, 9)) { eShapeType = XmlShapeTypePresTitleTextShape; } - else if(aType.EqualsAscii("Outliner", 26, 8)) { eShapeType = XmlShapeTypePresOutlinerShape; } - else if(aType.EqualsAscii("Subtitle", 26, 8)) { eShapeType = XmlShapeTypePresSubtitleShape; } - else if(aType.EqualsAscii("GraphicObject", 26, 13)) { eShapeType = XmlShapeTypePresGraphicObjectShape; } - else if(aType.EqualsAscii("Page", 26, 4)) { eShapeType = XmlShapeTypePresPageShape; } - else if(aType.EqualsAscii("OLE2", 26, 4)) { eShapeType = XmlShapeTypePresOLE2Shape; } - else if(aType.EqualsAscii("Chart", 26, 5)) { eShapeType = XmlShapeTypePresChartShape; } - else if(aType.EqualsAscii("Table", 26, 5)) { eShapeType = XmlShapeTypePresTableShape; } - else if(aType.EqualsAscii("OrgChart", 26, 8)) { eShapeType = XmlShapeTypePresOrgChartShape; } - else if(aType.EqualsAscii("Notes", 26, 5)) { eShapeType = XmlShapeTypePresNotesShape; } - } - } - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpWriteSingleShapeStyleInfo( - SvXMLExport& rExp, - const uno::Reference< drawing::XShape >& xShape, - sal_uInt16 nFamily, const OUString& rStyleName, XmlShapeType eShapeType, - sal_Int32 nFeatures /* = SEF_DEFAULT */, - com::sun::star::awt::Point* pRefPoint /* = NULL */ ) -{ - if( rStyleName.getLength() ) - { - // add style-name attribute (REQUIRED) Style-name, evtl. auto-style - if(XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily) - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_style_name, rStyleName); - else - rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_style_name, rStyleName); - } - - // export shape name if he has one - uno::Reference< container::XNamed > xNamed( xShape, uno::UNO_QUERY ); - if( xNamed.is() ) - { - const OUString aName( xNamed->getName() ); - if( aName.getLength() ) - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_name, aName ); - } - - // export shape id if needed - sal_Int32 nShapeId = rExp.GetShapeExport()->getShapeId( xShape ); - if( nShapeId != -1 ) - { - const OUString sId( OUString::valueOf( nShapeId ) ); - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_id, sId ); - } - - if( rExp.GetShapeExport()->IsLayerExportEnabled() ) - { - try - { - uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY ); - OUString aLayerName; - xProps->getPropertyValue( OUString::createFromAscii( "LayerName" ) ) >>= aLayerName; - rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_layer, aLayerName ); - -/* - sal_Int16 nLayerId; - - uno::Reference< drawing::XLayer > xLayer; - xLayerManager->getByIndex( nLayerId ) >>= xLayer; - if( xLayer.is() ) - { - - } -*/ - } - catch( uno::Exception e ) - { - DBG_ERROR( "could not export layer name for shape!" ); - } - - } - - switch(eShapeType) - { - case XmlShapeTypeDrawRectangleShape: - { - ImpExportRectangleShape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - case XmlShapeTypeDrawEllipseShape: - { - ImpExportEllipseShape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - case XmlShapeTypeDrawLineShape: - { - ImpExportLineShape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - case XmlShapeTypeDrawPolyPolygonShape: // closed PolyPolygon - case XmlShapeTypeDrawPolyLineShape: // open PolyPolygon - case XmlShapeTypeDrawClosedBezierShape: // closed PolyPolygon containing curves - case XmlShapeTypeDrawOpenBezierShape: // open PolyPolygon containing curves - { - ImpExportPolygonShape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - - case XmlShapeTypeDrawTextShape: - case XmlShapeTypePresTitleTextShape: - case XmlShapeTypePresOutlinerShape: - case XmlShapeTypePresSubtitleShape: - case XmlShapeTypePresNotesShape: - { - ImpExportTextBoxShape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - - case XmlShapeTypeDrawGraphicObjectShape: - case XmlShapeTypePresGraphicObjectShape: - { - ImpExportGraphicObjectShape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - - case XmlShapeTypeDrawChartShape: - case XmlShapeTypePresChartShape: - { - ImpExportChartShape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - - case XmlShapeTypeDrawTableShape: - case XmlShapeTypePresTableShape: - { - ImpExportSpreadsheetShape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - - case XmlShapeTypeDrawControlShape: - { - ImpExportControlShape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - - case XmlShapeTypeDrawConnectorShape: - { - ImpExportConnectorShape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - - case XmlShapeTypeDrawMeasureShape: - { - ImpExportMeasureShape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - - case XmlShapeTypeDrawOLE2Shape: - case XmlShapeTypePresOLE2Shape: - { - ImpExportOLE2Shape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - - case XmlShapeTypeDrawPageShape: - case XmlShapeTypePresPageShape: - { - ImpExportPageShape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - - case XmlShapeTypeDrawCaptionShape: - { - ImpExportCaptionShape(rExp, xShape, eShapeType, nFeatures, pRefPoint ); - break; - } - - case XmlShapeTypeDraw3DCubeObject: - case XmlShapeTypeDraw3DSphereObject: - case XmlShapeTypeDraw3DLatheObject: - case XmlShapeTypeDraw3DExtrudeObject: - { - ImpExport3DShape((SdXMLExport&)rExp, xShape, eShapeType); - break; - } - - case XmlShapeTypeDraw3DSceneObject: - { - // empty 3dscene - DBG_ASSERT(FALSE, "XMLEXP: WriteShape: empty 3DScene in export, not exported."); - break; - } - - case XmlShapeTypeDrawGroupShape: - { - // empty group - DBG_ASSERT(FALSE, "XMLEXP: WriteShape: empty GroupShape in export, not exported."); - break; - } - - case XmlShapeTypePresOrgChartShape: - case XmlShapeTypeDrawFrameShape: - case XmlShapeTypeUnknown: - case XmlShapeTypeNotYetSet: - default: - { - // this should never happen and is an error - DBG_ERROR("XMLEXP: WriteShape: unknown or unexpected type of shape in export!"); - break; - } - } - -} - -void SdXMLExport::ImpWriteSingleShapeStyleInfos(uno::Reference< container::XIndexAccess >& xShapes, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ ) -{ - const sal_Int32 nShapeCount(xShapes->getCount()); - sal_Int32 nShapeId; - - // loop over shapes - for(nShapeId = 0L; nShapeId < nShapeCount; nShapeId++) - { - uno::Any aAny(xShapes->getByIndex(nShapeId)); - uno::Reference< drawing::XShape > xShape; - - aAny >>= xShape; - if(xShape.is()) - { - // collect animation informations if needed - { - UniReference< XMLAnimationsExporter > xAnimExport( GetShapeExport()->getAnimationsExporter() ); - if( xAnimExport.is() ) - xAnimExport->collect( xShape ); - } - - // check for group or scene shape - uno::Reference< container::XIndexAccess > xShapes(xShape, uno::UNO_QUERY); - if(xShapes.is() && xShapes->getCount()) - { - // export shape id if needed - sal_Int32 nShapeId = GetShapeExport()->getShapeId( xShape ); - if( nShapeId != -1 ) - { - const OUString sId( OUString::valueOf( nShapeId ) ); - AddAttribute(XML_NAMESPACE_DRAW, sXML_id, sId ); - } - - // group shape or 3Dscene? - sal_Bool bIsScene(FALSE); - uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xShape, uno::UNO_QUERY); - if(xShapeDescriptor.is()) - { - String aType((OUString)xShapeDescriptor->getShapeType()); - if(aType.EqualsAscii((const sal_Char*)"com.sun.star.drawing.Shape3DSceneObject")) - { - bIsScene = TRUE; - } - } - - if(bIsScene) - { - // prepare write 3DScene - ImpPrepareExport3DScene(*this, xShape, XmlShapeTypeDraw3DSceneObject, nFeatures, pRefPoint); - - // write 3DScene shape - SvXMLElementExport aOBJ(*this, XML_NAMESPACE_DR3D, sXML_scene, sal_True, sal_True); - - // write 3DSceneLights - ImpExport3DLamps(*this, xShape, XmlShapeTypeDraw3DSceneObject, nFeatures, pRefPoint); - - // write members - ImpWriteSingleShapeStyleInfos(xShapes, nFeatures, pRefPoint ); - } - else - { - // write group shape - SvXMLElementExport aPGR(*this, XML_NAMESPACE_DRAW, sXML_g, sal_True, sal_True); - - // write members - ImpWriteSingleShapeStyleInfos(xShapes, nFeatures, pRefPoint); - } - } - else - { - // single shape - ImpWriteSingleShapeStyleInfo(xShape, nFeatures, pRefPoint ); - } - } - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SdXMLExport::ImpPrepSingleShapeStyleInfo(uno::Reference< drawing::XShape >& xShape, - const OUString& rPrefix) -{ - uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - OUString aParentName; - OUString aNewName; - uno::Reference< style::XStyle > xStyle; - sal_Int32 nFamily(XML_STYLE_FAMILY_SD_GRAPHICS_ID); - - uno::Any aAny = xPropSet->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("Style"))); - if((aAny >>= xStyle) && xStyle.is()) - { - // get family ID - uno::Reference< beans::XPropertySet > xStylePropSet(xStyle, uno::UNO_QUERY); - if(xStylePropSet.is()) - { - OUString aFamilyName; - aAny = xStylePropSet->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("Family"))); - if(aAny >>= aFamilyName) - { - if(aFamilyName.getLength() && aFamilyName.equals( - OUString(RTL_CONSTASCII_USTRINGPARAM("presentation")))) - { - nFamily = XML_STYLE_FAMILY_SD_PRESENTATION_ID; - } - } - } - - // get parent-style name - if(XML_STYLE_FAMILY_SD_PRESENTATION_ID == nFamily && rPrefix.getLength()) - { - aParentName = rPrefix; - aParentName += xStyle->getName(); - } - else - aParentName = xStyle->getName(); - } - - // filter propset - std::vector< XMLPropertyState > xPropStates = GetPropertySetMapper()->Filter( xPropSet ); - - if(!xPropStates.size()) - { - // no hard attributes, use parent style name for export - aNewName = aParentName; - } - else - { - // there are filtered properties -> hard attributes - // try to find this style in AutoStylePool - aNewName = GetAutoStylePool()->Find(nFamily, aParentName, xPropStates); - - if(!aNewName.getLength()) - { - // Style did not exist, add it to AutoStalePool - aNewName = GetAutoStylePool()->Add(nFamily, aParentName, xPropStates); - } - } - - // in aNewName is the StyleInfo to be used for exporting this object. - // Remember: String maybe still empty due to objects without style, - // like PageObjects(!) - // Now remember this association in helper class for later export - ImpXMLShapeStyleInfo* pInfo = new ImpXMLShapeStyleInfo(aNewName, nFamily); - mpShapeStyleInfoList->Insert(pInfo, LIST_APPEND); - - const OUString aShapeType( xShape->getShapeType() ); - - // prep text styles - uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY); - if(xText.is()) - { - uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); - - sal_Bool bIsEmptyPresObj = sal_False; - - if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(msEmptyPres)) - { - uno::Any aAny = xPropSet->getPropertyValue(msEmptyPres); - aAny >>= bIsEmptyPresObj; - } - - if(!bIsEmptyPresObj) - { - OUString aTxt( xText->getString() ); - if( aTxt.getLength() ) - { - // only collect text auto styles if there is text - GetTextParagraphExport()->collectTextAutoStyles( xText ); - } - } - } - - // check for calc ole - if( aShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.OLE2Shape" )) || - aShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.presentation.ChartShape" )) ) - { - uno::Reference< chart::XChartDocument > xChartDoc; - uno::Any aAny( xPropSet->getPropertyValue( msModel ) ); - aAny >>= xChartDoc; - if( xChartDoc.is() ) - { - GetChartExport()->collectAutoStyles( xChartDoc ); - } - } - - // check for connector - if( aShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.ConnectorShape" ) ) ) - { - uno::Reference< drawing::XShape > xConnection; - - // create shape ids for export later - if( xPropSet->getPropertyValue( msStartShape ) >>= xConnection ) - { - GetShapeExport()->createShapeId( xConnection ); - } - if( xPropSet->getPropertyValue( msEndShape ) >>= xConnection ) - { - GetShapeExport()->createShapeId( xConnection ); - } - } - } -} - -void SdXMLExport::ImpPrepSingleShapeStyleInfos(uno::Reference< container::XIndexAccess >& xShapes, - const OUString& rPrefix) -{ - const sal_Int32 nShapeCount(xShapes->getCount()); - sal_Int32 nShapeId; - - // loop over shapes - for(nShapeId = 0L; nShapeId < nShapeCount; nShapeId++) - { - uno::Any aAny(xShapes->getByIndex(nShapeId)); - uno::Reference< drawing::XShape > xShape; - - if(aAny >>= xShape) - { - uno::Reference< container::XIndexAccess > xShapes(xShape, uno::UNO_QUERY); - if(xShapes.is() && xShapes->getCount()) - { - // group shape - ImpPrepSingleShapeStyleInfos(xShapes, rPrefix); - } - else - { - // single shape - ImpPrepSingleShapeStyleInfo(xShape, rPrefix); - } - } - } -} ////////////////////////////////////////////////////////////////////////////// @@ -4124,10 +1726,11 @@ void SdXMLExport::_ExportAutoStyles() { aMasterPageNamePrefix += OUString(RTL_CONSTASCII_USTRINGPARAM("-")); } + GetShapeExport()->setPresentationStylePrefix( aMasterPageNamePrefix ); - uno::Reference< container::XIndexAccess > xShapes(xMasterPage, uno::UNO_QUERY); + uno::Reference< drawing::XShapes > xShapes(xMasterPage, uno::UNO_QUERY); if(xShapes.is() && xShapes->getCount()) - ImpPrepSingleShapeStyleInfos(xShapes, aMasterPageNamePrefix); + GetShapeExport()->collectShapesAutoStyles( xShapes ); if(IsImpress()) { @@ -4140,9 +1743,9 @@ void SdXMLExport::_ExportAutoStyles() // collect layer information GetFormExport()->examineForms( xNotesPage ); - uno::Reference< container::XIndexAccess > xShapes(xNotesPage, uno::UNO_QUERY); + uno::Reference< drawing::XShapes > xShapes(xNotesPage, uno::UNO_QUERY); if(xShapes.is() && xShapes->getCount()) - ImpPrepSingleShapeStyleInfos(xShapes, aMasterPageNamePrefix); + GetShapeExport()->collectShapesAutoStyles( xShapes ); } } } @@ -4180,10 +1783,12 @@ void SdXMLExport::_ExportAutoStyles() aMasterPageNamePrefix += OUString(RTL_CONSTASCII_USTRINGPARAM("-")); } + GetShapeExport()->setPresentationStylePrefix( aMasterPageNamePrefix ); + // prepare object infos - uno::Reference< container::XIndexAccess > xShapes(xDrawPage, uno::UNO_QUERY); + uno::Reference< drawing::XShapes > xShapes(xDrawPage, uno::UNO_QUERY); if(xShapes.is() && xShapes->getCount()) - ImpPrepSingleShapeStyleInfos(xShapes, aMasterPageNamePrefix); + GetShapeExport()->collectShapesAutoStyles( xShapes ); // prepare presentation notes page object infos (ONLY if presentation) if(IsImpress()) @@ -4197,9 +1802,9 @@ void SdXMLExport::_ExportAutoStyles() // collect layer information GetFormExport()->examineForms( xNotesPage ); - uno::Reference< container::XIndexAccess > xShapes(xNotesPage, uno::UNO_QUERY); + uno::Reference< drawing::XShapes > xShapes(xNotesPage, uno::UNO_QUERY); if(xShapes.is() && xShapes->getCount()) - ImpPrepSingleShapeStyleInfos(xShapes, aMasterPageNamePrefix); + GetShapeExport()->collectShapesAutoStyles( xShapes ); } } } @@ -4260,9 +1865,9 @@ void SdXMLExport::_ExportMasterStyles() exportFormsElement( xMasterPage ); // write graphic objects on this master page (if any) - uno::Reference< container::XIndexAccess > xShapes(xMasterPage, uno::UNO_QUERY); + uno::Reference< drawing::XShapes > xShapes(xMasterPage, uno::UNO_QUERY); if(xShapes.is() && xShapes->getCount()) - ImpWriteSingleShapeStyleInfos(xShapes); + GetShapeExport()->exportShapes( xShapes ); // write presentation notes (ONLY if presentation) if(IsImpress()) @@ -4273,7 +1878,7 @@ void SdXMLExport::_ExportMasterStyles() uno::Reference< drawing::XDrawPage > xNotesPage(xPresPage->getNotesPage()); if(xNotesPage.is()) { - uno::Reference< container::XIndexAccess > xShapes(xNotesPage, uno::UNO_QUERY); + uno::Reference< drawing::XShapes > xShapes(xNotesPage, uno::UNO_QUERY); if(xShapes.is() && xShapes->getCount()) { // write presentation notes @@ -4283,7 +1888,7 @@ void SdXMLExport::_ExportMasterStyles() exportFormsElement( xNotesPage ); // write shapes per se - ImpWriteSingleShapeStyleInfos(xShapes); + GetShapeExport()->exportShapes( xShapes ); } } } diff --git a/xmloff/source/draw/sdxmlexp_impl.hxx b/xmloff/source/draw/sdxmlexp_impl.hxx index f4b156279c94..28f471475f17 100644 --- a/xmloff/source/draw/sdxmlexp_impl.hxx +++ b/xmloff/source/draw/sdxmlexp_impl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: sdxmlexp_impl.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: cl $ $Date: 2001-01-18 14:49:52 $ + * last change: $Author: cl $ $Date: 2001-02-02 11:14:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -100,7 +100,6 @@ class ImpPresPageDrawStylePropMapper; class ImpXMLEXPPageMasterList; class ImpXMLEXPPageMasterInfo; class ImpXMLDrawPageInfoList; -class ImpXMLShapeStyleInfoList; class ImpXMLAutoLayoutInfoList; class SvXMLAutoStylePoolP; class XMLSdPropHdlFactory; @@ -128,52 +127,6 @@ enum XmlPlaceholder ////////////////////////////////////////////////////////////////////////////// -enum XmlShapeType -{ - XmlShapeTypeUnknown, // not known - - XmlShapeTypeDrawRectangleShape, // "com.sun.star.drawing.RectangleShape" - XmlShapeTypeDrawEllipseShape, // "com.sun.star.drawing.EllipseShape" - XmlShapeTypeDrawControlShape, // "com.sun.star.drawing.ControlShape" - XmlShapeTypeDrawConnectorShape, // "com.sun.star.drawing.ConnectorShape" - XmlShapeTypeDrawMeasureShape, // "com.sun.star.drawing.MeasureShape" - XmlShapeTypeDrawLineShape, // "com.sun.star.drawing.LineShape" - XmlShapeTypeDrawPolyPolygonShape, // "com.sun.star.drawing.PolyPolygonShape" - XmlShapeTypeDrawPolyLineShape, // "com.sun.star.drawing.PolyLineShape" - XmlShapeTypeDrawOpenBezierShape, // "com.sun.star.drawing.OpenBezierShape" - XmlShapeTypeDrawClosedBezierShape, // "com.sun.star.drawing.ClosedBezierShape" - XmlShapeTypeDrawGraphicObjectShape, // "com.sun.star.drawing.GraphicObjectShape" - XmlShapeTypeDrawGroupShape, // "com.sun.star.drawing.GroupShape" - XmlShapeTypeDrawTextShape, // "com.sun.star.drawing.TextShape" - XmlShapeTypeDrawOLE2Shape, // "com.sun.star.drawing.OLE2Shape" - XmlShapeTypeDrawChartShape, // embedded com.sun.star.chart - XmlShapeTypeDrawTableShape, // embedded com.sun.star.sheet - XmlShapeTypeDrawPageShape, // "com.sun.star.drawing.PageShape" - XmlShapeTypeDrawFrameShape, // "com.sun.star.drawing.FrameShape" - XmlShapeTypeDrawCaptionShape, // "com.sun.star.drawing.CaptionShape" - - XmlShapeTypeDraw3DSceneObject, // "com.sun.star.drawing.Shape3DSceneObject" - XmlShapeTypeDraw3DCubeObject, // "com.sun.star.drawing.Shape3DCubeObject" - XmlShapeTypeDraw3DSphereObject, // "com.sun.star.drawing.Shape3DSphereObject" - XmlShapeTypeDraw3DLatheObject, // "com.sun.star.drawing.Shape3DLatheObject" - XmlShapeTypeDraw3DExtrudeObject, // "com.sun.star.drawing.Shape3DExtrudeObject" - - XmlShapeTypePresTitleTextShape, // "com.sun.star.presentation.TitleTextShape" - XmlShapeTypePresOutlinerShape, // "com.sun.star.presentation.OutlinerShape" - XmlShapeTypePresSubtitleShape, // "com.sun.star.presentation.SubtitleShape" - XmlShapeTypePresGraphicObjectShape, // "com.sun.star.presentation.GraphicObjectShape" - XmlShapeTypePresPageShape, // "com.sun.star.presentation.PageShape" - XmlShapeTypePresOLE2Shape, // "com.sun.star.presentation.OLE2Shape" - XmlShapeTypePresChartShape, // "com.sun.star.presentation.ChartShape" - XmlShapeTypePresTableShape, // "com.sun.star.presentation.TableShape" - XmlShapeTypePresOrgChartShape, // "com.sun.star.presentation.OrgChartShape" - XmlShapeTypePresNotesShape, // "com.sun.star.presentation.NotesShape" - - XmlShapeTypeNotYetSet -}; - -////////////////////////////////////////////////////////////////////////////// - class SdXMLExport : public SvXMLExport { com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > mxDocStyleFamilies; @@ -186,7 +139,6 @@ class SdXMLExport : public SvXMLExport // temporary infos ImpXMLEXPPageMasterList* mpPageMasterInfoList; ImpXMLEXPPageMasterList* mpPageMaterUsageList; - ImpXMLShapeStyleInfoList* mpShapeStyleInfoList; ImpXMLAutoLayoutInfoList* mpAutoLayoutInfoList; ::std::vector< ::rtl::OUString > maDrawPagesAutoLayoutNames; @@ -231,65 +183,9 @@ class SdXMLExport : public SvXMLExport void ImpWriteDefaultStyleInfos(); - void ImpPrepSingleShapeStyleInfo(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, - const rtl::OUString& rPrefix); - void ImpPrepSingleShapeStyleInfos(com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& xShapes, - const rtl::OUString& rPrefix); - void ImpWriteSingleShapeStyleInfos(com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& xShapes, - sal_Int32 nFeatures = SEF_DEFAULT, - com::sun::star::awt::Point* pRefPoint = NULL - ); - - void ImpWriteSingleShapeStyleInfo(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, - sal_Int32 nFeatures = SEF_DEFAULT, - com::sun::star::awt::Point* pRefPoint = NULL - ); - void exportFormsElement( com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > xDrawPage ); public: - static void ImpWriteSingleShapeStyleInfo(SvXMLExport& rExp, - const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, - sal_uInt16 nFamily, const rtl::OUString& rStyleName, XmlShapeType eShapeType, - sal_Int32 nFeatures = SEF_DEFAULT, - com::sun::star::awt::Point* pRefPoint = NULL - ); - static void ImpWriteSingleShapeStyleInfos(SvXMLExport& rExp, - com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& xShapes, - sal_Int32 nFeatures = SEF_DEFAULT, - com::sun::star::awt::Point* pRefPoint = NULL - ); - static void ImpStartWriteGroupShape(SvXMLExport& rExp, - const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, - sal_Int32 nFeatures = SEF_DEFAULT, - com::sun::star::awt::Point* pRefPoint = NULL - ); - - static void ImpCalcShapeType(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, - XmlShapeType& eShapeType); - -private: - // single shape exporters - static void ImpExportRectangleShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExportLineShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExportEllipseShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExportPolygonShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExportTextBoxShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExportGraphicObjectShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExportChartShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExportSpreadsheetShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExportControlShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExportConnectorShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExportMeasureShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExportOLE2Shape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExportPageShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExportCaptionShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExport3DShape(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - - static void ImpPrepareExport3DScene(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - static void ImpExport3DLamps(SvXMLExport& rExp, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL ); - -public: SdXMLExport( sal_Bool bIsDraw ); virtual ~SdXMLExport(); diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index b0b7ccb76b82..6968d37b3add 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -2,9 +2,9 @@ * * $RCSfile: shapeexport.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: cl $ $Date: 2001-01-19 16:25:18 $ + * last change: $Author: cl $ $Date: 2001-02-02 11:14:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,6 +67,10 @@ #include <com/sun/star/chart/XChartDocument.hpp> #endif +#ifndef _COM_SUN_STAR_STYLE_XSTYLE_HPP_ +#include <com/sun/star/style/XStyle.hpp> +#endif + #ifndef _XMLOFF_SHAPEEXPORT_HXX #include "shapeexport.hxx" #endif @@ -107,11 +111,11 @@ XMLShapeExport::XMLShapeExport(SvXMLExport& rExp, msEndShape( RTL_CONSTASCII_USTRINGPARAM("EndShape") ) { // construct PropertyHandlerFactory - xSdPropHdlFactory = new XMLSdPropHdlFactory( rExp.GetModel() ); + xSdPropHdlFactory = new XMLSdPropHdlFactory( rExport.GetModel() ); // construct PropertySetMapper UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( xSdPropHdlFactory); - xPropertySetMapper = new XMLShapeExportPropertyMapper( xMapper, (XMLTextListAutoStylePool*)&rExp.GetTextParagraphExport()->GetListAutoStylePool(), rExp ); + xPropertySetMapper = new XMLShapeExportPropertyMapper( xMapper, (XMLTextListAutoStylePool*)&rExport.GetTextParagraphExport()->GetListAutoStylePool(), rExp ); if( pExtMapper ) { UniReference < SvXMLExportPropertyMapper > xExtMapper( pExtMapper ); @@ -121,50 +125,109 @@ XMLShapeExport::XMLShapeExport(SvXMLExport& rExp, // chain text attributes xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateCharExtPropMapper(rExp)); - rExp.GetAutoStylePool()->AddFamily( + rExport.GetAutoStylePool()->AddFamily( XML_STYLE_FAMILY_SD_GRAPHICS_ID, OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)), GetPropertySetMapper(), OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX))); - rExp.GetAutoStylePool()->AddFamily( + rExport.GetAutoStylePool()->AddFamily( XML_STYLE_FAMILY_SD_PRESENTATION_ID, OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_PRESENTATION_NAME)), GetPropertySetMapper(), OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_PRESENTATION_PREFIX))); + + maCurrentInfo = maShapeInfos.end(); } +/////////////////////////////////////////////////////////////////////// + XMLShapeExport::~XMLShapeExport() { } +/////////////////////////////////////////////////////////////////////// + // This method collects all automatic styles for the given XShape void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShape >& xShape) { + ImplXMLShapeExportInfo aShapeInfo; + + // ----------------------------- + // first compute the shapes type + // ----------------------------- + ImpCalcShapeType(xShape, aShapeInfo.meShapeType); + + // ------------------------------ + // compute the shape parent style + // ------------------------------ uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); if(xPropSet.is()) { + uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); + + OUString aParentName; + uno::Reference< style::XStyle > xStyle; + + if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName( OUString(RTL_CONSTASCII_USTRINGPARAM("Style"))) ) + xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Style"))) >>= xStyle; + + if(xStyle.is()) + { + // get family ID + uno::Reference< beans::XPropertySet > xStylePropSet(xStyle, uno::UNO_QUERY); + DBG_ASSERT( xStylePropSet.is(), "style without a XPropertySet?" ); + if(xStylePropSet.is()) + { + OUString aFamilyName; + xStylePropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Family"))) >>= aFamilyName; + if(aFamilyName.getLength() && aFamilyName.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("presentation")))) + aShapeInfo.mnFamily = XML_STYLE_FAMILY_SD_PRESENTATION_ID; + } + + // get parent-style name + if(XML_STYLE_FAMILY_SD_PRESENTATION_ID == aShapeInfo.mnFamily) + { + aParentName = msPresentationStylePrefix; + } + + aParentName += xStyle->getName(); + } + // filter propset - OUString aParentName; // parent maybe the pool in later versions - OUString aNewName; std::vector< XMLPropertyState > xPropStates = GetPropertySetMapper()->Filter( xPropSet ); - if(xPropStates.size()) + sal_Int32 nCount = 0; + std::vector< XMLPropertyState >::iterator aIter = xPropStates.begin(); + const std::vector< XMLPropertyState >::iterator aEnd = xPropStates.end(); + while( aIter != aEnd ) + { + if( aIter->mnIndex != -1 ) + nCount++; + aIter++; + } + + if(nCount == 0) + { + // no hard attributes, use parent style name for export + aShapeInfo.msStyleName = aParentName; + } + else { // there are filtered properties -> hard attributes // try to find this style in AutoStylePool - aNewName = GetExport().GetAutoStylePool()->Find( - XML_STYLE_FAMILY_SD_GRAPHICS_ID, aParentName, xPropStates); + aShapeInfo.msStyleName = rExport.GetAutoStylePool()->Find(aShapeInfo.mnFamily, aParentName, xPropStates); - if(!aNewName.getLength()) + if(!aShapeInfo.msStyleName.getLength()) { // Style did not exist, add it to AutoStalePool - GetExport().GetAutoStylePool()->Add( - XML_STYLE_FAMILY_SD_GRAPHICS_ID, aParentName, xPropStates); + aShapeInfo.msStyleName = rExport.GetAutoStylePool()->Add(aShapeInfo.mnFamily, aParentName, xPropStates); } } } + // ---------------- // prep text styles + // ---------------- uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY); if(xText.is()) { @@ -184,22 +247,23 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap } } - // check for calc ole - const OUString aShapeType( xShape->getShapeType() ); - if( aShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.OLE2Shape" )) || - aShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.presentation.CalcShape" )) ) + // ------------------- + // check for chart ole + // ------------------- + if( aShapeInfo.meShapeType == XmlShapeTypeDrawChartShape || aShapeInfo.meShapeType == XmlShapeTypePresChartShape ) { uno::Reference< chart::XChartDocument > xChartDoc; - uno::Any aAny( xPropSet->getPropertyValue(msModel) ); - aAny >>= xChartDoc; + xPropSet->getPropertyValue(msModel) >>= xChartDoc; if( xChartDoc.is() ) { GetExport().GetChartExport()->collectAutoStyles( xChartDoc ); } } + // ------------------- // check for connector - if( aShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.ConnectorShape" ) ) ) + // ------------------- + if( aShapeInfo.meShapeType == XmlShapeTypeDrawConnectorShape ) { uno::Reference< drawing::XShape > xConnection; @@ -213,43 +277,283 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap createShapeId( xConnection ); } } + + maShapeInfos.push_back( aShapeInfo ); + maCurrentInfo = maShapeInfos.begin(); + + // ----------------------------------------------------- + // check for shape collections (group shape or 3d scene) + // and collect contained shapes style infos + // ----------------------------------------------------- + { + uno::Reference< drawing::XShapes > xShapes( xShape, uno::UNO_QUERY ); + if( xShapes.is() ) + { + collectShapesAutoStyles( xShapes ); + } + } } +/////////////////////////////////////////////////////////////////////// + // This method exports the given XShape void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape, sal_Int32 nFeatures /* = SEF_DEFAULT */, com::sun::star::awt::Point* pRefPoint /* = NULL */ ) { - uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) + if( maCurrentInfo == maShapeInfos.end() ) { - OUString aParentName; // parent maybe the pool in later versions - OUString aNewName; - std::vector< XMLPropertyState > xPropStates( GetPropertySetMapper()->Filter( xPropSet ) ); + DBG_ERROR( "exportShape callings do not correspond to collectShapeAutoStyles calls!" ); + return; + } - if(xPropStates.size()) - aNewName = GetExport().GetAutoStylePool()->Find( - XML_STYLE_FAMILY_SD_GRAPHICS_ID, aParentName, xPropStates); + const ImplXMLShapeExportInfo aShapeInfo( *maCurrentInfo ); + maCurrentInfo++; - // compute the shape type +#ifdef DBG_UTIL + // ----------------------------- + // first compute the shapes type + // ----------------------------- + { XmlShapeType eShapeType(XmlShapeTypeNotYetSet); - SdXMLExport::ImpCalcShapeType(xShape, eShapeType); + ImpCalcShapeType(xShape, eShapeType); - uno::Reference< container::XIndexAccess > xShapes(xShape, uno::UNO_QUERY); - if(xShapes.is() && xShapes->getCount()) + DBG_ASSERT( eShapeType == aShapeInfo.meShapeType, "exportShape callings do not correspond to collectShapeAutoStyles calls!" ); + } +#endif + + // ------------------------------- + // export shapes name if he has one + // ------------------------------- + { + uno::Reference< container::XNamed > xNamed( xShape, uno::UNO_QUERY ); + if( xNamed.is() ) { - // group shape - SdXMLExport::ImpStartWriteGroupShape(GetExport(), xShape, nFeatures, pRefPoint); + const OUString aName( xNamed->getName() ); + if( aName.getLength() ) + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_name, aName ); } + } + + // ------------------ + // export style name + // ------------------ + if( aShapeInfo.msStyleName.getLength() != 0 ) + { + if(XML_STYLE_FAMILY_SD_GRAPHICS_ID == aShapeInfo.mnFamily) + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_style_name, aShapeInfo.msStyleName); else + rExport.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_style_name, aShapeInfo.msStyleName); + } + + // -------------------------- + // export shapes id if needed + // -------------------------- + { + const sal_Int32 nShapeId = getShapeId( xShape ); + if( nShapeId != -1 ) + { + const OUString sId( OUString::valueOf( nShapeId ) ); + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_id, sId ); + } + } + + // -------------------------- + // export layer information + // -------------------------- + if( IsLayerExportEnabled() ) + { + try + { + uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY ); + OUString aLayerName; + xProps->getPropertyValue( OUString::createFromAscii( "LayerName" ) ) >>= aLayerName; + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_layer, aLayerName ); + + } + catch( uno::Exception e ) + { + DBG_ERROR( "could not export layer name for shape!" ); + } + } + + // ---------------------------------------- + // collect animation informations if needed + // ---------------------------------------- + if( mxAnimationsExporter.is() ) + mxAnimationsExporter->collect( xShape ); + + // -------------------- + // export shape element + // -------------------- + switch(aShapeInfo.meShapeType) + { + case XmlShapeTypeDrawRectangleShape: + { + ImpExportRectangleShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + case XmlShapeTypeDrawEllipseShape: + { + ImpExportEllipseShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + case XmlShapeTypeDrawLineShape: + { + ImpExportLineShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + case XmlShapeTypeDrawPolyPolygonShape: // closed PolyPolygon + case XmlShapeTypeDrawPolyLineShape: // open PolyPolygon + case XmlShapeTypeDrawClosedBezierShape: // closed PolyPolygon containing curves + case XmlShapeTypeDrawOpenBezierShape: // open PolyPolygon containing curves + { + ImpExportPolygonShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + + case XmlShapeTypeDrawTextShape: + case XmlShapeTypePresTitleTextShape: + case XmlShapeTypePresOutlinerShape: + case XmlShapeTypePresSubtitleShape: + case XmlShapeTypePresNotesShape: + { + ImpExportTextBoxShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + + case XmlShapeTypeDrawGraphicObjectShape: + case XmlShapeTypePresGraphicObjectShape: + { + ImpExportGraphicObjectShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + + case XmlShapeTypeDrawChartShape: + case XmlShapeTypePresChartShape: + { + ImpExportChartShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + + case XmlShapeTypeDrawTableShape: + case XmlShapeTypePresTableShape: + { + ImpExportSpreadsheetShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + + case XmlShapeTypeDrawControlShape: + { + ImpExportControlShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + + case XmlShapeTypeDrawConnectorShape: + { + ImpExportConnectorShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + + case XmlShapeTypeDrawMeasureShape: + { + ImpExportMeasureShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + + case XmlShapeTypeDrawOLE2Shape: + case XmlShapeTypePresOLE2Shape: + { + ImpExportOLE2Shape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + + case XmlShapeTypeDrawPageShape: + case XmlShapeTypePresPageShape: + { + ImpExportPageShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + + case XmlShapeTypeDrawCaptionShape: + { + ImpExportCaptionShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + + case XmlShapeTypeDraw3DCubeObject: + case XmlShapeTypeDraw3DSphereObject: + case XmlShapeTypeDraw3DLatheObject: + case XmlShapeTypeDraw3DExtrudeObject: + { + ImpExport3DShape(xShape, aShapeInfo.meShapeType); + break; + } + + case XmlShapeTypeDraw3DSceneObject: { - // single shape - SdXMLExport::ImpWriteSingleShapeStyleInfo(GetExport(), xShape, - XML_STYLE_FAMILY_SD_GRAPHICS_ID, aNewName, eShapeType, nFeatures, pRefPoint); + ImpExport3DSceneShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; } + + case XmlShapeTypeDrawGroupShape: + { + // empty group + ImpExportGroupShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint ); + break; + } + + case XmlShapeTypePresOrgChartShape: + case XmlShapeTypeDrawFrameShape: + case XmlShapeTypeUnknown: + case XmlShapeTypeNotYetSet: + default: + { + // this should never happen and is an error + DBG_ERROR("XMLEXP: WriteShape: unknown or unexpected type of shape in export!"); + break; + } + } +} + +/////////////////////////////////////////////////////////////////////// + +// This method collects all automatic styles for the shapes inside the given XShapes collection +void XMLShapeExport::collectShapesAutoStyles( const uno::Reference < drawing::XShapes >& xShapes ) +{ + uno::Reference< drawing::XShape > xShape; + const sal_Int32 nShapeCount(xShapes->getCount()); + for(sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++) + { + xShapes->getByIndex(nShapeId) >>= xShape; + DBG_ASSERT( xShape.is(), "Shape without a XShape?" ); + if(!xShape.is()) + continue; + + collectShapeAutoStyles( xShape ); } } +/////////////////////////////////////////////////////////////////////// + +// This method exports all XShape inside the given XShapes collection +void XMLShapeExport::exportShapes( const uno::Reference < drawing::XShapes >& xShapes, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ ) +{ + uno::Reference< drawing::XShape > xShape; + const sal_Int32 nShapeCount(xShapes->getCount()); + for(sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++) + { + xShapes->getByIndex(nShapeId) >>= xShape; + DBG_ASSERT( xShape.is(), "Shape without a XShape?" ); + if(!xShape.is()) + continue; + + exportShape( xShape, nFeatures, pRefPoint ); + } +} + +/////////////////////////////////////////////////////////////////////// + void XMLShapeExport::exportAutoStyles() { // export all autostyle infos @@ -275,6 +579,8 @@ void XMLShapeExport::exportAutoStyles() } } +/////////////////////////////////////////////////////////////////////// + /** creates a unique id for this shape, this id is saved and exported with this shape later with the exportShape method. Its ok to call this twice with the same shape */ void XMLShapeExport::createShapeId( const uno::Reference < drawing::XShape >& xShape ) @@ -285,6 +591,8 @@ void XMLShapeExport::createShapeId( const uno::Reference < drawing::XShape >& xS maShapeIds[xShape] = mnNextUniqueShapeId++; } +/////////////////////////////////////////////////////////////////////// + /** returns the unique id for this shape. It returns -1 if the was no createShapeId call for this shape yet. */ sal_Int32 XMLShapeExport::getShapeId( const uno::Reference < drawing::XShape >& xShape ) @@ -297,6 +605,8 @@ sal_Int32 XMLShapeExport::getShapeId( const uno::Reference < drawing::XShape >& return -1; } +/////////////////////////////////////////////////////////////////////// + /// returns the export property mapper for external chaining SvXMLExportPropertyMapper* XMLShapeExport::CreateShapePropMapper( SvXMLExport& rExport ) @@ -311,3 +621,97 @@ SvXMLExportPropertyMapper* XMLShapeExport::CreateShapePropMapper( pResult->ChainExportMapper( XMLTextParagraphExport::CreateCharExtPropMapper( rExport )); return pResult; } + +/////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpCalcShapeType(const uno::Reference< drawing::XShape >& xShape, + XmlShapeType& eShapeType) +{ + // set in every case, so init here + eShapeType = XmlShapeTypeUnknown; + + uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xShape, uno::UNO_QUERY); + if(xShapeDescriptor.is()) + { + String aType((OUString)xShapeDescriptor->getShapeType()); + + if(aType.EqualsAscii((const sal_Char*)"com.sun.star.", 0, 13)) + { + if(aType.EqualsAscii("drawing.", 13, 8)) + { + // drawing shapes + if (aType.EqualsAscii("Rectangle", 21, 9)) { eShapeType = XmlShapeTypeDrawRectangleShape; } + else if(aType.EqualsAscii("Ellipse", 21, 7)) { eShapeType = XmlShapeTypeDrawEllipseShape; } + else if(aType.EqualsAscii("Control", 21, 7)) { eShapeType = XmlShapeTypeDrawControlShape; } + else if(aType.EqualsAscii("Connector", 21, 9)) { eShapeType = XmlShapeTypeDrawConnectorShape; } + else if(aType.EqualsAscii("Measure", 21, 7)) { eShapeType = XmlShapeTypeDrawMeasureShape; } + else if(aType.EqualsAscii("Line", 21, 4)) { eShapeType = XmlShapeTypeDrawLineShape; } + else if(aType.EqualsAscii("PolyPolygon", 21, 11)) { eShapeType = XmlShapeTypeDrawPolyPolygonShape; } + else if(aType.EqualsAscii("PolyLine", 21, 8)) { eShapeType = XmlShapeTypeDrawPolyLineShape; } + else if(aType.EqualsAscii("OpenBezier", 21, 10)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; } + else if(aType.EqualsAscii("ClosedBezier", 21, 12)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; } + else if(aType.EqualsAscii("GraphicObject", 21, 13)) { eShapeType = XmlShapeTypeDrawGraphicObjectShape; } + else if(aType.EqualsAscii("Group", 21, 5)) { eShapeType = XmlShapeTypeDrawGroupShape; } + else if(aType.EqualsAscii("Text", 21, 4)) { eShapeType = XmlShapeTypeDrawTextShape; } + else if(aType.EqualsAscii("OLE2", 21, 4)) + { + eShapeType = XmlShapeTypeDrawOLE2Shape; + + // get info about presentation shape + uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY); + + if(xPropSet.is()) + { + uno::Any aAny; + aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Model"))); + uno::Reference <lang::XServiceInfo> xObjectInfo; + + if(aAny >>= xObjectInfo) + { + if(xObjectInfo->supportsService(OUString(RTL_CONSTASCII_USTRINGPARAM + ("com.sun.star.chart.ChartDocument")))) + { + eShapeType = XmlShapeTypeDrawChartShape; + } + else if(xObjectInfo->supportsService(OUString(RTL_CONSTASCII_USTRINGPARAM + ("com.sun.star.sheet.SpreadsheetDocument")))) + { + eShapeType = XmlShapeTypeDrawTableShape; + } + else + { + // general OLE2 Object + } + } + } + } + else if(aType.EqualsAscii("Page", 21, 4)) { eShapeType = XmlShapeTypeDrawPageShape; } + else if(aType.EqualsAscii("Frame", 21, 5)) { eShapeType = XmlShapeTypeDrawFrameShape; } + else if(aType.EqualsAscii("Caption", 21, 6)) { eShapeType = XmlShapeTypeDrawCaptionShape; } + + // 3D shapes + else if(aType.EqualsAscii("Scene", 21 + 7, 5)) { eShapeType = XmlShapeTypeDraw3DSceneObject; } + else if(aType.EqualsAscii("Cube", 21 + 7, 4)) { eShapeType = XmlShapeTypeDraw3DCubeObject; } + else if(aType.EqualsAscii("Sphere", 21 + 7, 6)) { eShapeType = XmlShapeTypeDraw3DSphereObject; } + else if(aType.EqualsAscii("Lathe", 21 + 7, 5)) { eShapeType = XmlShapeTypeDraw3DLatheObject; } + else if(aType.EqualsAscii("Extrude", 21 + 7, 7)) { eShapeType = XmlShapeTypeDraw3DExtrudeObject; } + } + else if(aType.EqualsAscii("presentation.", 13, 13)) + { + // presentation shapes + if (aType.EqualsAscii("TitleText", 26, 9)) { eShapeType = XmlShapeTypePresTitleTextShape; } + else if(aType.EqualsAscii("Outliner", 26, 8)) { eShapeType = XmlShapeTypePresOutlinerShape; } + else if(aType.EqualsAscii("Subtitle", 26, 8)) { eShapeType = XmlShapeTypePresSubtitleShape; } + else if(aType.EqualsAscii("GraphicObject", 26, 13)) { eShapeType = XmlShapeTypePresGraphicObjectShape; } + else if(aType.EqualsAscii("Page", 26, 4)) { eShapeType = XmlShapeTypePresPageShape; } + else if(aType.EqualsAscii("OLE2", 26, 4)) { eShapeType = XmlShapeTypePresOLE2Shape; } + else if(aType.EqualsAscii("Chart", 26, 5)) { eShapeType = XmlShapeTypePresChartShape; } + else if(aType.EqualsAscii("Table", 26, 5)) { eShapeType = XmlShapeTypePresTableShape; } + else if(aType.EqualsAscii("OrgChart", 26, 8)) { eShapeType = XmlShapeTypePresOrgChartShape; } + else if(aType.EqualsAscii("Notes", 26, 5)) { eShapeType = XmlShapeTypePresNotesShape; } + } + } + } +} + +/////////////////////////////////////////////////////////////////////// diff --git a/xmloff/source/draw/shapeexport2.cxx b/xmloff/source/draw/shapeexport2.cxx new file mode 100644 index 000000000000..c25114d82d25 --- /dev/null +++ b/xmloff/source/draw/shapeexport2.cxx @@ -0,0 +1,1088 @@ +/************************************************************************* + * + * $RCSfile: shapeexport2.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: cl $ $Date: 2001-02-02 11:14:37 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * 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. + * + * 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. + * + * 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 + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_ +#include <com/sun/star/text/XText.hpp> +#endif + +#ifndef _COM_SUN_STAR_CHART_XCHARTDOCUMENT_HPP_ +#include <com/sun/star/chart/XChartDocument.hpp> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_CIRCLEKIND_HPP_ +#include <com/sun/star/drawing/CircleKind.hpp> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_CONNECTORTYPE_HPP_ +#include <com/sun/star/drawing/ConnectorType.hpp> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_XCONTROLSHAPE_HPP_ +#include <com/sun/star/drawing/XControlShape.hpp> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_POLYPOLYGONBEZIERCOORDS_HPP_ +#include <com/sun/star/drawing/PolyPolygonBezierCoords.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 + +#include "xmlkywd.hxx" +#include "xmlnmspe.hxx" + +using namespace ::rtl; +using namespace ::com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportSize( const uno::Reference< drawing::XShape >& xShape, sal_Int32 nFeatures ) +{ + OUStringBuffer sStringBuffer; + + awt::Size aSize( xShape->getSize() ); + + if( nFeatures & SEF_EXPORT_WIDTH ) + { + // svg: width + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_width, sStringBuffer.makeStringAndClear()); + } + + if( nFeatures & SEF_EXPORT_HEIGHT ) + { + // svg: height + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_height, sStringBuffer.makeStringAndClear()); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportPosition( const uno::Reference< drawing::XShape >& xShape, sal_Int32 nFeatures, awt::Point* pRefPoint ) +{ + OUStringBuffer sStringBuffer; + + awt::Point aPoint( xShape->getPosition() ); + if( pRefPoint ) + { + aPoint.X -= pRefPoint->X; + aPoint.Y -= pRefPoint->Y; + } + + if( nFeatures & SEF_EXPORT_X ) + { + // svg: x + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_x, sStringBuffer.makeStringAndClear()); + } + + if( nFeatures & SEF_EXPORT_Y ) + { + // svg: y + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_y, sStringBuffer.makeStringAndClear()); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportTransformation( const uno::Reference< beans::XPropertySet >& xPropSet ) +{ + OUStringBuffer sStringBuffer; + + SdXMLImExTransform2D aTransform; + + // evtl. rotation (100'th degree, part of transformation)? + sal_Int32 nRotAngle(0L); + uno::Any aAny = xPropSet->getPropertyValue( + OUString(RTL_CONSTASCII_USTRINGPARAM("RotateAngle"))); + aAny >>= nRotAngle; + if(nRotAngle) + aTransform.AddRotate(nRotAngle / 100.0); + + // does transformation need to be exported? + if(aTransform.NeedsAction()) + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_transform, aTransform.GetExportString(rExport.GetMM100UnitConverter())); +} + +////////////////////////////////////////////////////////////////////////////// + +sal_Bool XMLShapeExport::ImpExportPresentationAttributes( const uno::Reference< beans::XPropertySet >& xPropSet, const rtl::OUString& rClass ) +{ + sal_Bool bIsEmpty = sal_False; + + OUStringBuffer sStringBuffer; + + // write presentation class entry + rExport.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class, rClass); + + if( xPropSet.is() ) + { + uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); + + sal_Bool bTemp; + + // is empty pes shape? + if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject")))) + { + xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))) >>= bIsEmpty; + if( bIsEmpty ) + rExport.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_placeholder, OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true))); + } + + // is user-transformed? + if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent")))) + { + xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent"))) >>= bTemp; + if(!bTemp) + rExport.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_user_transformed, OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true))); + } + } + + return bIsEmpty; +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportText( const uno::Reference< drawing::XShape >& xShape ) +{ + uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); + if( xText.is() && xText->getString().getLength() ) + rExport.GetTextParagraphExport()->exportText( xText ); +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportGroupShape( const uno::Reference< drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint) +{ + uno::Reference< drawing::XShapes > xShapes(xShape, uno::UNO_QUERY); + if(xShapes.is() && xShapes->getCount()) + { + // write group shape + SvXMLElementExport aPGR(rExport, XML_NAMESPACE_DRAW, sXML_g, sal_True, sal_True); + + // write members + exportShapes( xShapes, nFeatures, pRefPoint ); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportTextBoxShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ ) +{ + const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); + if(xPropSet.is()) + { + uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); + + OUString aStr; + OUStringBuffer sStringBuffer; + + // presentation attribute (if presentation) + sal_Bool bIsPresShape(FALSE); + sal_Bool bIsEmptyPresObj(FALSE); + + switch(eShapeType) + { + case XmlShapeTypePresSubtitleShape: + { + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_subtitle)); + bIsPresShape = TRUE; + break; + } + case XmlShapeTypePresTitleTextShape: + { + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_title)); + bIsPresShape = TRUE; + break; + } + case XmlShapeTypePresOutlinerShape: + { + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_outline)); + bIsPresShape = TRUE; + break; + } + case XmlShapeTypePresNotesShape: + { + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_notes)); + bIsPresShape = TRUE; + break; + } + } + + ImpExportPosition( xShape, nFeatures, pRefPoint ); + ImpExportSize( xShape, nFeatures ); + ImpExportTransformation( xPropSet ); + + if(bIsPresShape) + bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, aStr ); + + // write text-box + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_text_box, sal_True, sal_True); + + // export text + if(!bIsEmptyPresObj) + ImpExportText( xShape ); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportRectangleShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /*= SEF_DEFAULT */, com::sun::star::awt::Point* pRefPoint /* = NULL */ ) +{ + const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); + if(xPropSet.is()) + { + OUStringBuffer sStringBuffer; + + ImpExportPosition( xShape, nFeatures, pRefPoint ); + ImpExportSize( xShape, nFeatures ); + ImpExportTransformation( xPropSet ); + + // evtl. corner radius? + sal_Int32 nCornerRadius(0L); + xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius"))) >>= nCornerRadius; + if(nCornerRadius) + { + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nCornerRadius); + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_corner_radius, sStringBuffer.makeStringAndClear()); + } + + // write rectangle + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_rect, sal_True, sal_True); + + // export text + ImpExportText( xShape ); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportLineShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ ) +{ + const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); + if(xPropSet.is()) + { + SdXMLImExTransform2D aTransform; + OUString aStr; + OUStringBuffer sStringBuffer; + awt::Point aStart(0,0); + awt::Point aEnd(1,1); + + drawing::PointSequenceSequence* pSourcePolyPolygon = 0L; + uno::Any aAny = xPropSet->getPropertyValue( + OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygon"))); + pSourcePolyPolygon = (drawing::PointSequenceSequence*)aAny.getValue(); + + if(pSourcePolyPolygon) + { + drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->getArray(); + if(pOuterSequence) + { + drawing::PointSequence* pInnerSequence = pOuterSequence++; + if(pInnerSequence) + { + awt::Point* pArray = pInnerSequence->getArray(); + if(pArray) + { + if(pInnerSequence->getLength() > 0) + { + aStart = awt::Point(pArray->X, pArray->Y); + pArray++; + } + + if(pInnerSequence->getLength() > 1) + { + aEnd = awt::Point(pArray->X, pArray->Y); + } + } + } + } + } + + if( pRefPoint ) + { + aStart.X -= pRefPoint->X; + aStart.Y -= pRefPoint->Y; + aEnd.X -= pRefPoint->X; + aEnd.Y -= pRefPoint->Y; + } + + if( nFeatures & SEF_EXPORT_X ) + { + // svg: x1 + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_x1, aStr); + } + else + { + aEnd.X -= aStart.X; + } + + if( nFeatures & SEF_EXPORT_Y ) + { + // svg: y1 + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_y1, aStr); + } + else + { + aEnd.Y -= aStart.Y; + } + + // svg: x2 + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_x2, aStr); + + // svg: y2 + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_y2, aStr); + + // write line + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_line, sal_True, sal_True); + + // export text + ImpExportText( xShape ); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportEllipseShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) +{ + const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); + if(xPropSet.is()) + { + SdXMLImExTransform2D aTransform; + // get size to decide between Circle and Ellipse + awt::Point aPoint = xShape->getPosition(); + if( pRefPoint ) + { + aPoint.X -= pRefPoint->X; + aPoint.Y -= pRefPoint->Y; + } + + awt::Size aSize = xShape->getSize(); + sal_Int32 nRx((aSize.Width + 1) / 2); + sal_Int32 nRy((aSize.Height + 1) / 2); + BOOL bCircle(nRx == nRy); + OUString aStr; + OUStringBuffer sStringBuffer; + + if( nFeatures & SEF_EXPORT_X ) + { + // svg: cx + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X + nRx); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_cx, aStr); + } + + if( nFeatures & SEF_EXPORT_Y ) + { + // svg: cy + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y + nRy); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_cy, aStr); + } + + ImpExportTransformation( xPropSet ); + + drawing::CircleKind eKind = drawing::CircleKind_FULL; + xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleKind")) ) >>= eKind; + if( eKind != drawing::CircleKind_FULL ) + { + sal_Int32 nStartAngle; + sal_Int32 nEndAngle; + xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleStartAngle")) ) >>= nStartAngle; + xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleEndAngle")) ) >>= nEndAngle; + + const double dStartAngle = nStartAngle / 100.0; + const double dEndAngle = nEndAngle / 100.0; + + SvXMLUnitConverter::convertEnum( sStringBuffer, (USHORT)eKind, aXML_CircleKind_EnumMap ); + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_kind, sStringBuffer.makeStringAndClear() ); + + SvXMLUnitConverter::convertNumber( sStringBuffer, dStartAngle ); + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_start_angle, sStringBuffer.makeStringAndClear() ); + + SvXMLUnitConverter::convertNumber( sStringBuffer, dEndAngle ); + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_end_angle, sStringBuffer.makeStringAndClear() ); + } + + if(bCircle) + { + // svg: r + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nRx); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_r, aStr); + + // write circle + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_circle, sal_True, sal_True); + + // export text + ImpExportText( xShape ); + } + else + { + // svg: rx + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nRx); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_rx, aStr); + + // svg: ry + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nRy); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_ry, aStr); + + // write ellipse + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_ellipse, sal_True, sal_True); + + // export text + ImpExportText( xShape ); + } + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportPolygonShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) +{ + const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); + if(xPropSet.is()) + { + BOOL bClosed(eShapeType == XmlShapeTypeDrawPolyPolygonShape + || eShapeType == XmlShapeTypeDrawClosedBezierShape); + BOOL bBezier(eShapeType == XmlShapeTypeDrawClosedBezierShape + || eShapeType == XmlShapeTypeDrawOpenBezierShape); + + OUStringBuffer sStringBuffer; + + ImpExportPosition( xShape, nFeatures, pRefPoint ); + ImpExportSize( xShape, nFeatures ); + ImpExportTransformation( xPropSet ); + + // create and export ViewBox + awt::Point aPoint( xShape->getPosition() ); + awt::Size aSize( xShape->getSize() ); + SdXMLImExViewBox aViewBox(0, 0, aSize.Width, aSize.Height); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_viewBox, aViewBox.GetExportString(rExport.GetMM100UnitConverter())); + + if(bBezier) + { + // get PolygonBezier + uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier"))) ); + drawing::PolyPolygonBezierCoords* pSourcePolyPolygon = + (drawing::PolyPolygonBezierCoords*)aAny.getValue(); + + if(pSourcePolyPolygon && pSourcePolyPolygon->Coordinates.getLength()) + { + sal_Int32 nOuterCnt(pSourcePolyPolygon->Coordinates.getLength()); + drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->Coordinates.getArray(); + drawing::FlagSequence* pOuterFlags = pSourcePolyPolygon->Flags.getArray(); + + if(pOuterSequence && pOuterFlags) + { + // prepare svx:d element export + SdXMLImExSvgDElement aSvgDElement(aViewBox); + + for(sal_Int32 a(0L); a < nOuterCnt; a++) + { + drawing::PointSequence* pSequence = pOuterSequence++; + drawing::FlagSequence* pFlags = pOuterFlags++; + + if(pSequence && pFlags) + { + aSvgDElement.AddPolygon(pSequence, pFlags, + aPoint, aSize, rExport.GetMM100UnitConverter(), bClosed); + } + } + + // write point array + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_d, aSvgDElement.GetExportString()); + } + + // write object now + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_path, sal_True, sal_True); + + // export text + uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); + if( xText.is() && xText->getString().getLength() ) + rExport.GetTextParagraphExport()->exportText( xText ); + } + } + else + { + // get non-bezier polygon + uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygon"))) ); + drawing::PointSequenceSequence* pSourcePolyPolygon = (drawing::PointSequenceSequence*)aAny.getValue(); + + if(pSourcePolyPolygon && pSourcePolyPolygon->getLength()) + { + sal_Int32 nOuterCnt(pSourcePolyPolygon->getLength()); + + if(1L == nOuterCnt && !bBezier) + { + // simple polygon shape, can be written as svg:points sequence + drawing::PointSequence* pSequence = pSourcePolyPolygon->getArray(); + if(pSequence) + { + SdXMLImExPointsElement aPoints(pSequence, aViewBox, aPoint, aSize, rExport.GetMM100UnitConverter()); + + // write point array + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_points, aPoints.GetExportString()); + } + + // write object now + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, + bClosed ? sXML_polygon : sXML_polyline , sal_True, sal_True); + + // export text + ImpExportText( xShape ); + } + else + { + // polypolygon or bezier, needs to be written as a svg:path sequence + drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->getArray(); + if(pOuterSequence) + { + // prepare svx:d element export + SdXMLImExSvgDElement aSvgDElement(aViewBox); + + for(sal_Int32 a(0L); a < nOuterCnt; a++) + { + drawing::PointSequence* pSequence = pOuterSequence++; + if(pSequence) + { + aSvgDElement.AddPolygon(pSequence, 0L, aPoint, + aSize, rExport.GetMM100UnitConverter(), bClosed); + } + } + + // write point array + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_d, aSvgDElement.GetExportString()); + } + + // write object now + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_path, sal_True, sal_True); + + // export text + ImpExportText( xShape ); + } + } + } + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportGraphicObjectShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) +{ + const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); + if(xPropSet.is()) + { + OUStringBuffer sStringBuffer; + + sal_Bool bIsEmptyPresObj = sal_False; + uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); + + ImpExportPosition( xShape, nFeatures, pRefPoint ); + ImpExportSize( xShape, nFeatures ); + ImpExportTransformation( xPropSet ); + + if(eShapeType == XmlShapeTypePresGraphicObjectShape) + bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_graphic)) ); + + if( !bIsEmptyPresObj ) + { + OUString aStreamURL; + OUString aStr; + + xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))) >>= aStr; + rExport.AddAttribute(XML_NAMESPACE_XLINK, sXML_href, aStr = rExport.AddEmbeddedGraphicObject( aStr ) ); + + if( aStr.getLength() && aStr[ 0 ] == '#' ) + { + aStreamURL = OUString::createFromAscii( "vnd.sun.star.Package:" ); + aStreamURL = aStreamURL.concat( aStr.copy( 1, aStr.getLength() - 1 ) ); + } + + // update stream URL for load on demand + uno::Any aAny; + aAny <<= aStreamURL; + xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL")), aAny ); + + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_simple)); + rExport.AddAttribute(XML_NAMESPACE_XLINK, sXML_type, aStr ); + + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_embed)); + rExport.AddAttribute(XML_NAMESPACE_XLINK, sXML_show, aStr ); + + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_onLoad)); + rExport.AddAttribute(XML_NAMESPACE_XLINK, sXML_actuate, aStr ); + } + // write graphic object + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_image, sal_True, sal_True); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportChartShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) +{ + const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); + if(xPropSet.is()) + { + uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); + + sal_Bool bIsEmptyPresObj = sal_False; + if(eShapeType == XmlShapeTypePresChartShape) + bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_chart)) ); + + OUStringBuffer sStringBuffer; + + ImpExportPosition( xShape, nFeatures, pRefPoint ); + ImpExportSize( xShape, nFeatures ); + + uno::Reference< chart::XChartDocument > xChartDoc; + if( !bIsEmptyPresObj ) + xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ) >>= xChartDoc; + + if( xChartDoc.is() ) + { + // export chart data if the flag is not set (default) + sal_Bool bExportOwnData = (( nFeatures & SEF_EXPORT_NO_CHART_DATA ) == 0 ); + rExport.GetChartExport()->exportChart( xChartDoc, bExportOwnData ); + } + else + { + // write chart object (fake for now, replace later) + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_CHART, sXML_chart, sal_True, sal_True); + } + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportSpreadsheetShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) +{ + const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); + if(xPropSet.is()) + { + uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); + + if(eShapeType == XmlShapeTypePresTableShape) + ImpExportPresentationAttributes( xPropSet, OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_table)) ); + + DBG_ERROR( "presentation spreadsheets not yet implemented!" ); + // write spreadsheet object (fake for now, replace later) + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML__unknown_, sal_True, sal_True); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportControlShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) +{ + OUStringBuffer sStringBuffer; + + ImpExportPosition( xShape, nFeatures, pRefPoint ); + ImpExportSize( xShape, nFeatures ); + + uno::Reference< drawing::XControlShape > xControl( xShape, uno::UNO_QUERY ); + DBG_ASSERT( xControl.is(), "Control shape is not supporting XControlShape" ); + if( xControl.is() ) + { + uno::Reference< beans::XPropertySet > xControlModel( xControl->getControl(), uno::UNO_QUERY ); + DBG_ASSERT( xControlModel.is(), "Control shape has not XControlModel" ); + if( xControlModel.is() ) + { + rExport.AddAttribute( XML_NAMESPACE_FORM, sXML_id, rExport.GetFormExport()->getControlId( xControlModel ) ); + } + } + + // this is a control shape, in this place the database team + // would have to export the control abilities. Add Export later + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_control, sal_True, sal_True); +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportConnectorShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) +{ + uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY ); + + OUString aStr; + OUStringBuffer sStringBuffer; + + // export connection kind + drawing::ConnectorType eType = drawing::ConnectorType_STANDARD; + uno::Any aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeKind"))); + aAny >>= eType; + + if( eType != drawing::ConnectorType_STANDARD ) + { + SvXMLUnitConverter::convertEnum( sStringBuffer, (sal_uInt16)eType, aXML_ConnectionKind_EnumMap ); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_type, aStr); + } + + // export line skew + sal_Int32 nDelta1 = 0, nDelta2 = 0, nDelta3 = 0; + + aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine1Delta"))); + aAny >>= nDelta1; + aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine2Delta"))); + aAny >>= nDelta2; + aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine3Delta"))); + aAny >>= nDelta3; + + if( nDelta1 != 0 || nDelta2 != 0 || nDelta3 != 0 ) + { + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta1); + if( nDelta2 != 0 || nDelta3 != 0 ) + { + const char aSpace = ' '; + sStringBuffer.appendAscii( &aSpace, 1 ); + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta2); + if( nDelta3 != 0 ) + { + sStringBuffer.appendAscii( &aSpace, 1 ); + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta3); + } + } + + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_line_skew, aStr); + } + + // export start and end point + awt::Point aStart(0,0); + awt::Point aEnd(1,1); + + xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition"))) >>= aStart; + xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition"))) >>= aEnd; + + if( pRefPoint ) + { + aStart.X -= pRefPoint->X; + aStart.Y -= pRefPoint->Y; + aEnd.X -= pRefPoint->X; + aEnd.Y -= pRefPoint->Y; + } + + if( nFeatures & SEF_EXPORT_X ) + { + // svg: x1 + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_x1, aStr); + } + else + { + aEnd.X -= aStart.X; + } + + if( nFeatures & SEF_EXPORT_Y ) + { + // svg: y1 + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_y1, aStr); + } + else + { + aEnd.Y -= aStart.Y; + } + + // svg: x2 + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_x2, aStr); + + // svg: y2 + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_y2, aStr); + + uno::Reference< drawing::XShape > xTempShape; + + // export start connection + aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartShape") ) ); + if( aAny >>= xTempShape ) + { + sal_Int32 nShapeId = rExport.GetShapeExport()->getShapeId( xTempShape ); + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_start_shape, OUString::valueOf( nShapeId )); + + aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartGluePointIndex")) ); + sal_Int32 nGluePointId; + if( aAny >>= nGluePointId ) + { + if( nGluePointId != -1 ) + { + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_start_glue_point, OUString::valueOf( nGluePointId )); + } + } + } + + // export end connection + aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndShape")) ); + if( aAny >>= xTempShape ) + { + sal_Int32 nShapeId = rExport.GetShapeExport()->getShapeId( xTempShape ); + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_end_shape, OUString::valueOf( nShapeId )); + + aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndGluePointIndex")) ); + sal_Int32 nGluePointId; + if( aAny >>= nGluePointId ) + { + if( nGluePointId != -1 ) + { + rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_end_glue_point, OUString::valueOf( nGluePointId )); + } + } + } + + // write connector shape. Add Export later. + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_connector, sal_True, sal_True); + + // export text + ImpExportText( xShape ); +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportMeasureShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) +{ + uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY ); + + OUString aStr; + OUStringBuffer sStringBuffer; + + // export start and end point + awt::Point aStart(0,0); + awt::Point aEnd(1,1); + + uno::Any aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition"))); + aAny >>= aStart; + + aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition"))); + aAny >>= aEnd; + + if( pRefPoint ) + { + aStart.X -= pRefPoint->X; + aStart.Y -= pRefPoint->Y; + aEnd.X -= pRefPoint->X; + aEnd.Y -= pRefPoint->Y; + } + + if( nFeatures & SEF_EXPORT_X ) + { + // svg: x1 + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_x1, aStr); + } + else + { + aEnd.X -= aStart.X; + } + + if( nFeatures & SEF_EXPORT_Y ) + { + // svg: y1 + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_y1, aStr); + } + else + { + aEnd.Y -= aStart.Y; + } + + // svg: x2 + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_x2, aStr); + + // svg: y2 + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_y2, aStr); + + // write measure shape + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_measure, sal_True, sal_True); + + // export text + uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); + if( xText.is() ) + rExport.GetTextParagraphExport()->exportText( xText ); +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportOLE2Shape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) +{ + const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); + if(xPropSet.is()) + { + uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); + + if(eShapeType == XmlShapeTypePresOLE2Shape) + ImpExportPresentationAttributes( xPropSet, OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_object))); + + DBG_ERROR("presentation ole2 not yet supported"); + + // write object + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML__unknown_, sal_True, sal_True); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportPageShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) +{ + OUString aStr; + + // a presentation page shape, normally used on notes pages only. If + // it is used not as presentation shape, it may have been created with + // copy-paste exchange between draw and impress (this IS possible...) + if(eShapeType == XmlShapeTypePresPageShape) + { + rExport.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class, + OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_page))); + } + + // write Page shape + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_page_thumbnail, sal_True, sal_True); +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExportCaptionShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) +{ + // write Caption shape. Add export later. + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_caption, sal_True, sal_True); + + // export text + uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); + if( xText.is() && xText->getString().getLength() ) + rExport.GetTextParagraphExport()->exportText( xText ); +} + diff --git a/xmloff/source/draw/shapeexport3.cxx b/xmloff/source/draw/shapeexport3.cxx new file mode 100644 index 000000000000..86ebfcfdda4a --- /dev/null +++ b/xmloff/source/draw/shapeexport3.cxx @@ -0,0 +1,561 @@ +/************************************************************************* + * + * $RCSfile: shapeexport3.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: cl $ $Date: 2001-02-02 11:14:37 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * 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. + * + * 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. + * + * 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 + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#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 + +#include "xmlkywd.hxx" +#include "xmlnmspe.hxx" + +using namespace ::rtl; +using namespace ::com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +inline sal_Int32 FRound( double fVal ) +{ + return( fVal > 0.0 ? (sal_Int32) ( fVal + 0.5 ) : -(sal_Int32) ( -fVal + 0.5 ) ); +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExport3DSceneShape( const uno::Reference< drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint) +{ + uno::Reference< drawing::XShapes > xShapes(xShape, uno::UNO_QUERY); + if(xShapes.is() && xShapes->getCount()) + { + // prepare write 3DScene + ImpPrepareExport3DScene( xShape, XmlShapeTypeDraw3DSceneObject, nFeatures, pRefPoint); + + // write 3DScene shape + SvXMLElementExport aOBJ( rExport, XML_NAMESPACE_DR3D, sXML_scene, sal_True, sal_True); + + uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY ); + if( xPropSet.is() ) + { + // write 3DSceneLights + ImpExport3DLamps( xPropSet ); + } + + // write members + exportShapes( xShapes, nFeatures, pRefPoint ); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExport3DShape( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) +{ + 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()) + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_transform, aTransform.GetExportString(rExport.GetMM100UnitConverter())); + + switch(eShapeType) + { + case XmlShapeTypeDraw3DCubeObject: + { + // write 3DCube shape + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DR3D, sXML_cube, sal_True, sal_True); + + // 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 + { + rExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aPos3D); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_min_edge, aStr); + } + + // write maxEdge + if(aDir3D != Vector3D(2500.0, 2500.0, 2500.0)) // write only when not default + { + rExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aDir3D); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_max_edge, aStr); + } + + break; + } + case XmlShapeTypeDraw3DSphereObject: + { + // write 3DSphere shape + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DR3D, sXML_sphere, sal_True, sal_True); + + // 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 + { + rExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aPos3D); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_center, aStr); + } + + // write Size + if(aDir3D != Vector3D(5000.0, 5000.0, 5000.0)) // write only when not default + { + rExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aDir3D); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_size, aStr); + } + + break; + } + case XmlShapeTypeDraw3DLatheObject: + case XmlShapeTypeDraw3DExtrudeObject: + { + // write special 3DLathe/3DExtrude attributes + uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPolyPolygon3D"))); + drawing::PolyPolygonShape3D xPolyPolygon3D; + aAny >>= xPolyPolygon3D; + + // look for maximal values + double fXMin, fXMax, fYMin, fYMax; + BOOL bInit(FALSE); + sal_Int32 nOuterSequenceCount(xPolyPolygon3D.SequenceX.getLength()); + drawing::DoubleSequence* pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray(); + drawing::DoubleSequence* pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray(); + + for(sal_Int32 a(0L); a < nOuterSequenceCount; a++) + { + 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); + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_viewBox, + aViewBox.GetExportString(rExport.GetMM100UnitConverter())); + + // 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, + aMaxSize, rExport.GetMM100UnitConverter(), bClosed); + + // #80594# corrected error in PolyPolygon3D export for 3D XML + pInnerSequenceX++; + pInnerSequenceY++; + } + + // write point array + rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_d, aSvgDElement.GetExportString()); + + if(eShapeType == XmlShapeTypeDraw3DLatheObject) + { + // write 3DLathe shape + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DR3D, sXML_rotate, sal_True, sal_True); + } + else + { + // write 3DExtrude shape + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DR3D, sXML_extrude, sal_True, sal_True); + } + break; + } + } + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpPrepareExport3DScene( + const uno::Reference< drawing::XShape >& xShape, + XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint) +{ + // write 3DScene attributes + const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); + if(xPropSet.is()) + { + OUString aStr; + OUStringBuffer sStringBuffer; + + ImpExportPosition( xShape, nFeatures, pRefPoint ); + ImpExportSize( xShape, nFeatures ); + + // 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()) + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_transform, aTransform.GetExportString(rExport.GetMM100UnitConverter())); + + // 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 + { + rExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aVRP); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_vrp, aStr); + } + + 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 + { + rExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aVPN); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_vpn, aStr); + } + + 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 + { + rExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aVUP); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_vup, aStr); + } + + // projection "D3DScenePerspective" drawing::ProjectionMode + aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DScenePerspective"))); + drawing::ProjectionMode xPrjMode; + aAny >>= xPrjMode; + if(xPrjMode == drawing::ProjectionMode_PARALLEL) + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_parallel)); + else + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_perspective)); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_projection, aStr); + + // distance + aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneDistance"))); + sal_Int32 nDistance; + aAny >>= nDistance; + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDistance); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_distance, aStr); + + // focalLength + aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneFocalLength"))); + sal_Int32 nFocalLength; + aAny >>= nFocalLength; + rExport.GetMM100UnitConverter().convertMeasure(sStringBuffer, nFocalLength); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_focal_length, aStr); + + // shadowSlant + aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadowSlant"))); + sal_Int16 nShadowSlant; + aAny >>= nShadowSlant; + rExport.GetMM100UnitConverter().convertNumber(sStringBuffer, (sal_Int32)nShadowSlant); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_shadow_slant, aStr); + + // shadeMode + aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadeMode"))); + drawing::ShadeMode xShadeMode; + if(aAny >>= xShadeMode) + { + if(xShadeMode == drawing::ShadeMode_FLAT) + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_flat)); + else if(xShadeMode == drawing::ShadeMode_PHONG) + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_phong)); + else if(xShadeMode == drawing::ShadeMode_SMOOTH) + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_gouraud)); + else + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_draft)); + } + else + { + // ShadeMode enum not there, write default + aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_gouraud)); + } + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_shade_mode, aStr); + + // ambientColor + aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor"))); + sal_Int32 aColTemp; + Color aAmbientColor; + aAny >>= aColTemp; aAmbientColor.SetColor(aColTemp); + rExport.GetMM100UnitConverter().convertColor(sStringBuffer, aAmbientColor); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_ambient_color, aStr); + + // lightingMode + aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneTwoSidedLighting"))); + sal_Bool bTwoSidedLighting; + aAny >>= bTwoSidedLighting; + rExport.GetMM100UnitConverter().convertBool(sStringBuffer, bTwoSidedLighting); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_lighting_mode, aStr); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void XMLShapeExport::ImpExport3DLamps( const uno::Reference< beans::XPropertySet >& xPropSet ) +{ + // 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; + for(sal_Int32 nLamp; nLamp < 8; nLamp++) + { + aIndexStr = OUString::valueOf( nLamp ); + + // lightcolor + aPropName = aColorPropName; + aPropName += aIndexStr; + xPropSet->getPropertyValue( aPropName ) >>= aColTemp; + aLightColor.SetColor(aColTemp); + rExport.GetMM100UnitConverter().convertColor(sStringBuffer, aLightColor); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_diffuse_color, aStr); + + // lightdirection + aPropName = aDirectionPropName; + aPropName += aIndexStr; + xPropSet->getPropertyValue(aPropName) >>= xLightDir; + aLightDirection = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ); + rExport.GetMM100UnitConverter().convertVector3D(sStringBuffer, aLightDirection); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_direction, aStr); + + // lighton + aPropName = aLightOnPropName; + aPropName += aIndexStr; + xPropSet->getPropertyValue(aPropName) >>= bLightOnOff; + rExport.GetMM100UnitConverter().convertBool(sStringBuffer, bLightOnOff); + aStr = sStringBuffer.makeStringAndClear(); + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_enabled, aStr); + + // specular + rExport.AddAttribute(XML_NAMESPACE_DR3D, sXML_specular, + nLamp == 0 ? OUString( RTL_CONSTASCII_USTRINGPARAM( sXML_true ) ) : + OUString( RTL_CONSTASCII_USTRINGPARAM( sXML_false ) ) ); + + // write light entry + SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DR3D, sXML_light, sal_True, sal_True); + } +} + +////////////////////////////////////////////////////////////////////////////// |