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 #ifndef ADC_DISPLAY_OUT_POSITION_HXX
29 #define ADC_DISPLAY_OUT_POSITION_HXX
30 
31 
32 // USED SERVICES
33     // BASE CLASSES
34     // COMPONENTS
35 #include <toolkit/out_node.hxx>
36     // PARAMETERS
37 
38 
39 
40 namespace output
41 {
42 
43 
44 
45 class Position
46 {
47   public:
48     // LIFECYCLE
49                         Position();
50     explicit            Position(
51                             Node &              i_directory,
52                             const String &      i_file = String::Null_() );
53                         Position(
54                             const Position &    i_directory,
55                             const String &      i_rDifferentFile );
56                         ~Position();
57 
58     // OPERATIONS
59     Position &          operator=(
60                             Node &              i_node );
61     Position &          operator+=(
62                             const String &      i_nodeName );
63     Position &          operator-=(
64                             intt                i_levels );
65 
66     // INQUIRY
67     bool                IsValid() const         { return pDirectory->Depth() >= 0; }
68     const String &      Name() const            { return pDirectory->Name(); }
69     const String &      File() const            { return sFile; }
70     intt                Depth() const           { return pDirectory->Depth(); }
71 
72     void                Get_Chain(
73                             StringVector &      o_result ) const
74                                                 { pDirectory->Get_Chain(o_result); }
75     String              LinkToRoot(
76                             const String &      i_localLabel = String::Null_() ) const;
77 
78     void                Get_LinkTo(
79                             StreamStr &         o_result,
80                             const Position &    i_destination,
81                             const String &      i_localLabel = String::Null_() ) const;
82     void                Get_LinkToRoot(
83                             StreamStr &         o_result,
84                             const String &      i_localLabel = String::Null_() ) const;
85 
86     static char         Delimiter()             { return '/'; }
87 
88     // ACCESS
89     Node &              RelatedNode() const     { return *pDirectory; }
90 
91     void                Set(
92                             Node &              i_node,
93                             const String &      i_file = String::Null_() );
94     void                Set_File(
95                             const String &      i_file );
96 
97   private:
98     // DATA
99     String              sFile;
100     Node *              pDirectory;
101 };
102 
103 
104 /// @return No delimiter at start, with delimiter at end.
105 const char *        get_UpLink(
106                         uintt                   i_depth );
107 
108 
109 // IMPLEMENTATION
110 
111 inline void
112 Position::Set_File( const String & i_file )
113     { sFile = i_file; }
114 
115 }   // namespace output
116 
117 #endif
118