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_framework.hxx"
26 
27 //_______________________________________________
28 // own includes
29 
30 #ifndef __FRAMEWORK_LOADENV_TARGETHELPER_HXX_
31 #include <loadenv/targethelper.hxx>
32 #endif
33 
34 //_______________________________________________
35 // namespace
36 
37 namespace framework{
38 
39 //_______________________________________________
40 // declarations
41 
42 /*-----------------------------------------------
43     05.08.2003 09:08
44 -----------------------------------------------*/
matchSpecialTarget(const::rtl::OUString & sCheckTarget,ESpecialTarget eSpecialTarget)45 sal_Bool TargetHelper::matchSpecialTarget(const ::rtl::OUString& sCheckTarget  ,
46                                                 ESpecialTarget   eSpecialTarget)
47 {
48     switch(eSpecialTarget)
49     {
50         case E_SELF :
51             return (
52                     (!sCheckTarget.getLength()              ) ||
53                     (sCheckTarget.equals(SPECIALTARGET_SELF))
54                    );
55 
56         case E_PARENT :
57             return (sCheckTarget.equals(SPECIALTARGET_PARENT));
58 
59         case E_TOP :
60             return (sCheckTarget.equals(SPECIALTARGET_TOP));
61 
62         case E_BLANK :
63             return (sCheckTarget.equals(SPECIALTARGET_BLANK));
64 
65         case E_DEFAULT :
66             return (sCheckTarget.equals(SPECIALTARGET_DEFAULT));
67 
68         case E_BEAMER :
69             return (sCheckTarget.equals(SPECIALTARGET_BEAMER));
70 
71         case E_MENUBAR :
72             return (sCheckTarget.equals(SPECIALTARGET_MENUBAR));
73 
74         case E_HELPAGENT :
75             return (sCheckTarget.equals(SPECIALTARGET_HELPAGENT));
76 
77         case E_HELPTASK :
78             return (sCheckTarget.equals(SPECIALTARGET_HELPTASK));
79         default:
80             return sal_False;
81     }
82 
83     return sal_False;
84 }
85 
86 /*-----------------------------------------------
87     05.08.2003 09:17
88 -----------------------------------------------*/
isValidNameForFrame(const::rtl::OUString & sName)89 sal_Bool TargetHelper::isValidNameForFrame(const ::rtl::OUString& sName)
90 {
91     // some special targets are really special ones :-)
92     // E.g. the are really used to locate one frame inside the frame tree.
93     if (
94         (!sName.getLength()                                 ) ||
95         (TargetHelper::matchSpecialTarget(sName, E_HELPTASK)) ||
96         (TargetHelper::matchSpecialTarget(sName, E_BEAMER)  )
97        )
98         return sal_True;
99 
100     // all other names must be checked more general
101     // special targets starts with a "_".
102     return (sName.indexOf('_') != 0);
103 }
104 
105 } // namespace framework
106