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