Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include <svl/zforlist.hxx>
21 : : #include <svl/stritem.hxx>
22 : :
23 : : #include "structpg.hxx"
24 : : #include "formdlgs.hrc"
25 : : #include "formula/formdata.hxx"
26 : : #include "formula/formula.hxx"
27 : : #include "ModuleHelper.hxx"
28 : : #include "formula/IFunctionDescription.hxx"
29 : : #include "ForResId.hrc"
30 : :
31 : : //----------------------------------------------------------------------------
32 : : namespace formula
33 : : {
34 : 0 : StructListBox::StructListBox(Window* pParent, const ResId& rResId ):
35 : 0 : SvTreeListBox(pParent,rResId )
36 : : {
37 : 0 : bActiveFlag=sal_False;
38 : :
39 [ # # ]: 0 : Font aFont( GetFont() );
40 [ # # ]: 0 : Size aSize = aFont.GetSize();
41 : 0 : aSize.Height() -= 2;
42 [ # # ]: 0 : aFont.SetSize( aSize );
43 [ # # ][ # # ]: 0 : SetFont( aFont );
44 : 0 : }
45 : :
46 : 0 : SvLBoxEntry* StructListBox::InsertStaticEntry(
47 : : const XubString& rText,
48 : : const Image& rEntryImg,
49 : : SvLBoxEntry* pParent, sal_uLong nPos, IFormulaToken* pToken )
50 : : {
51 : 0 : SvLBoxEntry* pEntry = InsertEntry( rText, rEntryImg, rEntryImg, pParent, sal_False, nPos, pToken );
52 : 0 : return pEntry;
53 : : }
54 : :
55 : 0 : void StructListBox::SetActiveFlag(sal_Bool bFlag)
56 : : {
57 : 0 : bActiveFlag=bFlag;
58 : 0 : }
59 : :
60 : 0 : sal_Bool StructListBox::GetActiveFlag()
61 : : {
62 : 0 : return bActiveFlag;
63 : : }
64 : :
65 : 0 : void StructListBox::MouseButtonDown( const MouseEvent& rMEvt )
66 : : {
67 : 0 : bActiveFlag=sal_True;
68 : 0 : SvTreeListBox::MouseButtonDown(rMEvt);
69 : 0 : }
70 : :
71 : 0 : void StructListBox::GetFocus()
72 : : {
73 : 0 : bActiveFlag=sal_True;
74 : 0 : SvTreeListBox::GetFocus();
75 : 0 : }
76 : :
77 : 0 : void StructListBox::LoseFocus()
78 : : {
79 : 0 : bActiveFlag=sal_False;
80 : 0 : SvTreeListBox::LoseFocus();
81 : 0 : }
82 : :
83 : : //==============================================================================
84 : :
85 : 0 : StructPage::StructPage(Window* pParent):
86 : : TabPage(pParent,ModuleRes(RID_FORMULATAB_STRUCT)),
87 : : aFtStruct ( this, ModuleRes( FT_STRUCT ) ),
88 : : aTlbStruct ( this, ModuleRes( TLB_STRUCT ) ),
89 : : maImgEnd ( ModuleRes( BMP_STR_END ) ),
90 : : maImgError ( ModuleRes( BMP_STR_ERROR ) ),
91 [ # # ][ # # ]: 0 : pSelectedToken ( NULL )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
92 : : {
93 [ # # ]: 0 : aTlbStruct.SetStyle(aTlbStruct.GetStyle()|WB_HASLINES|WB_CLIPCHILDREN|
94 [ # # ]: 0 : WB_HASBUTTONS|WB_HSCROLL|WB_NOINITIALSELECTION);
95 : :
96 [ # # ]: 0 : aTlbStruct.SetNodeDefaultImages();
97 [ # # ][ # # ]: 0 : aTlbStruct.SetDefaultExpandedEntryBmp( Image( ModuleRes( BMP_STR_OPEN ) ) );
[ # # ][ # # ]
98 [ # # ][ # # ]: 0 : aTlbStruct.SetDefaultCollapsedEntryBmp( Image( ModuleRes( BMP_STR_CLOSE ) ) );
[ # # ][ # # ]
99 : :
100 [ # # ]: 0 : FreeResource();
101 : :
102 [ # # ]: 0 : aTlbStruct.SetSelectHdl(LINK( this, StructPage, SelectHdl ) );
103 : 0 : }
104 : :
105 : 0 : void StructPage::ClearStruct()
106 : : {
107 : 0 : aTlbStruct.SetActiveFlag(sal_False);
108 : 0 : aTlbStruct.Clear();
109 : 0 : }
110 : :
111 : 0 : SvLBoxEntry* StructPage::InsertEntry( const XubString& rText, SvLBoxEntry* pParent,
112 : : sal_uInt16 nFlag,sal_uLong nPos,IFormulaToken* pIFormulaToken)
113 : : {
114 : 0 : aTlbStruct.SetActiveFlag( sal_False );
115 : :
116 : 0 : SvLBoxEntry* pEntry = NULL;
117 [ # # # # ]: 0 : switch( nFlag )
118 : : {
119 : : case STRUCT_FOLDER:
120 : 0 : pEntry = aTlbStruct.InsertEntry( rText, pParent, sal_False, nPos, pIFormulaToken );
121 : 0 : break;
122 : : case STRUCT_END:
123 : 0 : pEntry = aTlbStruct.InsertStaticEntry( rText, maImgEnd, pParent, nPos, pIFormulaToken );
124 : 0 : break;
125 : : case STRUCT_ERROR:
126 : 0 : pEntry = aTlbStruct.InsertStaticEntry( rText, maImgError, pParent, nPos, pIFormulaToken );
127 : 0 : break;
128 : : }
129 : :
130 [ # # ][ # # ]: 0 : if( pEntry && pParent )
131 : 0 : aTlbStruct.Expand( pParent );
132 : 0 : return pEntry;
133 : : }
134 : :
135 : 0 : String StructPage::GetEntryText(SvLBoxEntry* pEntry) const
136 : : {
137 : 0 : String aString;
138 [ # # ]: 0 : if(pEntry!=NULL)
139 [ # # ][ # # ]: 0 : aString=aTlbStruct.GetEntryText(pEntry);
[ # # ]
140 : 0 : return aString;
141 : : }
142 : :
143 : 0 : SvLBoxEntry* StructPage::GetParent(SvLBoxEntry* pEntry) const
144 : : {
145 : 0 : return aTlbStruct.GetParent(pEntry);
146 : : }
147 : 0 : IFormulaToken* StructPage::GetFunctionEntry(SvLBoxEntry* pEntry)
148 : : {
149 [ # # ]: 0 : if(pEntry!=NULL)
150 : : {
151 : 0 : IFormulaToken * pToken=(IFormulaToken *)pEntry->GetUserData();
152 [ # # ]: 0 : if(pToken!=NULL)
153 : : {
154 [ # # ][ # # ]: 0 : if ( !(pToken->isFunction() || pToken->getArgumentCount() > 1 ) )
[ # # ]
155 : : {
156 : 0 : return GetFunctionEntry(aTlbStruct.GetParent(pEntry));
157 : : }
158 : : else
159 : : {
160 : 0 : return pToken;
161 : : }
162 : : }
163 : : }
164 : 0 : return NULL;
165 : : }
166 : :
167 : 0 : IMPL_LINK( StructPage, SelectHdl, SvTreeListBox*, pTlb )
168 : : {
169 [ # # ]: 0 : if(aTlbStruct.GetActiveFlag())
170 : : {
171 [ # # ]: 0 : if(pTlb==&aTlbStruct)
172 : : {
173 : 0 : SvLBoxEntry* pCurEntry=aTlbStruct.GetCurEntry();
174 [ # # ]: 0 : if(pCurEntry!=NULL)
175 : : {
176 : 0 : pSelectedToken=(IFormulaToken *)pCurEntry->GetUserData();
177 [ # # ]: 0 : if(pSelectedToken!=NULL)
178 : : {
179 [ # # ][ # # ]: 0 : if ( !(pSelectedToken->isFunction() || pSelectedToken->getArgumentCount() > 1) )
[ # # ]
180 : : {
181 : 0 : pSelectedToken = GetFunctionEntry(pCurEntry);
182 : : }
183 : : }
184 : : }
185 : : }
186 : :
187 : 0 : aSelLink.Call(this);
188 : : }
189 : 0 : return 0;
190 : : }
191 : :
192 : : } // formula
193 : :
194 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|