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         const bool bIsEnabled);
85 
86 	void ShowMenu (void);
87 	sal_uInt16 GetBulletTypeIndex(){ return mnBulletTypeIndex; }
88 	sal_uInt16 GetNumTypeIndex(){ return mnNumTypeIndex; }
89 	FieldUnit GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState );
90 
91 	void EndSpacingPopupMode (void);
92 	void EndBulletsPopupMode (void);
93 	void EndNumberingPopupMode (void);
94 
95 private:
96 	/**********************************************************
97 	 **
98 	 ** UI controls
99 	 **
100 	***********************************************************/
101 	//Alignment
102 	::boost::scoped_ptr<Window> 			maAlignToolBoxBackground;
103 	::boost::scoped_ptr<ToolBox>			maAlignToolBox;
104 	::boost::scoped_ptr<Window> 			maTBxVertAlignBackground;
105 	::boost::scoped_ptr<ToolBox>			maTBxVertAlign;
106 	//NumBullet&Backcolor
107 	::boost::scoped_ptr<Window> 			maTBxNumBulletBackground;
108 	::boost::scoped_ptr<ToolBox>			maTBxNumBullet;
109 	::boost::scoped_ptr<Window> 			maTBxBackColorBackground;
110 	::boost::scoped_ptr<ToolBox>			maTBxBackColor;
111 	//Paragraph spacing
112 	::boost::scoped_ptr<FixedText>			maFTUL;
113 	::boost::scoped_ptr<Window> 			maTbxUL_IncDecBackground;
114 	::boost::scoped_ptr<ToolBox>			maTbxUL_IncDec;
115 	::boost::scoped_ptr<SvxRelativeField>	maTopDist;
116 	::boost::scoped_ptr<SvxRelativeField>	maBottomDist;
117 	//Line spacing
118 	::boost::scoped_ptr<Window> 			maLineSPTbxBackground;
119 	::boost::scoped_ptr<ToolBox>			maLineSPTbx;
120 	//Indent
121 	::boost::scoped_ptr<FixedText>			maFTIndent;
122 	::boost::scoped_ptr<Window> 			maTbxIndent_IncDecBackground;
123 	::boost::scoped_ptr<ToolBox>			maTbxIndent_IncDec;
124 	::boost::scoped_ptr<Window> 			maTbxProDemoteBackground;
125 	::boost::scoped_ptr<ToolBox>			maTbxProDemote;
126 	::boost::scoped_ptr<SvxRelativeField>	maLeftIndent;
127 	::boost::scoped_ptr<SvxRelativeField>	maRightIndent;
128 	::boost::scoped_ptr<SvxRelativeField>	maFLineIndent;
129 	::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > mpColorUpdater;
130 
131 	/**********************************************************
132 	 **
133 	 ** Resources
134 	 **
135 	***********************************************************/
136 	FixedImage  maFISpace1;
137 	FixedImage  maFISpace2;
138 	FixedImage  maFIndent1;
139 	FixedImage  maFIndent2;
140 	FixedImage  maFIndent3;
141 
142 	Image  maSpace1;
143 	Image  maSpace2;
144 	Image  maSpace3;
145 	Image  maIndent1;
146 	Image  maIndent2;
147 	Image  maIndent3;
148 
149 	Image  maLeftPara;
150 	Image  maCentPara;
151 	Image  maRightPara;
152 	Image  maJusPara;
153 
154 	Image  maIndInc;
155 	Image  maIndDec;
156 	Image  maIndInc_BD;
157 	Image  maIndDec_BD;
158 	Image  maIndHang;
159 	Image  maParInc;
160 	Image  maParDec;
161 
162 	ImageList	maVertImageList;
163 	ImageList	maVertImageListH;
164 	ImageList	maNumBImageList;
165 	ImageList	maNumBImageListH;
166 	ImageList	maNumBImageListRTL;
167 	Image		maImgBackColorHigh;
168 	Image		maImgBackColor;
169 
170 	/****************************************************************
171 	**
172 	** Data Member
173 	**
174 	*****************************************************************/
175 	long				maTxtLeft;
176 	//Line spacing
177 	SvxLineSpacingItem	*mpLnSPItem;
178 	SfxItemState			meLnSpState;
179 	bool					mbOutLineLeft;
180 	bool					mbOutLineRight;
181 	long					maUpper;
182 	long					maLower;
183 
184 	sal_uInt16			mnBulletTypeIndex;
185 	sal_uInt16			mnNumTypeIndex;
186 	Color				maColor;
187 	bool					mbColorAvailable;
188 	FieldUnit						m_eMetricUnit;
189 	FieldUnit						m_last_eMetricUnit;
190 	SfxMapUnit                      m_eLRSpaceUnit;
191 	SfxMapUnit                      m_eULSpaceUnit;
192 	/****************************************************************
193 	**
194 	** Controll Items
195 	**
196 	*****************************************************************/
197 
198 	::sfx2::sidebar::ControllerItem  maLeftAlignControl;
199 	::sfx2::sidebar::ControllerItem  maCenterAlignControl;
200 	::sfx2::sidebar::ControllerItem  maRightAlignControl;
201 	::sfx2::sidebar::ControllerItem  maJustifyAlignControl;
202 	::sfx2::sidebar::ControllerItem  maLRSpaceControl;
203 	::sfx2::sidebar::ControllerItem  maLNSpaceControl;
204 	::sfx2::sidebar::ControllerItem  maULSpaceControl;
205 	::sfx2::sidebar::ControllerItem  maOutLineLeftControl;
206 	::sfx2::sidebar::ControllerItem  maOutLineRightControl;
207 	::sfx2::sidebar::ControllerItem  maDecIndentControl;
208 	::sfx2::sidebar::ControllerItem  maIncIndentControl;
209 	::sfx2::sidebar::ControllerItem  maVertTop;
210 	::sfx2::sidebar::ControllerItem  maVertCenter;
211 	::sfx2::sidebar::ControllerItem  maVertBottom;
212 	::sfx2::sidebar::ControllerItem  maBulletOnOff;
213 	::sfx2::sidebar::ControllerItem  maNumberOnOff;
214 	::sfx2::sidebar::ControllerItem  maBackColorControl;
215 	::sfx2::sidebar::ControllerItem  m_aMetricCtl;
216 	::sfx2::sidebar::ControllerItem  maBulletNumRuleIndex;
217 	::sfx2::sidebar::ControllerItem  maNumNumRuleIndex;
218 
219 	//i122166, the icons for numbering or bullets toolbox inside toolbar and sidebar should be the same one
220 	cssu::Reference<css::frame::XFrame> mxFrame;
221 	//End of i122166
222     ::sfx2::sidebar::EnumContext maContext;
223     SfxBindings* mpBindings;
224 	ParaLineSpacingPopup maLineSpacePopup;
225 	ParaBulletsPopup maBulletsPopup;
226 	ParaNumberingPopup maNumberingPopup;
227 	ColorPopup maBGColorPopup;
228     cssu::Reference<css::ui::XSidebar> mxSidebar;
229 
230 
231     ParaPropertyPanel (
232         Window* pParent,
233         const cssu::Reference<css::frame::XFrame>& rxFrame,
234         SfxBindings* pBindings,
235         const cssu::Reference<css::ui::XSidebar>& rxSidebar);
236 	virtual ~ParaPropertyPanel (void);
237 
238 	void InitImageList(::boost::scoped_ptr<ToolBox>& rTbx, ImageList& rImglst, ImageList& rImgHlst);
239 
240 	DECL_LINK(AlignStyleModifyHdl_Impl, ToolBox*);
241 	DECL_LINK(VertTbxSelectHandler, ToolBox*);
242 	DECL_LINK(NumBTbxSelectHandler, ToolBox*);
243 	DECL_LINK(ModifyIndentHdl_Impl, SvxRelativeField*);
244 	DECL_LINK(ClickIndent_IncDec_Hdl_Impl, ToolBox*);
245 	DECL_LINK(ClickProDemote_Hdl_Impl, ToolBox*);
246 	DECL_LINK(ULSpaceHdl_Impl, SvxRelativeField*);
247 	DECL_LINK(ClickUL_IncDec_Hdl_Impl, ToolBox*);
248 	DECL_LINK(ImplPopupModeEndHdl, FloatingWindow* );
249 
250 	void VertStateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState);
251 	void ParaBKGStateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState);
252 	void StateChangedAlignmentImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
253 	void StateChangedIndentImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
254 	void StateChangedLnSPImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
255 	void StateChangedULImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
256 	void StateChangeOutLineImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
257 	void StateChangeIncDecImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
258 	// Add toggle state for numbering and bullet icons
259 	void StateChangeBulletNumImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
260 	//Modified for Numbering&Bullets Dialog UX Enh
261 	//Handing the transferred the num rule index data of the current selection
262 	void StateChangeBulletNumRuleImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
263 
264 	void initial();
265 	void ReSize(bool bSize);
266 
267 
268 	PopupControl* CreateLineSpacingControl (PopupContainer* pParent);
269 	PopupControl* CreateBulletsPopupControl (PopupContainer* pParent);
270 	PopupControl* CreateNumberingPopupControl (PopupContainer* pParent);
271 	PopupControl* CreateBGColorPopupControl (PopupContainer* pParent);
272 	DECL_LINK(ClickLineSPDropDownHdl_Impl, ToolBox*);
273 	DECL_LINK(NumBTbxDDHandler, ToolBox*);
274 	DECL_LINK(ToolBoxBackColorDDHandler, ToolBox *);
275 
276 	void SetupIcons (void);
277 	void InitToolBoxAlign();
278 	void InitToolBoxVertAlign();
279 	void InitToolBoxIndent();
280 	void InitToolBoxBGColor();
281 	void InitToolBoxBulletsNumbering();
282 	void InitToolBoxSpacing();
283 	void InitToolBoxLineSpacing();
284 
285 	void SetBGColor (const String& rsColorName, const Color aColor);
286 };
287 
288 } } // end of namespace ::svx::sidebar
289 
290 #endif
291 
292