xref: /trunk/main/extensions/source/bibliography/toolbar.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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 _BIB_TOOLBAR_HXX
29 #define _BIB_TOOLBAR_HXX
30 
31 #include <com/sun/star/frame/XController.hpp>
32 #include <com/sun/star/frame/XStatusListener.hpp>
33 
34 
35 #include <vcl/toolbox.hxx>
36 #include <vcl/lstbox.hxx>
37 #include <vcl/edit.hxx>
38 #include <vcl/fixed.hxx>
39 #include <svl/svarray.hxx>
40 #include <vcl/timer.hxx>
41 #include <cppuhelper/implbase1.hxx> // helper for implementations
42 
43 class BibDataManager;
44 class BibToolBar;
45 
46 class BibToolBarListener: public cppu::WeakImplHelper1 < ::com::sun::star::frame::XStatusListener>
47 {
48 private:
49 
50     sal_uInt16      nIndex;
51     rtl::OUString           aCommand;
52 
53 protected:
54 
55     BibToolBar      *pToolBar;
56 
57 public:
58 
59     BibToolBarListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId);
60     ~BibToolBarListener();
61 
62     rtl::OUString           GetCommand();
63 
64     // ::com::sun::star::lang::XEventListener
65     // we do not hold References to dispatches, so there is nothing to do on disposal
66     virtual void    SAL_CALL disposing(const ::com::sun::star::lang::EventObject& /*Source*/)
67                                             throw( ::com::sun::star::uno::RuntimeException ){};
68 
69     // ::com::sun::star::frame::XStatusListener
70     virtual void    SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
71                                             throw( ::com::sun::star::uno::RuntimeException );
72 
73 };
74 
75 class BibTBListBoxListener: public BibToolBarListener
76 {
77 public:
78 
79     BibTBListBoxListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId);
80     ~BibTBListBoxListener();
81 
82     virtual void    SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
83                                             throw( ::com::sun::star::uno::RuntimeException );
84 
85 };
86 
87 class BibTBEditListener: public BibToolBarListener
88 {
89 public:
90 
91     BibTBEditListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId);
92     ~BibTBEditListener();
93 
94     virtual void    SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
95                                             throw( ::com::sun::star::uno::RuntimeException );
96 
97 };
98 
99 class BibTBQueryMenuListener:   public BibToolBarListener
100 {
101 public:
102 
103     BibTBQueryMenuListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId);
104     ~BibTBQueryMenuListener();
105 
106     virtual void    SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
107                                             throw( ::com::sun::star::uno::RuntimeException );
108 
109 };
110 
111 
112 typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener>* BibToolBarListenerPtr;
113 SV_DECL_PTRARR_DEL( BibToolBarListenerArr, BibToolBarListenerPtr, 4, 4 )
114 
115 class BibToolBar:   public ToolBox
116 {
117     private:
118 
119         BibToolBarListenerArr   aListenerArr;
120         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >            xController;
121         Timer                   aTimer;
122 //      Timer                   aMenuTimer;
123         ImageList               aImgLst;
124         ImageList               aImgLstHC;
125         ImageList               aBigImgLst;
126         ImageList               aBigImgLstHC;
127         FixedText               aFtSource;
128         ListBox                 aLBSource;
129         FixedText               aFtQuery;
130         Edit                    aEdQuery;
131         PopupMenu               aPopupMenu;
132         sal_uInt16              nMenuId;
133         sal_uInt16              nSelMenuItem;
134         rtl::OUString           aQueryField;
135         Link                    aLayoutManager;
136         sal_Int16               nSymbolsSize;
137         sal_Int16               nOutStyle;
138 
139         BibDataManager*         pDatMan;
140         DECL_LINK( SelHdl, ListBox* );
141         DECL_LINK( SendSelHdl, Timer* );
142         DECL_LINK( MenuHdl, ToolBox* );
143         DECL_LINK( OptionsChanged_Impl, void* );
144         DECL_LINK( SettingsChanged_Impl, void* );
145 
146         void                    ApplyImageList();
147         void                    RebuildToolbar();
148 
149     protected:
150 
151         void                    DataChanged( const DataChangedEvent& rDCEvt );
152         void                    InitListener();
153         virtual void            Select();
154         virtual void            Click();
155         long                    PreNotify( NotifyEvent& rNEvt );
156 
157 
158     public:
159 
160         BibToolBar(Window* pParent, Link aLink, WinBits nStyle = WB_3DLOOK );
161         ~BibToolBar();
162 
163         void    SetXController(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > &);
164 
165         void    ClearSourceList();
166         void    UpdateSourceList(sal_Bool bFlag=sal_True);
167         void    EnableSourceList(sal_Bool bFlag=sal_True);
168         void    InsertSourceEntry(const XubString&,sal_uInt16 nPos=LISTBOX_APPEND );
169         void    SelectSourceEntry(const XubString& );
170 
171         void    EnableQuery(sal_Bool bFlag=sal_True);
172         void    SetQueryString(const XubString& );
173         void    AdjustToolBox();
174 
175         void    ClearFilterMenu();
176         sal_uInt16  InsertFilterItem(const XubString& );
177         void    SelectFilterItem(sal_uInt16 nId);
178 
179         void    statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
180                                             throw( ::com::sun::star::uno::RuntimeException );
181 
182         void    SetDatMan(BibDataManager& rDatMan) {pDatMan = &rDatMan;}
183         void    SendDispatch(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs);
184 };
185 
186 
187 
188 
189 #endif
190