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> 			mpAlignToolBoxBackground;
103 	::boost::scoped_ptr<ToolBox>			mpAlignToolBox;
104 	::boost::scoped_ptr<Window> 			mpTBxVertAlignBackground;
105 	::boost::scoped_ptr<ToolBox>			mpTBxVertAlign;
106 	//NumBullet&Backcolor
107 	::boost::scoped_ptr<Window> 			mpTBxNumBulletBackground;
108 	::boost::scoped_ptr<ToolBox>			mpTBxNumBullet;
109 	::boost::scoped_ptr<Window> 			mpTBxBackColorBackground;
110 	::boost::scoped_ptr<ToolBox>			mpTBxBackColor;
111 	//Paragraph spacing
112 	::boost::scoped_ptr<FixedText>			mpFTUL;
113 	::boost::scoped_ptr<Window> 			mpTbxUL_IncDecBackground;
114 	::boost::scoped_ptr<ToolBox>			mpTbxUL_IncDec;
115     ::boost::scoped_ptr<SvxRelativeField>	mpTopDist;
116 	::boost::scoped_ptr<SvxRelativeField>	mpBottomDist;
117 	::boost::scoped_ptr<Window> 			mpLineSPTbxBackground;
118 	::boost::scoped_ptr<ToolBox>			mpLineSPTbx;
119     ::boost::scoped_ptr<FixedText>			mpFTIndent;
120 	::boost::scoped_ptr<Window> 			mpTbxIndent_IncDecBackground;
121 	::boost::scoped_ptr<ToolBox>			mpTbxIndent_IncDec;
122 	::boost::scoped_ptr<Window> 			mpTbxProDemoteBackground;
123 	::boost::scoped_ptr<ToolBox>			mpTbxProDemote;
124     ::boost::scoped_ptr<SvxRelativeField>	mpLeftIndent;
125     ::boost::scoped_ptr<SvxRelativeField>	mpRightIndent;
126 	::boost::scoped_ptr<SvxRelativeField>	mpFLineIndent;
127 
128 	::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > mpColorUpdater;
129 
130 	/**********************************************************
131 	 **
132 	 ** Resources
133 	 **
134 	***********************************************************/
135 	FixedImage  maFISpace1;
136 	FixedImage  maFISpace2;
137 	FixedImage  maFIndent1;
138 	FixedImage  maFIndent2;
139 	FixedImage  maFIndent3;
140 
141 	Image  maSpace1;
142 	Image  maSpace2;
143 	Image  maSpace3;
144 	Image  maIndent1;
145 	Image  maIndent2;
146 	Image  maIndent3;
147 
148 	Image  maIndHang;
149 
150 	ImageList	maNumBImageList;
151 	ImageList	maNumBImageListH;
152 	ImageList	maNumBImageListRTL;
153 	Image		maImgBackColorHigh;
154 	Image		maImgBackColor;
155 
156 	/****************************************************************
157 	**
158 	** Data Member
159 	**
160 	*****************************************************************/
161 	long				maTxtLeft;
162 	//Line spacing
163 	SvxLineSpacingItem	*mpLnSPItem;
164 	SfxItemState			meLnSpState;
165 	bool					mbOutLineLeft;
166 	bool					mbOutLineRight;
167 	long					maUpper;
168 	long					maLower;
169 
170 	sal_uInt16			mnBulletTypeIndex;
171 	sal_uInt16			mnNumTypeIndex;
172 	Color				maColor;
173 	bool					mbColorAvailable;
174 	FieldUnit						m_eMetricUnit;
175 	FieldUnit						m_last_eMetricUnit;
176 	SfxMapUnit                      m_eLRSpaceUnit;
177 	SfxMapUnit                      m_eULSpaceUnit;
178 	/****************************************************************
179 	**
180 	** Controll Items
181 	**
182 	*****************************************************************/
183 
184 	::sfx2::sidebar::ControllerItem  maLeftAlignControl;
185 	::sfx2::sidebar::ControllerItem  maCenterAlignControl;
186 	::sfx2::sidebar::ControllerItem  maRightAlignControl;
187 	::sfx2::sidebar::ControllerItem  maJustifyAlignControl;
188 	::sfx2::sidebar::ControllerItem  maLRSpaceControl;
189 	::sfx2::sidebar::ControllerItem  maLNSpaceControl;
190 	::sfx2::sidebar::ControllerItem  maULSpaceControl;
191 	::sfx2::sidebar::ControllerItem  maOutLineLeftControl;
192 	::sfx2::sidebar::ControllerItem  maOutLineRightControl;
193 	::sfx2::sidebar::ControllerItem  maDecIndentControl;
194 	::sfx2::sidebar::ControllerItem  maIncIndentControl;
195 	::sfx2::sidebar::ControllerItem  maVertTop;
196 	::sfx2::sidebar::ControllerItem  maVertCenter;
197 	::sfx2::sidebar::ControllerItem  maVertBottom;
198 	::sfx2::sidebar::ControllerItem  maBulletOnOff;
199 	::sfx2::sidebar::ControllerItem  maNumberOnOff;
200 	::sfx2::sidebar::ControllerItem  maBackColorControl;
201 	::sfx2::sidebar::ControllerItem  m_aMetricCtl;
202 	::sfx2::sidebar::ControllerItem  maBulletNumRuleIndex;
203 	::sfx2::sidebar::ControllerItem  maNumNumRuleIndex;
204 
205     cssu::Reference<css::frame::XFrame> mxFrame;
206     ::sfx2::sidebar::EnumContext maContext;
207     SfxBindings* mpBindings;
208 	ParaLineSpacingPopup maLineSpacePopup;
209 	ParaBulletsPopup maBulletsPopup;
210 	ParaNumberingPopup maNumberingPopup;
211 	ColorPopup maBGColorPopup;
212     cssu::Reference<css::ui::XSidebar> mxSidebar;
213 
214 
215     ParaPropertyPanel (
216         Window* pParent,
217         const cssu::Reference<css::frame::XFrame>& rxFrame,
218         SfxBindings* pBindings,
219         const cssu::Reference<css::ui::XSidebar>& rxSidebar);
220 	virtual ~ParaPropertyPanel (void);
221 
222 	void InitImageList(::boost::scoped_ptr<ToolBox>& rTbx, ImageList& rImglst, ImageList& rImgHlst);
223 
224 	DECL_LINK(AlignStyleModifyHdl_Impl, ToolBox*);
225 	DECL_LINK(VertTbxSelectHandler, ToolBox*);
226 	DECL_LINK(NumBTbxSelectHandler, ToolBox*);
227 	DECL_LINK(ModifyIndentHdl_Impl, SvxRelativeField*);
228 	DECL_LINK(ClickIndent_IncDec_Hdl_Impl, ToolBox*);
229 	DECL_LINK(ClickProDemote_Hdl_Impl, ToolBox*);
230 	DECL_LINK(ULSpaceHdl_Impl, SvxRelativeField*);
231 	DECL_LINK(ClickUL_IncDec_Hdl_Impl, ToolBox*);
232 	DECL_LINK(ImplPopupModeEndHdl, FloatingWindow* );
233 
234 	void VertStateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState);
235 	void ParaBKGStateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState);
236 	void StateChangedAlignmentImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
237 	void StateChangedIndentImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
238 	void StateChangedLnSPImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
239 	void StateChangedULImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
240 	void StateChangeOutLineImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
241 	void StateChangeIncDecImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
242 	// Add toggle state for numbering and bullet icons
243 	void StateChangeBulletNumImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
244 	//Modified for Numbering&Bullets Dialog UX Enh
245 	//Handing the transferred the num rule index data of the current selection
246 	void StateChangeBulletNumRuleImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
247 
248 	void initial();
249 	void ReSize(bool bSize);
250 
251 
252 	PopupControl* CreateLineSpacingControl (PopupContainer* pParent);
253 	PopupControl* CreateBulletsPopupControl (PopupContainer* pParent);
254 	PopupControl* CreateNumberingPopupControl (PopupContainer* pParent);
255 	PopupControl* CreateBGColorPopupControl (PopupContainer* pParent);
256 	DECL_LINK(ClickLineSPDropDownHdl_Impl, ToolBox*);
257 	DECL_LINK(NumBTbxDDHandler, ToolBox*);
258 	DECL_LINK(ToolBoxBackColorDDHandler, ToolBox *);
259 
260 	void InitToolBoxAlign();
261 	void InitToolBoxVertAlign();
262 	void InitToolBoxIndent();
263 	void InitToolBoxBGColor();
264 	void InitToolBoxBulletsNumbering();
265 	void InitToolBoxSpacing();
266 	void InitToolBoxLineSpacing();
267 
268 	void SetBGColor (const String& rsColorName, const Color aColor);
269 };
270 
271 } } // end of namespace ::svx::sidebar
272 
273 #endif
274 
275