xref: /aoo41x/main/sd/source/core/cusshow.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 
32 #include <com/sun/star/lang/XComponent.hpp>
33 
34 #include "sdiocmpt.hxx"
35 #include "cusshow.hxx"
36 #include "sdpage.hxx"
37 #include "drawdoc.hxx"
38 
39 // #90477#
40 #include <tools/tenccvt.hxx>
41 
42 using namespace ::com::sun::star;
43 
44 /*************************************************************************
45 |*
46 |* Ctor
47 |*
48 \************************************************************************/
49 SdCustomShow::SdCustomShow(SdDrawDocument* pDrawDoc)
50   : List(),
51   pDoc(pDrawDoc)
52 {
53 }
54 
55 /*************************************************************************
56 |*
57 |* Copy-Ctor
58 |*
59 \************************************************************************/
60 SdCustomShow::SdCustomShow( const SdCustomShow& rShow )
61 	: List( rShow )
62 {
63 	aName = rShow.GetName();
64 	pDoc = rShow.GetDoc();
65 }
66 
67 SdCustomShow::SdCustomShow(SdDrawDocument* pDrawDoc, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xShow )
68   : List(),
69   pDoc(pDrawDoc),
70   mxUnoCustomShow( xShow )
71 {
72 }
73 
74 /*************************************************************************
75 |*
76 |* Dtor
77 |*
78 \************************************************************************/
79 SdCustomShow::~SdCustomShow()
80 {
81 	uno::Reference< uno::XInterface > xShow( mxUnoCustomShow );
82 	uno::Reference< lang::XComponent > xComponent( xShow, uno::UNO_QUERY );
83 	if( xComponent.is() )
84 		xComponent->dispose();
85 }
86 
87 extern uno::Reference< uno::XInterface > createUnoCustomShow( SdCustomShow* pShow );
88 
89 uno::Reference< uno::XInterface > SdCustomShow::getUnoCustomShow()
90 {
91 	// try weak reference first
92 	uno::Reference< uno::XInterface > xShow( mxUnoCustomShow );
93 
94 	if( !xShow.is() )
95 	{
96 		xShow = createUnoCustomShow( this );
97 	}
98 
99 	return xShow;
100 }
101 
102 void SdCustomShow::ReplacePage( const SdPage* pOldPage, const SdPage* pNewPage )
103 {
104 	if( !pNewPage )
105 	{
106 		RemovePage( pOldPage );
107 	}
108 	else
109 	{
110 		sal_uLong nPos;
111 		while( (nPos = GetPos( (void*)pOldPage )) != CONTAINER_ENTRY_NOTFOUND  )
112 		{
113 			Replace( (void*)pNewPage, nPos );
114 		}
115 	}
116 }
117 
118 void SdCustomShow::RemovePage( const SdPage* pPage )
119 {
120 	sal_uLong nPos;
121 	while( (nPos = GetPos( (void*)pPage )) != CONTAINER_ENTRY_NOTFOUND  )
122 	{
123 		Remove( nPos );
124 	}
125 }
126 
127 void   SdCustomShow::SetName(const String& rName)
128 {
129     aName = rName;
130 }
131 
132 String SdCustomShow::GetName() const
133 {
134     return aName;
135 }
136 
137