1*766ce4d0SZheng Fan /**************************************************************
2*766ce4d0SZheng Fan  *
3*766ce4d0SZheng Fan  * Licensed to the Apache Software Foundation (ASF) under one
4*766ce4d0SZheng Fan  * or more contributor license agreements.  See the NOTICE file
5*766ce4d0SZheng Fan  * distributed with this work for additional information
6*766ce4d0SZheng Fan  * regarding copyright ownership.  The ASF licenses this file
7*766ce4d0SZheng Fan  * to you under the Apache License, Version 2.0 (the
8*766ce4d0SZheng Fan  * "License"); you may not use this file except in compliance
9*766ce4d0SZheng Fan  * with the License.  You may obtain a copy of the License at
10*766ce4d0SZheng Fan  *
11*766ce4d0SZheng Fan  *   http://www.apache.org/licenses/LICENSE-2.0
12*766ce4d0SZheng Fan  *
13*766ce4d0SZheng Fan  * Unless required by applicable law or agreed to in writing,
14*766ce4d0SZheng Fan  * software distributed under the License is distributed on an
15*766ce4d0SZheng Fan  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*766ce4d0SZheng Fan  * KIND, either express or implied.  See the License for the
17*766ce4d0SZheng Fan  * specific language governing permissions and limitations
18*766ce4d0SZheng Fan  * under the License.
19*766ce4d0SZheng Fan  *
20*766ce4d0SZheng Fan  *************************************************************/
21*766ce4d0SZheng Fan 
22*766ce4d0SZheng Fan #include "precompiled_svx.hxx"
23*766ce4d0SZheng Fan #include "ParaNumberingControl.hxx"
24*766ce4d0SZheng Fan #include "ParaPropertyPanel.hrc"
25*766ce4d0SZheng Fan #include <sfx2/sidebar/propertypanel.hrc>
26*766ce4d0SZheng Fan #include <svx/dialogs.hrc>
27*766ce4d0SZheng Fan #include <svx/dialmgr.hxx>
28*766ce4d0SZheng Fan #include <unotools/viewoptions.hxx>
29*766ce4d0SZheng Fan #include <editeng/kernitem.hxx>
30*766ce4d0SZheng Fan #include <sfx2/bindings.hxx>
31*766ce4d0SZheng Fan #include <sfx2/dispatch.hxx>
32*766ce4d0SZheng Fan #include <sfx2/sidebar/Theme.hxx>
33*766ce4d0SZheng Fan #include <svtools/unitconv.hxx>
34*766ce4d0SZheng Fan #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35*766ce4d0SZheng Fan #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
36*766ce4d0SZheng Fan #include <com/sun/star/text/XNumberingFormatter.hpp>
37*766ce4d0SZheng Fan #include <com/sun/star/beans/PropertyValue.hpp>
38*766ce4d0SZheng Fan #include <comphelper/processfactory.hxx>
39*766ce4d0SZheng Fan #include <svx/nbdtmg.hxx>
40*766ce4d0SZheng Fan #include <svx/nbdtmgfact.hxx>
41*766ce4d0SZheng Fan #include <editeng/unolingu.hxx>
42*766ce4d0SZheng Fan using namespace com::sun::star;
43*766ce4d0SZheng Fan using namespace com::sun::star::uno;
44*766ce4d0SZheng Fan using namespace com::sun::star::beans;
45*766ce4d0SZheng Fan using namespace com::sun::star::lang;
46*766ce4d0SZheng Fan using namespace com::sun::star::text;
47*766ce4d0SZheng Fan 
48*766ce4d0SZheng Fan namespace svx { namespace sidebar {
49*766ce4d0SZheng Fan 
50*766ce4d0SZheng Fan Reference<XDefaultNumberingProvider> lcl_GetNumberingProvider()
51*766ce4d0SZheng Fan {
52*766ce4d0SZheng Fan 	Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
53*766ce4d0SZheng Fan 	Reference < XInterface > xI = xMSF->createInstance(
54*766ce4d0SZheng Fan 		::rtl::OUString::createFromAscii( "com.sun.star.text.DefaultNumberingProvider" ) );
55*766ce4d0SZheng Fan 	Reference<XDefaultNumberingProvider> xRet(xI, UNO_QUERY);
56*766ce4d0SZheng Fan //	DBG_ASSERT(xRet.is(), "service missing: \"com.sun.star.text.DefaultNumberingProvider\"")
57*766ce4d0SZheng Fan 
58*766ce4d0SZheng Fan 	return xRet;
59*766ce4d0SZheng Fan }
60*766ce4d0SZheng Fan 
61*766ce4d0SZheng Fan ParaNumberingControl::ParaNumberingControl(Window* pParent, svx::sidebar::ParaPropertyPanel& rPanel):
62*766ce4d0SZheng Fan 	PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_NUMBERING)),
63*766ce4d0SZheng Fan 	maNumberVS(this,SVX_RES(VS_NUMBERING)),
64*766ce4d0SZheng Fan 	maFISep(this,SVX_RES(IMG_SEPERATOR_NUMBERING)),
65*766ce4d0SZheng Fan 	maMoreButton(this,SVX_RES(CB_NUMBERING_MORE) ),
66*766ce4d0SZheng Fan 	mrParaPropertyPanel(rPanel),
67*766ce4d0SZheng Fan 	mpBindings(NULL)
68*766ce4d0SZheng Fan {
69*766ce4d0SZheng Fan 	FreeResource();
70*766ce4d0SZheng Fan 	mpBindings = mrParaPropertyPanel.GetBindings();
71*766ce4d0SZheng Fan 
72*766ce4d0SZheng Fan 	maNumberVS.SetStyle(maNumberVS.GetStyle() | WB_NO_DIRECTSELECT);
73*766ce4d0SZheng Fan 	maNumberVS.SetExtraSpacing(NUM_IMAGE_SPACING);
74*766ce4d0SZheng Fan 	//add by wj for sym2_7246 high contrast
75*766ce4d0SZheng Fan 	if(GetSettings().GetStyleSettings().GetHighContrastMode())
76*766ce4d0SZheng Fan 		maNumberVS.SetBackground(GetSettings().GetStyleSettings().GetMenuColor());
77*766ce4d0SZheng Fan 	else
78*766ce4d0SZheng Fan 		maNumberVS.SetBackground(Color(244,245,249));
79*766ce4d0SZheng Fan 
80*766ce4d0SZheng Fan 	maNumberVS.SetItemWidth(NUM_IMAGE_WIDTH);
81*766ce4d0SZheng Fan 	maNumberVS.SetItemHeight(NUM_IMAGE_HEIGHT);
82*766ce4d0SZheng Fan 
83*766ce4d0SZheng Fan 	Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider();
84*766ce4d0SZheng Fan 	if(xDefNum.is())
85*766ce4d0SZheng Fan 	{
86*766ce4d0SZheng Fan 		Sequence< Sequence< PropertyValue > > aNumberings;
87*766ce4d0SZheng Fan         LanguageType eLang = GetSettings().GetLanguage();
88*766ce4d0SZheng Fan 		Locale aLocale = SvxCreateLocale(eLang);
89*766ce4d0SZheng Fan 		try
90*766ce4d0SZheng Fan 		{
91*766ce4d0SZheng Fan 			aNumberings =
92*766ce4d0SZheng Fan 				xDefNum->getDefaultContinuousNumberingLevels( aLocale );
93*766ce4d0SZheng Fan 		}
94*766ce4d0SZheng Fan 		catch(Exception&)
95*766ce4d0SZheng Fan 		{
96*766ce4d0SZheng Fan 		}
97*766ce4d0SZheng Fan 		Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY);
98*766ce4d0SZheng Fan 		maNumberVS.SetNumberingSettings(aNumberings, xFormat, aLocale);
99*766ce4d0SZheng Fan 	}
100*766ce4d0SZheng Fan 
101*766ce4d0SZheng Fan     maNumberVS.Show();
102*766ce4d0SZheng Fan 	maNumberVS.SetSelectHdl(LINK(this, ParaNumberingControl, NumSelectHdl_Impl));
103*766ce4d0SZheng Fan 
104*766ce4d0SZheng Fan 	/*maMoreButton.SetDefBkColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
105*766ce4d0SZheng Fan 		GetSettings().GetStyleSettings().GetMenuColor():
106*766ce4d0SZheng Fan 		sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_DropDownBackground ));//Color(244,245,249)//for high contract
107*766ce4d0SZheng Fan 	maMoreButton.SetHoverBkColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
108*766ce4d0SZheng Fan 		GetSettings().GetStyleSettings().GetMenuColor():
109*766ce4d0SZheng Fan 		sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ) );//Color( 93, 120, 163 )
110*766ce4d0SZheng Fan 	maMoreButton.SetHoverTxtColor( sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Color_PanelTitleFont ) );//Color( 255, 255, 255 )
111*766ce4d0SZheng Fan 	maMoreButton.SetIcoPosX( 2);*/
112*766ce4d0SZheng Fan 	maNumberVS.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
113*766ce4d0SZheng Fan 		GetSettings().GetStyleSettings().GetMenuColor():
114*766ce4d0SZheng Fan 		sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
115*766ce4d0SZheng Fan 	maNumberVS.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()?
116*766ce4d0SZheng Fan 		GetSettings().GetStyleSettings().GetMenuColor():
117*766ce4d0SZheng Fan 		sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
118*766ce4d0SZheng Fan 
119*766ce4d0SZheng Fan 	maMoreButton.SetClickHdl(LINK(this, ParaNumberingControl, MoreButtonClickHdl_Impl));
120*766ce4d0SZheng Fan 
121*766ce4d0SZheng Fan }
122*766ce4d0SZheng Fan 
123*766ce4d0SZheng Fan ParaNumberingControl::~ParaNumberingControl()
124*766ce4d0SZheng Fan {
125*766ce4d0SZheng Fan }
126*766ce4d0SZheng Fan 
127*766ce4d0SZheng Fan 
128*766ce4d0SZheng Fan IMPL_LINK(ParaNumberingControl, NumSelectHdl_Impl, ValueSet*, EMPTYARG)
129*766ce4d0SZheng Fan {
130*766ce4d0SZheng Fan 	sal_uInt16 nIdx = maNumberVS.GetSelectItemId();
131*766ce4d0SZheng Fan 	SfxUInt16Item aItem(FN_SVX_SET_NUMBER, nIdx);
132*766ce4d0SZheng Fan 	if (mpBindings)
133*766ce4d0SZheng Fan 		mpBindings->GetDispatcher()->Execute( FN_SVX_SET_NUMBER, SFX_CALLMODE_RECORD, &aItem, 0L );
134*766ce4d0SZheng Fan 
135*766ce4d0SZheng Fan 	mrParaPropertyPanel.EndNumberingPopupMode();
136*766ce4d0SZheng Fan 
137*766ce4d0SZheng Fan 	return 0;
138*766ce4d0SZheng Fan }
139*766ce4d0SZheng Fan 
140*766ce4d0SZheng Fan IMPL_LINK(ParaNumberingControl, MoreButtonClickHdl_Impl, void*, EMPTYARG)
141*766ce4d0SZheng Fan {
142*766ce4d0SZheng Fan 	if (mpBindings)
143*766ce4d0SZheng Fan 		mpBindings->GetDispatcher()->Execute( SID_OUTLINE_BULLET, SFX_CALLMODE_ASYNCHRON );
144*766ce4d0SZheng Fan 
145*766ce4d0SZheng Fan 	mrParaPropertyPanel.EndNumberingPopupMode();
146*766ce4d0SZheng Fan 
147*766ce4d0SZheng Fan 	return 0;
148*766ce4d0SZheng Fan }
149*766ce4d0SZheng Fan 
150*766ce4d0SZheng Fan void ParaNumberingControl::UpdateValueSet()
151*766ce4d0SZheng Fan {
152*766ce4d0SZheng Fan 	maNumberVS.StateChanged(STATE_CHANGE_STYLE);
153*766ce4d0SZheng Fan 	maNumberVS.StateChanged(STATE_CHANGE_INITSHOW);
154*766ce4d0SZheng Fan }
155*766ce4d0SZheng Fan 
156*766ce4d0SZheng Fan void ParaNumberingControl::ToGetFocus()
157*766ce4d0SZheng Fan {
158*766ce4d0SZheng Fan 	sal_uInt16 nTypeIndex = mrParaPropertyPanel.GetNumTypeIndex();
159*766ce4d0SZheng Fan 	if ( nTypeIndex != (sal_uInt16)0xFFFF )
160*766ce4d0SZheng Fan 		maNumberVS.SelectItem( nTypeIndex );
161*766ce4d0SZheng Fan 	else
162*766ce4d0SZheng Fan 	{
163*766ce4d0SZheng Fan 		maNumberVS.SelectItem(0);
164*766ce4d0SZheng Fan 	}
165*766ce4d0SZheng Fan 	maMoreButton.GrabFocus();
166*766ce4d0SZheng Fan }
167*766ce4d0SZheng Fan 
168*766ce4d0SZheng Fan }} // end of namespace sidebar
169*766ce4d0SZheng Fan 
170*766ce4d0SZheng Fan 
171*766ce4d0SZheng Fan 
172