xref: /aoo42x/main/sfx2/source/view/viewfac.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_sfx2.hxx"
30 // INCLUDE ---------------------------------------------------------------
31 
32 #include <sfx2/app.hxx>
33 #include "sfx2/viewfac.hxx"
34 #include <rtl/ustrbuf.hxx>
35 
36 // STATIC DATA -----------------------------------------------------------
37 
38 DBG_NAME(SfxViewFactory)
39 
40 SfxViewShell *SfxViewFactory::CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldSh )
41 {
42 	DBG_CHKTHIS(SfxViewFactory, 0);
43 	return (*fnCreate)(pFrame, pOldSh);
44 }
45 
46 void SfxViewFactory::InitFactory()
47 {
48 	DBG_CHKTHIS(SfxViewFactory, 0);
49 	(*fnInit)();
50 }
51 
52 String SfxViewFactory::GetLegacyViewName() const
53 {
54     ::rtl::OUStringBuffer aViewName;
55     aViewName.appendAscii( "view" );
56     aViewName.append( sal_Int32( GetOrdinal() ) );
57     return aViewName.makeStringAndClear();
58 }
59 
60 String SfxViewFactory::GetAPIViewName() const
61 {
62     if ( m_sViewName.Len() > 0 )
63         return m_sViewName;
64 
65     if ( GetOrdinal() == 0 )
66         return String::CreateFromAscii( "Default" );
67 
68     return GetLegacyViewName();
69 }
70 
71 // CTOR / DTOR -----------------------------------------------------------
72 
73 SfxViewFactory::SfxViewFactory( SfxViewCtor fnC, SfxViewInit fnI,
74 								sal_uInt16 nOrdinal, const sal_Char* asciiViewName ):
75 	fnCreate(fnC),
76 	fnInit(fnI),
77 	nOrd(nOrdinal),
78     m_sViewName( String::CreateFromAscii( asciiViewName ) )
79 {
80 	DBG_CTOR(SfxViewFactory, 0);
81 }
82 
83 SfxViewFactory::~SfxViewFactory()
84 {
85 	DBG_DTOR(SfxViewFactory, 0);
86 }
87 
88 
89