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

#86794# added xml clipboard support for drawing layer

üst c1412ac0
......@@ -395,6 +395,7 @@ hedabu: ..\inc\unoshcol.hxx %_DEST%\inc%_EXT%\svx\unoshcol.hxx
hedabu: ..\inc\unoipset.hxx %_DEST%\inc%_EXT%\svx\unoipset.hxx
hedabu: ..\inc\unoprov.hxx %_DEST%\inc%_EXT%\svx\unoprov.hxx
hedabu: ..\inc\unomod.hxx %_DEST%\inc%_EXT%\svx\unomod.hxx
hedabu: ..\inc\unomodel.hxx %_DEST%\inc%_EXT%\svx\unomodel.hxx
hedabu: ..\inc\fmdpage.hxx %_DEST%\inc%_EXT%\svx\fmdpage.hxx
hedabu: ..\inc\fmsearch.hxx %_DEST%\inc%_EXT%\svx\fmsearch.hxx
hedabu: ..\inc\vcattr.hxx %_DEST%\inc%_EXT%\svx\vcattr.hxx
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: unomod.cxx,v $
*
* $Revision: 1.7 $
* $Revision: 1.8 $
*
* last change: $Author: cl $ $Date: 2001-07-24 15:35:53 $
* last change: $Author: cl $ $Date: 2001-09-28 14:56:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -71,6 +71,14 @@
#include <com/sun/star/drawing/XShape.hpp>
#endif
#ifndef _VOS_MUTEX_HXX_
#include <vos/mutex.hxx>
#endif
#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif
#ifndef _LIST_HXX
#include <tools/list.hxx>
#endif
......@@ -79,18 +87,126 @@
#include <svtools/itemprop.hxx>
#endif
#ifndef _SVTOOLS_UNOEVENT_HXX_
#include <svtools/unoevent.hxx>
#endif
#ifndef _COMPHELPER_SEQUENCE_HXX_
#include <comphelper/sequence.hxx>
#endif
#include <cppuhelper/implbase2.hxx>
#ifndef _SVX_UNOFILL_HXX_
#include <unofill.hxx>
#endif
#ifndef _SVX_UNONRULE_HXX
#include <unonrule.hxx>
#endif
#ifndef _SVTOOLS_UNOIMAP_HXX
#include <svtools/unoimap.hxx>
#endif
#ifndef _SVX_FMDPAGE_HXX
#include <fmdpage.hxx>
#endif
#ifndef _SVX_FMMODEL_HXX
#include <fmmodel.hxx>
#endif
#ifndef _SVX_FMPAGE_HXX
#include <fmpage.hxx>
#endif
#ifndef _SFX_HRC
#include <sfx2/sfx.hrc>
#endif
#ifndef _SVX_UNOAPI_HXX_
#include <unoapi.hxx>
#endif
#include "svdmodel.hxx"
#include "globl3d.hxx"
#include "svdtypes.hxx"
#include "unoprov.hxx"
#include "unomod.hxx"
#include "unopage.hxx"
#include "unofield.hxx"
#include "unomod.hxx"
#include "unomodel.hxx"
#include "svdobj.hxx"
#include "svdpage.hxx"
#include "unoshape.hxx"
extern UHashMapEntry pSdrShapeIdentifierMap[];
//-////////////////////////////////////////////////////////////////////
using namespace ::rtl;
using namespace ::osl;
using namespace ::vos;
using namespace ::com::sun::star;
//-////////////////////////////////////////////////////////////////////
#define QUERYINT( xint ) \
if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \
aAny <<= uno::Reference< xint >(this)
#define ITYPE( xint ) \
::getCppuType((const uno::Reference< xint >*)0)
//-////////////////////////////////////////////////////////////////////
#ifndef SVX_LIGHT
class SvxUnoDrawPagesAccess : public ::cppu::WeakImplHelper2< ::com::sun::star::drawing::XDrawPages, ::com::sun::star::lang::XServiceInfo >
{
private:
SvxUnoDrawingModel& mrModel;
public:
SvxUnoDrawPagesAccess( SvxUnoDrawingModel& rMyModel ) throw();
virtual ~SvxUnoDrawPagesAccess() throw();
// XDrawPages
virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage ) throw(::com::sun::star::uno::RuntimeException);
// XIndexAccess
virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
// XElementAccess
virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
// XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
};
#endif
//-////////////////////////////////////////////////////////////////////
#ifndef SVX_LIGHT
const SvEventDescription* ImplGetSupportedMacroItems()
{
static const SvEventDescription aMacroDescriptionsImpl[] =
{
{ SFX_EVENT_MOUSEOVER_OBJECT, "OnMouseOver" },
{ SFX_EVENT_MOUSEOUT_OBJECT, "OnMouseOut" },
{ 0, NULL }
};
return aMacroDescriptionsImpl;
}
#endif
//-////////////////////////////////////////////////////////////////////
uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstance( const OUString& ServiceSpecifier )
throw( uno::Exception, uno::RuntimeException )
{
......@@ -235,3 +351,463 @@ uno::Sequence< OUString > SvxUnoDrawMSFactory::concatServiceNames( uno::Sequence
}
#ifndef SVX_LIGHT
///
SvxUnoDrawingModel::SvxUnoDrawingModel( SdrModel* pDoc )
: mpDoc( pDoc )
{
}
SvxUnoDrawingModel::~SvxUnoDrawingModel() throw()
{
}
uno::Any SAL_CALL SvxUnoDrawingModel::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
{
uno::Any aAny;
QUERYINT(lang::XServiceInfo);
else QUERYINT(lang::XMultiServiceFactory);
else QUERYINT(drawing::XDrawPagesSupplier);
else QUERYINT(com::sun::star::ucb::XAnyCompareFactory);
else
return SfxBaseModel::queryInterface( rType );
return aAny;
}
void SAL_CALL SvxUnoDrawingModel::acquire() throw(uno::RuntimeException)
{
SfxBaseModel::acquire();
}
void SAL_CALL SvxUnoDrawingModel::release() throw(uno::RuntimeException)
{
SfxBaseModel::release();
}
// XTypeProvider
uno::Sequence< uno::Type > SAL_CALL SvxUnoDrawingModel::getTypes( ) throw(uno::RuntimeException)
{
if( maTypeSequence.getLength() == 0 )
{
const uno::Sequence< uno::Type > aBaseTypes( SfxBaseModel::getTypes() );
const sal_Int32 nBaseTypes = aBaseTypes.getLength();
const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
const sal_Int32 nOwnTypes = 4; // !DANGER! Keep this updated!
maTypeSequence.realloc( nBaseTypes + nOwnTypes );
uno::Type* pTypes = maTypeSequence.getArray();
*pTypes++ = ITYPE(lang::XServiceInfo);
*pTypes++ = ITYPE(lang::XMultiServiceFactory);
*pTypes++ = ITYPE(drawing::XDrawPagesSupplier);
*pTypes++ = ITYPE(com::sun::star::ucb::XAnyCompareFactory);
for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
*pTypes++ = *pBaseTypes++;
}
return maTypeSequence;
}
uno::Sequence< sal_Int8 > SAL_CALL SvxUnoDrawingModel::getImplementationId( ) throw(uno::RuntimeException)
{
static uno::Sequence< sal_Int8 > aId;
if( aId.getLength() == 0 )
{
aId.realloc( 16 );
rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
}
return aId;
}
void SAL_CALL SvxUnoDrawingModel::lockControllers( )
throw(uno::RuntimeException)
{
if( mpDoc )
mpDoc->setLock( sal_True );
}
void SAL_CALL SvxUnoDrawingModel::unlockControllers( )
throw(uno::RuntimeException)
{
if( mpDoc && mpDoc->isLocked() )
{
mpDoc->setLock( sal_False );
}
}
sal_Bool SAL_CALL SvxUnoDrawingModel::hasControllersLocked( )
throw(uno::RuntimeException)
{
return mpDoc && mpDoc->isLocked();
}
// XDrawPagesSupplier
uno::Reference< drawing::XDrawPages > SAL_CALL SvxUnoDrawingModel::getDrawPages()
throw(uno::RuntimeException)
{
OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< drawing::XDrawPages > xDrawPages( mxDrawPagesAccess );
if( !xDrawPages.is() )
mxDrawPagesAccess = xDrawPages = (drawing::XDrawPages*)new SvxUnoDrawPagesAccess(*this);
return xDrawPages;
}
// XMultiServiceFactory ( SvxFmMSFactory )
uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawingModel::createInstance( const OUString& aServiceSpecifier )
throw(uno::Exception, uno::RuntimeException)
{
OGuard aGuard( Application::GetSolarMutex() );
if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) )
{
if( !mxDashTable.is() )
mxDashTable = SvxUnoDashTable_createInstance( mpDoc );
return mxDashTable;
}
if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) )
{
if( !mxGradientTable.is() )
mxGradientTable = SvxUnoGradientTable_createInstance( mpDoc );
return mxGradientTable;
}
if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) )
{
if( !mxHatchTable.is() )
mxHatchTable = SvxUnoHatchTable_createInstance( mpDoc );
return mxHatchTable;
}
if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) )
{
if( !mxBitmapTable.is() )
mxBitmapTable = SvxUnoBitmapTable_createInstance( mpDoc );
return mxBitmapTable;
}
if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) )
{
if( !mxTransGradientTable.is() )
mxTransGradientTable = SvxUnoTransGradientTable_createInstance( mpDoc );
return mxTransGradientTable;
}
if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) )
{
if( !mxMarkerTable.is() )
mxMarkerTable = SvxUnoMarkerTable_createInstance( mpDoc );
return mxMarkerTable;
}
if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.NumberingRules" ) ) )
{
return SvxCreateNumRule( mpDoc );
}
if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapRectangleObject") ) )
{
return SvUnoImageMapRectangleObject_createInstance( ImplGetSupportedMacroItems() );
}
if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapCircleObject") ) )
{
return SvUnoImageMapCircleObject_createInstance( ImplGetSupportedMacroItems() );
}
if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapPolygonObject") ) )
{
return SvUnoImageMapPolygonObject_createInstance( ImplGetSupportedMacroItems() );
}
if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextField.DateTime") ) )
{
return (::cppu::OWeakObject * )new SvxUnoTextField( ID_EXT_DATEFIELD );
}
uno::Reference< uno::XInterface > xRet;
const String aType( aServiceSpecifier );
if( aType.EqualsAscii( "com.sun.star.presentation.", 0, 26 ) )
{
SvxShape* pShape = NULL;
sal_uInt16 nType = OBJ_TEXT;
// create a shape wrapper
if( aType.EqualsAscii( "TitleTextShape", 26, 14 ) )
{
nType = OBJ_TEXT;
}
else if( aType.EqualsAscii( "OutlinerShape", 26, 13 ) )
{
nType = OBJ_TEXT;
}
else if( aType.EqualsAscii( "SubtitleShape", 26, 13 ) )
{
nType = OBJ_TEXT;
}
else if( aType.EqualsAscii( "GraphicObjectShape", 26, 18 ) )
{
nType = OBJ_GRAF;
}
else if( aType.EqualsAscii( "PageShape", 26, 9 ) )
{
nType = OBJ_PAGE;
}
else if( aType.EqualsAscii( "OLE2Shape", 26, 9 ) )
{
nType = OBJ_OLE2;
}
else if( aType.EqualsAscii( "ChartShape", 26, 10 ) )
{
nType = OBJ_OLE2;
}
else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
{
nType = OBJ_OLE2;
}
else if( aType.EqualsAscii( "OrgChartShape", 26, 13 ) )
{
nType = OBJ_OLE2;
}
else if( aType.EqualsAscii( "NotesShape", 26, 13 ) )
{
nType = OBJ_TEXT;
}
else if( aType.EqualsAscii( "HandoutShape", 26, 13 ) )
{
nType = OBJ_PAGE;
}
else
{
throw lang::ServiceNotRegisteredException();
}
// create the API wrapper
pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor );
// set shape type
if( pShape )
pShape->SetShapeType(aServiceSpecifier);
xRet = (uno::XWeak*)pShape;
}
else
{
xRet = SvxFmMSFactory::createInstance( aServiceSpecifier );
}
return xRet;
}
uno::Sequence< OUString > SAL_CALL SvxUnoDrawingModel::getAvailableServiceNames()
throw(uno::RuntimeException)
{
const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() );
uno::Sequence< OUString > aSNS( 21 );
sal_uInt16 i = 0;
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.NumberingRules"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapRectangleObject"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapCircleObject"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapPolygonObject"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlinerShape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SubtitleShape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.GraphicObjectShape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.ChartShape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PageShape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OLE2Shape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TableShape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OrgChartShape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesShape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutShape"));
DBG_ASSERT( i == aSNS.getLength(), "Sequence overrun!" );
return comphelper::concatSequences( aSNS_ORG, aSNS );
}
// lang::XServiceInfo
OUString SAL_CALL SvxUnoDrawingModel::getImplementationName()
throw(uno::RuntimeException)
{
return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoDrawingModel"));
}
sal_Bool SAL_CALL SvxUnoDrawingModel::supportsService( const OUString& ServiceName )
throw(uno::RuntimeException)
{
return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
}
uno::Sequence< OUString > SAL_CALL SvxUnoDrawingModel::getSupportedServiceNames() throw(uno::RuntimeException)
{
OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocument"));
uno::Sequence< OUString > aSeq( &aSN, 1 );
return aSeq;
}
// XAnyCompareFactory
uno::Reference< com::sun::star::ucb::XAnyCompare > SAL_CALL SvxUnoDrawingModel::createAnyCompareByName( const OUString& PropertyName )
throw(uno::RuntimeException)
{
return SvxCreateNumRuleCompare();
}
//=============================================================================
// class SvxUnoDrawPagesAccess
//=============================================================================
SvxUnoDrawPagesAccess::SvxUnoDrawPagesAccess( SvxUnoDrawingModel& rMyModel ) throw()
: mrModel(rMyModel)
{
}
SvxUnoDrawPagesAccess::~SvxUnoDrawPagesAccess() throw()
{
}
// XIndexAccess
sal_Int32 SAL_CALL SvxUnoDrawPagesAccess::getCount()
throw(uno::RuntimeException)
{
OGuard aGuard( Application::GetSolarMutex() );
sal_Int32 nCount = 0;
if( mrModel.mpDoc )
nCount = mrModel.mpDoc->GetPageCount();
return( nCount );
}
uno::Any SAL_CALL SvxUnoDrawPagesAccess::getByIndex( sal_Int32 Index )
throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
{
OGuard aGuard( Application::GetSolarMutex() );
uno::Any aAny;
if( mrModel.mpDoc )
{
if( (Index < 0) || (Index >= mrModel.mpDoc->GetPageCount() ) )
throw lang::IndexOutOfBoundsException();
SdrPage* pPage = mrModel.mpDoc->GetPage( (sal_uInt16)Index );
if( pPage )
{
uno::Reference< uno::XInterface > xPage( pPage->mxUnoPage );
if( !xPage.is() )
{
if( PTR_CAST( FmFormModel, mrModel.mpDoc ) )
xPage = (drawing::XDrawPage*)new SvxFmDrawPage( pPage );
else
xPage = (drawing::XDrawPage*)new SvxDrawPage( pPage );
pPage->mxUnoPage = xPage;
}
aAny <<= xPage;
}
}
return aAny;
}
// XElementAccess
uno::Type SAL_CALL SvxUnoDrawPagesAccess::getElementType()
throw(uno::RuntimeException)
{
return ITYPE( drawing::XDrawPage );
}
sal_Bool SAL_CALL SvxUnoDrawPagesAccess::hasElements()
throw(uno::RuntimeException)
{
return getCount() > 0;
}
// XDrawPages
/******************************************************************************
* Erzeugt eine neue Seite mit Model an der angegebennen Position und gibt die *
* dazugehoerige SdDrawPage zurueck. *
******************************************************************************/
uno::Reference< drawing::XDrawPage > SAL_CALL SvxUnoDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex )
throw(uno::RuntimeException)
{
OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< drawing::XDrawPage > xDrawPage;
if( mrModel.mpDoc )
{
SdrPage* pPage;
if( PTR_CAST( FmFormModel, mrModel.mpDoc ) )
pPage = new FmFormPage(*(FmFormModel*)mrModel.mpDoc, NULL);
else
pPage = new SdrPage(*mrModel.mpDoc);
mrModel.mpDoc->InsertPage( pPage, (sal_uInt16)nIndex );
xDrawPage = uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() );
}
return xDrawPage;
}
void SAL_CALL SvxUnoDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
throw(uno::RuntimeException)
{
OGuard aGuard( Application::GetSolarMutex() );
sal_uInt16 nPageCount = mrModel.mpDoc->GetPageCount();
if( nPageCount > 1 )
{
// pPage von xPage besorgen und dann die Id (nPos )ermitteln
SvxDrawPage* pSvxPage = SvxDrawPage::getImplementation( xPage );
if( pSvxPage )
{
SdrPage* pPage = pSvxPage->GetSdrPage();
if(pPage)
{
sal_uInt16 nPage = pPage->GetPageNum();
mrModel.mpDoc->DeletePage( nPage );
}
}
}
}
// XServiceInfo
sal_Char pSvxUnoDrawPagesAccessService[sizeof("com.sun.star.drawing.DrawPages")] = "com.sun.star.drawing.DrawPages";
OUString SAL_CALL SvxUnoDrawPagesAccess::getImplementationName( ) throw(uno::RuntimeException)
{
return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoDrawPagesAccess" ) );
}
sal_Bool SAL_CALL SvxUnoDrawPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
{
return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSvxUnoDrawPagesAccessService ) );
}
uno::Sequence< OUString > SAL_CALL SvxUnoDrawPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException)
{
OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSvxUnoDrawPagesAccessService ) );
uno::Sequence< OUString > aSeq( &aService, 1 );
return aSeq;
}
#endif
\ No newline at end of file
......@@ -2,9 +2,9 @@
*
* $RCSfile: unopage.cxx,v $
*
* $Revision: 1.17 $
* $Revision: 1.18 $
*
* last change: $Author: ka $ $Date: 2001-09-13 09:29:53 $
* last change: $Author: cl $ $Date: 2001-09-28 14:56:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -648,6 +648,8 @@ SvxShape* SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt3
case OBJ_CAPTION:
pRet = new SvxShapeCaption( pObj );
break;
case OBJ_TITLETEXT:
case OBJ_OUTLINETEXT:
case OBJ_TEXT:
pRet = new SvxShapeText( pObj );
break;
......@@ -758,6 +760,11 @@ SvxShape* SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt3
case E3D_SCENE_ID | E3D_INVENTOR_FLAG:
nObjId = E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG;
break;
case OBJ_TITLETEXT:
case OBJ_OUTLINETEXT:
nObjId = OBJ_TEXT;
break;
}
UHashMapEntry* pMap = pSdrShapeIdentifierMap;
......
......@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.7 $
# $Revision: 1.8 $
#
# last change: $Author: cl $ $Date: 2001-07-20 13:48:52 $
# last change: $Author: cl $ $Date: 2001-09-28 14:57:46 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
......@@ -73,6 +73,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Files --------------------------------------------------------
SLOFILES = \
$(SLO)$/xmlexport.obj \
$(SLO)$/xmltxtimp.obj \
$(SLO)$/xmltxtexp.obj \
$(SLO)$/xmlxtimp.obj \
......
/*************************************************************************
*
* $RCSfile: xmlexport.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: cl $ $Date: 2001-09-28 14:57:46 $
*
* 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 _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#ifndef _COM_SUN_STAR_XML_SAX_INPUTSOURCE_HPP_
#include <com/sun/star/xml/sax/InputSource.hpp>
#endif
#ifndef _COM_SUN_STAR_XML_SAX_XPARSER_HPP_
#include <com/sun/star/xml/sax/XParser.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
#include <com/sun/star/lang/XComponent.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_
#include <com/sun/star/io/XActiveDataSource.hpp>
#endif
#ifndef _COM_SUN_STAR_XML_SAX_SAXPARSEEXCEPTION_HPP_
#include <com/sun/star/xml/sax/SAXParseException.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
#include <com/sun/star/io/XOutputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_
#include <com/sun/star/document/XFilter.hpp>
#endif
#ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_
#include <com/sun/star/document/XExporter.hpp>
#endif
#ifndef _COM_SUN_STAR_DOCUMENT_XIMPORTER_HPP_
#include <com/sun/star/document/XImporter.hpp>
#endif
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
#endif
#ifndef _UTL_STREAM_WRAPPER_HXX_
#include <unotools/streamwrap.hxx>
#endif
#ifndef _SOT_STORAGE_HXX
#include <sot/storage.hxx>
#endif
#ifndef _SVDMODEL_HXX
#include <svdmodel.hxx>
#endif
#ifndef _XMLEOHLP_HXX
#include <xmleohlp.hxx>
#endif
#ifndef _XMLGRHLP_HXX
#include <xmlgrhlp.hxx>
#endif
#include "unomodel.hxx"
using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
sal_Bool SvxDrawingLayerExport( SdrModel* pModel, uno::Reference<io::XOutputStream> xOut )
{
sal_Bool bDocRet = xOut.is();
Reference< document::XGraphicObjectResolver > xGraphicResolver;
SvXMLGraphicHelper *pGraphicHelper = 0;
Reference< document::XEmbeddedObjectResolver > xObjectResolver;
SvXMLEmbeddedObjectHelper *pObjectHelper = 0;
try
{
Reference< lang::XComponent > xComponent( new SvxUnoDrawingModel( pModel ) );
pModel->setUnoModel( Reference< XInterface >::query( xComponent ) );
uno::Reference< lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() );
if( !xServiceFactory.is() )
{
DBG_ERROR( "got no service manager" );
bDocRet = sal_False;
}
if( bDocRet )
{
uno::Reference< uno::XInterface > xWriter( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer" ) ) ) );
if( !xWriter.is() )
{
DBG_ERROR( "com.sun.star.xml.sax.Writer service missing" );
bDocRet = sal_False;
}
// init resolver
SvPersist *pPersist = pModel->GetPersist();
if( pPersist )
{
pObjectHelper = SvXMLEmbeddedObjectHelper::Create( *pPersist, EMBEDDEDOBJECTHELPER_MODE_WRITE );
xObjectResolver = pObjectHelper;
}
pGraphicHelper = SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_WRITE );
xGraphicResolver = pGraphicHelper;
if( bDocRet )
{
uno::Reference<xml::sax::XDocumentHandler> xHandler( xWriter, uno::UNO_QUERY );
// doc export
uno::Reference< io::XActiveDataSource > xDocSrc( xWriter, uno::UNO_QUERY );
xDocSrc->setOutputStream( xOut );
uno::Sequence< uno::Any > aArgs( xObjectResolver.is() ? 3 : 2 );
aArgs[0] <<= xHandler;
aArgs[1] <<= xGraphicResolver;
if( xObjectResolver.is() )
aArgs[2] <<= xObjectResolver;
uno::Reference< document::XFilter > xFilter( xServiceFactory->createInstanceWithArguments( OUString::createFromAscii( "com.sun.star.comp.DrawingLayer.XMLExporter" ), aArgs ), uno::UNO_QUERY );
if( !xFilter.is() )
{
DBG_ERROR( "com.sun.star.comp.Draw.XMLExporter service missing" );
bDocRet = sal_False;
}
if( bDocRet )
{
uno::Reference< document::XExporter > xExporter( xFilter, uno::UNO_QUERY );
if( xExporter.is() )
{
xExporter->setSourceDocument( xComponent );
uno::Sequence< beans::PropertyValue > aDescriptor( 0 );
bDocRet = xFilter->filter( aDescriptor );
}
}
}
}
}
catch(uno::Exception e)
{
#ifdef DEBUG
ByteString aError( "uno Exception caught while exporting:\n" );
aError += ByteString( String( e.Message), RTL_TEXTENCODING_ASCII_US );
DBG_ERROR( aError.GetBuffer() );
#endif
bDocRet = sal_False;
}
if( pGraphicHelper )
SvXMLGraphicHelper::Destroy( pGraphicHelper );
xGraphicResolver = 0;
if( pObjectHelper )
SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
xObjectResolver = 0;
return bDocRet;
}
//-////////////////////////////////////////////////////////////////////
sal_Bool SvxDrawingLayerImport( SdrModel* pModel, uno::Reference<io::XInputStream> xInputStream )
{
sal_uInt32 nRet = 0;
Reference< document::XGraphicObjectResolver > xGraphicResolver;
SvXMLGraphicHelper *pGraphicHelper = 0;
Reference< document::XEmbeddedObjectResolver > xObjectResolver;
SvXMLEmbeddedObjectHelper *pObjectHelper = 0;
Reference< frame::XModel > xModel( new SvxUnoDrawingModel( pModel ) );
try
{
Reference< lang::XComponent > xComponent( xModel, uno::UNO_QUERY );
pModel->setUnoModel( Reference< XInterface >::query( xComponent ) );
// Get service factory
Reference< lang::XMultiServiceFactory > xServiceFactory = comphelper::getProcessServiceFactory();
DBG_ASSERT( xServiceFactory.is(), "XMLReader::Read: got no service manager" );
if( !xServiceFactory.is() )
nRet = 1;
if( 0 == nRet )
{
xModel->lockControllers();
// -------------------------------------
pGraphicHelper = SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_READ );
xGraphicResolver = pGraphicHelper;
SvPersist *pPersist = pModel->GetPersist();
if( pPersist )
{
pObjectHelper = SvXMLEmbeddedObjectHelper::Create(
*pPersist,
EMBEDDEDOBJECTHELPER_MODE_READ );
xObjectResolver = pObjectHelper;
}
}
// -------------------------------------
if( 0 == nRet )
{
// parse
// prepare ParserInputSrouce
xml::sax::InputSource aParserInput;
aParserInput.aInputStream = xInputStream;
// get parser
Reference< xml::sax::XParser > xParser( xServiceFactory->createInstance( OUString::createFromAscii("com.sun.star.xml.sax.Parser") ), UNO_QUERY );
DBG_ASSERT( xParser.is(), "Can't create parser" );
// prepare filter arguments
Sequence<Any> aFilterArgs( 2 );
Any *pArgs = aFilterArgs.getArray();
*pArgs++ <<= xGraphicResolver;
*pArgs++ <<= xObjectResolver;
// get filter
Reference< xml::sax::XDocumentHandler > xFilter( xServiceFactory->createInstanceWithArguments( OUString::createFromAscii("com.sun.star.comp.Draw.XMLImporter"), aFilterArgs), UNO_QUERY );
DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." );
if( !xParser.is() || !xFilter.is() )
{
nRet = 1;
}
else
{
// connect parser and filter
xParser->setDocumentHandler( xFilter );
// connect model and filter
uno::Reference < document::XImporter > xImporter( xFilter, UNO_QUERY );
xImporter->setTargetDocument( xComponent );
// finally, parser the stream
xParser->parseStream( aParserInput );
}
}
}
catch( xml::sax::SAXParseException& r )
{
#ifdef DEBUG
ByteString aError( "SAX parse exception catched while importing:\n" );
aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
DBG_ERROR( aError.GetBuffer() );
#endif
}
catch( xml::sax::SAXException& r )
{
#ifdef DEBUG
ByteString aError( "SAX exception catched while importing:\n" );
aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
DBG_ERROR( aError.GetBuffer() );
#endif
}
catch( io::IOException& r )
{
#ifdef DEBUG
ByteString aError( "IO exception catched while importing:\n" );
aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
DBG_ERROR( aError.GetBuffer() );
#endif
}
catch( uno::Exception& r )
{
#ifdef DEBUG
ByteString aError( "uno exception catched while importing:\n" );
aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
DBG_ERROR( aError.GetBuffer() );
#endif
}
if( pGraphicHelper )
SvXMLGraphicHelper::Destroy( pGraphicHelper );
xGraphicResolver = 0;
if( pObjectHelper )
SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
xObjectResolver = 0;
if( xModel.is() )
xModel->unlockControllers();
return nRet == 0;
}
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