1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svl/zforlist.hxx>
21 #include <svl/stritem.hxx>
22 #include "svtools/treelistentry.hxx"
24 #include "structpg.hxx"
25 #include "formdlgs.hrc"
26 #include "formula/formdata.hxx"
27 #include "formula/formula.hxx"
28 #include "ModuleHelper.hxx"
29 #include "formula/IFunctionDescription.hxx"
30 #include "ForResId.hrc"
32 //----------------------------------------------------------------------------
35 StructListBox::StructListBox(Window
* pParent
, const ResId
& rResId
):
36 SvTreeListBox(pParent
,rResId
)
38 bActiveFlag
=sal_False
;
40 Font
aFont( GetFont() );
41 Size aSize
= aFont
.GetSize();
43 aFont
.SetSize( aSize
);
47 SvTreeListEntry
* StructListBox::InsertStaticEntry(
48 const XubString
& rText
,
49 const Image
& rEntryImg
,
50 SvTreeListEntry
* pParent
, sal_uLong nPos
, IFormulaToken
* pToken
)
52 SvTreeListEntry
* pEntry
= InsertEntry( rText
, rEntryImg
, rEntryImg
, pParent
, sal_False
, nPos
, pToken
);
56 void StructListBox::SetActiveFlag(sal_Bool bFlag
)
61 sal_Bool
StructListBox::GetActiveFlag()
66 void StructListBox::MouseButtonDown( const MouseEvent
& rMEvt
)
69 SvTreeListBox::MouseButtonDown(rMEvt
);
72 void StructListBox::GetFocus()
75 SvTreeListBox::GetFocus();
78 void StructListBox::LoseFocus()
80 bActiveFlag
=sal_False
;
81 SvTreeListBox::LoseFocus();
84 //==============================================================================
86 StructPage::StructPage(Window
* pParent
):
87 TabPage(pParent
,ModuleRes(RID_FORMULATAB_STRUCT
)),
88 aFtStruct ( this, ModuleRes( FT_STRUCT
) ),
89 aTlbStruct ( this, ModuleRes( TLB_STRUCT
) ),
90 maImgEnd ( ModuleRes( BMP_STR_END
) ),
91 maImgError ( ModuleRes( BMP_STR_ERROR
) ),
92 pSelectedToken ( NULL
)
94 aTlbStruct
.SetStyle(aTlbStruct
.GetStyle()|WB_HASLINES
|WB_CLIPCHILDREN
|
95 WB_HASBUTTONS
|WB_HSCROLL
|WB_NOINITIALSELECTION
);
97 aTlbStruct
.SetNodeDefaultImages();
98 aTlbStruct
.SetDefaultExpandedEntryBmp( Image( ModuleRes( BMP_STR_OPEN
) ) );
99 aTlbStruct
.SetDefaultCollapsedEntryBmp( Image( ModuleRes( BMP_STR_CLOSE
) ) );
103 aTlbStruct
.SetSelectHdl(LINK( this, StructPage
, SelectHdl
) );
106 void StructPage::ClearStruct()
108 aTlbStruct
.SetActiveFlag(sal_False
);
112 SvTreeListEntry
* StructPage::InsertEntry( const XubString
& rText
, SvTreeListEntry
* pParent
,
113 sal_uInt16 nFlag
,sal_uLong nPos
,IFormulaToken
* pIFormulaToken
)
115 aTlbStruct
.SetActiveFlag( sal_False
);
117 SvTreeListEntry
* pEntry
= NULL
;
121 pEntry
= aTlbStruct
.InsertEntry( rText
, pParent
, sal_False
, nPos
, pIFormulaToken
);
124 pEntry
= aTlbStruct
.InsertStaticEntry( rText
, maImgEnd
, pParent
, nPos
, pIFormulaToken
);
127 pEntry
= aTlbStruct
.InsertStaticEntry( rText
, maImgError
, pParent
, nPos
, pIFormulaToken
);
131 if( pEntry
&& pParent
)
132 aTlbStruct
.Expand( pParent
);
136 String
StructPage::GetEntryText(SvTreeListEntry
* pEntry
) const
140 aString
=aTlbStruct
.GetEntryText(pEntry
);
144 SvTreeListEntry
* StructPage::GetParent(SvTreeListEntry
* pEntry
) const
146 return aTlbStruct
.GetParent(pEntry
);
148 IFormulaToken
* StructPage::GetFunctionEntry(SvTreeListEntry
* pEntry
)
152 IFormulaToken
* pToken
=(IFormulaToken
*)pEntry
->GetUserData();
155 if ( !(pToken
->isFunction() || pToken
->getArgumentCount() > 1 ) )
157 return GetFunctionEntry(aTlbStruct
.GetParent(pEntry
));
168 IMPL_LINK( StructPage
, SelectHdl
, SvTreeListBox
*, pTlb
)
170 if(aTlbStruct
.GetActiveFlag())
172 if(pTlb
==&aTlbStruct
)
174 SvTreeListEntry
* pCurEntry
=aTlbStruct
.GetCurEntry();
177 pSelectedToken
=(IFormulaToken
*)pCurEntry
->GetUserData();
178 if(pSelectedToken
!=NULL
)
180 if ( !(pSelectedToken
->isFunction() || pSelectedToken
->getArgumentCount() > 1) )
182 pSelectedToken
= GetFunctionEntry(pCurEntry
);
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */