Kaydet (Commit) fa6a680f authored tarafından Christian Lippka's avatar Christian Lippka

#80699# added support for Connector and Measures Shapes

üst 9dc54161
......@@ -2,9 +2,9 @@
*
* $RCSfile: xmlkywd.hxx,v $
*
* $Revision: 1.51 $
* $Revision: 1.52 $
*
* last change: $Author: cl $ $Date: 2000-11-24 18:52:31 $
* last change: $Author: cl $ $Date: 2000-11-26 19:38:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -1253,7 +1253,7 @@ XML_CONSTASCII_ACTION( sXML_string_value_if_false, "string-value-if-false" );
XML_CONSTASCII_ACTION( sXML_string_value_if_true, "string-value-if-true" );
XML_CONSTASCII_ACTION( sXML_stroke , "stroke" );
XML_CONSTASCII_ACTION( sXML_stroke_color , "stroke-color" );
XML_CONSTASCII_ACTION( sXML_stroke_dasharray , "stroke-dasharray" );
XML_CONSTASCII_ACTION( sXML_stroke_dash , "stroke-dash" );
XML_CONSTASCII_ACTION( sXML_stroke_linejoin , "stroke-linejoin" );
XML_CONSTASCII_ACTION( sXML_stroke_opacity, "stroke-opacity" );
XML_CONSTASCII_ACTION( sXML_stroke_width, "stroke-width" );
......@@ -1521,4 +1521,26 @@ XML_CONSTASCII_ACTION( sXML_lighting_mode, "lighting-mode");
XML_CONSTASCII_ACTION( sXML_specular, "specular");
XML_CONSTASCII_ACTION( sXML_light, "light");
XML_CONSTASCII_ACTION( sXML_3DScene, "scene");
XML_CONSTASCII_ACTION( sXML_start_shape, "start-shape");
XML_CONSTASCII_ACTION( sXML_start_glue_point, "start-glue-point");
XML_CONSTASCII_ACTION( sXML_end_shape, "end-shape");
XML_CONSTASCII_ACTION( sXML_end_glue_point, "end-glue-point");
XML_CONSTASCII_ACTION( sXML_line_skew, "line-skew");
XML_CONSTASCII_ACTION( sXML_curve, "curve" );
XML_CONSTASCII_ACTION( sXML_start_line_spacing_horizontal, "start-line-spacing-horizontal" );
XML_CONSTASCII_ACTION( sXML_start_line_spacing_vertical, "start-line-spacing-vertical" );
XML_CONSTASCII_ACTION( sXML_end_line_spacing_horizontal, "end-line-spacing-horizontal" );
XML_CONSTASCII_ACTION( sXML_end_line_spacing_vertical, "end-line-spacing-vertical" );
XML_CONSTASCII_ACTION( sXML_line_distance, "line-distance" );
XML_CONSTASCII_ACTION( sXML_guide_overhang, "guide-overhang" );
XML_CONSTASCII_ACTION( sXML_guide_distance, "guide-distance" );
XML_CONSTASCII_ACTION( sXML_start_guide, "start-guide" );
XML_CONSTASCII_ACTION( sXML_end_guide, "end-guide" );
XML_CONSTASCII_ACTION( sXML_dots, "dots" );
XML_CONSTASCII_ACTION( sXML_dots_length, "dots-length" );
XML_CONSTASCII_ACTION( sXML_dashes, "dashes" );
XML_CONSTASCII_ACTION( sXML_dashes_length, "dashes-length" );
#endif
......@@ -2,9 +2,9 @@
*
* $RCSfile: sdpropls.cxx,v $
*
* $Revision: 1.5 $
* $Revision: 1.6 $
*
* last change: $Author: aw $ $Date: 2000-11-24 16:59:46 $
* last change: $Author: cl $ $Date: 2000-11-26 19:40:47 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -85,6 +85,10 @@
#include <com/sun/star/presentation/FadeEffect.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_CONNECTORTYPE_HPP_
#include <com/sun/star/drawing/ConnectorType.hpp>
#endif
#ifndef _XMLOFF_ENUMPROPERTYHANDLER_HXX
#include <EnumPropertyHdl.hxx>
#endif
......@@ -147,8 +151,8 @@ using namespace ::com::sun::star;
const XMLPropertyMapEntry aXMLSDProperties[] =
{
// stroke attributes
{ "LineStyle", XML_NAMESPACE_DRAW, sXML_stroke, XML_SD_TYPE_STROKE, 0 },
{ "LineDashName", XML_NAMESPACE_DRAW, sXML_stroke_dasharray, XML_TYPE_STRING, 0 },
{ "LineStyle", XML_NAMESPACE_DRAW, sXML_stroke, XML_SD_TYPE_STROKE, 0 },
{ "LineDashName", XML_NAMESPACE_DRAW, sXML_stroke_dash, XML_TYPE_STRING, 0 },
{ "LineWidth", XML_NAMESPACE_SVG, sXML_stroke_width, XML_TYPE_MEASURE, 0 },
{ "LineColor", XML_NAMESPACE_SVG, sXML_stroke_color, XML_TYPE_COLOR, 0 },
{ "LineStartName", XML_NAMESPACE_DRAW, sXML_marker_start, XML_TYPE_STRING, 0 },
......@@ -189,6 +193,24 @@ const XMLPropertyMapEntry aXMLSDProperties[] =
// animation text attributes
// connector attributes
{ "EdgeNode1HorzDist", XML_NAMESPACE_DRAW, sXML_start_line_spacing_horizontal, XML_TYPE_MEASURE, 0 },
{ "EdgeNode1VertDist", XML_NAMESPACE_DRAW, sXML_start_line_spacing_vertical, XML_TYPE_MEASURE, 0 },
{ "EdgeNode2HorzDist", XML_NAMESPACE_DRAW, sXML_end_line_spacing_horizontal, XML_TYPE_MEASURE, 0 },
{ "EdgeNode2VertDist", XML_NAMESPACE_DRAW, sXML_end_line_spacing_vertical, XML_TYPE_MEASURE, 0 },
// measure attributes
{ "MeasureLineDistance", XML_NAMESPACE_DRAW, sXML_line_distance, XML_TYPE_MEASURE, 0 },
{ "MeasureHelpLineOverhang", XML_NAMESPACE_DRAW, sXML_guide_overhang, XML_TYPE_MEASURE, 0 },
{ "MeasureHelpLineDistance", XML_NAMESPACE_DRAW, sXML_guide_distance, XML_TYPE_MEASURE, 0 },
{ "MeasureHelpLine1Length", XML_NAMESPACE_DRAW, sXML_start_guide, XML_TYPE_MEASURE, 0 },
{ "MeasureHelpLine2Length", XML_NAMESPACE_DRAW, sXML_end_guide, XML_TYPE_MEASURE, 0 },
// { "MeasureUnit", XML_NAMESPACE_DRAW, sXML_unit, XML_TYPE_MEASURE_UNIT|MID_FLAG_MULTI_PROPERTY, 0 },
// { "MeasureShowUnit", XML_NAMESPACE_DRAW, sXML_unit, XML_TYPE_MEASURE_UNIT|MID_FLAG_MULTI_PROPERTY, 0 },
// { "MeasureBelowReferenceEdge", XML_NAMESPACE_DRAW, sXML_placing, XML_TYPE_MEASURE_PLACING, 0 },
{ "MeasureTextRotate90", XML_NAMESPACE_DRAW, sXML_parallel, XML_TYPE_BOOL, 0 },
// text attributes
{ "CharColor", XML_NAMESPACE_FO, sXML_color, XML_TYPE_COLOR, 0 },
{ "CharCrossedOut", XML_NAMESPACE_STYLE, sXML_text_crossing_out, XML_SD_TYPE_TEXT_CROSSEDOUT, 0},
......@@ -392,6 +414,15 @@ SvXMLEnumMapEntry aXML_FadeEffect_EnumMap[] =
{ NULL, 0 }
};
SvXMLEnumMapEntry aXML_ConnectionKind_EnumMap[] =
{
{ sXML_standard, drawing::ConnectorType_STANDARD },
{ sXML_curve, drawing::ConnectorType_CURVE },
{ sXML_line, drawing::ConnectorType_LINE },
{ sXML_lines, drawing::ConnectorType_LINES },
{ NULL, 0 }
};
//////////////////////////////////////////////////////////////////////////////
// 3D EnumMaps
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: sdpropls.hxx,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: aw $ $Date: 2000-11-24 17:00:21 $
* last change: $Author: cl $ $Date: 2000-11-26 19:41:43 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -63,11 +63,15 @@
#define _SDPROPLS_HXX
#ifndef _XMLOFF_PROPMAPPINGTYPES_HXX
#include <maptype.hxx>
#include "maptype.hxx"
#endif
#ifndef _XMLOFF_XMLTYPES_HXX
#include <xmltypes.hxx>
#include "xmltypes.hxx"
#endif
#ifndef _SVTOOLS_XMLEMENT_HXX
#include "xmlement.hxx"
#endif
#ifndef _XMLOFF_PROPERTYHANDLERFACTORY_HXX
......@@ -115,6 +119,11 @@ extern const XMLPropertyMapEntry aXMLSDPresPageProps[];
#define XML_SD_TYPE_TEX_KIND (XML_SD_TYPES_START + 22 )
#define XML_SD_TYPE_TEX_MODE (XML_SD_TYPES_START + 23 )
//////////////////////////////////////////////////////////////////////////////
// enum maps for attributes
extern SvXMLEnumMapEntry aXML_ConnectionKind_EnumMap[];
//////////////////////////////////////////////////////////////////////////////
// factory for own graphic properties
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: shapeexport.cxx,v $
*
* $Revision: 1.5 $
* $Revision: 1.6 $
*
* last change: $Author: cl $ $Date: 2000-11-15 12:18:13 $
* last change: $Author: cl $ $Date: 2000-11-26 19:45:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -87,6 +87,9 @@
#include <tools/debug.hxx>
#endif
#include "xmlkywd.hxx"
#include "xmlnmspe.hxx"
using namespace ::rtl;
using namespace ::com::sun::star;
......@@ -94,7 +97,13 @@ using namespace ::com::sun::star;
XMLShapeExport::XMLShapeExport(SvXMLExport& rExp,
SvXMLExportPropertyMapper *pExtMapper )
: rExport( rExp )
: rExport( rExp ),
mnNextUniqueShapeId(1),
msZIndex( RTL_CONSTASCII_USTRINGPARAM("ZOrder") ),
msEmptyPres( RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ),
msModel( RTL_CONSTASCII_USTRINGPARAM("Model") ),
msStartShape( RTL_CONSTASCII_USTRINGPARAM("StartShape") ),
msEndShape( RTL_CONSTASCII_USTRINGPARAM("EndShape") )
{
// construct PropertyHandlerFactory
xSdPropHdlFactory = new XMLSdPropHdlFactory;
......@@ -161,9 +170,9 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap
sal_Bool bIsEmptyPresObj = sal_False;
if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))))
if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(msEmptyPres) )
{
uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject")));
uno::Any aAny = xPropSet->getPropertyValue(msEmptyPres);
aAny >>= bIsEmptyPresObj;
}
......@@ -175,17 +184,33 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap
// check for calc ole
const OUString aShapeType( xShape->getShapeType() );
if( (0 == aShapeType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.OLE2Shape" ))) ||
(0 == aShapeType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.presentation.CalcShape" ))) )
if( aShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.OLE2Shape" )) ||
aShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.presentation.CalcShape" )) )
{
uno::Reference< chart::XChartDocument > xChartDoc;
uno::Any aAny( xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ) );
uno::Any aAny( xPropSet->getPropertyValue(msModel) );
aAny >>= xChartDoc;
if( xChartDoc.is() )
{
GetExport().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 )
{
createShapeId( xConnection );
}
if( xPropSet->getPropertyValue( msEndShape ) >>= xConnection )
{
createShapeId( xConnection );
}
}
}
// This method exports the given XShape
......@@ -204,9 +229,10 @@ void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape
aNewName = GetExport().GetAutoStylePool()->Find(
XML_STYLE_FAMILY_SD_GRAPHICS_ID, aParentName, xPropStates);
// compute the shape type
XmlShapeType eShapeType(XmlShapeTypeNotYetSet);
SdXMLExport::ImpCalcShapeType(xShape, eShapeType);
SdXMLExport::ImpWriteSingleShapeStyleInfo(GetExport(), xShape,
XML_STYLE_FAMILY_SD_GRAPHICS_ID, aNewName, eShapeType, nFeatures, pRefPoint);
}
......@@ -237,3 +263,51 @@ 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 com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& xShape )
{
uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
if( xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName( msZIndex ) )
{
sal_Int32 nIndex = 0;
xPropSet->getPropertyValue( msZIndex ) >>= nIndex;
const std::vector<XMLShapeIdHint>::size_type nCount = maUsedShapeIds.size();
for( std::vector<XMLShapeIdHint>::size_type i = 0; i < nCount; i++ )
{
if( maUsedShapeIds[i].mnShapeIndex == nIndex )
return; // we already have an id for this shape;
}
XMLShapeIdHint aNewHint;
aNewHint.mnShapeIndex = nIndex;
aNewHint.mnShapeId = mnNextUniqueShapeId++;
maUsedShapeIds.push_back( aNewHint );
}
else
{
DBG_ERROR( "createShapeId failed!" );
}
}
/** 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 com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& xShape )
{
uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
if( xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName( msZIndex ) )
{
sal_Int32 nIndex = 0;
xPropSet->getPropertyValue( msZIndex ) >>= nIndex;
const std::vector<XMLShapeIdHint>::size_type nCount = maUsedShapeIds.size();
for( std::vector<XMLShapeIdHint>::size_type i = 0; i < nCount; i++ )
{
if( maUsedShapeIds[i].mnShapeIndex == nIndex )
return maUsedShapeIds[i].mnShapeId;
}
}
return -1;
}
......@@ -2,9 +2,9 @@
*
* $RCSfile: shapeimport.cxx,v $
*
* $Revision: 1.11 $
* $Revision: 1.12 $
*
* last change: $Author: aw $ $Date: 2000-11-24 17:37:17 $
* last change: $Author: cl $ $Date: 2000-11-26 19:46:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -827,23 +827,55 @@ struct ZOrderHint
int operator<(const ZOrderHint& rComp) const { return nShould < rComp.nShould; }
};
struct ConnectionHint
{
sal_Int32 nConnectorIndex;
sal_Bool bStart;
sal_Int32 nDestShapeId;
sal_Int32 nDestGlueId;
};
struct ltint32
{
bool operator()(const sal_Int32 p, sal_Int32 q) const
{
return p < q;
}
};
class ShapeSortContext
{
public:
uno::Reference< drawing::XShapes > mxShapes;
list<ZOrderHint> maZOrderList;
list<ZOrderHint> maUnsortedList;
vector<ConnectionHint> maConnections;
map<sal_Int32,sal_Int32,ltint32> maShapeIdMap;
sal_Int32 mnCurrentZ;
ShapeSortContext* mpParentContext;
const OUString maZOrderStr;
const OUString msZOrder;
const OUString msStartShape;
const OUString msEndShape;
const OUString msStartGluePointIndex;
const OUString msEndGluePointIndex;
ShapeSortContext( uno::Reference< drawing::XShapes >& rShapes, ShapeSortContext* pParentContext = NULL );
void moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos );
void restoreConnections();
void createShapeId( sal_Int32 nId );
uno::Reference< drawing::XShape > getShapeFromId( sal_Int32 nId );
};
ShapeSortContext::ShapeSortContext( uno::Reference< drawing::XShapes >& rShapes, ShapeSortContext* pParentContext )
: mxShapes( rShapes ), mnCurrentZ( 0 ), mpParentContext( pParentContext ), maZOrderStr(RTL_CONSTASCII_USTRINGPARAM("ZOrder"))
: mxShapes( rShapes ), mnCurrentZ( 0 ), mpParentContext( pParentContext ),
msZOrder(RTL_CONSTASCII_USTRINGPARAM("ZOrder")),
msStartShape(RTL_CONSTASCII_USTRINGPARAM("StartShape")),
msEndShape(RTL_CONSTASCII_USTRINGPARAM("EndShape")),
msStartGluePointIndex(RTL_CONSTASCII_USTRINGPARAM("StartGluePointIndex")),
msEndGluePointIndex(RTL_CONSTASCII_USTRINGPARAM("EndGluePointIndex"))
{
}
......@@ -853,10 +885,10 @@ void ShapeSortContext::moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos )
uno::Reference< beans::XPropertySet > xPropSet;
aAny >>= xPropSet;
if( xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName( maZOrderStr ) )
if( xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName( msZOrder ) )
{
aAny <<= nDestPos;
xPropSet->setPropertyValue( maZOrderStr, aAny );
xPropSet->setPropertyValue( msZOrder, aAny );
list<ZOrderHint>::iterator aIter = maZOrderList.begin();
list<ZOrderHint>::iterator aEnd = maZOrderList.end();
......@@ -886,6 +918,52 @@ void ShapeSortContext::moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos )
}
}
void ShapeSortContext::restoreConnections()
{
if( !maConnections.empty() )
{
uno::Any aAny;
uno::Reference< beans::XPropertySet > xConnector;
const vector<ConnectionHint>::size_type nCount = maConnections.size();
for( vector<ConnectionHint>::size_type i = 0; i < nCount; i++ )
{
ConnectionHint& rHint = maConnections[i];
if( mxShapes->getByIndex( rHint.nConnectorIndex ) >>= xConnector )
{
uno::Reference< drawing::XShape > xShape( getShapeFromId( rHint.nDestShapeId ) );
if( xShape.is() )
{
aAny <<= xShape;
xConnector->setPropertyValue( rHint.bStart ? msStartShape : msEndShape, aAny );
}
aAny <<= rHint.nDestGlueId;
xConnector->setPropertyValue( rHint.bStart ? msStartGluePointIndex : msEndGluePointIndex, aAny );
}
}
}
}
void ShapeSortContext::createShapeId( sal_Int32 nId )
{
maShapeIdMap[nId] = mnCurrentZ;
}
uno::Reference< drawing::XShape > ShapeSortContext::getShapeFromId( sal_Int32 nId )
{
uno::Reference< drawing::XShape > xShape;
map<sal_Int32,sal_Int32,ltint32>::iterator aIter = maShapeIdMap.find( nId );
if( aIter != maShapeIdMap.end() )
{
uno::Any aAny( mxShapes->getByIndex( maShapeIdMap[nId] ) );
aAny >>= xShape;
}
return xShape;
}
void XMLShapeImportHelper::pushGroupForSorting( uno::Reference< drawing::XShapes >& rShapes )
{
mpSortContext = new ShapeSortContext( rShapes, mpSortContext );
......@@ -897,6 +975,10 @@ void XMLShapeImportHelper::popGroupAndSort()
if( mpSortContext == NULL )
return;
// restore connections for connection shapes
mpSortContext->restoreConnections();
// sort shapes
list<ZOrderHint>& rZList = mpSortContext->maZOrderList;
if( !rZList.empty() )
{
......@@ -959,3 +1041,26 @@ void XMLShapeImportHelper::shapeWithZIndexAdded( com::sun::star::uno::Reference<
}
}
void XMLShapeImportHelper::addShapeConnection( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rConnectorShape,
sal_Bool bStart,
sal_Int32 nDestShapeId,
sal_Int32 nDestGlueId )
{
DBG_ASSERT( mpSortContext, "Connection Shapes are not working without a sort context!" );
if( mpSortContext )
{
ConnectionHint aHint;
aHint.nConnectorIndex = mpSortContext->mnCurrentZ;
aHint.bStart = bStart;
aHint.nDestShapeId = nDestShapeId;
aHint.nDestGlueId = nDestGlueId;
mpSortContext->maConnections.push_back( aHint );
}
}
void XMLShapeImportHelper::createShapeId( sal_Int32 nId )
{
if( mpSortContext )
mpSortContext->createShapeId( nId );
}
......@@ -2,9 +2,9 @@
*
* $RCSfile: ximpshap.cxx,v $
*
* $Revision: 1.11 $
* $Revision: 1.12 $
*
* last change: $Author: aw $ $Date: 2000-11-24 17:50:31 $
* last change: $Author: cl $ $Date: 2000-11-26 19:48:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -97,6 +97,10 @@
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_CONNECTORTYPE_HPP_
#include <com/sun/star/drawing/ConnectorType.hpp>
#endif
#ifndef _XMLOFF_FAMILIES_HXX_
#include "families.hxx"
#endif
......@@ -113,6 +117,10 @@
#include "xmlkywd.hxx"
#endif
#ifndef _SDPROPLS_HXX
#include "sdpropls.hxx"
#endif
using namespace ::rtl;
using namespace ::com::sun::star;
......@@ -351,6 +359,10 @@ void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUStr
{
mnZOrder = rValue.toInt32();
}
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_id)) )
{
GetImport().GetShapeImport()->createShapeId( rValue.toInt32() );
}
}
}
......@@ -1174,7 +1186,17 @@ SdXMLConnectorShapeContext::SdXMLConnectorShapeContext(
const OUString& rLocalName,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
uno::Reference< drawing::XShapes >& rShapes)
: SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes )
: SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes ),
maStart(0,0),
maEnd(1,1),
mnType( (USHORT)drawing::ConnectorType_STANDARD ),
mnStartShapeId(-1),
mnStartGlueId(-1),
mnEndShapeId(-1),
mnEndGlueId(-1),
mnDelta1(0),
mnDelta2(0),
mnDelta3(0)
{
}
......@@ -1186,6 +1208,85 @@ SdXMLConnectorShapeContext::~SdXMLConnectorShapeContext()
//////////////////////////////////////////////////////////////////////////////
// this is called from the parent group for each unparsed attribute in the attribute list
void SdXMLConnectorShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
{
switch( nPrefix )
{
case XML_NAMESPACE_DRAW:
{
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_start_shape)) )
{
mnStartShapeId = rValue.toInt32();
break;
}
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_start_glue_point)) )
{
mnStartGlueId = rValue.toInt32();
break;
}
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_end_shape)) )
{
mnEndShapeId = rValue.toInt32();
break;
}
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_end_glue_point)) )
{
mnEndGlueId = rValue.toInt32();
break;
}
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_line_skew)) )
{
SvXMLTokenEnumerator aTokenEnum( rValue );
OUString aToken;
if( aTokenEnum.getNextToken( aToken ) )
{
GetImport().GetMM100UnitConverter().convertMeasure(mnDelta1, aToken);
if( aTokenEnum.getNextToken( aToken ) )
{
GetImport().GetMM100UnitConverter().convertMeasure(mnDelta2, aToken);
if( aTokenEnum.getNextToken( aToken ) )
{
GetImport().GetMM100UnitConverter().convertMeasure(mnDelta3, aToken);
}
}
}
break;
}
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_type)) )
{
SvXMLUnitConverter::convertEnum( mnType, rValue, aXML_ConnectionKind_EnumMap );
break;
}
}
case XML_NAMESPACE_SVG:
{
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_x1)) )
{
GetImport().GetMM100UnitConverter().convertMeasure(maStart.X, rValue);
break;
}
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_y1)) )
{
GetImport().GetMM100UnitConverter().convertMeasure(maStart.Y, rValue);
break;
}
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_x2)) )
{
GetImport().GetMM100UnitConverter().convertMeasure(maEnd.X, rValue);
break;
}
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_y2)) )
{
GetImport().GetMM100UnitConverter().convertMeasure(maEnd.Y, rValue);
break;
}
}
}
}
//////////////////////////////////////////////////////////////////////////////
void SdXMLConnectorShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
{
// create Connector shape
......@@ -1196,8 +1297,37 @@ void SdXMLConnectorShapeContext::StartElement(const uno::Reference< xml::sax::XA
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ConnectorShape"))), uno::UNO_QUERY);
if(xShape.is())
{
// add connection ids
if( mnStartShapeId != -1 )
GetImport().GetShapeImport()->addShapeConnection( xShape, sal_True, mnStartShapeId, mnStartGlueId );
if( mnEndShapeId != -1 )
GetImport().GetShapeImport()->addShapeConnection( xShape, sal_False, mnEndShapeId, mnEndGlueId );
// add, set style and properties from base shape
AddShape(xShape);
uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
if( xProps.is() )
{
uno::Any aAny;
aAny <<= maStart;
xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")), aAny);
aAny <<= maEnd;
xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")), aAny );
aAny <<= (drawing::ConnectorType)mnType;
xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeKind")), aAny );
aAny <<= mnDelta1;
xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine1Delta")), aAny );
aAny <<= mnDelta2;
xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine2Delta")), aAny );
aAny <<= mnDelta3;
xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine3Delta")), aAny );
}
SetStyle();
SdXMLShapeContext::StartElement(xAttrList);
}
......@@ -1217,7 +1347,9 @@ SdXMLMeasureShapeContext::SdXMLMeasureShapeContext(
const OUString& rLocalName,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
uno::Reference< drawing::XShapes >& rShapes)
: SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes )
: SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes ),
maStart(0,0),
maEnd(1,1)
{
}
......@@ -1227,6 +1359,37 @@ SdXMLMeasureShapeContext::~SdXMLMeasureShapeContext()
{
}
// this is called from the parent group for each unparsed attribute in the attribute list
void SdXMLMeasureShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
{
switch( nPrefix )
{
case XML_NAMESPACE_SVG:
{
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_x1)) )
{
GetImport().GetMM100UnitConverter().convertMeasure(maStart.X, rValue);
break;
}
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_y1)) )
{
GetImport().GetMM100UnitConverter().convertMeasure(maStart.Y, rValue);
break;
}
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_x2)) )
{
GetImport().GetMM100UnitConverter().convertMeasure(maEnd.X, rValue);
break;
}
if( rLocalName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sXML_y2)) )
{
GetImport().GetMM100UnitConverter().convertMeasure(maEnd.Y, rValue);
break;
}
}
}
}
//////////////////////////////////////////////////////////////////////////////
void SdXMLMeasureShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
......@@ -1241,6 +1404,18 @@ void SdXMLMeasureShapeContext::StartElement(const uno::Reference< xml::sax::XAtt
{
// add, set style and properties from base shape
AddShape(xShape);
uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
if( xProps.is() )
{
uno::Any aAny;
aAny <<= maStart;
xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")), aAny);
aAny <<= maEnd;
xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")), aAny );
}
SetStyle();
SdXMLShapeContext::StartElement(xAttrList);
}
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: ximpshap.hxx,v $
*
* $Revision: 1.8 $
* $Revision: 1.9 $
*
* last change: $Author: cl $ $Date: 2000-11-23 18:30:39 $
* last change: $Author: cl $ $Date: 2000-11-26 19:48:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -82,6 +82,10 @@
#include <com/sun/star/text/XTextCursor.hpp>
#endif
#ifndef _COM_SUN_STAR_AWT_POINT_HPP_
#include <com/sun/star/awt/Point.hpp>
#endif
#ifndef _RTTI_HXX
#include <tools/rtti.hxx>
#endif
......@@ -111,6 +115,9 @@ protected:
void SetStyle();
void AddShape(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape);
SvXMLImport& GetImport() { return SvXMLImportContext::GetImport(); }
const SvXMLImport& GetImport() const { return SvXMLImportContext::GetImport(); }
public:
TYPEINFO();
......@@ -289,6 +296,20 @@ public:
class SdXMLConnectorShapeContext : public SdXMLShapeContext
{
private:
::com::sun::star::awt::Point maStart;
::com::sun::star::awt::Point maEnd;
USHORT mnType;
sal_Int32 mnStartShapeId;
sal_Int32 mnStartGlueId;
sal_Int32 mnEndShapeId;
sal_Int32 mnEndGlueId;
sal_Int32 mnDelta1;
sal_Int32 mnDelta2;
sal_Int32 mnDelta3;
public:
TYPEINFO();
......@@ -298,6 +319,9 @@ public:
com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes);
virtual ~SdXMLConnectorShapeContext();
virtual void StartElement(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList);
// this is called from the parent group for each unparsed attribute in the attribute list
virtual void processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue );
};
//////////////////////////////////////////////////////////////////////////////
......@@ -305,6 +329,10 @@ public:
class SdXMLMeasureShapeContext : public SdXMLShapeContext
{
private:
::com::sun::star::awt::Point maStart;
::com::sun::star::awt::Point maEnd;
public:
TYPEINFO();
......@@ -314,6 +342,9 @@ public:
com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes);
virtual ~SdXMLMeasureShapeContext();
virtual void StartElement(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList);
// this is called from the parent group for each unparsed attribute in the attribute list
virtual void processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue );
};
//////////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment