1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2008 by Sun Microsystems, Inc.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * $RCSfile: layoutmanager.hxx,v $
10  * $Revision: 1.34 $
11  *
12  * This file is part of OpenOffice.org.
13  *
14  * OpenOffice.org is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU Lesser General Public License version 3
16  * only, as published by the Free Software Foundation.
17  *
18  * OpenOffice.org is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU Lesser General Public License version 3 for more details
22  * (a copy is included in the LICENSE file that accompanied this code).
23  *
24  * You should have received a copy of the GNU Lesser General Public License
25  * version 3 along with OpenOffice.org.  If not, see
26  * <http://www.openoffice.org/license.html>
27  * for a copy of the LGPLv3 License.
28  *
29  ************************************************************************/
30 
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
33 
34 //_________________________________________________________________________________________________________________
35 //	my own includes
36 //_________________________________________________________________________________________________________________
37 
38 #include <uielement/uielement.hxx>
39 
40 //_________________________________________________________________________________________________________________
41 //	interface includes
42 //_________________________________________________________________________________________________________________
43 
44 #include <com/sun/star/ui/DockingArea.hpp>
45 
46 //_________________________________________________________________________________________________________________
47 //	namespace
48 //_________________________________________________________________________________________________________________
49 
50 using namespace ::com::sun::star;
51 
52 namespace framework
53 {
54 
55     bool UIElement::operator< ( const ::framework::UIElement& aUIElement ) const
56 {
57     if ( !m_xUIElement.is() && aUIElement.m_xUIElement.is() )
58         return false;
59     else if ( m_xUIElement.is() && !aUIElement.m_xUIElement.is() )
60         return true;
61     else if ( !m_bVisible && aUIElement.m_bVisible )
62         return false;
63     else if ( m_bVisible && !aUIElement.m_bVisible )
64         return true;
65     else if ( !m_bFloating && aUIElement.m_bFloating )
66         return true;
67     else if ( m_bFloating && !aUIElement.m_bFloating )
68         return false;
69     else
70     {
71         if ( m_bFloating )
72         {
73             bool bEqual = ( m_aFloatingData.m_aPos.Y() == aUIElement.m_aFloatingData.m_aPos.Y() );
74             if ( bEqual )
75                 return ( m_aFloatingData.m_aPos.X() < aUIElement.m_aFloatingData.m_aPos.X() );
76             else
77                 return ( m_aFloatingData.m_aPos.Y() < aUIElement.m_aFloatingData.m_aPos.Y() );
78         }
79         else
80         {
81             if ( m_aDockedData.m_nDockedArea < aUIElement.m_aDockedData.m_nDockedArea )
82                 return true;
83             else if ( m_aDockedData.m_nDockedArea > aUIElement.m_aDockedData.m_nDockedArea )
84                 return false;
85             else
86             {
87                 if ( m_aDockedData.m_nDockedArea == ui::DockingArea_DOCKINGAREA_TOP ||
88                      m_aDockedData.m_nDockedArea == ui::DockingArea_DOCKINGAREA_BOTTOM )
89                 {
90                     if ( !( m_aDockedData.m_aPos.Y() == aUIElement.m_aDockedData.m_aPos.Y() ) )
91                         return  ( m_aDockedData.m_aPos.Y() < aUIElement.m_aDockedData.m_aPos.Y() );
92                     else
93                     {
94                         bool bEqual = ( m_aDockedData.m_aPos.X() == aUIElement.m_aDockedData.m_aPos.X() );
95                         if ( bEqual )
96                         {
97                             if ( m_bUserActive && !aUIElement.m_bUserActive )
98                                 return sal_True;
99                             else if ( !m_bUserActive && aUIElement.m_bUserActive )
100                                 return sal_False;
101                             else
102                                 return sal_False;
103                         }
104                         else
105                             return ( m_aDockedData.m_aPos.X() <= aUIElement.m_aDockedData.m_aPos.X() );
106                     }
107                 }
108                 else
109                 {
110                     if ( !( m_aDockedData.m_aPos.X() == aUIElement.m_aDockedData.m_aPos.X() ) )
111                         return ( m_aDockedData.m_aPos.X() < aUIElement.m_aDockedData.m_aPos.X() );
112                     else
113                     {
114                         bool bEqual = ( m_aDockedData.m_aPos.Y() == aUIElement.m_aDockedData.m_aPos.Y() );
115                         if ( bEqual )
116                         {
117                             if ( m_bUserActive && !aUIElement.m_bUserActive )
118                                 return sal_True;
119                             else if ( !m_bUserActive && aUIElement.m_bUserActive )
120                                 return sal_False;
121                             else
122                                 return sal_False;
123                         }
124                         else
125                             return ( m_aDockedData.m_aPos.Y() <= aUIElement.m_aDockedData.m_aPos.Y() );
126                     }
127                 }
128             }
129         }
130     }
131 }
132 
133 UIElement& UIElement::operator= ( const UIElement& rUIElement )
134 {
135     if (&rUIElement != this)
136     {
137         m_aType             = rUIElement.m_aType;
138         m_aName             = rUIElement.m_aName;
139         m_aUIName           = rUIElement.m_aUIName;
140         m_xUIElement        = rUIElement.m_xUIElement;
141         m_bFloating         = rUIElement.m_bFloating;
142         m_bVisible          = rUIElement.m_bVisible;
143         m_bUserActive       = rUIElement.m_bUserActive;
144         m_bCreateNewRowCol0 = rUIElement.m_bCreateNewRowCol0;
145         m_bDeactiveHide     = rUIElement.m_bDeactiveHide;
146         m_bMasterHide       = rUIElement.m_bMasterHide;
147         m_bContextSensitive = rUIElement.m_bContextSensitive;
148         m_bContextActive    = rUIElement.m_bContextActive;
149         m_bNoClose          = rUIElement.m_bNoClose;
150         m_bSoftClose        = rUIElement.m_bSoftClose;
151         m_bStateRead        = rUIElement.m_bStateRead;
152         m_nStyle            = rUIElement.m_nStyle;
153         m_aDockedData       = rUIElement.m_aDockedData;
154         m_aFloatingData     = rUIElement.m_aFloatingData;
155     }
156     return *this;
157 }
158 
159 } // namespace framework
160