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 "createunocustomshow.hxx"
23 : #include "sdiocmpt.hxx"
24 : #include "cusshow.hxx"
25 : #include "sdpage.hxx"
26 : #include "drawdoc.hxx"
27 :
28 : #include <tools/tenccvt.hxx>
29 :
30 : using namespace ::com::sun::star;
31 :
32 : /*************************************************************************
33 : |*
34 : |* Ctor
35 : |*
36 : \************************************************************************/
37 0 : SdCustomShow::SdCustomShow(SdDrawDocument* pDrawDoc)
38 : : maPages(),
39 0 : pDoc(pDrawDoc)
40 : {
41 0 : }
42 :
43 : /*************************************************************************
44 : |*
45 : |* Copy-Ctor
46 : |*
47 : \************************************************************************/
48 0 : SdCustomShow::SdCustomShow( const SdCustomShow& rShow )
49 0 : : maPages(rShow.maPages)
50 : {
51 0 : aName = rShow.GetName();
52 0 : pDoc = rShow.GetDoc();
53 0 : }
54 :
55 6 : SdCustomShow::SdCustomShow(SdDrawDocument* pDrawDoc, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xShow )
56 : : maPages(),
57 : pDoc(pDrawDoc),
58 6 : mxUnoCustomShow( xShow )
59 : {
60 6 : }
61 :
62 : /*************************************************************************
63 : |*
64 : |* Dtor
65 : |*
66 : \************************************************************************/
67 18 : SdCustomShow::~SdCustomShow()
68 : {
69 6 : uno::Reference< uno::XInterface > xShow( mxUnoCustomShow );
70 12 : uno::Reference< lang::XComponent > xComponent( xShow, uno::UNO_QUERY );
71 6 : if( xComponent.is() )
72 12 : xComponent->dispose();
73 12 : }
74 :
75 0 : uno::Reference< uno::XInterface > SdCustomShow::getUnoCustomShow()
76 : {
77 : // try weak reference first
78 0 : uno::Reference< uno::XInterface > xShow( mxUnoCustomShow );
79 :
80 0 : if( !xShow.is() )
81 : {
82 0 : xShow = createUnoCustomShow( this );
83 : }
84 :
85 0 : return xShow;
86 : }
87 :
88 26 : void SdCustomShow::ReplacePage( const SdPage* pOldPage, const SdPage* pNewPage )
89 : {
90 26 : if( !pNewPage )
91 : {
92 26 : RemovePage(pOldPage);
93 : }
94 : else
95 : {
96 0 : ::std::replace(maPages.begin(), maPages.end(), pOldPage, pNewPage);
97 : }
98 26 : }
99 :
100 26 : void SdCustomShow::RemovePage( const SdPage* pPage )
101 : {
102 26 : maPages.erase(::std::remove(maPages.begin(), maPages.end(), pPage), maPages.end());
103 26 : }
104 :
105 10 : void SdCustomShow::SetName(const OUString& rName)
106 : {
107 10 : aName = rName;
108 124 : }
109 :
110 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|