Kaydet (Commit) 0c0db434 authored tarafından Armin Weiss's avatar Armin Weiss

Corrected Arrowhead Import/Export to use new StarOfficeAPI and to

Im/Export full PolyPolygons or Beziers.
üst f11cba5e
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: MarkerStyle.cxx,v $ * $RCSfile: MarkerStyle.cxx,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change: $Author: cl $ $Date: 2001-01-24 18:48:25 $ * last change: $Author: aw $ $Date: 2001-03-08 17:41:23 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -63,10 +63,6 @@ ...@@ -63,10 +63,6 @@
#include "MarkerStyle.hxx" #include "MarkerStyle.hxx"
#endif #endif
#ifndef _COM_SUN_STAR_DRAWING_POINTSEQUENCE_HPP_
#include <com/sun/star/drawing/PointSequence.hpp>
#endif
#ifndef _XEXPTRANSFORM_HXX #ifndef _XEXPTRANSFORM_HXX
#include "xexptran.hxx" #include "xexptran.hxx"
#endif #endif
...@@ -99,6 +95,10 @@ ...@@ -99,6 +95,10 @@
#include<rtl/ustring> #include<rtl/ustring>
#endif #endif
#ifndef _COM_SUN_STAR_DRAWING_POLYPOLYGONBEZIERCOORDS_HPP_
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
#endif
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::rtl; using namespace ::rtl;
...@@ -134,19 +134,19 @@ sal_Bool XMLMarkerStyle::importXML( const uno::Reference< xml::sax::XAttributeLi ...@@ -134,19 +134,19 @@ sal_Bool XMLMarkerStyle::importXML( const uno::Reference< xml::sax::XAttributeLi
} }
sal_Bool XMLMarkerStyle::ImpExportXML( const uno::Reference< xml::sax::XDocumentHandler > & rHandler, sal_Bool XMLMarkerStyle::ImpExportXML( const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
const SvXMLNamespaceMap& rNamespaceMap, const SvXMLUnitConverter& rUnitConverter, const SvXMLNamespaceMap& rNamespaceMap, const SvXMLUnitConverter& rUnitConverter,
const OUString& rStrName, const uno::Any& rValue ) const OUString& rStrName, const uno::Any& rValue )
{ {
sal_Bool bRet = sal_False; sal_Bool bRet(sal_False);
drawing::PointSequence aPointSequence;
if( rStrName.getLength() ) if(rStrName.getLength())
{ {
if( rValue >>= aPointSequence ) drawing::PolyPolygonBezierCoords aBezier;
if(rValue >>= aBezier)
{ {
pAttrList = new SvXMLAttributeList(); // Do NOT delete me !! pAttrList = new SvXMLAttributeList(); // Do NOT delete me !!
::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > xAttrList( pAttrList ); uno::Reference< xml::sax::XAttributeList > xAttrList( pAttrList );
OUString aStrValue; OUString aStrValue;
OUStringBuffer aOut; OUStringBuffer aOut;
...@@ -157,39 +157,75 @@ sal_Bool XMLMarkerStyle::ImpExportXML( const uno::Reference< xml::sax::XDocument ...@@ -157,39 +157,75 @@ sal_Bool XMLMarkerStyle::ImpExportXML( const uno::Reference< xml::sax::XDocument
///////////////// /////////////////
// Viewbox (viewBox="0 0 1500 1000") // Viewbox (viewBox="0 0 1500 1000")
const awt::Point *pPoints = aPointSequence.getConstArray(); sal_Int32 nMinX(0x7fffffff);
sal_Int32 nPointCount = aPointSequence.getLength(); sal_Int32 nMaxX(0x80000000);
sal_Int32 nMinX = 0, nMaxX = 0, nMinY = 0, nMaxY = 0; sal_Int32 nMinY(0x7fffffff);
sal_Int32 nMaxY(0x80000000);
for( sal_Int32 i = 0; i<nPointCount; i++ ) sal_Int32 nOuterCnt(aBezier.Coordinates.getLength());
drawing::PointSequence* pOuterSequence = aBezier.Coordinates.getArray();
sal_Int32 a, b;
sal_Bool bClosed(sal_False);
for(a = 0L; a < nOuterCnt; a++)
{ {
const awt::Point aPoint = pPoints[i]; drawing::PointSequence* pSequence = pOuterSequence++;
const awt::Point *pPoints = pSequence->getConstArray();
if( aPoint.X < nMinX ) sal_Int32 nPointCount(pSequence->getLength());
nMinX = aPoint.X;
if( aPoint.X > nMaxX ) if(nPointCount)
nMaxX = aPoint.X; {
if( aPoint.Y < nMinY ) const awt::Point aStart = pPoints[0];
nMinY = aPoint.Y; const awt::Point aEnd = pPoints[nPointCount - 1];
if( aPoint.Y > nMaxY )
nMaxY = aPoint.Y; if(aStart.X == aEnd.X && aStart.Y == aEnd.Y)
{
bClosed = sal_True;
}
}
for(b = 0L; b < nPointCount; b++)
{
const awt::Point aPoint = pPoints[b];
if( aPoint.X < nMinX )
nMinX = aPoint.X;
if( aPoint.X > nMaxX )
nMaxX = aPoint.X;
if( aPoint.Y < nMinY )
nMinY = aPoint.Y;
if( aPoint.Y > nMaxY )
nMaxY = aPoint.Y;
}
} }
sal_Int32 nDifX = nMaxX - nMinX; sal_Int32 nDifX(nMaxX - nMinX);
sal_Int32 nDifY = nMaxY - nMinY; sal_Int32 nDifY(nMaxY - nMinY);
nDifX = nDifX >= 0 ? nDifX : -nDifX;
nDifY = nDifY >= 0 ? nDifY : -nDifY;
SdXMLImExViewBox aViewBox( 0, 0, nDifX, nDifY ); SdXMLImExViewBox aViewBox( 0, 0, nDifX, nDifY );
AddAttribute( XML_NAMESPACE_SVG, sXML_viewBox, aViewBox.GetExportString( rUnitConverter ) ); AddAttribute( XML_NAMESPACE_SVG, sXML_viewBox, aViewBox.GetExportString( rUnitConverter ) );
///////////////// /////////////////
// Pathdata // Pathdata
SdXMLImExPointsElement aPoints( &aPointSequence, aViewBox, awt::Point( 0, 0 ), pOuterSequence = aBezier.Coordinates.getArray();
awt::Size( aViewBox.GetWidth(), aViewBox.GetHeight() ), drawing::FlagSequence* pOuterFlags = aBezier.Flags.getArray();
rUnitConverter ); SdXMLImExSvgDElement aSvgDElement(aViewBox);
AddAttribute( XML_NAMESPACE_SVG, sXML_d, aPoints.GetExportString() ); for(a = 0L; a < nOuterCnt; a++)
{
drawing::PointSequence* pSequence = pOuterSequence++;
drawing::FlagSequence* pFlags = pOuterFlags++;
aSvgDElement.AddPolygon(pSequence, pFlags,
awt::Point( 0, 0 ),
awt::Size( aViewBox.GetWidth(), aViewBox.GetHeight() ),
rUnitConverter, bClosed);
}
// write point array
AddAttribute(XML_NAMESPACE_SVG, sXML_d, aSvgDElement.GetExportString());
///////////////// /////////////////
// Do Write // Do Write
...@@ -207,8 +243,8 @@ sal_Bool XMLMarkerStyle::ImpExportXML( const uno::Reference< xml::sax::XDocument ...@@ -207,8 +243,8 @@ sal_Bool XMLMarkerStyle::ImpExportXML( const uno::Reference< xml::sax::XDocument
} }
sal_Bool XMLMarkerStyle::ImpImportXML( const SvXMLUnitConverter& rUnitConverter, sal_Bool XMLMarkerStyle::ImpImportXML( const SvXMLUnitConverter& rUnitConverter,
const uno::Reference< xml::sax::XAttributeList >& xAttrList, const uno::Reference< xml::sax::XAttributeList >& xAttrList,
uno::Any& rValue, OUString& rStrName ) uno::Any& rValue, OUString& rStrName )
{ {
sal_Bool bRet = sal_False; sal_Bool bRet = sal_False;
sal_Bool bHasViewBox = sal_False; sal_Bool bHasViewBox = sal_False;
...@@ -216,8 +252,6 @@ sal_Bool XMLMarkerStyle::ImpImportXML( const SvXMLUnitConverter& rUnitConverter, ...@@ -216,8 +252,6 @@ sal_Bool XMLMarkerStyle::ImpImportXML( const SvXMLUnitConverter& rUnitConverter,
SdXMLImExViewBox* pViewBox = NULL; SdXMLImExViewBox* pViewBox = NULL;
drawing::PointSequence aPointSequence;
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
for( sal_Int16 i = 0; i < nAttrCount; i++ ) for( sal_Int16 i = 0; i < nAttrCount; i++ )
{ {
...@@ -229,32 +263,59 @@ sal_Bool XMLMarkerStyle::ImpImportXML( const SvXMLUnitConverter& rUnitConverter, ...@@ -229,32 +263,59 @@ sal_Bool XMLMarkerStyle::ImpImportXML( const SvXMLUnitConverter& rUnitConverter,
if( aStrAttrName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( sXML_name ) ) == 0 ) if( aStrAttrName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( sXML_name ) ) == 0 )
{ {
rStrName = aStrValue; rStrName = aStrValue;
}
} else if( aStrAttrName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( sXML_viewBox ) ) == 0 ) else if( aStrAttrName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( sXML_viewBox ) ) == 0 )
{ {
pViewBox = new SdXMLImExViewBox( aStrValue, rUnitConverter ); pViewBox = new SdXMLImExViewBox( aStrValue, rUnitConverter );
bHasViewBox = sal_True; bHasViewBox = sal_True;
} else if( bHasViewBox && aStrAttrName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( sXML_d ) ) == 0 ) }
else if( bHasViewBox && aStrAttrName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( sXML_d ) ) == 0 )
{ {
SdXMLImExPointsElement aPoints( aStrValue, *pViewBox, awt::Point( 0, 0 ), SdXMLImExSvgDElement aPoints(aStrValue, *pViewBox, awt::Point( 0, 0 ),
awt::Size( pViewBox->GetWidth(), pViewBox->GetHeight() ), awt::Size( pViewBox->GetWidth(), pViewBox->GetHeight() ),
rUnitConverter ); rUnitConverter );
const drawing::PointSequenceSequence& rSequence = aPoints.GetPointSequenceSequence();
if( rSequence.getLength() ) if(aPoints.IsCurve())
{ {
const drawing::PointSequence *pSequences = rSequence.getConstArray(); drawing::PolyPolygonBezierCoords aSourcePolyPolygon(
aPoints.GetPointSequenceSequence(),
aPoints.GetFlagSequenceSequence());
rValue <<= aSourcePolyPolygon;
}
else
{
drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
aSourcePolyPolygon.Coordinates = aPoints.GetPointSequenceSequence();
aSourcePolyPolygon.Flags.realloc(aSourcePolyPolygon.Coordinates.getLength());
// Zeiger auf innere sequences holen
const drawing::PointSequence* pInnerSequence = aSourcePolyPolygon.Coordinates.getConstArray();
drawing::FlagSequence* pInnerSequenceFlags = aSourcePolyPolygon.Flags.getArray();
for(sal_Int32 a(0); a < aSourcePolyPolygon.Coordinates.getLength(); a++)
{
pInnerSequenceFlags->realloc(pInnerSequence->getLength());
drawing::PolygonFlags* pPolyFlags = pInnerSequenceFlags->getArray();
for(sal_Int32 b(0); b < pInnerSequence->getLength(); b++)
*pPolyFlags++ = drawing::PolygonFlags_NORMAL;
aPointSequence = drawing::PointSequence( pSequences[0] ); // next run
pInnerSequence++;
pInnerSequenceFlags++;
}
rValue <<= aSourcePolyPolygon;
} }
bHasPathData = sal_True;
} }
} }
if( pViewBox ) if( pViewBox )
delete pViewBox; delete pViewBox;
rValue <<= aPointSequence;
bRet = bHasViewBox && bHasPathData; bRet = bHasViewBox && bHasPathData;
return bRet; return bRet;
......
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