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