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

added api friendlier interface

üst 50063bb8
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: VisAreaContext.hxx,v $ * $RCSfile: VisAreaContext.hxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: sab $ $Date: 2001-02-15 11:04:10 $ * last change: $Author: cl $ $Date: 2001-02-21 18:04:03 $
* *
* 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
...@@ -72,6 +72,10 @@ ...@@ -72,6 +72,10 @@
class Rectangle; class Rectangle;
namespace com { namespace sun { namespace star { namespace awt {
struct Rectangle;
} } } }
class XMLVisAreaContext : public SvXMLImportContext class XMLVisAreaContext : public SvXMLImportContext
{ {
public: public:
...@@ -80,6 +84,12 @@ public: ...@@ -80,6 +84,12 @@ public:
const ::com::sun::star::uno::Reference< const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList, ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
Rectangle& rRect, const MapUnit aMapUnit); Rectangle& rRect, const MapUnit aMapUnit);
XMLVisAreaContext( SvXMLImport& rImport, USHORT nPrfx, const NAMESPACE_RTL(OUString)& rLName,
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList,
::com::sun::star::awt::Rectangle& rRect, const sal_Int16 nMeasureUnit);
virtual ~XMLVisAreaContext(); virtual ~XMLVisAreaContext();
virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
...@@ -87,6 +97,12 @@ public: ...@@ -87,6 +97,12 @@ public:
const ::com::sun::star::uno::Reference< const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList ); ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
virtual void EndElement(); virtual void EndElement();
private:
void process( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
::com::sun::star::awt::Rectangle& rRect,
const sal_Int16 nMeasureUnit );
}; };
#endif #endif
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: VisAreaExport.hxx,v $ * $RCSfile: VisAreaExport.hxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: sab $ $Date: 2001-02-15 11:04:10 $ * last change: $Author: cl $ $Date: 2001-02-21 18:04:03 $
* *
* 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
...@@ -73,6 +73,10 @@ ...@@ -73,6 +73,10 @@
class SvXMLExport; class SvXMLExport;
class Rectangle; class Rectangle;
namespace com { namespace sun { namespace star { namespace awt {
struct Rectangle;
} } } }
class XMLVisAreaExport class XMLVisAreaExport
{ {
public: public:
...@@ -80,6 +84,9 @@ public: ...@@ -80,6 +84,9 @@ public:
XMLVisAreaExport(SvXMLExport& rExport, const sal_Char *pName, XMLVisAreaExport(SvXMLExport& rExport, const sal_Char *pName,
const Rectangle& aRect, const MapUnit aMapUnit); const Rectangle& aRect, const MapUnit aMapUnit);
XMLVisAreaExport(SvXMLExport& rExport, const sal_Char *pName,
const com::sun::star::awt::Rectangle& aRect, const sal_Int16 nMeasureUnit );
~XMLVisAreaExport(); ~XMLVisAreaExport();
}; };
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: VisAreaContext.cxx,v $ * $RCSfile: VisAreaContext.cxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: sab $ $Date: 2001-02-15 11:03:18 $ * last change: $Author: cl $ $Date: 2001-02-21 18:05:31 $
* *
* 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
...@@ -102,6 +102,33 @@ XMLVisAreaContext::XMLVisAreaContext( SvXMLImport& rImport, ...@@ -102,6 +102,33 @@ XMLVisAreaContext::XMLVisAreaContext( SvXMLImport& rImport,
Rectangle& rRect, const MapUnit aMapUnit ) : Rectangle& rRect, const MapUnit aMapUnit ) :
SvXMLImportContext( rImport, nPrfx, rLName ) SvXMLImportContext( rImport, nPrfx, rLName )
{ {
awt::Rectangle rAwtRect( rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight() );
process( xAttrList, rAwtRect, (sal_Int16)aMapUnit );
rRect.setX( rAwtRect.X );
rRect.setY( rAwtRect.Y );
rRect.setWidth( rAwtRect.Width );
rRect.setHeight( rAwtRect.Height );
}
XMLVisAreaContext::XMLVisAreaContext( SvXMLImport& rImport,
USHORT nPrfx,
const NAMESPACE_RTL(OUString)& rLName,
const uno::Reference<xml::sax::XAttributeList>& xAttrList,
::com::sun::star::awt::Rectangle& rRect, const sal_Int16 nMeasureUnit ) :
SvXMLImportContext( rImport, nPrfx, rLName )
{
process( xAttrList, rRect, nMeasureUnit );
}
XMLVisAreaContext::~XMLVisAreaContext()
{
}
void XMLVisAreaContext::process( const uno::Reference< xml::sax::XAttributeList>& xAttrList, awt::Rectangle& rRect, const sal_Int16 nMeasureUnit )
{
MapUnit aMapUnit = (MapUnit)nMeasureUnit;
sal_Int32 nX(0); sal_Int32 nX(0);
sal_Int32 nY(0); sal_Int32 nY(0);
sal_Int32 nWidth(0); sal_Int32 nWidth(0);
...@@ -111,7 +138,7 @@ XMLVisAreaContext::XMLVisAreaContext( SvXMLImport& rImport, ...@@ -111,7 +138,7 @@ XMLVisAreaContext::XMLVisAreaContext( SvXMLImport& rImport,
{ {
rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
rtl::OUString aLocalName; rtl::OUString aLocalName;
USHORT nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName( USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(
sAttrName, &aLocalName ); sAttrName, &aLocalName );
rtl::OUString sValue = xAttrList->getValueByIndex( i ); rtl::OUString sValue = xAttrList->getValueByIndex( i );
...@@ -120,31 +147,27 @@ XMLVisAreaContext::XMLVisAreaContext( SvXMLImport& rImport, ...@@ -120,31 +147,27 @@ XMLVisAreaContext::XMLVisAreaContext( SvXMLImport& rImport,
if (aLocalName.compareToAscii(sXML_x) == 0) if (aLocalName.compareToAscii(sXML_x) == 0)
{ {
SvXMLUnitConverter::convertMeasure(nX, sValue, aMapUnit); SvXMLUnitConverter::convertMeasure(nX, sValue, aMapUnit);
rRect.setX(nX); rRect.X = nX;
} }
else if (aLocalName.compareToAscii(sXML_y) == 0) else if (aLocalName.compareToAscii(sXML_y) == 0)
{ {
SvXMLUnitConverter::convertMeasure(nY, sValue, aMapUnit); SvXMLUnitConverter::convertMeasure(nY, sValue, aMapUnit);
rRect.setY(nY); rRect.Y = nY;
} }
else if (aLocalName.compareToAscii(sXML_width) == 0) else if (aLocalName.compareToAscii(sXML_width) == 0)
{ {
SvXMLUnitConverter::convertMeasure(nWidth, sValue, aMapUnit); SvXMLUnitConverter::convertMeasure(nWidth, sValue, aMapUnit);
rRect.setWidth(nWidth); rRect.Width = nWidth;
} }
else if (aLocalName.compareToAscii(sXML_height) == 0) else if (aLocalName.compareToAscii(sXML_height) == 0)
{ {
SvXMLUnitConverter::convertMeasure(nHeight, sValue, aMapUnit); SvXMLUnitConverter::convertMeasure(nHeight, sValue, aMapUnit);
rRect.setHeight(nHeight); rRect.Height = nHeight;
} }
} }
} }
} }
XMLVisAreaContext::~XMLVisAreaContext()
{
}
SvXMLImportContext *XMLVisAreaContext::CreateChildContext( USHORT nPrefix, SvXMLImportContext *XMLVisAreaContext::CreateChildContext( USHORT nPrefix,
const NAMESPACE_RTL(OUString)& rLocalName, const NAMESPACE_RTL(OUString)& rLocalName,
const ::com::sun::star::uno::Reference< const ::com::sun::star::uno::Reference<
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: VisAreaExport.cxx,v $ * $RCSfile: VisAreaExport.cxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: sab $ $Date: 2001-02-15 11:03:18 $ * last change: $Author: cl $ $Date: 2001-02-21 18:05:31 $
* *
* 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
...@@ -59,6 +59,10 @@ ...@@ -59,6 +59,10 @@
* *
************************************************************************/ ************************************************************************/
#ifndef _COM_SUN_STAR_AWT_RECTANGLE_HPP_
#include <com/sun/star/awt/Rectangle.hpp>
#endif
#ifndef _XMLOFF_VISAREAEXPORT_HXX #ifndef _XMLOFF_VISAREAEXPORT_HXX
#include "VisAreaExport.hxx" #include "VisAreaExport.hxx"
#endif #endif
...@@ -104,6 +108,26 @@ XMLVisAreaExport::XMLVisAreaExport(SvXMLExport& rExport, const sal_Char *pName, ...@@ -104,6 +108,26 @@ XMLVisAreaExport::XMLVisAreaExport(SvXMLExport& rExport, const sal_Char *pName,
SvXMLElementExport aVisAreaElem(rExport, XML_NAMESPACE_OFFICE, pName, sal_True, sal_True); SvXMLElementExport aVisAreaElem(rExport, XML_NAMESPACE_OFFICE, pName, sal_True, sal_True);
} }
XMLVisAreaExport::XMLVisAreaExport(SvXMLExport& rExport, const sal_Char *pName,
const com::sun::star::awt::Rectangle& aRect, const sal_Int16 nMeasureUnit )
{
MapUnit aMapUnit = (MapUnit)nMeasureUnit;
SvXMLUnitConverter& rUnitConv = rExport.GetMM100UnitConverter();
// write VisArea Element and its Attributes
rtl::OUStringBuffer sBuffer;
rUnitConv.convertMeasure(sBuffer, aRect.X, aMapUnit);
rExport.AddAttribute(XML_NAMESPACE_OFFICE, sXML_x, sBuffer.makeStringAndClear());
rUnitConv.convertMeasure(sBuffer, aRect.Y, aMapUnit);
rExport.AddAttribute(XML_NAMESPACE_OFFICE, sXML_y, sBuffer.makeStringAndClear());
rUnitConv.convertMeasure(sBuffer, aRect.Width, aMapUnit);
rExport.AddAttribute(XML_NAMESPACE_OFFICE, sXML_width, sBuffer.makeStringAndClear());
rUnitConv.convertMeasure(sBuffer, aRect.Height, aMapUnit);
rExport.AddAttribute(XML_NAMESPACE_OFFICE, sXML_height, sBuffer.makeStringAndClear());
SvXMLElementExport aVisAreaElem(rExport, XML_NAMESPACE_OFFICE, pName, sal_True, sal_True);
}
XMLVisAreaExport::~XMLVisAreaExport() XMLVisAreaExport::~XMLVisAreaExport()
{ {
} }
......
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