#87219# added user glue points

This commit is contained in:
Christian Lippka 2001-05-31 10:18:38 +00:00
parent cbaeb1f48b
commit e88904df1e
6 changed files with 242 additions and 12 deletions

View file

@ -2,9 +2,9 @@
*
* $RCSfile: xmlkywd.hxx,v $
*
* $Revision: 1.162 $
* $Revision: 1.163 $
*
* last change: $Author: cl $ $Date: 2001-05-28 13:20:52 $
* last change: $Author: cl $ $Date: 2001-05-31 11:14:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -2010,4 +2010,6 @@ XML_CONSTASCII_ACTION( sXML_data_source_has_labels, "data-source-has-labels" );
XML_CONSTASCII_ACTION( sXML_play, "play" );
XML_CONSTASCII_ACTION( sXML_handout_master, "handout-master" );
XML_CONSTASCII_ACTION( sXML_escape_direction, "escape-direction" );
XML_CONSTASCII_ACTION( sXML_glue_point, "glue-point" );
#endif

View file

@ -2,9 +2,9 @@
*
* $RCSfile: shapeexport.cxx,v $
*
* $Revision: 1.27 $
* $Revision: 1.28 $
*
* last change: $Author: fs $ $Date: 2001-05-28 15:13:43 $
* last change: $Author: cl $ $Date: 2001-05-31 11:18:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -862,3 +862,92 @@ void XMLShapeExport::ImpCalcShapeType(const uno::Reference< drawing::XShape >& x
}
///////////////////////////////////////////////////////////////////////
#ifndef _COM_SUN_STAR_DRAWING_XGLUEPOINTSSUPPLIER_HPP_
#include <com/sun/star/drawing/XGluePointsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_GLUEPOINT2_HPP_
#include <com/sun/star/drawing/GluePoint2.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_ALIGNMENT_HPP_
#include <com/sun/star/drawing/Alignment.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_ESCAPEDIRECTION_HPP_
#include <com/sun/star/drawing/EscapeDirection.hpp>
#endif
#ifndef _XMLOFF_XMLUCONV_HXX
#include "xmluconv.hxx"
#endif
#include "xmlnmspe.hxx"
SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap[] =
{
{ sXML_top_left, drawing::Alignment_TOP_LEFT },
{ sXML_top, drawing::Alignment_TOP },
{ sXML_top_right, drawing::Alignment_TOP_RIGHT },
{ sXML_left, drawing::Alignment_LEFT },
{ sXML_center, drawing::Alignment_CENTER },
{ sXML_right, drawing::Alignment_RIGHT },
{ sXML_bottom_left, drawing::Alignment_BOTTOM_LEFT },
{ sXML_bottom, drawing::Alignment_BOTTOM },
{ sXML_bottom_right,drawing::Alignment_BOTTOM_RIGHT },
{ NULL, 0 }
};
SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap[] =
{
{ sXML_auto, drawing::EscapeDirection_SMART },
{ sXML_left, drawing::EscapeDirection_LEFT },
{ sXML_right, drawing::EscapeDirection_RIGHT },
{ sXML_up, drawing::EscapeDirection_UP },
{ sXML_down, drawing::EscapeDirection_DOWN },
{ sXML_horizontal, drawing::EscapeDirection_HORIZONTAL },
{ sXML_vertical, drawing::EscapeDirection_VERTICAL },
{ NULL, 0 }
};
/** exports all user defined glue points */
void XMLShapeExport::ImpExportGluePoints( const uno::Reference< drawing::XShape >& xShape )
{
uno::Reference< drawing::XGluePointsSupplier > xSupplier( xShape, uno::UNO_QUERY );
if( !xSupplier.is() )
return;
uno::Reference< container::XIndexContainer > xGluePoints( xSupplier->getGluePoints() );
if( !xGluePoints.is() )
return;
drawing::GluePoint2 aGluePoint;
const sal_Int32 nCount = xGluePoints->getCount();
for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
{
if( (xGluePoints->getByIndex( nIndex ) >>= aGluePoint) && aGluePoint.IsUserDefined )
{
// export only user defined glue points
const OUString sId( OUString::valueOf( nIndex ) );
rExport.AddAttribute(XML_NAMESPACE_DRAW, sXML_id, sId );
rExport.GetMM100UnitConverter().convertMeasure(msBuffer, aGluePoint.Position.X);
rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_x, msBuffer.makeStringAndClear());
rExport.GetMM100UnitConverter().convertMeasure(msBuffer, aGluePoint.Position.Y);
rExport.AddAttribute(XML_NAMESPACE_SVG, sXML_y, msBuffer.makeStringAndClear());
if( !aGluePoint.IsRelative )
{
SvXMLUnitConverter::convertEnum( msBuffer, aGluePoint.PositionAlignment, aXML_GlueAlignment_EnumMap );
rExport.AddAttribute( XML_NAMESPACE_DRAW, sXML_align, msBuffer.makeStringAndClear() );
}
if( aGluePoint.Escape != drawing::EscapeDirection_SMART )
{
SvXMLUnitConverter::convertEnum( msBuffer, aGluePoint.Escape, aXML_GlueEscapeDirection_EnumMap );
rExport.AddAttribute( XML_NAMESPACE_DRAW, sXML_escape_direction, msBuffer.makeStringAndClear() );
}
SvXMLElementExport aEventsElemt(rExport, XML_NAMESPACE_DRAW, sXML_glue_point, sal_True, sal_True);
}
}
}

