xref: /trunk/main/sd/source/core/cusshow.cxx (revision 79aad27f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 
28 #include <com/sun/star/lang/XComponent.hpp>
29 
30 #include "sdiocmpt.hxx"
31 #include "cusshow.hxx"
32 #include "sdpage.hxx"
33 #include "drawdoc.hxx"
34 
35 // #90477#
36 #include <tools/tenccvt.hxx>
37 
38 using namespace ::com::sun::star;
39 
40 /*************************************************************************
41 |*
42 |* Ctor
43 |*
44 \************************************************************************/
SdCustomShow(SdDrawDocument * pDrawDoc)45 SdCustomShow::SdCustomShow(SdDrawDocument* pDrawDoc)
46   : List(),
47   pDoc(pDrawDoc)
48 {
49 }
50 
51 /*************************************************************************
52 |*
53 |* Copy-Ctor
54 |*
55 \************************************************************************/
SdCustomShow(const SdCustomShow & rShow)56 SdCustomShow::SdCustomShow( const SdCustomShow& rShow )
57 	: List( rShow )
58 {
59 	aName = rShow.GetName();
60 	pDoc = rShow.GetDoc();
61 }
62 
SdCustomShow(SdDrawDocument * pDrawDoc,::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> xShow)63 SdCustomShow::SdCustomShow(SdDrawDocument* pDrawDoc, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xShow )
64   : List(),
65   pDoc(pDrawDoc),
66   mxUnoCustomShow( xShow )
67 {
68 }
69 
70 /*************************************************************************
71 |*
72 |* Dtor
73 |*
74 \************************************************************************/
~SdCustomShow()75 SdCustomShow::~SdCustomShow()
76 {
77 	uno::Reference< uno::XInterface > xShow( mxUnoCustomShow );
78 	uno::Reference< lang::XComponent > xComponent( xShow, uno::UNO_QUERY );
79 	if( xComponent.is() )
80 		xComponent->dispose();
81 }
82 
83 extern uno::Reference< uno::XInterface > createUnoCustomShow( SdCustomShow* pShow );
84 
getUnoCustomShow()85 uno::Reference< uno::XInterface > SdCustomShow::getUnoCustomShow()
86 {
87 	// try weak reference first
88 	uno::Reference< uno::XInterface > xShow( mxUnoCustomShow );
89 
90 	if( !xShow.is() )
91 	{
92 		xShow = createUnoCustomShow( this );
93 	}
94 
95 	return xShow;
96 }
97 
ReplacePage(const SdPage * pOldPage,const SdPage * pNewPage)98 void SdCustomShow::ReplacePage( const SdPage* pOldPage, const SdPage* pNewPage )
99 {
100 	if( !pNewPage )
101 	{
102 		RemovePage( pOldPage );
103 	}
104 	else
105 	{
106 		sal_uLong nPos;
107 		while( (nPos = GetPos( (void*)pOldPage )) != CONTAINER_ENTRY_NOTFOUND  )
108 		{
109 			Replace( (void*)pNewPage, nPos );
110 		}
111 	}
112 }
113 
RemovePage(const SdPage * pPage)114 void SdCustomShow::RemovePage( const SdPage* pPage )
115 {
116 	sal_uLong nPos;
117 	while( (nPos = GetPos( (void*)pPage )) != CONTAINER_ENTRY_NOTFOUND  )
118 	{
119 		Remove( nPos );
120 	}
121 }
122 
SetName(const String & rName)123 void   SdCustomShow::SetName(const String& rName)
124 {
125     aName = rName;
126 }
127 
GetName() const128 String SdCustomShow::GetName() const
129 {
130     return aName;
131 }
132 
133