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 #ifndef __FRAMEWORK_TARGETHELPER_HXX_
25 #define __FRAMEWORK_TARGETHELPER_HXX_
26 
27 //_______________________________________________
28 // own includes
29 
30 #include <sal/types.h>
31 #include <rtl/ustring.hxx>
32 #include <targets.h>
33 //_______________________________________________
34 // namespace
35 
36 namespace framework{
37 
38 //_______________________________________________
39 // definitions
40 
41 /** @short  can be used to detect, if a target name (used e.g. for XFrame.findFrame())
42             has a special meaning or can be used as normal frame name (e.g. for XFrame.setName()).
43 
44     @author as96863
45  */
46 class TargetHelper
47 {
48     //___________________________________________
49     // const
50 
51     public:
52 
53         /** @short  its used at the following interfaces to classify
54                     target names.
55          */
56         enum ESpecialTarget
57         {
58             E_NOT_SPECIAL   ,
59             E_SELF          ,
60             E_PARENT        ,
61             E_TOP           ,
62             E_BLANK         ,
63             E_DEFAULT       ,
64             E_BEAMER        ,
65             E_MENUBAR       ,
66             E_HELPAGENT     ,
67             E_HELPTASK
68         };
69 
70     //___________________________________________
71     // interface
72 
73     public:
74 
75         //___________________________________________
76 
77         /** @short  it checks the given unknown target name,
78                     if it's the expected special one.
79 
80             @note   An empty target is similar to "_self"!
81 
82             @param  sCheckTarget
83                     must be the unknwon target name, which should be checked.
84 
85             @param  eSpecialTarget
86                     represent the expected target.
87 
88             @return It returns <TRUE/> if <var>sCheckTarget</var> represent
89                     the expected <var>eSpecialTarget</var> value; <FALSE/> otherwhise.
90          */
91         static sal_Bool matchSpecialTarget(const ::rtl::OUString& sCheckTarget  ,
92                                                  ESpecialTarget   eSpecialTarget);
93 
94         //___________________________________________
95 
96         /** @short  it checks, if the given name can be used
97                     to set it at a frame using XFrame.setName() method.
98 
99             @descr  Because we handle special targets in a hard coded way
100                     (means we do not check the real name of a frame then)
101                     such named frames will never be found!
102 
103                     And in case such special names can exists one times only
104                     by definition inside the same frame tree (e.g. _beamer and
105                     OFFICE_HELP_TASK) its not a good idea to allow anything here :-)
106 
107                     Of course we can't check unknwon names, which are not special ones.
108                     But we decide, that it's not allowed to use "_" as first sign
109                     (because we reserve this letter for our own purposes!)
110                     and the value must not a well known special target.
111 
112             @param  sName
113                     the new frame name, which sould be checked.
114          */
115         static sal_Bool isValidNameForFrame(const ::rtl::OUString& sName);
116 };
117 
118 } // namespace framework
119 
120 #endif // #ifndef __FRAMEWORK_TARGETHELPER_HXX_
121