Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/lang/XComponent.hpp>
21 :
22 : #include "sdiocmpt.hxx"
23 : #include "cusshow.hxx"
24 : #include "sdpage.hxx"
25 : #include "drawdoc.hxx"
26 :
27 : #include <tools/tenccvt.hxx>
28 :
29 : using namespace ::com::sun::star;
30 :
31 : /*************************************************************************
32 : |*
33 : |* Ctor
34 : |*
35 : \************************************************************************/
36 0 : SdCustomShow::SdCustomShow(SdDrawDocument* pDrawDoc)
37 : : maPages(),
38 0 : pDoc(pDrawDoc)
39 : {
40 0 : }
41 :
42 : /*************************************************************************
43 : |*
44 : |* Copy-Ctor
45 : |*
46 : \************************************************************************/
47 0 : SdCustomShow::SdCustomShow( const SdCustomShow& rShow )
48 0 : : maPages(rShow.maPages)
49 : {
50 0 : aName = rShow.GetName();
51 0 : pDoc = rShow.GetDoc();
52 0 : }
53 :
54 0 : SdCustomShow::SdCustomShow(SdDrawDocument* pDrawDoc, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xShow )
55 : : maPages(),
56 : pDoc(pDrawDoc),
57 0 : mxUnoCustomShow( xShow )
58 : {
59 0 : }
60 :
61 : /*************************************************************************
62 : |*
63 : |* Dtor
64 : |*
65 : \************************************************************************/
66 0 : SdCustomShow::~SdCustomShow()
67 : {
68 0 : uno::Reference< uno::XInterface > xShow( mxUnoCustomShow );
69 0 : uno::Reference< lang::XComponent > xComponent( xShow, uno::UNO_QUERY );
70 0 : if( xComponent.is() )
71 0 : xComponent->dispose();
72 0 : }
73 :
74 : extern uno::Reference< uno::XInterface > createUnoCustomShow( SdCustomShow* pShow );
75 :
76 0 : uno::Reference< uno::XInterface > SdCustomShow::getUnoCustomShow()
77 : {
78 : // try weak reference first
79 0 : uno::Reference< uno::XInterface > xShow( mxUnoCustomShow );
80 :
81 0 : if( !xShow.is() )
82 : {
83 0 : xShow = createUnoCustomShow( this );
84 : }
85 :
86 0 : return xShow;
87 : }
88 :
89 0 : SdCustomShow::PageVec& SdCustomShow::PagesVector()
90 : {
91 0 : return maPages;
92 : }
93 :
94 0 : void SdCustomShow::ReplacePage( const SdPage* pOldPage, const SdPage* pNewPage )
95 : {
96 0 : if( !pNewPage )
97 : {
98 0 : RemovePage(pOldPage);
99 : }
100 : else
101 : {
102 0 : ::std::replace(maPages.begin(), maPages.end(), pOldPage, pNewPage);
103 : }
104 0 : }
105 :
106 0 : void SdCustomShow::RemovePage( const SdPage* pPage )
107 : {
108 0 : maPages.erase(::std::remove(maPages.begin(), maPages.end(), pPage), maPages.end());
109 0 : }
110 :
111 0 : void SdCustomShow::SetName(const OUString& rName)
112 : {
113 0 : aName = rName;
114 0 : }
115 :
116 0 : OUString SdCustomShow::GetName() const
117 : {
118 0 : return aName;
119 : }
120 :
121 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|