View file

@ -2,9 +2,9 @@
*
* $RCSfile: shapeexport2.cxx,v $
*
* $Revision: 1.13 $
* $Revision: 1.14 $
*
* last change: $Author: cl $ $Date: 2001-05-07 14:35:39 $
* last change: $Author: cl $ $Date: 2001-05-31 11:18:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -551,6 +551,7 @@ void XMLShapeExport::ImpExportGroupShape( const uno::Reference< drawing::XShape
SvXMLElementExport aPGR(rExport, XML_NAMESPACE_DRAW, sXML_g, sal_True, sal_True);
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
// write members
exportShapes( xShapes, nFeatures, pRefPoint );
@ -611,6 +612,7 @@ void XMLShapeExport::ImpExportTextBoxShape(
SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_text_box, sal_True, sal_True);
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
if(!bIsEmptyPresObj)
ImpExportText( xShape );
}
@ -642,6 +644,7 @@ void XMLShapeExport::ImpExportRectangleShape(
SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_rect, sal_True, sal_True);
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
ImpExportText( xShape );
}
}
@ -749,6 +752,7 @@ void XMLShapeExport::ImpExportLineShape(
SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_line, sal_True, sal_True);
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
ImpExportText( xShape );
}
}
@ -803,6 +807,7 @@ void XMLShapeExport::ImpExportEllipseShape(
SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_circle, sal_True, sal_True);
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
ImpExportText( xShape );
}
else
@ -811,6 +816,7 @@ void XMLShapeExport::ImpExportEllipseShape(
SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_ellipse, sal_True, sal_True);
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
ImpExportText( xShape );
}
}
@ -888,6 +894,7 @@ void XMLShapeExport::ImpExportPolygonShape(
SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_path, sal_True, sal_True);
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
ImpExportText( xShape );
}
}
@ -918,6 +925,7 @@ void XMLShapeExport::ImpExportPolygonShape(
bClosed ? sXML_polygon : sXML_polyline , sal_True, sal_True);
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
ImpExportText( xShape );
}
else
@ -947,6 +955,7 @@ void XMLShapeExport::ImpExportPolygonShape(
SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_path, sal_True, sal_True);
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
ImpExportText( xShape );
}
}
@ -1003,6 +1012,7 @@ void XMLShapeExport::ImpExportGraphicObjectShape(
// write graphic object
SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_image, sal_True, sal_True);
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
ImpExportText( xShape );
// image map
@ -1202,6 +1212,7 @@ void XMLShapeExport::ImpExportConnectorShape(
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 ));
@ -1220,6 +1231,7 @@ void XMLShapeExport::ImpExportConnectorShape(
SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_connector, sal_True, sal_True);
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
ImpExportText( xShape );
}
@ -1290,6 +1302,7 @@ void XMLShapeExport::ImpExportMeasureShape(
SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_measure, sal_True, sal_True);
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
if( xText.is() )
@ -1350,6 +1363,7 @@ void XMLShapeExport::ImpExportOLE2Shape(
SvXMLElementExport aElem( rExport, XML_NAMESPACE_DRAW, pElem, sal_False, sal_True );
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
}
}
@ -1415,6 +1429,7 @@ void XMLShapeExport::ImpExportCaptionShape(
SvXMLElementExport aOBJ(rExport, XML_NAMESPACE_DRAW, sXML_caption, sal_True, sal_True);
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
ImpExportText( xShape );
}
}

View file

@ -2,9 +2,9 @@
*
* $RCSfile: shapeimport.cxx,v $
*
* $Revision: 1.32 $
* $Revision: 1.33 $
*
* last change: $Author: cl $ $Date: 2001-05-18 08:40:43 $
* last change: $Author: cl $ $Date: 2001-05-31 11:18:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -242,9 +242,16 @@ XMLShapeImportHelper::~XMLShapeImportHelper()
// Styles or AutoStyles context?
if(mpStylesContext)
{
mpStylesContext->Clear();
mpStylesContext->ReleaseRef();
}
if(mpAutoStylesContext)
{
mpAutoStylesContext->Clear();
mpAutoStylesContext->ReleaseRef();
}
}
//////////////////////////////////////////////////////////////////////////////

View file

