xref: /trunk/main/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx (revision bfaba8a2bfbeecb976bed59dc67e51a3365db0fb)
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 #ifndef SVX_SIDEBAR_PARA_PROPERTY_PANEL_HXX
23 #define SVX_SIDEBAR_PARA_PROPERTY_PANEL_HXX
24 
25 #include <vcl/ctrl.hxx>
26 #include <sfx2/sidebar/ControllerItem.hxx>
27 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
28 #include <editeng/lspcitem.hxx>
29 #include <svtools/ctrlbox.hxx>
30 #include <svx/tbxcolorupdate.hxx>
31 #include <svx/relfld.hxx>
32 #include <editeng/svxenum.hxx>
33 #include <editeng/fhgtitem.hxx>
34 
35 #include <com/sun/star/frame/XFrame.hpp>
36 #include <com/sun/star/ui/XSidebar.hpp>
37 
38 #include <boost/scoped_ptr.hpp>
39 
40 #include <svx/sidebar/ColorPopup.hxx>
41 #include <vcl/vclenum.hxx>
42 #include <vcl/fixed.hxx>
43 #include <svl/poolitem.hxx>
44 #include <tools/fldunit.hxx>
45 
46 #include "ParaBulletsPopup.hxx"
47 #include "ParaNumberingPopup.hxx"
48 #include "ParaLineSpacingPopup.hxx"
49 
50 class FloatingWindow;
51 class ToolBox;
52 
53 namespace css = ::com::sun::star;
54 namespace cssu = ::com::sun::star::uno;
55 
56 
57 namespace svx { namespace sidebar {
58 
59 class PopupControl;
60 class PopupContainer;
61 
62 class ParaPropertyPanel
63     : public Control,
64       public ::sfx2::sidebar::IContextChangeReceiver,
65       public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
66 {
67 public:
68     static ParaPropertyPanel* Create (
69         Window* pParent,
70         const cssu::Reference<css::frame::XFrame>& rxFrame,
71         SfxBindings* pBindings,
72         const cssu::Reference<css::ui::XSidebar>& rxSidebar);
73 
74     virtual void DataChanged (const DataChangedEvent& rEvent);
75     SfxBindings* GetBindings();
76 
77     virtual void HandleContextChange (
78         const ::sfx2::sidebar::EnumContext aContext);
79 
80     virtual void NotifyItemUpdate(
81         const sal_uInt16 nSId,
82         const SfxItemState eState,
83         const SfxPoolItem* pState);
84 
85     void ShowMenu (void);
86     sal_uInt16 GetBulletTypeIndex(){ return mnBulletTypeIndex; }
87     void SetBulletTypeIndex(sal_uInt16 nInd){ mnBulletTypeIndex = nInd; }
88     sal_uInt16 GetNumTypeIndex(){ return mnNumTypeIndex; }
89     void SetNumTypeIndex(sal_uInt16 nInd){ mnNumTypeIndex = nInd; }
90     FieldUnit GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState );
91 
92     void EndSpacingPopupMode (void);
93     void EndBulletsPopupMode (void);
94     void EndNumberingPopupMode (void);
95 
96 private:
97     /**********************************************************
98      **
99      ** UI controls
100      **
101     ***********************************************************/
102     //Alignment
103     ::boost::scoped_ptr<Window>             maAlignToolBoxBackground;
104     ::boost::scoped_ptr<ToolBox>            maAlignToolBox;
105     ::boost::scoped_ptr<Window>             maTBxVertAlignBackground;
106     ::boost::scoped_ptr<ToolBox>            maTBxVertAlign;
107     //NumBullet&Backcolor
108     ::boost::scoped_ptr<Window>             maTBxNumBulletBackground;
109     ::boost::scoped_ptr<ToolBox>            maTBxNumBullet;
110     ::boost::scoped_ptr<Window>             maTBxBackColorBackground;
111     ::boost::scoped_ptr<ToolBox>            maTBxBackColor;
112     //Paragraph spacing
113     ::boost::scoped_ptr<FixedText>          maFTUL;
114     ::boost::scoped_ptr<Window>             maTbxUL_IncDecBackground;
115     ::boost::scoped_ptr<ToolBox>            maTbxUL_IncDec;
116     ::boost::scoped_ptr<SvxRelativeField>   maTopDist;
117     ::boost::scoped_ptr<SvxRelativeField>   maBottomDist;
118     //Line spacing
119     ::boost::scoped_ptr<Window>             maLineSPTbxBackground;
120     ::boost::scoped_ptr<ToolBox>            maLineSPTbx;
121     //Indent
122     ::boost::scoped_ptr<FixedText>          maFTIndent;
123     ::boost::scoped_ptr<Window>             maTbxIndent_IncDecBackground;
124     ::boost::scoped_ptr<ToolBox>            maTbxIndent_IncDec;
125     ::boost::scoped_ptr<Window>             maTbxProDemoteBackground;
126     ::boost::scoped_ptr<ToolBox>            maTbxProDemote;
127     ::boost::scoped_ptr<SvxRelativeField>   maLeftIndent;
128     ::boost::scoped_ptr<SvxRelativeField>   maRightIndent;
129     ::boost::scoped_ptr<SvxRelativeField>   maFLineIndent;
130     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > mpColorUpdater;
131 
132     /**********************************************************
133      **
134      ** Resources
135      **
136     ***********************************************************/
137     FixedImage  maFISpace1;
138     FixedImage  maFISpace2;
139     FixedImage  maFIndent1;
140     FixedImage  maFIndent2;
141     FixedImage  maFIndent3;
142 
143     Image  maSpace1;
144     Image  maSpace2;
145     Image  maSpace3;
146     Image  maIndent1;
147     Image  maIndent2;
148     Image  maIndent3;
149 
150     Image  maLeftPara;
151     Image  maCentPara;
152     Image  maRightPara;
153     Image  maJusPara;
154 
155     Image  maIndInc;
156     Image  maIndDec;
157     Image  maIndInc_BD;
158     Image  maIndDec_BD;
159     Image  maIndHang;
160     Image  maParInc;
161     Image  maParDec;
162 
163     ImageList   maVertImageList;
164     ImageList   maVertImageListH;
165     ImageList   maNumBImageList;
166     ImageList   maNumBImageListH;
167     ImageList   maNumBImageListRTL;
168     Image       maImgBackColorHigh;
169     Image       maImgBackColor;
170 
171     /****************************************************************
172     **
173     ** Data Member
174     **
175     *****************************************************************/
176     long                maTxtLeft;
177     //Line spacing
178     SvxLineSpacingItem  *mpLnSPItem;
179     SfxItemState            meLnSpState;
180     bool                    mbOutLineLeft;
181     bool                    mbOutLineRight;
182     long                    maUpper;
183     long                    maLower;
184 
185     sal_uInt16          mnBulletTypeIndex;
186     sal_uInt16          mnNumTypeIndex;
187     Color               maColor;
188     bool                    mbColorAvailable;
189     FieldUnit                       m_eMetricUnit;
190     FieldUnit                       m_last_eMetricUnit;
191     SfxMapUnit                      m_eLRSpaceUnit;
192     SfxMapUnit                      m_eULSpaceUnit;
193     /****************************************************************
194     **
195     ** Controll Items
196     **
197     *****************************************************************/
198 
199     ::sfx2::sidebar::ControllerItem  maLeftAlignControl;
200     ::sfx2::sidebar::ControllerItem  maCenterAlignControl;
201     ::sfx2::sidebar::ControllerItem  maRightAlignControl;
202     ::sfx2::sidebar::ControllerItem  maJustifyAlignControl;
203     ::sfx2::sidebar::ControllerItem  maLRSpaceControl;
204     ::sfx2::sidebar::ControllerItem  maLNSpaceControl;
205     ::sfx2::sidebar::ControllerItem  maULSpaceControl;
206     ::sfx2::sidebar::ControllerItem  maOutLineLeftControl;
207     ::sfx2::sidebar::ControllerItem  maOutLineRightControl;
208     ::sfx2::sidebar::ControllerItem  maDecIndentControl;
209     ::sfx2::sidebar::ControllerItem  maIncIndentControl;
210     ::sfx2::sidebar::ControllerItem  maVertTop;
211     ::sfx2::sidebar::ControllerItem  maVertCenter;
212     ::sfx2::sidebar::ControllerItem  maVertBottom;
213     ::sfx2::sidebar::ControllerItem  maBulletOnOff;
214     ::sfx2::sidebar::ControllerItem  maNumberOnOff;
215     ::sfx2::sidebar::ControllerItem  maBackColorControl;
216     ::sfx2::sidebar::ControllerItem  m_aMetricCtl;
217     ::sfx2::sidebar::ControllerItem  maBulletNumRuleIndex;
218     ::sfx2::sidebar::ControllerItem  maNumNumRuleIndex;
219 
220     ::sfx2::sidebar::EnumContext maContext;
221     SfxBindings* mpBindings;
222     ParaLineSpacingPopup maLineSpacePopup;
223     ParaBulletsPopup maBulletsPopup;
224     ParaNumberingPopup maNumberingPopup;
225     ColorPopup maBGColorPopup;
226     cssu::Reference<css::ui::XSidebar> mxSidebar;
227 
228 
229     ParaPropertyPanel (
230         Window* pParent,
231         const cssu::Reference<css::frame::XFrame>& rxFrame,
232         SfxBindings* pBindings,
233         const cssu::Reference<css::ui::XSidebar>& rxSidebar);
234     virtual ~ParaPropertyPanel (void);
235 
236     void InitImageList(::boost::scoped_ptr<ToolBox>& rTbx, ImageList& rImglst, ImageList& rImgHlst);
237 
238     DECL_LINK(AlignStyleModifyHdl_Impl, ToolBox*);
239     DECL_LINK(VertTbxSelectHandler, ToolBox*);
240     DECL_LINK(NumBTbxSelectHandler, ToolBox*);
241     DECL_LINK(ModifyIndentHdl_Impl, SvxRelativeField*);
242     DECL_LINK(ClickIndent_IncDec_Hdl_Impl, ToolBox*);
243     DECL_LINK(ClickProDemote_Hdl_Impl, ToolBox*);
244     DECL_LINK(ULSpaceHdl_Impl, SvxRelativeField*);
245     DECL_LINK(ClickUL_IncDec_Hdl_Impl, ToolBox*);
246     DECL_LINK(ImplPopupModeEndHdl, FloatingWindow* );
247 
248     void VertStateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState);
249     void ParaBKGStateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState);
250     void StateChangedAlignmentImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
251     void StateChangedIndentImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
252     void StateChangedLnSPImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
253     void StateChangedULImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
254     void StateChangeOutLineImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
255     void StateChangeIncDecImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
256     // Add toggle state for numbering and bullet icons
257     void StateChangeBulletNumImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
258     //Modified for Numbering&Bullets Dialog UX Enh
259     //Handing the transferred the num rule index data of the current selection
260     void StateChangeBulletNumRuleImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
261 
262     void initial();
263     void ReSize(bool bSize);
264 
265 
266     PopupControl* CreateLineSpacingControl (PopupContainer* pParent);
267     PopupControl* CreateBulletsPopupControl (PopupContainer* pParent);
268     PopupControl* CreateNumberingPopupControl (PopupContainer* pParent);
269     PopupControl* CreateBGColorPopupControl (PopupContainer* pParent);
270     DECL_LINK(ClickLineSPDropDownHdl_Impl, ToolBox*);
271     DECL_LINK(NumBTbxDDHandler, ToolBox*);
272     DECL_LINK(ToolBoxBackColorDDHandler, ToolBox *);
273 
274     void SetupIcons (void);
275     void InitToolBoxAlign();
276     void InitToolBoxVertAlign();
277     void InitToolBoxIndent();
278     void InitToolBoxBGColor();
279     void InitToolBoxBulletsNumbering();
280     void InitToolBoxSpacing();
281     void InitToolBoxLineSpacing();
282 
283     Color GetBGColor (void) const;
284     void SetBGColor (const String& rsColorName, const Color aColor);
285 };
286 
287 } } // end of namespace ::svx::sidebar
288 
289 #endif
290 
291