1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unolayer.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <com/sun/star/lang/DisposedException.hpp>
35 #include "unolayer.hxx"
36 #include <osl/mutex.hxx>
37 #include <vos/mutex.hxx>
39 #include <svx/svdpagv.hxx>
40 #include <svx/unoshape.hxx>
41 #include <svx/svdobj.hxx>
43 // folgende fuer InsertSdPage()
44 #include <svx/svdlayer.hxx>
47 #ifndef SD_DRAW_DOC_SHELL_HXX
48 #include "DrawDocShell.hxx"
51 #include <drawdoc.hxx>
52 #include <unomodel.hxx>
53 #include "unoprnms.hxx"
54 #include <com/sun/star/lang/NoSupportException.hpp>
56 #include "unohelp.hxx"
57 #include "FrameView.hxx"
58 #include "DrawViewShell.hxx"
60 #include "ViewShell.hxx"
62 #include "strings.hrc"
63 #include "sdresid.hxx"
66 #include "unokywds.hxx"
67 #include "unowcntr.hxx"
68 #include <vcl/svapp.hxx>
70 using namespace ::rtl
;
71 using namespace ::vos
;
72 using namespace ::com::sun::star
;
74 //=============================================================================
76 //=============================================================================
78 #define WID_LAYER_LOCKED 1
79 #define WID_LAYER_PRINTABLE 2
80 #define WID_LAYER_VISIBLE 3
81 #define WID_LAYER_NAME 4
82 #define WID_LAYER_TITLE 5
83 #define WID_LAYER_DESC 6
85 const SvxItemPropertySet
* ImplGetSdLayerPropertySet()
87 static const SfxItemPropertyMapEntry aSdLayerPropertyMap_Impl
[] =
89 { MAP_CHAR_LEN(UNO_NAME_LAYER_LOCKED
), WID_LAYER_LOCKED
, &::getBooleanCppuType(), 0, 0 },
90 { MAP_CHAR_LEN(UNO_NAME_LAYER_PRINTABLE
), WID_LAYER_PRINTABLE
,&::getBooleanCppuType(), 0, 0 },
91 { MAP_CHAR_LEN(UNO_NAME_LAYER_VISIBLE
), WID_LAYER_VISIBLE
, &::getBooleanCppuType(), 0, 0 },
92 { MAP_CHAR_LEN(UNO_NAME_LAYER_NAME
), WID_LAYER_NAME
, &::getCppuType((const OUString
*)0), 0, 0 },
93 { MAP_CHAR_LEN("Title"), WID_LAYER_TITLE
, &::getCppuType((const OUString
*)0), 0, 0 },
94 { MAP_CHAR_LEN("Description"), WID_LAYER_DESC
, &::getCppuType((const OUString
*)0), 0, 0 },
97 static SvxItemPropertySet
aSDLayerPropertySet_Impl( aSdLayerPropertyMap_Impl
);
98 return &aSDLayerPropertySet_Impl
;
101 String
SdLayer::convertToInternalName( const OUString
& rName
)
103 if( rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_background
) ) )
105 return String( SdResId( STR_LAYER_BCKGRND
) );
107 else if( rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_background_objects
) ) )
109 return String( SdResId( STR_LAYER_BCKGRNDOBJ
) );
111 else if( rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_layout
) ) )
113 return String( SdResId( STR_LAYER_LAYOUT
) );
115 else if( rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_controls
) ) )
117 return String( SdResId( STR_LAYER_CONTROLS
) );
119 else if( rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_LayerName_measurelines
) ) )
121 return String( SdResId( STR_LAYER_MEASURELINES
) );
125 return String( rName
);
129 OUString
SdLayer::convertToExternalName( const String
& rName
)
131 const String
aCompare( rName
);
132 if( rName
== String( SdResId( STR_LAYER_BCKGRND
) ) )
134 return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_background
) );
136 else if( rName
== String( SdResId( STR_LAYER_BCKGRNDOBJ
) ) )
138 return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_background_objects
) );
140 else if( rName
== String( SdResId( STR_LAYER_LAYOUT
) ) )
142 return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_layout
) );
144 else if( rName
== String( SdResId( STR_LAYER_CONTROLS
) ) )
146 return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_controls
) );
148 else if( rName
== String( SdResId( STR_LAYER_MEASURELINES
) ) )
150 return OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_LayerName_measurelines
) );
154 return OUString( rName
);
159 SdLayer::SdLayer( SdLayerManager
* pLayerManager_
, SdrLayer
* pSdrLayer_
) throw()
160 : pLayerManager(pLayerManager_
)
161 , mxLayerManager(pLayerManager_
)
163 , pPropSet(ImplGetSdLayerPropertySet())
168 SdLayer::~SdLayer() throw()
173 UNO3_GETIMPLEMENTATION_IMPL( SdLayer
);
176 OUString SAL_CALL
SdLayer::getImplementationName()
177 throw(uno::RuntimeException
)
179 return OUString( OUString::createFromAscii(sUNO_SdLayer
) );
182 sal_Bool SAL_CALL
SdLayer::supportsService( const OUString
& ServiceName
)
183 throw(uno::RuntimeException
)
185 return SvxServiceInfoHelper::supportsService( ServiceName
, getSupportedServiceNames() );
188 uno::Sequence
< OUString
> SAL_CALL
SdLayer::getSupportedServiceNames()
189 throw(uno::RuntimeException
)
191 OUString
aServiceName( OUString::createFromAscii(sUNO_Service_DrawingLayer
) );
192 uno::Sequence
< OUString
> aSeq( &aServiceName
, 1 );
196 // beans::XPropertySet
197 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
SdLayer::getPropertySetInfo( )
198 throw(uno::RuntimeException
)
200 OGuard
aGuard( Application::GetSolarMutex() );
201 return pPropSet
->getPropertySetInfo();
204 void SAL_CALL
SdLayer::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
)
205 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
207 OGuard
aGuard( Application::GetSolarMutex() );
209 if(pLayer
== NULL
|| pLayerManager
== NULL
)
210 throw lang::DisposedException();
212 const SfxItemPropertySimpleEntry
* pEntry
= pPropSet
->getPropertyMapEntry(aPropertyName
);
214 switch( pEntry
? pEntry
->nWID
: -1 )
216 case WID_LAYER_LOCKED
:
218 sal_Bool bValue
= sal_False
;
219 if(!sd::any2bool( aValue
, bValue
))
220 throw lang::IllegalArgumentException();
221 set( LOCKED
, bValue
);
224 case WID_LAYER_PRINTABLE
:
226 sal_Bool bValue
= sal_False
;
227 if(!sd::any2bool( aValue
, bValue
))
228 throw lang::IllegalArgumentException();
229 set( PRINTABLE
, bValue
);
232 case WID_LAYER_VISIBLE
:
234 sal_Bool bValue
= sal_False
;
235 if(!sd::any2bool( aValue
, bValue
))
236 throw lang::IllegalArgumentException();
237 set( VISIBLE
, bValue
);
243 if(!(aValue
>>= aName
))
244 throw lang::IllegalArgumentException();
246 pLayer
->SetName(SdLayer::convertToInternalName( aName
) );
247 pLayerManager
->UpdateLayerView();
251 case WID_LAYER_TITLE
:
254 if(!(aValue
>>= sTitle
))
255 throw lang::IllegalArgumentException();
257 pLayer
->SetTitle(sTitle
);
263 OUString sDescription
;
264 if(!(aValue
>>= sDescription
))
265 throw lang::IllegalArgumentException();
267 pLayer
->SetDescription(sDescription
);
272 throw beans::UnknownPropertyException();
276 if( pLayerManager
->GetDocShell() )
277 pLayerManager
->GetDocShell()->SetModified();
281 uno::Any SAL_CALL
SdLayer::getPropertyValue( const OUString
& PropertyName
)
282 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
284 OGuard
aGuard( Application::GetSolarMutex() );
286 if(pLayer
== NULL
|| pLayerManager
== NULL
)
287 throw lang::DisposedException();
289 const SfxItemPropertySimpleEntry
* pEntry
= pPropSet
->getPropertyMapEntry(PropertyName
);
293 switch( pEntry
? pEntry
->nWID
: -1 )
295 case WID_LAYER_LOCKED
:
296 sd::bool2any( get( LOCKED
), aValue
);
298 case WID_LAYER_PRINTABLE
:
299 sd::bool2any( get( PRINTABLE
), aValue
);
301 case WID_LAYER_VISIBLE
:
302 sd::bool2any( get( VISIBLE
), aValue
);
306 OUString
aRet( SdLayer::convertToExternalName( pLayer
->GetName() ) );
310 case WID_LAYER_TITLE
:
311 aValue
<<= OUString( pLayer
->GetTitle() );
314 aValue
<<= OUString( pLayer
->GetDescription() );
317 throw beans::UnknownPropertyException();
323 void SAL_CALL
SdLayer::addPropertyChangeListener( const OUString
& , const uno::Reference
< beans::XPropertyChangeListener
>& ) throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
) {}
324 void SAL_CALL
SdLayer::removePropertyChangeListener( const OUString
& , const uno::Reference
< beans::XPropertyChangeListener
>& ) throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
) {}
325 void SAL_CALL
SdLayer::addVetoableChangeListener( const OUString
& , const uno::Reference
< beans::XVetoableChangeListener
>& ) throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
) {}
326 void SAL_CALL
SdLayer::removeVetoableChangeListener( const OUString
& , const uno::Reference
< beans::XVetoableChangeListener
>& ) throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
) {}
329 sal_Bool
SdLayer::get( LayerAttribute what
) throw()
331 if(pLayer
&&pLayerManager
)
333 // Versuch 1. ist eine beliebige Seite geoeffnet?
334 ::sd::View
*pView
= pLayerManager
->GetView();
335 SdrPageView
* pSdrPageView
= NULL
;
337 pSdrPageView
= pView
->GetSdrPageView();
341 String aLayerName
= pLayer
->GetName();
344 case VISIBLE
: return pSdrPageView
->IsLayerVisible(aLayerName
);
345 case PRINTABLE
: return pSdrPageView
->IsLayerPrintable(aLayerName
);
346 case LOCKED
: return pSdrPageView
->IsLayerLocked(aLayerName
);
351 // Versuch 2. Info von der FrameView besorgen
352 if(pLayerManager
->GetDocShell())
354 ::sd::FrameView
*pFrameView
= pLayerManager
->GetDocShell()->GetFrameView();
358 case VISIBLE
: return pFrameView
->GetVisibleLayers().IsSet(pLayer
->GetID());
359 case PRINTABLE
: return pFrameView
->GetPrintableLayers().IsSet(pLayer
->GetID());
360 case LOCKED
: return pFrameView
->GetLockedLayers().IsSet(pLayer
->GetID());
365 return sal_False
; //TODO: uno::Exception?
368 void SdLayer::set( LayerAttribute what
, sal_Bool flag
) throw()
370 if(pLayer
&&pLayerManager
)
372 // Versuch 1. ist eine beliebige Seite geoeffnet?
373 ::sd::View
*pView
= pLayerManager
->GetView();
374 SdrPageView
* pSdrPageView
= NULL
;
376 pSdrPageView
= pView
->GetSdrPageView();
380 String
aLayerName(pLayer
->GetName());
383 case VISIBLE
: pSdrPageView
->SetLayerVisible(aLayerName
,flag
);
385 case PRINTABLE
: pSdrPageView
->SetLayerPrintable(aLayerName
,flag
);
387 case LOCKED
: pSdrPageView
->SetLayerLocked(aLayerName
,flag
);
393 // Versuch 2. Info von der FrameView besorgen
394 if(pLayerManager
->GetDocShell())
396 ::sd::FrameView
*pFrameView
= pLayerManager
->GetDocShell()->GetFrameView();
400 SetOfByte aNewLayers
;
403 case VISIBLE
: aNewLayers
= pFrameView
->GetVisibleLayers();
405 case PRINTABLE
: aNewLayers
= pFrameView
->GetPrintableLayers();
407 case LOCKED
: aNewLayers
= pFrameView
->GetLockedLayers();
411 aNewLayers
.Set(pLayer
->GetID(),flag
);
415 case VISIBLE
: pFrameView
->SetVisibleLayers(aNewLayers
);
417 case PRINTABLE
: pFrameView
->SetPrintableLayers(aNewLayers
);
419 case LOCKED
: pFrameView
->SetLockedLayers(aNewLayers
);
427 //TODO: uno::Exception?
433 //===== ::com::sun::star::container::XChild =================================
435 uno::Reference
<uno::XInterface
> SAL_CALL
SdLayer::getParent (void)
436 throw (::com::sun::star::uno::RuntimeException
)
438 OGuard
aGuard( Application::GetSolarMutex() );
440 if( pLayerManager
== NULL
)
441 throw lang::DisposedException();
443 return uno::Reference
<uno::XInterface
> (mxLayerManager
, uno::UNO_QUERY
);
447 void SAL_CALL
SdLayer::setParent (const uno::Reference
<uno::XInterface
>& )
448 throw (::com::sun::star::lang::NoSupportException
,
449 ::com::sun::star::uno::RuntimeException
)
451 throw lang::NoSupportException ();
455 void SAL_CALL
SdLayer::dispose( ) throw (uno::RuntimeException
)
462 void SAL_CALL
SdLayer::addEventListener( const uno::Reference
< lang::XEventListener
>& ) throw (uno::RuntimeException
)
464 DBG_ERROR("not implemented!");
467 void SAL_CALL
SdLayer::removeEventListener( const uno::Reference
< lang::XEventListener
>& ) throw (uno::RuntimeException
)
469 DBG_ERROR("not implemented!");
473 //=============================================================================
474 // class SdLayerManager
475 //=============================================================================
478 SdLayerManager::SdLayerManager( SdXImpressDocument
& rMyModel
) throw()
481 mpLayers
= new SvUnoWeakContainer
;
485 SdLayerManager::~SdLayerManager() throw()
491 UNO3_GETIMPLEMENTATION_IMPL( SdLayerManager
);
494 void SAL_CALL
SdLayerManager::dispose( ) throw (uno::RuntimeException
)
506 void SAL_CALL
SdLayerManager::addEventListener( const uno::Reference
< lang::XEventListener
>& ) throw (uno::RuntimeException
)
508 DBG_ERROR("not implemented!");
511 void SAL_CALL
SdLayerManager::removeEventListener( const uno::Reference
< lang::XEventListener
>& ) throw (uno::RuntimeException
)
513 DBG_ERROR("not implemented!");
517 OUString SAL_CALL
SdLayerManager::getImplementationName()
518 throw(uno::RuntimeException
)
520 return OUString( OUString::createFromAscii(sUNO_SdLayerManager
) );
523 sal_Bool SAL_CALL
SdLayerManager::supportsService( const OUString
& ServiceName
)
524 throw(uno::RuntimeException
)
526 return SvxServiceInfoHelper::supportsService( ServiceName
, getSupportedServiceNames() );
529 uno::Sequence
< OUString
> SAL_CALL
SdLayerManager::getSupportedServiceNames()
530 throw(uno::RuntimeException
)
532 OUString
aServiceName( OUString::createFromAscii(sUNO_Service_DrawingLayerManager
) );
533 uno::Sequence
< OUString
> aSeq( &aServiceName
, 1 );
538 uno::Reference
< drawing::XLayer
> SAL_CALL
SdLayerManager::insertNewByIndex( sal_Int32 nIndex
)
539 throw(uno::RuntimeException
)
541 OGuard
aGuard( Application::GetSolarMutex() );
544 throw lang::DisposedException();
546 uno::Reference
< drawing::XLayer
> xLayer
;
550 SdrLayerAdmin
& rLayerAdmin
= mpModel
->mpDoc
->GetLayerAdmin();
551 sal_uInt16 nLayerCnt
= rLayerAdmin
.GetLayerCount();
552 sal_uInt16 nLayer
= nLayerCnt
- 2 + 1;
555 // Ueberpruefung auf schon vorhandene Namen
556 while( aLayerName
.Len()==0 || rLayerAdmin
.GetLayer( aLayerName
, sal_False
) )
558 aLayerName
= String(SdResId(STR_LAYER
));
559 aLayerName
+= String::CreateFromInt32( (sal_Int32
)nLayer
);
563 SdrLayerAdmin
& rLA
=mpModel
->mpDoc
->GetLayerAdmin();
564 const sal_Int32 nMax
=rLA
.GetLayerCount();
565 if (nIndex
>nMax
) nIndex
=nMax
;
566 xLayer
= GetLayer (rLA
.NewLayer(aLayerName
,(USHORT
)nIndex
));
567 mpModel
->SetModified();
572 void SAL_CALL
SdLayerManager::remove( const uno::Reference
< drawing::XLayer
>& xLayer
)
573 throw(container::NoSuchElementException
, uno::RuntimeException
)
575 OGuard
aGuard( Application::GetSolarMutex() );
578 throw lang::DisposedException();
580 SdLayer
* pSdLayer
= SdLayer::getImplementation(xLayer
);
582 if(pSdLayer
&& GetView())
584 const SdrLayer
* pSdrLayer
= pSdLayer
->GetSdrLayer();
585 GetView()->DeleteLayer( pSdrLayer
->GetName() );
590 mpModel
->SetModified();
593 void SAL_CALL
SdLayerManager::attachShapeToLayer( const uno::Reference
< drawing::XShape
>& xShape
, const uno::Reference
< drawing::XLayer
>& xLayer
)
594 throw(uno::RuntimeException
)
596 OGuard
aGuard( Application::GetSolarMutex() );
599 throw lang::DisposedException();
601 SdLayer
* pSdLayer
= SdLayer::getImplementation(xLayer
);
602 SdrLayer
* pSdrLayer
= pSdLayer
?pSdLayer
->GetSdrLayer():NULL
;
606 SvxShape
* pShape
= SvxShape::getImplementation( xShape
);
607 SdrObject
* pSdrObject
= pShape
?pShape
->GetSdrObject():NULL
;
609 if(pSdrObject
&& pSdrLayer
)
610 pSdrObject
->SetLayer(pSdrLayer
->GetID());
612 mpModel
->SetModified();
615 uno::Reference
< drawing::XLayer
> SAL_CALL
SdLayerManager::getLayerForShape( const uno::Reference
< drawing::XShape
>& xShape
) throw(uno::RuntimeException
)
617 OGuard
aGuard( Application::GetSolarMutex() );
620 throw lang::DisposedException();
622 uno::Reference
< drawing::XLayer
> xLayer
;
626 SvxShape
* pShape
= SvxShape::getImplementation( xShape
);
627 SdrObject
* pObj
= pShape
?pShape
->GetSdrObject():NULL
;
630 SdrLayerID aId
= pObj
->GetLayer();
631 SdrLayerAdmin
& rLayerAdmin
= mpModel
->mpDoc
->GetLayerAdmin();
632 xLayer
= GetLayer (rLayerAdmin
.GetLayerPerID(aId
));
639 sal_Int32 SAL_CALL
SdLayerManager::getCount()
640 throw(uno::RuntimeException
)
642 OGuard
aGuard( Application::GetSolarMutex() );
645 throw lang::DisposedException();
649 SdrLayerAdmin
& rLayerAdmin
= mpModel
->mpDoc
->GetLayerAdmin();
650 return rLayerAdmin
.GetLayerCount();
656 uno::Any SAL_CALL
SdLayerManager::getByIndex( sal_Int32 nLayer
)
657 throw(lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
)
659 OGuard
aGuard( Application::GetSolarMutex() );
662 throw lang::DisposedException();
664 if( nLayer
>= getCount() || nLayer
< 0 )
665 throw lang::IndexOutOfBoundsException();
671 SdrLayerAdmin
& rLayerAdmin
= mpModel
->mpDoc
->GetLayerAdmin();
672 uno::Reference
<drawing::XLayer
> xLayer (GetLayer (rLayerAdmin
.GetLayer((sal_uInt16
)nLayer
)));
680 uno::Any SAL_CALL
SdLayerManager::getByName( const OUString
& aName
)
681 throw(container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
683 OGuard
aGuard( Application::GetSolarMutex() );
685 if( (mpModel
== 0) || (mpModel
->mpDoc
== 0 ) )
686 throw lang::DisposedException();
688 SdrLayerAdmin
& rLayerAdmin
= mpModel
->mpDoc
->GetLayerAdmin();
689 SdrLayer
* pLayer
= rLayerAdmin
.GetLayer( SdLayer::convertToInternalName( aName
), FALSE
);
691 throw container::NoSuchElementException();
693 return uno::Any( GetLayer (pLayer
) );
696 uno::Sequence
< OUString
> SAL_CALL
SdLayerManager::getElementNames()
697 throw(uno::RuntimeException
)
699 OGuard
aGuard( Application::GetSolarMutex() );
702 throw lang::DisposedException();
704 SdrLayerAdmin
& rLayerAdmin
= mpModel
->mpDoc
->GetLayerAdmin();
705 const sal_uInt16 nLayerCount
= rLayerAdmin
.GetLayerCount();
707 uno::Sequence
< OUString
> aSeq( nLayerCount
);
709 OUString
* pStrings
= aSeq
.getArray();
712 for( sal_uInt16 nLayer
= 0; nLayer
< nLayerCount
; nLayer
++ )
714 pLayer
= rLayerAdmin
.GetLayer( nLayer
);
716 *pStrings
++ = SdLayer::convertToExternalName( pLayer
->GetName() );
722 sal_Bool SAL_CALL
SdLayerManager::hasByName( const OUString
& aName
) throw(uno::RuntimeException
)
724 OGuard
aGuard( Application::GetSolarMutex() );
727 throw lang::DisposedException();
729 SdrLayerAdmin
& rLayerAdmin
= mpModel
->mpDoc
->GetLayerAdmin();
731 return NULL
!= rLayerAdmin
.GetLayer( SdLayer::convertToInternalName( aName
), FALSE
);
735 uno::Type SAL_CALL
SdLayerManager::getElementType()
736 throw(uno::RuntimeException
)
738 return ITYPE( drawing::XLayer
);
741 sal_Bool SAL_CALL
SdLayerManager::hasElements() throw(uno::RuntimeException
)
743 return getCount() > 0;
746 /** Falls an den Layern was geaendert wurde sorgt diese Methode dafuer, das
747 die Aenderungen auch in der sdbcx::View sichtbar gemacht werden */
748 void SdLayerManager::UpdateLayerView( sal_Bool modify
) const throw()
750 if(mpModel
->mpDocShell
)
752 ::sd::DrawViewShell
* pDrViewSh
=
753 PTR_CAST(::sd::DrawViewShell
, mpModel
->mpDocShell
->GetViewShell());
757 sal_Bool bLayerMode
= pDrViewSh
->IsLayerModeActive();
758 pDrViewSh
->ChangeEditMode(pDrViewSh
->GetEditMode(), !bLayerMode
);
759 pDrViewSh
->ChangeEditMode(pDrViewSh
->GetEditMode(), bLayerMode
);
763 mpModel
->mpDoc
->SetChanged(sal_True
);
768 ::sd::View
* SdLayerManager::GetView() const throw()
770 if( mpModel
->mpDocShell
)
772 ::sd::ViewShell
* pViewSh
= mpModel
->mpDocShell
->GetViewShell();
774 return pViewSh
->GetView();
783 /** Compare two pointers to <type>SdrLayer</type> objects.
785 The implementing SdLayer class provides the first pointer by the
786 <member>SdLayer::GetSdrLayer</member> method.
788 This void pointer is the second pointer to an <type>SdrLayer</type>
791 Return </True> if both pointers point to the same object.
793 sal_Bool
compare_layers (uno::WeakReference
<uno::XInterface
> xRef
, void* pSearchData
)
795 uno::Reference
<uno::XInterface
> xLayer (xRef
);
798 SdLayer
* pSdLayer
= SdLayer::getImplementation (xRef
);
799 if (pSdLayer
!= NULL
)
801 SdrLayer
* pSdrLayer
= pSdLayer
->GetSdrLayer ();
802 if (pSdrLayer
== static_cast<SdrLayer
*>(pSearchData
))
810 /** Use the <member>mpLayers</member> container of weak references to either
811 retrieve and return a previously created <type>XLayer</type> object for
812 the given <type>SdrLayer</type> object or create and remember a new one.
814 uno::Reference
<drawing::XLayer
> SdLayerManager::GetLayer (SdrLayer
* pLayer
)
816 uno::WeakReference
<uno::XInterface
> xRef
;
817 uno::Reference
<drawing::XLayer
> xLayer
;
819 // Search existing xLayer for the given pLayer.
820 if (mpLayers
->findRef (xRef
, (void*)pLayer
, compare_layers
))
821 xLayer
= uno::Reference
<drawing::XLayer
> (xRef
, uno::UNO_QUERY
);
823 // Create the xLayer if necessary.
826 xLayer
= new SdLayer (this, pLayer
);
828 // Remember the new xLayer for future calls.
829 xRef
= uno::Reference
<uno::XInterface
> (xLayer
, uno::UNO_QUERY
);
830 mpLayers
->insert (xRef
);