2000-09-18 11:07:07 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 00:50:45 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2005-09-09 00:50:45 -05:00
|
|
|
* $RCSfile: unolayer.cxx,v $
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2005-09-09 00:50:45 -05:00
|
|
|
* $Revision: 1.9 $
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2005-09-09 00:50:45 -05:00
|
|
|
* last change: $Author: rt $ $Date: 2005-09-09 06:50:45 $
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2005-09-09 00:50:45 -05:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 00:50:45 -05:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2005-09-09 00:50:45 -05:00
|
|
|
* 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.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2005-09-09 00:50:45 -05:00
|
|
|
* 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.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2005-09-09 00:50:45 -05:00
|
|
|
* 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
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/lang/DisposedException.hpp>
|
|
|
|
#endif
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2004-01-20 05:34:10 -06:00
|
|
|
#include "unolayer.hxx"
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
#ifndef _OSL_MUTEX_HXX_
|
|
|
|
#include <osl/mutex.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _VOS_MUTEX_HXX_ //autogen
|
|
|
|
#include <vos/mutex.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <svx/svdpagv.hxx>
|
|
|
|
#include <svx/unoshape.hxx>
|
|
|
|
#include <svx/svdobj.hxx>
|
|
|
|
|
|
|
|
// folgende fuer InsertSdPage()
|
|
|
|
#ifndef _SVDLAYER_HXX //autogen
|
|
|
|
#include <svx/svdlayer.hxx>
|
|
|
|
#endif
|
|
|
|
|
2001-03-19 02:53:25 -06:00
|
|
|
#ifndef SVX_LIGHT
|
2004-01-20 05:34:10 -06:00
|
|
|
#ifndef SD_DRAW_DOC_SHELL_HXX
|
|
|
|
#include "DrawDocShell.hxx"
|
2000-09-18 11:07:07 -05:00
|
|
|
#endif
|
2001-03-19 02:53:25 -06:00
|
|
|
#endif
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
#ifndef _DRAWDOC_HXX
|
|
|
|
#include <drawdoc.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _UNOMODEL_HXX
|
|
|
|
#include <unomodel.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _SD_UNOPRNMS_HXX
|
|
|
|
#include "unoprnms.hxx"
|
|
|
|
#endif
|
|
|
|
|
2002-08-02 06:09:48 -05:00
|
|
|
#ifndef _COM_SUN_STAR_LANG_NOSUPPORTEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/lang/NoSupportException.hpp>
|
|
|
|
#endif
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
#include "unohelp.hxx"
|
2004-01-20 05:34:10 -06:00
|
|
|
#ifndef SD_FRAME_VIEW_HXX
|
|
|
|
#include "FrameView.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef SD_DRAW_VIEW_SHELL_HXX
|
|
|
|
#include "DrawViewShell.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef SD_VIEW_HXX
|
|
|
|
#include "View.hxx"
|
|
|
|
#endif
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2004-01-20 05:34:10 -06:00
|
|
|
#ifndef SD_VIEW_SHELL_HXX
|
|
|
|
#include "ViewShell.hxx"
|
|
|
|
#endif
|
2000-09-18 11:07:07 -05:00
|
|
|
#include "app.hrc"
|
|
|
|
#include "strings.hrc"
|
|
|
|
#include "sdresid.hxx"
|
2001-01-19 09:19:32 -06:00
|
|
|
#include "glob.hrc"
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
#include "unokywds.hxx"
|
2002-08-02 06:09:48 -05:00
|
|
|
#include "unowcntr.hxx"
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
using namespace ::rtl;
|
|
|
|
using namespace ::vos;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// class SdLayer
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
#define WID_LAYER_LOCKED 1
|
|
|
|
#define WID_LAYER_PRINTABLE 2
|
|
|
|
#define WID_LAYER_VISIBLE 3
|
|
|
|
#define WID_LAYER_NAME 4
|
|
|
|
|
|
|
|
const SfxItemPropertyMap* ImplGetSdLayerPropertyMap()
|
|
|
|
{
|
|
|
|
static const SfxItemPropertyMap aSdLayerPropertyMap_Impl[] =
|
|
|
|
{
|
|
|
|
{ MAP_CHAR_LEN(UNO_NAME_LAYER_LOCKED), WID_LAYER_LOCKED, &::getBooleanCppuType(), 0, 0 },
|
|
|
|
{ MAP_CHAR_LEN(UNO_NAME_LAYER_PRINTABLE), WID_LAYER_PRINTABLE,&::getBooleanCppuType(), 0, 0 },
|
|
|
|
{ MAP_CHAR_LEN(UNO_NAME_LAYER_VISIBLE), WID_LAYER_VISIBLE, &::getBooleanCppuType(), 0, 0 },
|
|
|
|
{ MAP_CHAR_LEN(UNO_NAME_LAYER_NAME), WID_LAYER_NAME, &::getCppuType((const OUString*)0), 0, 0 },
|
|
|
|
{ 0,0,0,0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return aSdLayerPropertyMap_Impl;
|
|
|
|
}
|
|
|
|
|
2001-01-19 09:19:32 -06:00
|
|
|
String SdLayer::convertToInternalName( const OUString& rName )
|
|
|
|
{
|
|
|
|
if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_background) ) )
|
|
|
|
{
|
|
|
|
return String( SdResId( STR_LAYER_BCKGRND ) );
|
|
|
|
}
|
|
|
|
else if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_background_objects) ) )
|
|
|
|
{
|
|
|
|
return String( SdResId( STR_LAYER_BCKGRNDOBJ ) );
|
|
|
|
}
|
|
|
|
else if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_layout) ) )
|
|
|
|
{
|
|
|
|
return String( SdResId( STR_LAYER_LAYOUT ) );
|
|
|
|
}
|
|
|
|
else if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_controls) ) )
|
|
|
|
{
|
|
|
|
return String( SdResId( STR_LAYER_CONTROLS ) );
|
|
|
|
}
|
|
|
|
else if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_measurelines) ) )
|
|
|
|
{
|
|
|
|
return String( SdResId( STR_LAYER_MEASURELINES ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return String( rName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString SdLayer::convertToExternalName( const String& rName )
|
|
|
|
{
|
|
|
|
const String aCompare( rName );
|
|
|
|
if( rName == String( SdResId( STR_LAYER_BCKGRND ) ) )
|
|
|
|
{
|
|
|
|
return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_background) );
|
|
|
|
}
|
|
|
|
else if( rName == String( SdResId( STR_LAYER_BCKGRNDOBJ ) ) )
|
|
|
|
{
|
|
|
|
return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_background_objects) );
|
|
|
|
}
|
|
|
|
else if( rName == String( SdResId( STR_LAYER_LAYOUT ) ) )
|
|
|
|
{
|
|
|
|
return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_layout) );
|
|
|
|
}
|
|
|
|
else if( rName == String( SdResId( STR_LAYER_CONTROLS ) ) )
|
|
|
|
{
|
|
|
|
return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_controls) );
|
|
|
|
}
|
|
|
|
else if( rName == String( SdResId( STR_LAYER_MEASURELINES ) ) )
|
|
|
|
{
|
|
|
|
return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_measurelines) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return OUString( rName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
/** */
|
|
|
|
SdLayer::SdLayer( SdLayerManager* pLayerManager_, SdrLayer* pSdrLayer_ ) throw()
|
|
|
|
: aPropSet(ImplGetSdLayerPropertyMap()),
|
|
|
|
pLayerManager(pLayerManager_), pLayer(pSdrLayer_),
|
|
|
|
mxLayerManager(pLayerManager_)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** */
|
|
|
|
SdLayer::~SdLayer() throw()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// uno helper
|
|
|
|
UNO3_GETIMPLEMENTATION_IMPL( SdLayer );
|
|
|
|
|
|
|
|
// XServiceInfo
|
|
|
|
OUString SAL_CALL SdLayer::getImplementationName()
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return OUString( OUString::createFromAscii(sUNO_SdLayer) );
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL SdLayer::supportsService( const OUString& ServiceName )
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Sequence< OUString > SAL_CALL SdLayer::getSupportedServiceNames()
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OUString aServiceName( OUString::createFromAscii(sUNO_Service_DrawingLayer) );
|
|
|
|
uno::Sequence< OUString > aSeq( &aServiceName, 1 );
|
|
|
|
return aSeq;
|
|
|
|
}
|
|
|
|
|
|
|
|
// beans::XPropertySet
|
|
|
|
uno::Reference< beans::XPropertySetInfo > SAL_CALL SdLayer::getPropertySetInfo( )
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
return aPropSet.getPropertySetInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SdLayer::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
|
|
|
|
throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
|
|
|
if(pLayer == NULL || pLayerManager == NULL)
|
2004-03-30 07:36:07 -06:00
|
|
|
throw lang::DisposedException();
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
const SfxItemPropertyMap* pMap = aPropSet.getPropertyMapEntry(aPropertyName);
|
|
|
|
|
|
|
|
switch( pMap ? pMap->nWID : -1 )
|
|
|
|
{
|
|
|
|
case WID_LAYER_LOCKED:
|
|
|
|
{
|
|
|
|
sal_Bool bValue;
|
|
|
|
if(!sd::any2bool( aValue, bValue ))
|
|
|
|
throw lang::IllegalArgumentException();
|
|
|
|
set( LOCKED, bValue );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WID_LAYER_PRINTABLE:
|
|
|
|
{
|
|
|
|
sal_Bool bValue;
|
|
|
|
if(!sd::any2bool( aValue, bValue ))
|
|
|
|
throw lang::IllegalArgumentException();
|
|
|
|
set( PRINTABLE, bValue );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WID_LAYER_VISIBLE:
|
|
|
|
{
|
|
|
|
sal_Bool bValue;
|
|
|
|
if(!sd::any2bool( aValue, bValue ))
|
|
|
|
throw lang::IllegalArgumentException();
|
|
|
|
set( VISIBLE, bValue );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WID_LAYER_NAME:
|
|
|
|
{
|
|
|
|
OUString aName;
|
|
|
|
if(!(aValue >>= aName))
|
|
|
|
throw lang::IllegalArgumentException();
|
|
|
|
|
2001-01-19 09:19:32 -06:00
|
|
|
pLayer->SetName(SdLayer::convertToInternalName( aName ) );
|
2000-09-18 11:07:07 -05:00
|
|
|
pLayerManager->UpdateLayerView();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
throw beans::UnknownPropertyException();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-03-19 02:53:25 -06:00
|
|
|
#ifndef SVX_LIGHT
|
2000-09-18 11:07:07 -05:00
|
|
|
if( pLayerManager->GetDocShell() )
|
|
|
|
pLayerManager->GetDocShell()->SetModified();
|
2001-03-19 02:53:25 -06:00
|
|
|
#endif
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uno::Any SAL_CALL SdLayer::getPropertyValue( const OUString& PropertyName )
|
|
|
|
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
|
|
|
if(pLayer == NULL || pLayerManager == NULL)
|
2004-03-30 07:36:07 -06:00
|
|
|
throw lang::DisposedException();
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
const SfxItemPropertyMap* pMap = aPropSet.getPropertyMapEntry(PropertyName);
|
|
|
|
|
|
|
|
uno::Any aValue;
|
|
|
|
|
|
|
|
switch( pMap ? pMap->nWID : -1 )
|
|
|
|
{
|
|
|
|
case WID_LAYER_LOCKED:
|
|
|
|
sd::bool2any( get( LOCKED ), aValue );
|
|
|
|
break;
|
|
|
|
case WID_LAYER_PRINTABLE:
|
|
|
|
sd::bool2any( get( PRINTABLE ), aValue );
|
|
|
|
break;
|
|
|
|
case WID_LAYER_VISIBLE:
|
|
|
|
sd::bool2any( get( VISIBLE ), aValue );
|
|
|
|
break;
|
|
|
|
case WID_LAYER_NAME:
|
|
|
|
{
|
2001-01-19 09:19:32 -06:00
|
|
|
OUString aRet( SdLayer::convertToExternalName( pLayer->GetName() ) );
|
2000-09-18 11:07:07 -05:00
|
|
|
aValue <<= aRet;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
throw beans::UnknownPropertyException();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SdLayer::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
|
|
|
|
void SAL_CALL SdLayer::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
|
|
|
|
void SAL_CALL SdLayer::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
|
|
|
|
void SAL_CALL SdLayer::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
|
|
|
|
|
|
|
|
/** */
|
|
|
|
sal_Bool SdLayer::get( LayerAttribute what ) throw()
|
|
|
|
{
|
|
|
|
if(pLayer&&pLayerManager)
|
|
|
|
{
|
|
|
|
// Versuch 1. ist eine beliebige Seite geoeffnet?
|
2004-01-20 05:34:10 -06:00
|
|
|
::sd::View *pView = pLayerManager->GetView();
|
2000-09-18 11:07:07 -05:00
|
|
|
SdrPageView* pSdrPageView = NULL;
|
|
|
|
if(pView)
|
|
|
|
pSdrPageView = pView->GetPageViewPvNum(0);
|
|
|
|
|
|
|
|
if(pSdrPageView)
|
|
|
|
{
|
|
|
|
String aLayerName = pLayer->GetName();
|
|
|
|
switch(what)
|
|
|
|
{
|
|
|
|
case VISIBLE: return pSdrPageView->IsLayerVisible(aLayerName);
|
|
|
|
case PRINTABLE: return pSdrPageView->IsLayerPrintable(aLayerName);
|
|
|
|
case LOCKED: return pSdrPageView->IsLayerLocked(aLayerName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-19 02:53:25 -06:00
|
|
|
#ifndef SVX_LIGHT
|
2000-09-18 11:07:07 -05:00
|
|
|
// Versuch 2. Info von der FrameView besorgen
|
|
|
|
if(pLayerManager->GetDocShell())
|
|
|
|
{
|
2004-01-20 05:34:10 -06:00
|
|
|
::sd::FrameView *pFrameView = pLayerManager->GetDocShell()->GetFrameView();
|
2000-09-18 11:07:07 -05:00
|
|
|
if(pFrameView)
|
|
|
|
switch(what)
|
|
|
|
{
|
|
|
|
case VISIBLE: return pFrameView->GetVisibleLayers().IsSet(pLayer->GetID());
|
|
|
|
case PRINTABLE: return pFrameView->GetPrintableLayers().IsSet(pLayer->GetID());
|
|
|
|
case LOCKED: return pFrameView->GetLockedLayers().IsSet(pLayer->GetID());
|
|
|
|
}
|
|
|
|
}
|
2001-03-19 02:53:25 -06:00
|
|
|
#endif
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
return sal_False; //TODO: uno::Exception?
|
|
|
|
}
|
|
|
|
|
|
|
|
void SdLayer::set( LayerAttribute what, sal_Bool flag ) throw()
|
|
|
|
{
|
|
|
|
if(pLayer&&pLayerManager)
|
|
|
|
{
|
|
|
|
// Versuch 1. ist eine beliebige Seite geoeffnet?
|
2004-01-20 05:34:10 -06:00
|
|
|
::sd::View *pView = pLayerManager->GetView();
|
2000-09-18 11:07:07 -05:00
|
|
|
SdrPageView* pSdrPageView = NULL;
|
|
|
|
if(pView)
|
|
|
|
pSdrPageView = pView->GetPageViewPvNum(0);
|
|
|
|
|
|
|
|
if(pSdrPageView)
|
|
|
|
{
|
|
|
|
String aLayerName(pLayer->GetName());
|
|
|
|
switch(what)
|
|
|
|
{
|
|
|
|
case VISIBLE: pSdrPageView->SetLayerVisible(aLayerName,flag);
|
|
|
|
break;
|
|
|
|
case PRINTABLE: pSdrPageView->SetLayerPrintable(aLayerName,flag);
|
|
|
|
break;
|
|
|
|
case LOCKED: pSdrPageView->SetLayerLocked(aLayerName,flag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-19 02:53:25 -06:00
|
|
|
#ifndef SVX_LIGHT
|
2000-09-18 11:07:07 -05:00
|
|
|
// Versuch 2. Info von der FrameView besorgen
|
|
|
|
if(pLayerManager->GetDocShell())
|
|
|
|
{
|
2004-01-20 05:34:10 -06:00
|
|
|
::sd::FrameView *pFrameView = pLayerManager->GetDocShell()->GetFrameView();
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if(pFrameView)
|
|
|
|
{
|
|
|
|
SetOfByte aNewLayers;
|
|
|
|
switch(what)
|
|
|
|
{
|
|
|
|
case VISIBLE: aNewLayers = pFrameView->GetVisibleLayers();
|
|
|
|
break;
|
|
|
|
case PRINTABLE: aNewLayers = pFrameView->GetPrintableLayers();
|
|
|
|
break;
|
|
|
|
case LOCKED: aNewLayers = pFrameView->GetLockedLayers();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
aNewLayers.Set(pLayer->GetID(),flag);
|
|
|
|
|
|
|
|
switch(what)
|
|
|
|
{
|
|
|
|
case VISIBLE: pFrameView->SetVisibleLayers(aNewLayers);
|
|
|
|
break;
|
|
|
|
case PRINTABLE: pFrameView->SetPrintableLayers(aNewLayers);
|
|
|
|
break;
|
|
|
|
case LOCKED: pFrameView->SetLockedLayers(aNewLayers);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2001-03-19 02:53:25 -06:00
|
|
|
#endif
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
//TODO: uno::Exception?
|
|
|
|
}
|
|
|
|
|
2002-08-02 06:09:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===== ::com::sun::star::container::XChild =================================
|
|
|
|
|
|
|
|
uno::Reference<uno::XInterface> SAL_CALL SdLayer::getParent (void)
|
|
|
|
throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2004-03-30 07:36:07 -06:00
|
|
|
OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
|
|
|
if( pLayerManager == NULL )
|
|
|
|
throw lang::DisposedException();
|
|
|
|
|
2002-08-02 06:09:48 -05:00
|
|
|
return uno::Reference<uno::XInterface> (mxLayerManager, uno::UNO_QUERY);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SAL_CALL SdLayer::setParent (const uno::Reference<uno::XInterface >& rxParent)
|
|
|
|
throw (::com::sun::star::lang::NoSupportException,
|
|
|
|
::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
throw lang::NoSupportException ();
|
|
|
|
}
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
// XComponent
|
|
|
|
void SAL_CALL SdLayer::dispose( ) throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
pLayerManager = 0;
|
|
|
|
mxLayerManager = 0;
|
|
|
|
pLayer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SdLayer::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
DBG_ERROR("not implemented!");
|
|
|
|
}
|
2002-08-02 06:09:48 -05:00
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
void SAL_CALL SdLayer::removeEventListener( const uno::Reference< lang::XEventListener >& aListener ) throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
DBG_ERROR("not implemented!");
|
|
|
|
}
|
2002-08-02 06:09:48 -05:00
|
|
|
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
//=============================================================================
|
|
|
|
// class SdLayerManager
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
/** */
|
|
|
|
SdLayerManager::SdLayerManager( SdXImpressDocument& rMyModel ) throw()
|
2004-03-30 07:36:07 -06:00
|
|
|
:mpModel( &rMyModel)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2002-08-02 06:09:48 -05:00
|
|
|
mpLayers = new SvUnoWeakContainer;
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/** */
|
|
|
|
SdLayerManager::~SdLayerManager() throw()
|
|
|
|
{
|
2004-03-30 07:36:07 -06:00
|
|
|
dispose();
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// uno helper
|
|
|
|
UNO3_GETIMPLEMENTATION_IMPL( SdLayerManager );
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
// XComponent
|
|
|
|
void SAL_CALL SdLayerManager::dispose( ) throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
mpModel = 0;
|
|
|
|
if( mpLayers )
|
|
|
|
{
|
|
|
|
mpLayers->dispose();
|
|
|
|
|
|
|
|
delete mpLayers;
|
|
|
|
mpLayers = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SdLayerManager::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
DBG_ERROR("not implemented!");
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SdLayerManager::removeEventListener( const uno::Reference< lang::XEventListener >& aListener ) throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
DBG_ERROR("not implemented!");
|
|
|
|
}
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
// XServiceInfo
|
|
|
|
OUString SAL_CALL SdLayerManager::getImplementationName()
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return OUString( OUString::createFromAscii(sUNO_SdLayerManager) );
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL SdLayerManager::supportsService( const OUString& ServiceName )
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Sequence< OUString > SAL_CALL SdLayerManager::getSupportedServiceNames()
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OUString aServiceName( OUString::createFromAscii(sUNO_Service_DrawingLayerManager) );
|
|
|
|
uno::Sequence< OUString > aSeq( &aServiceName, 1 );
|
|
|
|
return aSeq;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XLayerManager
|
|
|
|
uno::Reference< drawing::XLayer > SAL_CALL SdLayerManager::insertNewByIndex( sal_Int32 nIndex )
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
if( mpModel == 0 )
|
|
|
|
throw lang::DisposedException();
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
uno::Reference< drawing::XLayer > xLayer;
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
if( mpModel->pDoc )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2004-03-30 07:36:07 -06:00
|
|
|
SdrLayerAdmin& rLayerAdmin = mpModel->pDoc->GetLayerAdmin();
|
2000-09-18 11:07:07 -05:00
|
|
|
sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount();
|
|
|
|
sal_uInt16 nLayer = nLayerCnt - 2 + 1;
|
|
|
|
String aLayerName;
|
|
|
|
|
|
|
|
// Ueberpruefung auf schon vorhandene Namen
|
|
|
|
while( aLayerName.Len()==0 || rLayerAdmin.GetLayer( aLayerName, sal_False) )
|
|
|
|
{
|
|
|
|
aLayerName = String(SdResId(STR_LAYER));
|
|
|
|
aLayerName += String::CreateFromInt32( (sal_Int32)nLayer );
|
|
|
|
nLayer++;
|
|
|
|
}
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
SdrLayerAdmin& rLA=mpModel->pDoc->GetLayerAdmin();
|
2001-01-19 09:19:32 -06:00
|
|
|
const sal_Int32 nMax=rLA.GetLayerCount();
|
|
|
|
if (nIndex>nMax) nIndex=nMax;
|
2002-08-02 06:09:48 -05:00
|
|
|
xLayer = GetLayer (rLA.NewLayer(aLayerName,(USHORT)nIndex));
|
2004-03-30 07:36:07 -06:00
|
|
|
mpModel->SetModified();
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
return xLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SdLayerManager::remove( const uno::Reference< drawing::XLayer >& xLayer )
|
|
|
|
throw(container::NoSuchElementException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
if( mpModel == 0 )
|
|
|
|
throw lang::DisposedException();
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
SdLayer* pSdLayer = SdLayer::getImplementation(xLayer);
|
|
|
|
|
|
|
|
if(pSdLayer && GetView())
|
|
|
|
{
|
|
|
|
const SdrLayer* pSdrLayer = pSdLayer->GetSdrLayer();
|
|
|
|
GetView()->DeleteLayer( pSdrLayer->GetName() );
|
|
|
|
|
|
|
|
UpdateLayerView();
|
|
|
|
}
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
mpModel->SetModified();
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SdLayerManager::attachShapeToLayer( const uno::Reference< drawing::XShape >& xShape, const uno::Reference< drawing::XLayer >& xLayer )
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
if( mpModel == 0 )
|
|
|
|
throw lang::DisposedException();
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
SdLayer* pSdLayer = SdLayer::getImplementation(xLayer);
|
|
|
|
SdrLayer* pSdrLayer = pSdLayer?pSdLayer->GetSdrLayer():NULL;
|
|
|
|
if(pSdrLayer==NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SvxShape* pShape = SvxShape::getImplementation( xShape );
|
|
|
|
SdrObject* pSdrObject = pShape?pShape->GetSdrObject():NULL;
|
|
|
|
|
|
|
|
if(pSdrObject && pSdrLayer )
|
|
|
|
pSdrObject->SetLayer(pSdrLayer->GetID());
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
mpModel->SetModified();
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uno::Reference< drawing::XLayer > SAL_CALL SdLayerManager::getLayerForShape( const uno::Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
if( mpModel == 0 )
|
|
|
|
throw lang::DisposedException();
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
uno::Reference< drawing::XLayer > xLayer;
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
if(mpModel->pDoc)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
|
|
|
SvxShape* pShape = SvxShape::getImplementation( xShape );
|
|
|
|
SdrObject* pObj = pShape?pShape->GetSdrObject():NULL;
|
|
|
|
if(pObj)
|
|
|
|
{
|
|
|
|
SdrLayerID aId = pObj->GetLayer();
|
2004-03-30 07:36:07 -06:00
|
|
|
SdrLayerAdmin& rLayerAdmin = mpModel->pDoc->GetLayerAdmin();
|
2002-08-02 06:09:48 -05:00
|
|
|
xLayer = GetLayer (rLayerAdmin.GetLayerPerID(aId));
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return xLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XIndexAccess
|
|
|
|
sal_Int32 SAL_CALL SdLayerManager::getCount()
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
if( mpModel == 0 )
|
|
|
|
throw lang::DisposedException();
|
|
|
|
|
|
|
|
if( mpModel->pDoc )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2004-03-30 07:36:07 -06:00
|
|
|
SdrLayerAdmin& rLayerAdmin = mpModel->pDoc->GetLayerAdmin();
|
2000-09-18 11:07:07 -05:00
|
|
|
return rLayerAdmin.GetLayerCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Any SAL_CALL SdLayerManager::getByIndex( sal_Int32 nLayer )
|
|
|
|
throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
if( mpModel == 0 )
|
|
|
|
throw lang::DisposedException();
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
if( nLayer >= getCount() || nLayer < 0 )
|
|
|
|
throw lang::IndexOutOfBoundsException();
|
|
|
|
|
|
|
|
uno::Any aAny;
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
if( mpModel->pDoc )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2004-03-30 07:36:07 -06:00
|
|
|
SdrLayerAdmin& rLayerAdmin = mpModel->pDoc->GetLayerAdmin();
|
2002-08-02 06:09:48 -05:00
|
|
|
uno::Reference<drawing::XLayer> xLayer (GetLayer (rLayerAdmin.GetLayer((sal_uInt16)nLayer)));
|
|
|
|
aAny <<= xLayer;
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
return aAny;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// XNameAccess
|
|
|
|
uno::Any SAL_CALL SdLayerManager::getByName( const OUString& aName )
|
|
|
|
throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
if( mpModel == 0 )
|
|
|
|
throw lang::DisposedException();
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
uno::Reference< drawing::XLayer > xLayer;
|
|
|
|
|
|
|
|
uno::Any aAny;
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
if( mpModel->pDoc )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2004-03-30 07:36:07 -06:00
|
|
|
SdrLayerAdmin& rLayerAdmin = mpModel->pDoc->GetLayerAdmin();
|
2001-01-19 09:19:32 -06:00
|
|
|
SdrLayer* pLayer = rLayerAdmin.GetLayer( SdLayer::convertToInternalName( aName ), FALSE );
|
2000-09-18 11:07:07 -05:00
|
|
|
if( pLayer == NULL )
|
|
|
|
throw container::NoSuchElementException();
|
|
|
|
|
2002-08-02 06:09:48 -05:00
|
|
|
xLayer = GetLayer (pLayer);
|
2000-09-18 11:07:07 -05:00
|
|
|
aAny <<= xLayer;
|
|
|
|
return aAny;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw container::NoSuchElementException();
|
|
|
|
return aAny;
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Sequence< OUString > SAL_CALL SdLayerManager::getElementNames()
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
if( mpModel == 0 )
|
|
|
|
throw lang::DisposedException();
|
|
|
|
|
|
|
|
SdrLayerAdmin& rLayerAdmin = mpModel->pDoc->GetLayerAdmin();
|
2000-09-18 11:07:07 -05:00
|
|
|
const sal_uInt16 nLayerCount = rLayerAdmin.GetLayerCount();
|
|
|
|
|
|
|
|
uno::Sequence< OUString > aSeq( nLayerCount );
|
|
|
|
|
|
|
|
OUString* pStrings = aSeq.getArray();
|
|
|
|
SdrLayer* pLayer;
|
|
|
|
|
|
|
|
for( sal_uInt16 nLayer = 0; nLayer < nLayerCount; nLayer++ )
|
|
|
|
{
|
|
|
|
pLayer = rLayerAdmin.GetLayer( nLayer );
|
|
|
|
if( pLayer )
|
2001-01-19 09:19:32 -06:00
|
|
|
*pStrings++ = SdLayer::convertToExternalName( pLayer->GetName() );
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return aSeq;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL SdLayerManager::hasByName( const OUString& aName ) throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
2004-03-30 07:36:07 -06:00
|
|
|
if( mpModel == 0 )
|
|
|
|
throw lang::DisposedException();
|
|
|
|
|
|
|
|
SdrLayerAdmin& rLayerAdmin = mpModel->pDoc->GetLayerAdmin();
|
2000-09-18 11:07:07 -05:00
|
|
|
|
2001-01-19 09:19:32 -06:00
|
|
|
return NULL != rLayerAdmin.GetLayer( SdLayer::convertToInternalName( aName ), FALSE );
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// XElementAccess
|
|
|
|
uno::Type SAL_CALL SdLayerManager::getElementType()
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return ITYPE( drawing::XLayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL SdLayerManager::hasElements() throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return getCount() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Falls an den Layern was geaendert wurde sorgt diese Methode dafuer, das
|
|
|
|
die Aenderungen auch in der sdbcx::View sichtbar gemacht werden */
|
|
|
|
void SdLayerManager::UpdateLayerView( sal_Bool modify ) const throw()
|
|
|
|
{
|
2004-03-30 07:36:07 -06:00
|
|
|
if(mpModel->pDocShell)
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2004-01-20 05:34:10 -06:00
|
|
|
::sd::DrawViewShell* pDrViewSh =
|
2004-03-30 07:36:07 -06:00
|
|
|
PTR_CAST(::sd::DrawViewShell, mpModel->pDocShell->GetViewShell());
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if(pDrViewSh)
|
|
|
|
{
|
2004-07-13 08:49:21 -05:00
|
|
|
sal_Bool bLayerMode = pDrViewSh->IsLayerModeActive();
|
2000-09-18 11:07:07 -05:00
|
|
|
pDrViewSh->ChangeEditMode(pDrViewSh->GetEditMode(), !bLayerMode);
|
|
|
|
pDrViewSh->ChangeEditMode(pDrViewSh->GetEditMode(), bLayerMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(modify)
|
2004-03-30 07:36:07 -06:00
|
|
|
mpModel->pDoc->SetChanged(sal_True);
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** */
|
2004-01-20 05:34:10 -06:00
|
|
|
::sd::View* SdLayerManager::GetView() const throw()
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2004-03-30 07:36:07 -06:00
|
|
|
if( mpModel->pDocShell )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2004-03-30 07:36:07 -06:00
|
|
|
::sd::ViewShell* pViewSh = mpModel->pDocShell->GetViewShell();
|
2000-09-18 11:07:07 -05:00
|
|
|
if(pViewSh)
|
|
|
|
return pViewSh->GetView();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-02 06:09:48 -05:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
/** Compare two pointers to <type>SdrLayer</type> objects.
|
|
|
|
@param xRef
|
|
|
|
The implementing SdLayer class provides the first pointer by the
|
|
|
|
<member>SdLayer::GetSdrLayer</member> method.
|
|
|
|
@param pSearchData
|
|
|
|
This void pointer is the second pointer to an <type>SdrLayer</type>
|
|
|
|
object.
|
|
|
|
@return
|
|
|
|
Return </True> if both pointers point to the same object.
|
|
|
|
*/
|
|
|
|
sal_Bool compare_layers (uno::WeakReference<uno::XInterface> xRef, void* pSearchData)
|
|
|
|
{
|
|
|
|
uno::Reference<uno::XInterface> xLayer (xRef);
|
|
|
|
if (xLayer.is())
|
|
|
|
{
|
|
|
|
SdLayer* pSdLayer = SdLayer::getImplementation (xRef);
|
|
|
|
if (pSdLayer != NULL)
|
|
|
|
{
|
|
|
|
SdrLayer* pSdrLayer = pSdLayer->GetSdrLayer ();
|
|
|
|
if (pSdrLayer == static_cast<SdrLayer*>(pSearchData))
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Use the <member>mpLayers</member> container of weak references to either
|
|
|
|
retrieve and return a previously created <type>XLayer</type> object for
|
|
|
|
the given <type>SdrLayer</type> object or create and remember a new one.
|
|
|
|
*/
|
|
|
|
uno::Reference<drawing::XLayer> SdLayerManager::GetLayer (SdrLayer* pLayer)
|
|
|
|
{
|
|
|
|
uno::WeakReference<uno::XInterface> xRef;
|
|
|
|
uno::Reference<drawing::XLayer> xLayer;
|
|
|
|
|
|
|
|
// Search existing xLayer for the given pLayer.
|
|
|
|
if (mpLayers->findRef (xRef, (void*)pLayer, compare_layers))
|
|
|
|
xLayer = uno::Reference<drawing::XLayer> (xRef, uno::UNO_QUERY);
|
|
|
|
|
|
|
|
// Create the xLayer if necessary.
|
|
|
|
if ( ! xLayer.is())
|
|
|
|
{
|
|
|
|
xLayer = new SdLayer (this, pLayer);
|
|
|
|
|
|
|
|
// Remember the new xLayer for future calls.
|
|
|
|
xRef = uno::Reference<uno::XInterface> (xLayer, uno::UNO_QUERY);
|
|
|
|
mpLayers->insert (xRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
return xLayer;
|
|
|
|
}
|