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 <sfx2/sidebar/GridLayouter.hxx>
29 #include <editeng/lspcitem.hxx>
30 #include <svtools/ctrlbox.hxx>
31 #include <svx/tbxcolorupdate.hxx>
32 #include <svx/relfld.hxx>
33 #include <editeng/svxenum.hxx>
34 #include <editeng/fhgtitem.hxx>
35 
36 #include <com/sun/star/frame/XFrame.hpp>
37 #include <com/sun/star/ui/XSidebar.hpp>
38 
39 #include <boost/scoped_ptr.hpp>
40 
41 #include <svx/sidebar/ColorPopup.hxx>
42 #include <vcl/vclenum.hxx>
43 #include <vcl/fixed.hxx>
44 #include <svl/poolitem.hxx>
45 #include <tools/fldunit.hxx>
46 
47 #include "ParaBulletsPopup.hxx"
48 #include "ParaNumberingPopup.hxx"
49 #include "ParaLineSpacingPopup.hxx"
50 
51 class FloatingWindow;
52 class ToolBox;
53 
54 namespace css = ::com::sun::star;
55 namespace cssu = ::com::sun::star::uno;
56 
57 
58 namespace svx { namespace sidebar {
59 
60 class PopupControl;
61 class PopupContainer;
62 
63 class ParaPropertyPanel
64     : public Control,
65       public ::sfx2::sidebar::IContextChangeReceiver,
66       public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
67 {
68 public:
69     static ParaPropertyPanel* Create (
70         Window* pParent,
71         const cssu::Reference<css::frame::XFrame>& rxFrame,
72         SfxBindings* pBindings,
73         const cssu::Reference<css::ui::XSidebar>& rxSidebar);
74 
75 	virtual void DataChanged (const DataChangedEvent& rEvent);
76 	SfxBindings* GetBindings();
77 
78 	virtual void HandleContextChange (
79 	    const ::sfx2::sidebar::EnumContext aContext);
80 
81 	virtual void NotifyItemUpdate(
82 	    const sal_uInt16 nSId,
83 	    const SfxItemState eState,
84 	    const SfxPoolItem* pState,
85         const bool bIsEnabled);
86 
87 	void ShowMenu (void);
GetBulletTypeIndex()88 	sal_uInt16 GetBulletTypeIndex(){ return mnBulletTypeIndex; }
GetNumTypeIndex()89 	sal_uInt16 GetNumTypeIndex(){ return mnNumTypeIndex; }
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> 			mpAlignToolBoxBackground;
104 	::boost::scoped_ptr<ToolBox>			mpAlignToolBox;
105 	::boost::scoped_ptr<Window> 			mpTBxVertAlignBackground;
106 	::boost::scoped_ptr<ToolBox>			mpTBxVertAlign;
107 	//NumBullet&Backcolor
108 	::boost::scoped_ptr<Window> 			mpTBxNumBulletBackground;
109 	::boost::scoped_ptr<ToolBox>			mpTBxNumBullet;
110 	::boost::scoped_ptr<Window> 			mpTBxBackColorBackground;
111 	::boost::scoped_ptr<ToolBox>			mpTBxBackColor;
112 	//Paragraph spacing
113 	::boost::scoped_ptr<FixedText>			mpFTUL;
114 	::boost::scoped_ptr<Window> 			mpTbxUL_IncDecBackground;
115 	::boost::scoped_ptr<ToolBox>			mpTbxUL_IncDec;
116     ::boost::scoped_ptr<SvxRelativeField>	mpTopDist;
117 	::boost::scoped_ptr<SvxRelativeField>	mpBottomDist;
118 	::boost::scoped_ptr<Window> 			mpLineSPTbxBackground;
119 	::boost::scoped_ptr<ToolBox>			mpLineSPTbx;
120     ::boost::scoped_ptr<FixedText>			mpFTIndent;
121 	::boost::scoped_ptr<Window> 			mpTbxIndent_IncDecBackground;
122 	::boost::scoped_ptr<ToolBox>			mpTbxIndent_IncDec;
123 	::boost::scoped_ptr<Window> 			mpTbxProDemoteBackground;
124 	::boost::scoped_ptr<ToolBox>			mpTbxProDemote;
125     ::boost::scoped_ptr<SvxRelativeField>	mpLeftIndent;
126     ::boost::scoped_ptr<SvxRelativeField>	mpRightIndent;
127 	::boost::scoped_ptr<SvxRelativeField>	mpFLineIndent;
128 
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  maIndHang;
150 
151 	ImageList	maNumBImageList;
152 	ImageList	maNumBImageListH;
153 	ImageList	maNumBImageListRTL;
154 	Image		maImgBackColorHigh;
155 	Image		maImgBackColor;
156 
157 	/****************************************************************
158 	**
159 	** Data Member
160 	**
161 	*****************************************************************/
162 	long				maTxtLeft;
163 	//Line spacing
164 	SvxLineSpacingItem	*mpLnSPItem;
165 	SfxItemState			meLnSpState;
166 	bool					mbOutLineLeft;
167 	bool					mbOutLineRight;
168 	long					maUpper;
169 	long					maLower;
170 
171 	sal_uInt16			mnBulletTypeIndex;
172 	sal_uInt16			mnNumTypeIndex;
173 	Color				maColor;
174 	bool					mbColorAvailable;
175 	FieldUnit						m_eMetricUnit;
176 	FieldUnit						m_last_eMetricUnit;
177 	SfxMapUnit                      m_eLRSpaceUnit;
178 	SfxMapUnit                      m_eULSpaceUnit;
179 	/****************************************************************
180 	**
181 	** Control Items
182 	**
183 	*****************************************************************/
184 
185 	::sfx2::sidebar::ControllerItem  maLeftAlignControl;
186 	::sfx2::sidebar::ControllerItem  maCenterAlignControl;
187 	::sfx2::sidebar::ControllerItem  maRightAlignControl;
188 	::sfx2::sidebar::ControllerItem  maJustifyAlignControl;
189 	::sfx2::sidebar::ControllerItem  maLRSpaceControl;
190 	::sfx2::sidebar::ControllerItem  maLNSpaceControl;
191 	::sfx2::sidebar::ControllerItem  maULSpaceControl;
192 	::sfx2::sidebar::ControllerItem  maOutLineLeftControl;
193 	::sfx2::sidebar::ControllerItem  maOutLineRightControl;
194 	::sfx2::sidebar::ControllerItem  maDecIndentControl;
195 	::sfx2::sidebar::ControllerItem  maIncIndentControl;
196 	::sfx2::sidebar::ControllerItem  maVertTop;
197 	::sfx2::sidebar::ControllerItem  maVertCenter;
198 	::sfx2::sidebar::ControllerItem  maVertBottom;
199 	::sfx2::sidebar::ControllerItem  maBulletOnOff;
200 	::sfx2::sidebar::ControllerItem  maNumberOnOff;
201 	::sfx2::sidebar::ControllerItem  maBackColorControl;
202 	::sfx2::sidebar::ControllerItem  m_aMetricCtl;
203 	::sfx2::sidebar::ControllerItem  maBulletNumRuleIndex;
204 	::sfx2::sidebar::ControllerItem  maNumNumRuleIndex;
205 
206     cssu::Reference<css::frame::XFrame> mxFrame;
207     ::sfx2::sidebar::EnumContext maContext;
208     SfxBindings* mpBindings;
209 	ParaLineSpacingPopup maLineSpacePopup;
210 	ParaBulletsPopup maBulletsPopup;
211 	ParaNumberingPopup maNumberingPopup;
212 	ColorPopup maBGColorPopup;
213     cssu::Reference<css::ui::XSidebar> mxSidebar;
214     ::sfx2::sidebar::GridLayouter maLayouter;
215 
216     ParaPropertyPanel (
217         Window* pParent,
218         const cssu::Reference<css::frame::XFrame>& rxFrame,
219         SfxBindings* pBindings,
220         const cssu::Reference<css::ui::XSidebar>& rxSidebar);
221 	virtual ~ParaPropertyPanel (void);
222 
223 	void InitImageList(::boost::scoped_ptr<ToolBox>& rTbx, ImageList& rImglst, ImageList& rImgHlst);
224 
225 	DECL_LINK(AlignStyleModifyHdl_Impl, ToolBox*);
226 	DECL_LINK(VertTbxSelectHandler, ToolBox*);
227 	DECL_LINK(NumBTbxSelectHandler, ToolBox*);
228 	DECL_LINK(ModifyIndentHdl_Impl, SvxRelativeField*);
229 	DECL_LINK(ClickIndent_IncDec_Hdl_Impl, ToolBox*);
230 	DECL_LINK(ClickProDemote_Hdl_Impl, ToolBox*);
231 	DECL_LINK(ULSpaceHdl_Impl, SvxRelativeField*);
232 	DECL_LINK(ClickUL_IncDec_Hdl_Impl, ToolBox*);
233 	DECL_LINK(ImplPopupModeEndHdl, FloatingWindow* );
234 
235 	void VertStateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState);
236 	void ParaBKGStateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState);
237 	void StateChangedAlignmentImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
238 	void StateChangedIndentImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
239 	void StateChangedLnSPImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
240 	void StateChangedULImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
241 	void StateChangeOutLineImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
242 	void StateChangeIncDecImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
243 	// Add toggle state for numbering and bullet icons
244 	void StateChangeBulletNumImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
245 	//Modified for Numbering&Bullets Dialog UX Enh
246 	//Handing the transferred the num rule index data of the current selection
247 	void StateChangeBulletNumRuleImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
248 
249 	void initial();
250 	void ReSize(bool bSize);
251 
252     // Inherited from vcl Window.
253     virtual void Resize (void);
254 
255 	PopupControl* CreateLineSpacingControl (PopupContainer* pParent);
256 	PopupControl* CreateBulletsPopupControl (PopupContainer* pParent);
257 	PopupControl* CreateNumberingPopupControl (PopupContainer* pParent);
258 	PopupControl* CreateBGColorPopupControl (PopupContainer* pParent);
259 	DECL_LINK(ClickLineSPDropDownHdl_Impl, ToolBox*);
260 	DECL_LINK(NumBTbxDDHandler, ToolBox*);
261 	DECL_LINK(ToolBoxBackColorDDHandler, ToolBox *);
262 
263 	void InitToolBoxAlign();
264 	void InitToolBoxVertAlign();
265 	void InitToolBoxIndent();
266 	void InitToolBoxBGColor();
267 	void InitToolBoxBulletsNumbering();
268 	void InitToolBoxSpacing();
269 	void InitToolBoxLineSpacing();
270 
271 	void SetBGColor (const String& rsColorName, const Color aColor);
272 };
273 
274 } } // end of namespace ::svx::sidebar
275 
276 #endif
277 
278