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 _BASICBOX_HXX
25 #define _BASICBOX_HXX
26 
27 #include "doceventnotifier.hxx"
28 #include <svl/stritem.hxx>
29 #include <svheader.hxx>
30 #include <sfx2/tbxctrl.hxx>
31 #include <vcl/lstbox.hxx>
32 
33 
34 class LibBoxControl: public SfxToolBoxControl
35 {
36 public:
37 						SFX_DECL_TOOLBOX_CONTROL();
38 
39 						LibBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
40 						~LibBoxControl();
41 
42 	virtual void		StateChanged( sal_uInt16 nSID, SfxItemState eState,
43 									  const SfxPoolItem* pState );
44 	virtual Window*		CreateItemWindow( Window *pParent );
45 };
46 
47 /** base class for list boxes which need to update their content according to the list
48     of open documents
49 */
50 class DocListenerBox    :public ListBox
51                         ,public ::basctl::DocumentEventListener
52 {
53 protected:
54     DocListenerBox( Window* pParent );
55     ~DocListenerBox();
56 
57 protected:
58 	virtual void    FillBox() = 0;
59 
60 private:
61     // DocumentEventListener
62     virtual void onDocumentCreated( const ScriptDocument& _rDocument );
63     virtual void onDocumentOpened( const ScriptDocument& _rDocument );
64     virtual void onDocumentSave( const ScriptDocument& _rDocument );
65     virtual void onDocumentSaveDone( const ScriptDocument& _rDocument );
66     virtual void onDocumentSaveAs( const ScriptDocument& _rDocument );
67     virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument );
68     virtual void onDocumentClosed( const ScriptDocument& _rDocument );
69     virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument );
70     virtual void onDocumentModeChanged( const ScriptDocument& _rDocument );
71 
72 private:
73     ::basctl::DocumentEventNotifier m_aNotifier;
74 };
75 
76 //
77 
78 class BasicLibBox : public DocListenerBox
79 {
80 private:
81 	String			aCurText;
82 	sal_Bool			bIgnoreSelect;
83 	sal_Bool			bFillBox;
84     com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
85 
86 	void			ReleaseFocus();
87     void            InsertEntries( const ScriptDocument& rDocument, LibraryLocation eLocation );
88 
89     void            ClearBox();
90 	void			NotifyIDE();
91 
92     // DocListenerBox
93 	virtual void	FillBox();
94 
95 protected:
96 	virtual void 	Select();
97 	virtual long	PreNotify( NotifyEvent& rNEvt );
98 
99 public:
100                     BasicLibBox( Window* pParent,
101                                  const com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame );
102 					~BasicLibBox();
103 
104 	using			Window::Update;
105 	void			Update( const SfxStringItem* pItem );
106 };
107 
108 class LanguageBoxControl: public SfxToolBoxControl
109 {
110 public:
111 						SFX_DECL_TOOLBOX_CONTROL();
112 
113 						LanguageBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
114 						~LanguageBoxControl();
115 
116 	virtual void		StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
117 	virtual Window*		CreateItemWindow( Window *pParent );
118 };
119 
120 class BasicLanguageBox : public DocListenerBox
121 {
122 private:
123 	String			m_sNotLocalizedStr;
124 	String			m_sDefaultLanguageStr;
125 	String			m_sCurrentText;
126 
127 	bool			m_bIgnoreSelect;
128 
129     void            ClearBox();
130 	void			SetLanguage();
131 
132     // DocListenerBox
133 	virtual void	FillBox();
134 
135 protected:
136 	virtual void 	Select();
137 	virtual long	PreNotify( NotifyEvent& rNEvt );
138 
139 public:
140     BasicLanguageBox( Window* pParent );
141 	~BasicLanguageBox();
142 
143 	using			Window::Update;
144 	void			Update( const SfxStringItem* pItem );
145 };
146 
147 #endif	// _BASICBOX_HXX
148 
149