1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sd.hxx" 30*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "unolayer.hxx" 33*cdf0e10cSrcweir #include <osl/mutex.hxx> 34*cdf0e10cSrcweir #include <vos/mutex.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <svx/svdpagv.hxx> 37*cdf0e10cSrcweir #include <svx/unoshape.hxx> 38*cdf0e10cSrcweir #include <svx/svdobj.hxx> 39*cdf0e10cSrcweir #include <comphelper/serviceinfohelper.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir // folgende fuer InsertSdPage() 42*cdf0e10cSrcweir #include <svx/svdlayer.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #ifndef SVX_LIGHT 45*cdf0e10cSrcweir #ifndef SD_DRAW_DOC_SHELL_HXX 46*cdf0e10cSrcweir #include "DrawDocShell.hxx" 47*cdf0e10cSrcweir #endif 48*cdf0e10cSrcweir #endif 49*cdf0e10cSrcweir #include <drawdoc.hxx> 50*cdf0e10cSrcweir #include <unomodel.hxx> 51*cdf0e10cSrcweir #include "unoprnms.hxx" 52*cdf0e10cSrcweir #include <com/sun/star/lang/NoSupportException.hpp> 53*cdf0e10cSrcweir #include <svx/svdpool.hxx> 54*cdf0e10cSrcweir #include "unohelp.hxx" 55*cdf0e10cSrcweir #include "FrameView.hxx" 56*cdf0e10cSrcweir #include "DrawViewShell.hxx" 57*cdf0e10cSrcweir #include "View.hxx" 58*cdf0e10cSrcweir #include "ViewShell.hxx" 59*cdf0e10cSrcweir #include "app.hrc" 60*cdf0e10cSrcweir #include "strings.hrc" 61*cdf0e10cSrcweir #include "sdresid.hxx" 62*cdf0e10cSrcweir #include "glob.hrc" 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #include "unokywds.hxx" 65*cdf0e10cSrcweir #include "unowcntr.hxx" 66*cdf0e10cSrcweir #include <vcl/svapp.hxx> 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir using namespace ::rtl; 69*cdf0e10cSrcweir using namespace ::vos; 70*cdf0e10cSrcweir using namespace ::com::sun::star; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir //============================================================================= 73*cdf0e10cSrcweir // class SdLayer 74*cdf0e10cSrcweir //============================================================================= 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir #define WID_LAYER_LOCKED 1 77*cdf0e10cSrcweir #define WID_LAYER_PRINTABLE 2 78*cdf0e10cSrcweir #define WID_LAYER_VISIBLE 3 79*cdf0e10cSrcweir #define WID_LAYER_NAME 4 80*cdf0e10cSrcweir #define WID_LAYER_TITLE 5 81*cdf0e10cSrcweir #define WID_LAYER_DESC 6 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir const SvxItemPropertySet* ImplGetSdLayerPropertySet() 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir static const SfxItemPropertyMapEntry aSdLayerPropertyMap_Impl[] = 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir { MAP_CHAR_LEN(UNO_NAME_LAYER_LOCKED), WID_LAYER_LOCKED, &::getBooleanCppuType(), 0, 0 }, 88*cdf0e10cSrcweir { MAP_CHAR_LEN(UNO_NAME_LAYER_PRINTABLE), WID_LAYER_PRINTABLE,&::getBooleanCppuType(), 0, 0 }, 89*cdf0e10cSrcweir { MAP_CHAR_LEN(UNO_NAME_LAYER_VISIBLE), WID_LAYER_VISIBLE, &::getBooleanCppuType(), 0, 0 }, 90*cdf0e10cSrcweir { MAP_CHAR_LEN(UNO_NAME_LAYER_NAME), WID_LAYER_NAME, &::getCppuType((const OUString*)0), 0, 0 }, 91*cdf0e10cSrcweir { MAP_CHAR_LEN("Title"), WID_LAYER_TITLE, &::getCppuType((const OUString*)0), 0, 0 }, 92*cdf0e10cSrcweir { MAP_CHAR_LEN("Description"), WID_LAYER_DESC, &::getCppuType((const OUString*)0), 0, 0 }, 93*cdf0e10cSrcweir { 0,0,0,0,0,0} 94*cdf0e10cSrcweir }; 95*cdf0e10cSrcweir static SvxItemPropertySet aSDLayerPropertySet_Impl( aSdLayerPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); 96*cdf0e10cSrcweir return &aSDLayerPropertySet_Impl; 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir String SdLayer::convertToInternalName( const OUString& rName ) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_background) ) ) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir return String( SdResId( STR_LAYER_BCKGRND ) ); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir else if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_background_objects) ) ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir return String( SdResId( STR_LAYER_BCKGRNDOBJ ) ); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir else if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_layout) ) ) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir return String( SdResId( STR_LAYER_LAYOUT ) ); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir else if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_controls) ) ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir return String( SdResId( STR_LAYER_CONTROLS ) ); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir else if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_measurelines) ) ) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir return String( SdResId( STR_LAYER_MEASURELINES ) ); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir else 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir return String( rName ); 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir OUString SdLayer::convertToExternalName( const String& rName ) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir const String aCompare( rName ); 130*cdf0e10cSrcweir if( rName == String( SdResId( STR_LAYER_BCKGRND ) ) ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_background) ); 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir else if( rName == String( SdResId( STR_LAYER_BCKGRNDOBJ ) ) ) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_background_objects) ); 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir else if( rName == String( SdResId( STR_LAYER_LAYOUT ) ) ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_layout) ); 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir else if( rName == String( SdResId( STR_LAYER_CONTROLS ) ) ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_controls) ); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir else if( rName == String( SdResId( STR_LAYER_MEASURELINES ) ) ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_measurelines) ); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir else 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir return OUString( rName ); 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir /** */ 157*cdf0e10cSrcweir SdLayer::SdLayer( SdLayerManager* pLayerManager_, SdrLayer* pSdrLayer_ ) throw() 158*cdf0e10cSrcweir : pLayerManager(pLayerManager_) 159*cdf0e10cSrcweir , mxLayerManager(pLayerManager_) 160*cdf0e10cSrcweir , pLayer(pSdrLayer_) 161*cdf0e10cSrcweir , pPropSet(ImplGetSdLayerPropertySet()) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir /** */ 166*cdf0e10cSrcweir SdLayer::~SdLayer() throw() 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir // uno helper 171*cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_IMPL( SdLayer ); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir // XServiceInfo 174*cdf0e10cSrcweir OUString SAL_CALL SdLayer::getImplementationName() 175*cdf0e10cSrcweir throw(uno::RuntimeException) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir return OUString( OUString::createFromAscii(sUNO_SdLayer) ); 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir sal_Bool SAL_CALL SdLayer::supportsService( const OUString& ServiceName ) 181*cdf0e10cSrcweir throw(uno::RuntimeException) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SdLayer::getSupportedServiceNames() 187*cdf0e10cSrcweir throw(uno::RuntimeException) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir OUString aServiceName( OUString::createFromAscii(sUNO_Service_DrawingLayer) ); 190*cdf0e10cSrcweir uno::Sequence< OUString > aSeq( &aServiceName, 1 ); 191*cdf0e10cSrcweir return aSeq; 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir // beans::XPropertySet 195*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL SdLayer::getPropertySetInfo( ) 196*cdf0e10cSrcweir throw(uno::RuntimeException) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 199*cdf0e10cSrcweir return pPropSet->getPropertySetInfo(); 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir void SAL_CALL SdLayer::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) 203*cdf0e10cSrcweir throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir if(pLayer == NULL || pLayerManager == NULL) 208*cdf0e10cSrcweir throw lang::DisposedException(); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMapEntry(aPropertyName); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir switch( pEntry ? pEntry->nWID : -1 ) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir case WID_LAYER_LOCKED: 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir sal_Bool bValue = sal_False; 217*cdf0e10cSrcweir if(!sd::any2bool( aValue, bValue )) 218*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 219*cdf0e10cSrcweir set( LOCKED, bValue ); 220*cdf0e10cSrcweir break; 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir case WID_LAYER_PRINTABLE: 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir sal_Bool bValue = sal_False; 225*cdf0e10cSrcweir if(!sd::any2bool( aValue, bValue )) 226*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 227*cdf0e10cSrcweir set( PRINTABLE, bValue ); 228*cdf0e10cSrcweir break; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir case WID_LAYER_VISIBLE: 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir sal_Bool bValue = sal_False; 233*cdf0e10cSrcweir if(!sd::any2bool( aValue, bValue )) 234*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 235*cdf0e10cSrcweir set( VISIBLE, bValue ); 236*cdf0e10cSrcweir break; 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir case WID_LAYER_NAME: 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir OUString aName; 241*cdf0e10cSrcweir if(!(aValue >>= aName)) 242*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir pLayer->SetName(SdLayer::convertToInternalName( aName ) ); 245*cdf0e10cSrcweir pLayerManager->UpdateLayerView(); 246*cdf0e10cSrcweir break; 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir case WID_LAYER_TITLE: 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir OUString sTitle; 252*cdf0e10cSrcweir if(!(aValue >>= sTitle)) 253*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir pLayer->SetTitle(sTitle); 256*cdf0e10cSrcweir break; 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir case WID_LAYER_DESC: 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir OUString sDescription; 262*cdf0e10cSrcweir if(!(aValue >>= sDescription)) 263*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir pLayer->SetDescription(sDescription); 266*cdf0e10cSrcweir break; 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir default: 270*cdf0e10cSrcweir throw beans::UnknownPropertyException(); 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir #ifndef SVX_LIGHT 274*cdf0e10cSrcweir if( pLayerManager->GetDocShell() ) 275*cdf0e10cSrcweir pLayerManager->GetDocShell()->SetModified(); 276*cdf0e10cSrcweir #endif 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir uno::Any SAL_CALL SdLayer::getPropertyValue( const OUString& PropertyName ) 280*cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir if(pLayer == NULL || pLayerManager == NULL) 285*cdf0e10cSrcweir throw lang::DisposedException(); 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMapEntry(PropertyName); 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir uno::Any aValue; 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir switch( pEntry ? pEntry->nWID : -1 ) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir case WID_LAYER_LOCKED: 294*cdf0e10cSrcweir sd::bool2any( get( LOCKED ), aValue ); 295*cdf0e10cSrcweir break; 296*cdf0e10cSrcweir case WID_LAYER_PRINTABLE: 297*cdf0e10cSrcweir sd::bool2any( get( PRINTABLE ), aValue ); 298*cdf0e10cSrcweir break; 299*cdf0e10cSrcweir case WID_LAYER_VISIBLE: 300*cdf0e10cSrcweir sd::bool2any( get( VISIBLE ), aValue ); 301*cdf0e10cSrcweir break; 302*cdf0e10cSrcweir case WID_LAYER_NAME: 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir OUString aRet( SdLayer::convertToExternalName( pLayer->GetName() ) ); 305*cdf0e10cSrcweir aValue <<= aRet; 306*cdf0e10cSrcweir break; 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir case WID_LAYER_TITLE: 309*cdf0e10cSrcweir aValue <<= OUString( pLayer->GetTitle() ); 310*cdf0e10cSrcweir break; 311*cdf0e10cSrcweir case WID_LAYER_DESC: 312*cdf0e10cSrcweir aValue <<= OUString( pLayer->GetDescription() ); 313*cdf0e10cSrcweir break; 314*cdf0e10cSrcweir default: 315*cdf0e10cSrcweir throw beans::UnknownPropertyException(); 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir return aValue; 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir void SAL_CALL SdLayer::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 322*cdf0e10cSrcweir void SAL_CALL SdLayer::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 323*cdf0e10cSrcweir void SAL_CALL SdLayer::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 324*cdf0e10cSrcweir void SAL_CALL SdLayer::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir /** */ 327*cdf0e10cSrcweir sal_Bool SdLayer::get( LayerAttribute what ) throw() 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir if(pLayer&&pLayerManager) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir // Versuch 1. ist eine beliebige Seite geoeffnet? 332*cdf0e10cSrcweir ::sd::View *pView = pLayerManager->GetView(); 333*cdf0e10cSrcweir SdrPageView* pSdrPageView = NULL; 334*cdf0e10cSrcweir if(pView) 335*cdf0e10cSrcweir pSdrPageView = pView->GetSdrPageView(); 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir if(pSdrPageView) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir String aLayerName = pLayer->GetName(); 340*cdf0e10cSrcweir switch(what) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir case VISIBLE: return pSdrPageView->IsLayerVisible(aLayerName); 343*cdf0e10cSrcweir case PRINTABLE: return pSdrPageView->IsLayerPrintable(aLayerName); 344*cdf0e10cSrcweir case LOCKED: return pSdrPageView->IsLayerLocked(aLayerName); 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir #ifndef SVX_LIGHT 349*cdf0e10cSrcweir // Versuch 2. Info von der FrameView besorgen 350*cdf0e10cSrcweir if(pLayerManager->GetDocShell()) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir ::sd::FrameView *pFrameView = pLayerManager->GetDocShell()->GetFrameView(); 353*cdf0e10cSrcweir if(pFrameView) 354*cdf0e10cSrcweir switch(what) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir case VISIBLE: return pFrameView->GetVisibleLayers().IsSet(pLayer->GetID()); 357*cdf0e10cSrcweir case PRINTABLE: return pFrameView->GetPrintableLayers().IsSet(pLayer->GetID()); 358*cdf0e10cSrcweir case LOCKED: return pFrameView->GetLockedLayers().IsSet(pLayer->GetID()); 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir #endif 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir return sal_False; //TODO: uno::Exception? 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir void SdLayer::set( LayerAttribute what, sal_Bool flag ) throw() 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir if(pLayer&&pLayerManager) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir // Versuch 1. ist eine beliebige Seite geoeffnet? 371*cdf0e10cSrcweir ::sd::View *pView = pLayerManager->GetView(); 372*cdf0e10cSrcweir SdrPageView* pSdrPageView = NULL; 373*cdf0e10cSrcweir if(pView) 374*cdf0e10cSrcweir pSdrPageView = pView->GetSdrPageView(); 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir if(pSdrPageView) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir String aLayerName(pLayer->GetName()); 379*cdf0e10cSrcweir switch(what) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir case VISIBLE: pSdrPageView->SetLayerVisible(aLayerName,flag); 382*cdf0e10cSrcweir break; 383*cdf0e10cSrcweir case PRINTABLE: pSdrPageView->SetLayerPrintable(aLayerName,flag); 384*cdf0e10cSrcweir break; 385*cdf0e10cSrcweir case LOCKED: pSdrPageView->SetLayerLocked(aLayerName,flag); 386*cdf0e10cSrcweir break; 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir #ifndef SVX_LIGHT 391*cdf0e10cSrcweir // Versuch 2. Info von der FrameView besorgen 392*cdf0e10cSrcweir if(pLayerManager->GetDocShell()) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir ::sd::FrameView *pFrameView = pLayerManager->GetDocShell()->GetFrameView(); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir if(pFrameView) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir SetOfByte aNewLayers; 399*cdf0e10cSrcweir switch(what) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir case VISIBLE: aNewLayers = pFrameView->GetVisibleLayers(); 402*cdf0e10cSrcweir break; 403*cdf0e10cSrcweir case PRINTABLE: aNewLayers = pFrameView->GetPrintableLayers(); 404*cdf0e10cSrcweir break; 405*cdf0e10cSrcweir case LOCKED: aNewLayers = pFrameView->GetLockedLayers(); 406*cdf0e10cSrcweir break; 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir aNewLayers.Set(pLayer->GetID(),flag); 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir switch(what) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir case VISIBLE: pFrameView->SetVisibleLayers(aNewLayers); 414*cdf0e10cSrcweir break; 415*cdf0e10cSrcweir case PRINTABLE: pFrameView->SetPrintableLayers(aNewLayers); 416*cdf0e10cSrcweir break; 417*cdf0e10cSrcweir case LOCKED: pFrameView->SetLockedLayers(aNewLayers); 418*cdf0e10cSrcweir break; 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir return; 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir #endif 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir //TODO: uno::Exception? 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir //===== ::com::sun::star::container::XChild ================================= 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir uno::Reference<uno::XInterface> SAL_CALL SdLayer::getParent (void) 434*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir if( pLayerManager == NULL ) 439*cdf0e10cSrcweir throw lang::DisposedException(); 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir return uno::Reference<uno::XInterface> (mxLayerManager, uno::UNO_QUERY); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir void SAL_CALL SdLayer::setParent (const uno::Reference<uno::XInterface >& ) 446*cdf0e10cSrcweir throw (::com::sun::star::lang::NoSupportException, 447*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir throw lang::NoSupportException (); 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir // XComponent 453*cdf0e10cSrcweir void SAL_CALL SdLayer::dispose( ) throw (uno::RuntimeException) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir pLayerManager = 0; 456*cdf0e10cSrcweir mxLayerManager = 0; 457*cdf0e10cSrcweir pLayer = 0; 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir void SAL_CALL SdLayer::addEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir DBG_ERROR("not implemented!"); 463*cdf0e10cSrcweir } 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir void SAL_CALL SdLayer::removeEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException) 466*cdf0e10cSrcweir { 467*cdf0e10cSrcweir DBG_ERROR("not implemented!"); 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir //============================================================================= 472*cdf0e10cSrcweir // class SdLayerManager 473*cdf0e10cSrcweir //============================================================================= 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir /** */ 476*cdf0e10cSrcweir SdLayerManager::SdLayerManager( SdXImpressDocument& rMyModel ) throw() 477*cdf0e10cSrcweir :mpModel( &rMyModel) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir mpLayers = new SvUnoWeakContainer; 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir /** */ 483*cdf0e10cSrcweir SdLayerManager::~SdLayerManager() throw() 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir dispose(); 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir // uno helper 489*cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_IMPL( SdLayerManager ); 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir // XComponent 492*cdf0e10cSrcweir void SAL_CALL SdLayerManager::dispose( ) throw (uno::RuntimeException) 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir mpModel = 0; 495*cdf0e10cSrcweir if( mpLayers ) 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir mpLayers->dispose(); 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir delete mpLayers; 500*cdf0e10cSrcweir mpLayers = 0; 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir void SAL_CALL SdLayerManager::addEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir DBG_ERROR("not implemented!"); 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir void SAL_CALL SdLayerManager::removeEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException) 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir DBG_ERROR("not implemented!"); 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir // XServiceInfo 515*cdf0e10cSrcweir OUString SAL_CALL SdLayerManager::getImplementationName() 516*cdf0e10cSrcweir throw(uno::RuntimeException) 517*cdf0e10cSrcweir { 518*cdf0e10cSrcweir return OUString( OUString::createFromAscii(sUNO_SdLayerManager) ); 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir sal_Bool SAL_CALL SdLayerManager::supportsService( const OUString& ServiceName ) 522*cdf0e10cSrcweir throw(uno::RuntimeException) 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SdLayerManager::getSupportedServiceNames() 528*cdf0e10cSrcweir throw(uno::RuntimeException) 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir OUString aServiceName( OUString::createFromAscii(sUNO_Service_DrawingLayerManager) ); 531*cdf0e10cSrcweir uno::Sequence< OUString > aSeq( &aServiceName, 1 ); 532*cdf0e10cSrcweir return aSeq; 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir // XLayerManager 536*cdf0e10cSrcweir uno::Reference< drawing::XLayer > SAL_CALL SdLayerManager::insertNewByIndex( sal_Int32 nIndex ) 537*cdf0e10cSrcweir throw(uno::RuntimeException) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir if( mpModel == 0 ) 542*cdf0e10cSrcweir throw lang::DisposedException(); 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir uno::Reference< drawing::XLayer > xLayer; 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir if( mpModel->mpDoc ) 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = mpModel->mpDoc->GetLayerAdmin(); 549*cdf0e10cSrcweir sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount(); 550*cdf0e10cSrcweir sal_uInt16 nLayer = nLayerCnt - 2 + 1; 551*cdf0e10cSrcweir String aLayerName; 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir // Ueberpruefung auf schon vorhandene Namen 554*cdf0e10cSrcweir while( aLayerName.Len()==0 || rLayerAdmin.GetLayer( aLayerName, sal_False) ) 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir aLayerName = String(SdResId(STR_LAYER)); 557*cdf0e10cSrcweir aLayerName += String::CreateFromInt32( (sal_Int32)nLayer ); 558*cdf0e10cSrcweir nLayer++; 559*cdf0e10cSrcweir } 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir SdrLayerAdmin& rLA=mpModel->mpDoc->GetLayerAdmin(); 562*cdf0e10cSrcweir const sal_Int32 nMax=rLA.GetLayerCount(); 563*cdf0e10cSrcweir if (nIndex>nMax) nIndex=nMax; 564*cdf0e10cSrcweir xLayer = GetLayer (rLA.NewLayer(aLayerName,(sal_uInt16)nIndex)); 565*cdf0e10cSrcweir mpModel->SetModified(); 566*cdf0e10cSrcweir } 567*cdf0e10cSrcweir return xLayer; 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir void SAL_CALL SdLayerManager::remove( const uno::Reference< drawing::XLayer >& xLayer ) 571*cdf0e10cSrcweir throw(container::NoSuchElementException, uno::RuntimeException) 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir if( mpModel == 0 ) 576*cdf0e10cSrcweir throw lang::DisposedException(); 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir SdLayer* pSdLayer = SdLayer::getImplementation(xLayer); 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir if(pSdLayer && GetView()) 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir const SdrLayer* pSdrLayer = pSdLayer->GetSdrLayer(); 583*cdf0e10cSrcweir GetView()->DeleteLayer( pSdrLayer->GetName() ); 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir UpdateLayerView(); 586*cdf0e10cSrcweir } 587*cdf0e10cSrcweir 588*cdf0e10cSrcweir mpModel->SetModified(); 589*cdf0e10cSrcweir } 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir void SAL_CALL SdLayerManager::attachShapeToLayer( const uno::Reference< drawing::XShape >& xShape, const uno::Reference< drawing::XLayer >& xLayer ) 592*cdf0e10cSrcweir throw(uno::RuntimeException) 593*cdf0e10cSrcweir { 594*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir if( mpModel == 0 ) 597*cdf0e10cSrcweir throw lang::DisposedException(); 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir SdLayer* pSdLayer = SdLayer::getImplementation(xLayer); 600*cdf0e10cSrcweir SdrLayer* pSdrLayer = pSdLayer?pSdLayer->GetSdrLayer():NULL; 601*cdf0e10cSrcweir if(pSdrLayer==NULL) 602*cdf0e10cSrcweir return; 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir SvxShape* pShape = SvxShape::getImplementation( xShape ); 605*cdf0e10cSrcweir SdrObject* pSdrObject = pShape?pShape->GetSdrObject():NULL; 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir if(pSdrObject && pSdrLayer ) 608*cdf0e10cSrcweir pSdrObject->SetLayer(pSdrLayer->GetID()); 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir mpModel->SetModified(); 611*cdf0e10cSrcweir } 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir uno::Reference< drawing::XLayer > SAL_CALL SdLayerManager::getLayerForShape( const uno::Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException) 614*cdf0e10cSrcweir { 615*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir if( mpModel == 0 ) 618*cdf0e10cSrcweir throw lang::DisposedException(); 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir uno::Reference< drawing::XLayer > xLayer; 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir if(mpModel->mpDoc) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir SvxShape* pShape = SvxShape::getImplementation( xShape ); 625*cdf0e10cSrcweir SdrObject* pObj = pShape?pShape->GetSdrObject():NULL; 626*cdf0e10cSrcweir if(pObj) 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir SdrLayerID aId = pObj->GetLayer(); 629*cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = mpModel->mpDoc->GetLayerAdmin(); 630*cdf0e10cSrcweir xLayer = GetLayer (rLayerAdmin.GetLayerPerID(aId)); 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir return xLayer; 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir // XIndexAccess 637*cdf0e10cSrcweir sal_Int32 SAL_CALL SdLayerManager::getCount() 638*cdf0e10cSrcweir throw(uno::RuntimeException) 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir if( mpModel == 0 ) 643*cdf0e10cSrcweir throw lang::DisposedException(); 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir if( mpModel->mpDoc ) 646*cdf0e10cSrcweir { 647*cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = mpModel->mpDoc->GetLayerAdmin(); 648*cdf0e10cSrcweir return rLayerAdmin.GetLayerCount(); 649*cdf0e10cSrcweir } 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir return 0; 652*cdf0e10cSrcweir } 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir uno::Any SAL_CALL SdLayerManager::getByIndex( sal_Int32 nLayer ) 655*cdf0e10cSrcweir throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) 656*cdf0e10cSrcweir { 657*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir if( mpModel == 0 ) 660*cdf0e10cSrcweir throw lang::DisposedException(); 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir if( nLayer >= getCount() || nLayer < 0 ) 663*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir uno::Any aAny; 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir if( mpModel->mpDoc ) 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = mpModel->mpDoc->GetLayerAdmin(); 670*cdf0e10cSrcweir uno::Reference<drawing::XLayer> xLayer (GetLayer (rLayerAdmin.GetLayer((sal_uInt16)nLayer))); 671*cdf0e10cSrcweir aAny <<= xLayer; 672*cdf0e10cSrcweir } 673*cdf0e10cSrcweir return aAny; 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir // XNameAccess 678*cdf0e10cSrcweir uno::Any SAL_CALL SdLayerManager::getByName( const OUString& aName ) 679*cdf0e10cSrcweir throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 680*cdf0e10cSrcweir { 681*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 682*cdf0e10cSrcweir 683*cdf0e10cSrcweir if( (mpModel == 0) || (mpModel->mpDoc == 0 ) ) 684*cdf0e10cSrcweir throw lang::DisposedException(); 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = mpModel->mpDoc->GetLayerAdmin(); 687*cdf0e10cSrcweir SdrLayer* pLayer = rLayerAdmin.GetLayer( SdLayer::convertToInternalName( aName ), sal_False ); 688*cdf0e10cSrcweir if( pLayer == NULL ) 689*cdf0e10cSrcweir throw container::NoSuchElementException(); 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir return uno::Any( GetLayer (pLayer) ); 692*cdf0e10cSrcweir } 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SdLayerManager::getElementNames() 695*cdf0e10cSrcweir throw(uno::RuntimeException) 696*cdf0e10cSrcweir { 697*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir if( mpModel == 0 ) 700*cdf0e10cSrcweir throw lang::DisposedException(); 701*cdf0e10cSrcweir 702*cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = mpModel->mpDoc->GetLayerAdmin(); 703*cdf0e10cSrcweir const sal_uInt16 nLayerCount = rLayerAdmin.GetLayerCount(); 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir uno::Sequence< OUString > aSeq( nLayerCount ); 706*cdf0e10cSrcweir 707*cdf0e10cSrcweir OUString* pStrings = aSeq.getArray(); 708*cdf0e10cSrcweir SdrLayer* pLayer; 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir for( sal_uInt16 nLayer = 0; nLayer < nLayerCount; nLayer++ ) 711*cdf0e10cSrcweir { 712*cdf0e10cSrcweir pLayer = rLayerAdmin.GetLayer( nLayer ); 713*cdf0e10cSrcweir if( pLayer ) 714*cdf0e10cSrcweir *pStrings++ = SdLayer::convertToExternalName( pLayer->GetName() ); 715*cdf0e10cSrcweir } 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir return aSeq; 718*cdf0e10cSrcweir } 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir sal_Bool SAL_CALL SdLayerManager::hasByName( const OUString& aName ) throw(uno::RuntimeException) 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 723*cdf0e10cSrcweir 724*cdf0e10cSrcweir if( mpModel == 0 ) 725*cdf0e10cSrcweir throw lang::DisposedException(); 726*cdf0e10cSrcweir 727*cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = mpModel->mpDoc->GetLayerAdmin(); 728*cdf0e10cSrcweir 729*cdf0e10cSrcweir return NULL != rLayerAdmin.GetLayer( SdLayer::convertToInternalName( aName ), sal_False ); 730*cdf0e10cSrcweir } 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir // XElementAccess 733*cdf0e10cSrcweir uno::Type SAL_CALL SdLayerManager::getElementType() 734*cdf0e10cSrcweir throw(uno::RuntimeException) 735*cdf0e10cSrcweir { 736*cdf0e10cSrcweir return ITYPE( drawing::XLayer ); 737*cdf0e10cSrcweir } 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir sal_Bool SAL_CALL SdLayerManager::hasElements() throw(uno::RuntimeException) 740*cdf0e10cSrcweir { 741*cdf0e10cSrcweir return getCount() > 0; 742*cdf0e10cSrcweir } 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir /** Falls an den Layern was geaendert wurde sorgt diese Methode dafuer, das 745*cdf0e10cSrcweir die Aenderungen auch in der sdbcx::View sichtbar gemacht werden */ 746*cdf0e10cSrcweir void SdLayerManager::UpdateLayerView( sal_Bool modify ) const throw() 747*cdf0e10cSrcweir { 748*cdf0e10cSrcweir if(mpModel->mpDocShell) 749*cdf0e10cSrcweir { 750*cdf0e10cSrcweir ::sd::DrawViewShell* pDrViewSh = 751*cdf0e10cSrcweir PTR_CAST(::sd::DrawViewShell, mpModel->mpDocShell->GetViewShell()); 752*cdf0e10cSrcweir 753*cdf0e10cSrcweir if(pDrViewSh) 754*cdf0e10cSrcweir { 755*cdf0e10cSrcweir sal_Bool bLayerMode = pDrViewSh->IsLayerModeActive(); 756*cdf0e10cSrcweir pDrViewSh->ChangeEditMode(pDrViewSh->GetEditMode(), !bLayerMode); 757*cdf0e10cSrcweir pDrViewSh->ChangeEditMode(pDrViewSh->GetEditMode(), bLayerMode); 758*cdf0e10cSrcweir } 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir if(modify) 761*cdf0e10cSrcweir mpModel->mpDoc->SetChanged(sal_True); 762*cdf0e10cSrcweir } 763*cdf0e10cSrcweir } 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir /** */ 766*cdf0e10cSrcweir ::sd::View* SdLayerManager::GetView() const throw() 767*cdf0e10cSrcweir { 768*cdf0e10cSrcweir if( mpModel->mpDocShell ) 769*cdf0e10cSrcweir { 770*cdf0e10cSrcweir ::sd::ViewShell* pViewSh = mpModel->mpDocShell->GetViewShell(); 771*cdf0e10cSrcweir if(pViewSh) 772*cdf0e10cSrcweir return pViewSh->GetView(); 773*cdf0e10cSrcweir } 774*cdf0e10cSrcweir return NULL; 775*cdf0e10cSrcweir } 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir namespace 780*cdf0e10cSrcweir { 781*cdf0e10cSrcweir /** Compare two pointers to <type>SdrLayer</type> objects. 782*cdf0e10cSrcweir @param xRef 783*cdf0e10cSrcweir The implementing SdLayer class provides the first pointer by the 784*cdf0e10cSrcweir <member>SdLayer::GetSdrLayer</member> method. 785*cdf0e10cSrcweir @param pSearchData 786*cdf0e10cSrcweir This void pointer is the second pointer to an <type>SdrLayer</type> 787*cdf0e10cSrcweir object. 788*cdf0e10cSrcweir @return 789*cdf0e10cSrcweir Return </True> if both pointers point to the same object. 790*cdf0e10cSrcweir */ 791*cdf0e10cSrcweir sal_Bool compare_layers (uno::WeakReference<uno::XInterface> xRef, void* pSearchData) 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir uno::Reference<uno::XInterface> xLayer (xRef); 794*cdf0e10cSrcweir if (xLayer.is()) 795*cdf0e10cSrcweir { 796*cdf0e10cSrcweir SdLayer* pSdLayer = SdLayer::getImplementation (xRef); 797*cdf0e10cSrcweir if (pSdLayer != NULL) 798*cdf0e10cSrcweir { 799*cdf0e10cSrcweir SdrLayer* pSdrLayer = pSdLayer->GetSdrLayer (); 800*cdf0e10cSrcweir if (pSdrLayer == static_cast<SdrLayer*>(pSearchData)) 801*cdf0e10cSrcweir return sal_True; 802*cdf0e10cSrcweir } 803*cdf0e10cSrcweir } 804*cdf0e10cSrcweir return sal_False; 805*cdf0e10cSrcweir } 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir /** Use the <member>mpLayers</member> container of weak references to either 809*cdf0e10cSrcweir retrieve and return a previously created <type>XLayer</type> object for 810*cdf0e10cSrcweir the given <type>SdrLayer</type> object or create and remember a new one. 811*cdf0e10cSrcweir */ 812*cdf0e10cSrcweir uno::Reference<drawing::XLayer> SdLayerManager::GetLayer (SdrLayer* pLayer) 813*cdf0e10cSrcweir { 814*cdf0e10cSrcweir uno::WeakReference<uno::XInterface> xRef; 815*cdf0e10cSrcweir uno::Reference<drawing::XLayer> xLayer; 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir // Search existing xLayer for the given pLayer. 818*cdf0e10cSrcweir if (mpLayers->findRef (xRef, (void*)pLayer, compare_layers)) 819*cdf0e10cSrcweir xLayer = uno::Reference<drawing::XLayer> (xRef, uno::UNO_QUERY); 820*cdf0e10cSrcweir 821*cdf0e10cSrcweir // Create the xLayer if necessary. 822*cdf0e10cSrcweir if ( ! xLayer.is()) 823*cdf0e10cSrcweir { 824*cdf0e10cSrcweir xLayer = new SdLayer (this, pLayer); 825*cdf0e10cSrcweir 826*cdf0e10cSrcweir // Remember the new xLayer for future calls. 827*cdf0e10cSrcweir uno::WeakReference<uno::XInterface> wRef(xLayer); 828*cdf0e10cSrcweir mpLayers->insert(wRef); 829*cdf0e10cSrcweir } 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir return xLayer; 832*cdf0e10cSrcweir } 833