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 #include "precompiled_svx.hxx" 23 #include "ParaNumberingControl.hxx" 24 #include "ParaPropertyPanel.hrc" 25 #include <sfx2/sidebar/propertypanel.hrc> 26 #include <svx/dialogs.hrc> 27 #include <svx/dialmgr.hxx> 28 #include <unotools/viewoptions.hxx> 29 #include <editeng/kernitem.hxx> 30 #include <sfx2/bindings.hxx> 31 #include <sfx2/dispatch.hxx> 32 #include <sfx2/sidebar/Theme.hxx> 33 #include <svtools/unitconv.hxx> 34 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 35 #include <com/sun/star/text/XDefaultNumberingProvider.hpp> 36 #include <com/sun/star/text/XNumberingFormatter.hpp> 37 #include <com/sun/star/beans/PropertyValue.hpp> 38 #include <comphelper/processfactory.hxx> 39 #include <svx/nbdtmg.hxx> 40 #include <svx/nbdtmgfact.hxx> 41 #include <editeng/unolingu.hxx> 42 using namespace com::sun::star; 43 using namespace com::sun::star::uno; 44 using namespace com::sun::star::beans; 45 using namespace com::sun::star::lang; 46 using namespace com::sun::star::text; 47 48 namespace svx { namespace sidebar { 49 50 Reference<XDefaultNumberingProvider> lcl_GetNumberingProvider() 51 { 52 Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); 53 Reference < XInterface > xI = xMSF->createInstance( 54 ::rtl::OUString::createFromAscii( "com.sun.star.text.DefaultNumberingProvider" ) ); 55 Reference<XDefaultNumberingProvider> xRet(xI, UNO_QUERY); 56 // DBG_ASSERT(xRet.is(), "service missing: \"com.sun.star.text.DefaultNumberingProvider\"") 57 58 return xRet; 59 } 60 61 ParaNumberingControl::ParaNumberingControl(Window* pParent, svx::sidebar::ParaPropertyPanel& rPanel): 62 PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_NUMBERING)), 63 maNumberVS(this,SVX_RES(VS_NUMBERING)), 64 maFISep(this,SVX_RES(IMG_SEPERATOR_NUMBERING)), 65 maMoreButton(this,SVX_RES(CB_NUMBERING_MORE) ), 66 mrParaPropertyPanel(rPanel), 67 mpBindings(NULL) 68 { 69 FreeResource(); 70 mpBindings = mrParaPropertyPanel.GetBindings(); 71 72 maNumberVS.SetStyle(maNumberVS.GetStyle() | WB_NO_DIRECTSELECT); 73 maNumberVS.SetExtraSpacing(NUM_IMAGE_SPACING); 74 //add by wj for sym2_7246 high contrast 75 if(GetSettings().GetStyleSettings().GetHighContrastMode()) 76 maNumberVS.SetBackground(GetSettings().GetStyleSettings().GetMenuColor()); 77 else 78 maNumberVS.SetBackground(Color(244,245,249)); 79 80 maNumberVS.SetItemWidth(NUM_IMAGE_WIDTH); 81 maNumberVS.SetItemHeight(NUM_IMAGE_HEIGHT); 82 83 Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider(); 84 if(xDefNum.is()) 85 { 86 Sequence< Sequence< PropertyValue > > aNumberings; 87 LanguageType eLang = GetSettings().GetLanguage(); 88 Locale aLocale = SvxCreateLocale(eLang); 89 try 90 { 91 aNumberings = 92 xDefNum->getDefaultContinuousNumberingLevels( aLocale ); 93 } 94 catch(Exception&) 95 { 96 } 97 Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY); 98 maNumberVS.SetNumberingSettings(aNumberings, xFormat, aLocale); 99 } 100 101 maNumberVS.Show(); 102 maNumberVS.SetSelectHdl(LINK(this, ParaNumberingControl, NumSelectHdl_Impl)); 103 104 /*maMoreButton.SetDefBkColor(GetSettings().GetStyleSettings().GetHighContrastMode()? 105 GetSettings().GetStyleSettings().GetMenuColor(): 106 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_DropDownBackground ));//Color(244,245,249)//for high contract 107 maMoreButton.SetHoverBkColor(GetSettings().GetStyleSettings().GetHighContrastMode()? 108 GetSettings().GetStyleSettings().GetMenuColor(): 109 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ) );//Color( 93, 120, 163 ) 110 maMoreButton.SetHoverTxtColor( sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Color_PanelTitleFont ) );//Color( 255, 255, 255 ) 111 maMoreButton.SetIcoPosX( 2);*/ 112 maNumberVS.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()? 113 GetSettings().GetStyleSettings().GetMenuColor(): 114 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 115 maNumberVS.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 116 GetSettings().GetStyleSettings().GetMenuColor(): 117 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 118 119 maMoreButton.SetClickHdl(LINK(this, ParaNumberingControl, MoreButtonClickHdl_Impl)); 120 121 } 122 123 ParaNumberingControl::~ParaNumberingControl() 124 { 125 } 126 127 128 IMPL_LINK(ParaNumberingControl, NumSelectHdl_Impl, ValueSet*, EMPTYARG) 129 { 130 sal_uInt16 nIdx = maNumberVS.GetSelectItemId(); 131 SfxUInt16Item aItem(FN_SVX_SET_NUMBER, nIdx); 132 if (mpBindings) 133 mpBindings->GetDispatcher()->Execute( FN_SVX_SET_NUMBER, SFX_CALLMODE_RECORD, &aItem, 0L ); 134 135 mrParaPropertyPanel.EndNumberingPopupMode(); 136 137 return 0; 138 } 139 140 IMPL_LINK(ParaNumberingControl, MoreButtonClickHdl_Impl, void*, EMPTYARG) 141 { 142 if (mpBindings) 143 mpBindings->GetDispatcher()->Execute( SID_OUTLINE_BULLET, SFX_CALLMODE_ASYNCHRON ); 144 145 mrParaPropertyPanel.EndNumberingPopupMode(); 146 147 return 0; 148 } 149 150 void ParaNumberingControl::UpdateValueSet() 151 { 152 maNumberVS.StateChanged(STATE_CHANGE_STYLE); 153 maNumberVS.StateChanged(STATE_CHANGE_INITSHOW); 154 } 155 156 void ParaNumberingControl::ToGetFocus() 157 { 158 sal_uInt16 nTypeIndex = mrParaPropertyPanel.GetNumTypeIndex(); 159 if ( nTypeIndex != (sal_uInt16)0xFFFF ) 160 maNumberVS.SelectItem( nTypeIndex ); 161 else 162 { 163 maNumberVS.SelectItem(0); 164 } 165 maMoreButton.GrabFocus(); 166 } 167 168 }} // end of namespace sidebar 169 170 171 172