@ -2,9 +2,9 @@
*
* $RCSfile: ximpshap.cxx,v $
*
* $Revision: 1.47 $
* $Revision: 1.48 $
*
* last change: $Author: cl $ $Date: 2001-05-28 13:32:20 $
* last change: $Author: cl $ $Date: 2001-05-31 11:18:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -63,6 +63,26 @@
#include <tools/debug.hxx>
#ifndef _COM_SUN_STAR_DRAWING_XGLUEPOINTSSUPPLIER_HPP_
#include <com/sun/star/drawing/XGluePointsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_XGLUEPOINTSSUPPLIER_HPP_
#include <com/sun/star/drawing/XGluePointsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_GLUEPOINT2_HPP_
#include <com/sun/star/drawing/GluePoint2.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_ALIGNMENT_HPP_
#include <com/sun/star/drawing/Alignment.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_ESCAPEDIRECTION_HPP_
#include <com/sun/star/drawing/EscapeDirection.hpp>
#endif
#ifndef _COMPHELPER_EXTRACT_HXX_
#include <comphelper/extract.hxx>
#endif
@ -166,6 +186,9 @@
using namespace ::rtl;
using namespace ::com::sun::star;
extern SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap[];
extern SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap[];
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -222,6 +245,10 @@ SvXMLImportContext *SdXMLShapeContext::CreateChildContext( USHORT nPrefix,
{
pContext = new SdXMLEventsContext( GetImport(), nPrefix, rLocalName, xAttrList, mxShape );
}
else if( nPrefix == XML_NAMESPACE_DRAW && rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_glue_point ) ) )
{
addGluePoint( xAttrList );
}
else
{
// create text cursor on demand
@ -254,6 +281,89 @@ SvXMLImportContext *SdXMLShapeContext::CreateChildContext( USHORT nPrefix,
return pContext;
}
void SdXMLShapeContext::addGluePoint( const uno::Reference< xml::sax::XAttributeList>& xAttrList )
{
// get the glue points container for this shape if its not already there
if( !mxGluePoints.is() )
{
uno::Reference< drawing::XGluePointsSupplier > xSupplier( mxShape, uno::UNO_QUERY );
if( !xSupplier.is() )
return;
mxGluePoints = xSupplier->getGluePoints();
if( !mxGluePoints.is() )
return;
}
drawing::GluePoint2 aGluePoint;
aGluePoint.IsUserDefined = sal_True;
aGluePoint.Position.X = 0;
aGluePoint.Position.Y = 0;
aGluePoint.Escape = drawing::EscapeDirection_SMART;
aGluePoint.PositionAlignment = drawing::Alignment_CENTER;
aGluePoint.IsRelative = sal_True;
sal_Int32 nId = -1;
// read attributes for the 3DScene
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
for(sal_Int16 i=0; i < nAttrCount; i++)
{
OUString sAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
const OUString sValue( xAttrList->getValueByIndex( i ) );
if( nPrefix == XML_NAMESPACE_SVG )
{
if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_x ) ) )
{
GetImport().GetMM100UnitConverter().convertMeasure(aGluePoint.Position.X, sValue);
}
else if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_y ) ) )
{
GetImport().GetMM100UnitConverter().convertMeasure(aGluePoint.Position.Y, sValue);
}
}
else if( nPrefix == XML_NAMESPACE_DRAW )
{
if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_id ) ) )
{
nId = sValue.toInt32();
}
else if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_align ) ) )
{
USHORT eKind;
if( SvXMLUnitConverter::convertEnum( eKind, sValue, aXML_GlueAlignment_EnumMap ) )
{
aGluePoint.PositionAlignment = (drawing::Alignment)eKind;
aGluePoint.IsRelative = sal_False;
}
}
else if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_escape_direction ) ) )
{
USHORT eKind;
if( SvXMLUnitConverter::convertEnum( eKind, sValue, aXML_GlueEscapeDirection_EnumMap ) )
{
aGluePoint.Escape = (drawing::EscapeDirection)eKind;
}
}
}
}
if( nId != -1 )
{
try
{
mxGluePoints->insertByIndex( nId, uno::makeAny( aGluePoint ) );
}
catch( uno::Exception& )
{
DBG_ERROR( "exception during setting of glue points!");
}
}
}
//////////////////////////////////////////////////////////////////////////////
void SdXMLShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)

View file

@ -2,9 +2,9 @@
*
* $RCSfile: ximpshap.hxx,v $
*
* $Revision: 1.22 $
* $Revision: 1.23 $
*
* last change: $Author: cl $ $Date: 2001-05-14 11:35:10 $
* last change: $Author: cl $ $Date: 2001-05-31 11:18:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -62,6 +62,10 @@
#ifndef _XIMPSHAPE_HXX
#define _XIMPSHAPE_HXX
#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
#include <com/sun/star/container/XIndexContainer.hpp>
#endif
#ifndef _XMLOFF_XMLICTXT_HXX
#include "xmlictxt.hxx"
#endif
@ -106,6 +110,8 @@ protected:
com::sun::star::uno::Reference< com::sun::star::text::XTextCursor > mxCursor;
com::sun::star::uno::Reference< com::sun::star::text::XTextCursor > mxOldCursor;
com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList> mxAttrList;
com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer > mxGluePoints;
rtl::OUString maDrawStyleName;
rtl::OUString maPresentationClass;
rtl::OUString maShapeName;
@ -130,6 +136,7 @@ protected:
SvXMLImport& GetImport() { return SvXMLImportContext::GetImport(); }
const SvXMLImport& GetImport() const { return SvXMLImportContext::GetImport(); }
void addGluePoint( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList );
public:
TYPEINFO();