1766ce4d0SZheng Fan /************************************************************** 2766ce4d0SZheng Fan * 3766ce4d0SZheng Fan * Licensed to the Apache Software Foundation (ASF) under one 4766ce4d0SZheng Fan * or more contributor license agreements. See the NOTICE file 5766ce4d0SZheng Fan * distributed with this work for additional information 6766ce4d0SZheng Fan * regarding copyright ownership. The ASF licenses this file 7766ce4d0SZheng Fan * to you under the Apache License, Version 2.0 (the 8766ce4d0SZheng Fan * "License"); you may not use this file except in compliance 9766ce4d0SZheng Fan * with the License. You may obtain a copy of the License at 10766ce4d0SZheng Fan * 11766ce4d0SZheng Fan * http://www.apache.org/licenses/LICENSE-2.0 12766ce4d0SZheng Fan * 13766ce4d0SZheng Fan * Unless required by applicable law or agreed to in writing, 14766ce4d0SZheng Fan * software distributed under the License is distributed on an 15766ce4d0SZheng Fan * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16766ce4d0SZheng Fan * KIND, either express or implied. See the License for the 17766ce4d0SZheng Fan * specific language governing permissions and limitations 18766ce4d0SZheng Fan * under the License. 19766ce4d0SZheng Fan * 20766ce4d0SZheng Fan *************************************************************/ 21766ce4d0SZheng Fan 22766ce4d0SZheng Fan #include "precompiled_svx.hxx" 23766ce4d0SZheng Fan #include "ParaNumberingControl.hxx" 24766ce4d0SZheng Fan #include "ParaPropertyPanel.hrc" 25766ce4d0SZheng Fan #include <sfx2/sidebar/propertypanel.hrc> 26766ce4d0SZheng Fan #include <svx/dialogs.hrc> 27766ce4d0SZheng Fan #include <svx/dialmgr.hxx> 28766ce4d0SZheng Fan #include <unotools/viewoptions.hxx> 29766ce4d0SZheng Fan #include <editeng/kernitem.hxx> 30766ce4d0SZheng Fan #include <sfx2/bindings.hxx> 31766ce4d0SZheng Fan #include <sfx2/dispatch.hxx> 32766ce4d0SZheng Fan #include <sfx2/sidebar/Theme.hxx> 33766ce4d0SZheng Fan #include <svtools/unitconv.hxx> 34766ce4d0SZheng Fan #include <com/sun/star/lang/XMultiServiceFactory.hpp> 35766ce4d0SZheng Fan #include <com/sun/star/text/XDefaultNumberingProvider.hpp> 36766ce4d0SZheng Fan #include <com/sun/star/text/XNumberingFormatter.hpp> 37766ce4d0SZheng Fan #include <com/sun/star/beans/PropertyValue.hpp> 38766ce4d0SZheng Fan #include <comphelper/processfactory.hxx> 39766ce4d0SZheng Fan #include <svx/nbdtmg.hxx> 40766ce4d0SZheng Fan #include <svx/nbdtmgfact.hxx> 41766ce4d0SZheng Fan #include <editeng/unolingu.hxx> 42766ce4d0SZheng Fan using namespace com::sun::star; 43766ce4d0SZheng Fan using namespace com::sun::star::uno; 44766ce4d0SZheng Fan using namespace com::sun::star::beans; 45766ce4d0SZheng Fan using namespace com::sun::star::lang; 46766ce4d0SZheng Fan using namespace com::sun::star::text; 47766ce4d0SZheng Fan 48766ce4d0SZheng Fan namespace svx { namespace sidebar { 49766ce4d0SZheng Fan 50766ce4d0SZheng Fan Reference<XDefaultNumberingProvider> lcl_GetNumberingProvider() 51766ce4d0SZheng Fan { 52766ce4d0SZheng Fan Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); 53766ce4d0SZheng Fan Reference < XInterface > xI = xMSF->createInstance( 54766ce4d0SZheng Fan ::rtl::OUString::createFromAscii( "com.sun.star.text.DefaultNumberingProvider" ) ); 55766ce4d0SZheng Fan Reference<XDefaultNumberingProvider> xRet(xI, UNO_QUERY); 56766ce4d0SZheng Fan 57766ce4d0SZheng Fan return xRet; 58766ce4d0SZheng Fan } 59766ce4d0SZheng Fan 60*7aed46aaSOliver-Rainer Wittmann ParaNumberingControl::ParaNumberingControl( 61*7aed46aaSOliver-Rainer Wittmann Window* pParent, 62*7aed46aaSOliver-Rainer Wittmann svx::sidebar::ParaPropertyPanel& rPanel ) 63*7aed46aaSOliver-Rainer Wittmann : PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_NUMBERING) ) 64*7aed46aaSOliver-Rainer Wittmann , maNumberVS( this,SVX_RES(VS_NUMBERING) ) 65*7aed46aaSOliver-Rainer Wittmann , maMoreButton( this,SVX_RES(CB_NUMBERING_MORE) ) 66*7aed46aaSOliver-Rainer Wittmann , mrParaPropertyPanel( rPanel ) 67*7aed46aaSOliver-Rainer Wittmann , mpBindings( mrParaPropertyPanel.GetBindings() ) 68766ce4d0SZheng Fan { 69766ce4d0SZheng Fan FreeResource(); 70766ce4d0SZheng Fan 71766ce4d0SZheng Fan maNumberVS.SetStyle( maNumberVS.GetStyle() | WB_NO_DIRECTSELECT ); 72766ce4d0SZheng Fan maNumberVS.SetExtraSpacing( NUM_IMAGE_SPACING ); 73766ce4d0SZheng Fan maNumberVS.SetItemWidth(NUM_IMAGE_WIDTH); 74766ce4d0SZheng Fan maNumberVS.SetItemHeight(NUM_IMAGE_HEIGHT); 75766ce4d0SZheng Fan 76766ce4d0SZheng Fan Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider(); 77766ce4d0SZheng Fan if(xDefNum.is()) 78766ce4d0SZheng Fan { 79766ce4d0SZheng Fan Sequence< Sequence< PropertyValue > > aNumberings; 80766ce4d0SZheng Fan LanguageType eLang = GetSettings().GetLanguage(); 81766ce4d0SZheng Fan Locale aLocale = SvxCreateLocale(eLang); 82766ce4d0SZheng Fan try 83766ce4d0SZheng Fan { 84*7aed46aaSOliver-Rainer Wittmann aNumberings = xDefNum->getDefaultContinuousNumberingLevels( aLocale ); 85766ce4d0SZheng Fan } 86766ce4d0SZheng Fan catch(Exception&) 87766ce4d0SZheng Fan { 88766ce4d0SZheng Fan } 89766ce4d0SZheng Fan Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY); 90766ce4d0SZheng Fan maNumberVS.SetNumberingSettings(aNumberings, xFormat, aLocale); 91766ce4d0SZheng Fan } 92766ce4d0SZheng Fan 93766ce4d0SZheng Fan maNumberVS.Show(); 94766ce4d0SZheng Fan maNumberVS.SetSelectHdl( LINK(this, ParaNumberingControl, NumSelectHdl_Impl) ); 95766ce4d0SZheng Fan 96*7aed46aaSOliver-Rainer Wittmann maNumberVS.SetColor( GetSettings().GetStyleSettings().GetHighContrastMode() 97*7aed46aaSOliver-Rainer Wittmann ? GetSettings().GetStyleSettings().GetMenuColor() 98*7aed46aaSOliver-Rainer Wittmann : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ) ); 99*7aed46aaSOliver-Rainer Wittmann maNumberVS.SetBackground( GetSettings().GetStyleSettings().GetHighContrastMode() 100*7aed46aaSOliver-Rainer Wittmann ? GetSettings().GetStyleSettings().GetMenuColor() 101*7aed46aaSOliver-Rainer Wittmann : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ) ); 102766ce4d0SZheng Fan 103766ce4d0SZheng Fan maMoreButton.SetClickHdl(LINK(this, ParaNumberingControl, MoreButtonClickHdl_Impl)); 104766ce4d0SZheng Fan } 105766ce4d0SZheng Fan 106*7aed46aaSOliver-Rainer Wittmann 107766ce4d0SZheng Fan ParaNumberingControl::~ParaNumberingControl() 108766ce4d0SZheng Fan { 109766ce4d0SZheng Fan } 110766ce4d0SZheng Fan 111766ce4d0SZheng Fan 112766ce4d0SZheng Fan IMPL_LINK(ParaNumberingControl, NumSelectHdl_Impl, ValueSet*, EMPTYARG) 113766ce4d0SZheng Fan { 114*7aed46aaSOliver-Rainer Wittmann const sal_uInt16 nIdx = maNumberVS.GetSelectItemId(); 115766ce4d0SZheng Fan SfxUInt16Item aItem( FN_SVX_SET_NUMBER, nIdx ); 116766ce4d0SZheng Fan if (mpBindings) 117766ce4d0SZheng Fan mpBindings->GetDispatcher()->Execute( FN_SVX_SET_NUMBER, SFX_CALLMODE_RECORD, &aItem, 0L ); 118766ce4d0SZheng Fan 119766ce4d0SZheng Fan mrParaPropertyPanel.EndNumberingPopupMode(); 120766ce4d0SZheng Fan 121766ce4d0SZheng Fan return 0; 122766ce4d0SZheng Fan } 123766ce4d0SZheng Fan 124*7aed46aaSOliver-Rainer Wittmann 125766ce4d0SZheng Fan IMPL_LINK(ParaNumberingControl, MoreButtonClickHdl_Impl, void*, EMPTYARG) 126766ce4d0SZheng Fan { 127766ce4d0SZheng Fan if (mpBindings) 128766ce4d0SZheng Fan mpBindings->GetDispatcher()->Execute( SID_OUTLINE_BULLET, SFX_CALLMODE_ASYNCHRON ); 129766ce4d0SZheng Fan 130766ce4d0SZheng Fan mrParaPropertyPanel.EndNumberingPopupMode(); 131766ce4d0SZheng Fan 132766ce4d0SZheng Fan return 0; 133766ce4d0SZheng Fan } 134766ce4d0SZheng Fan 135*7aed46aaSOliver-Rainer Wittmann 136766ce4d0SZheng Fan void ParaNumberingControl::UpdateValueSet() 137766ce4d0SZheng Fan { 138766ce4d0SZheng Fan maNumberVS.StateChanged(STATE_CHANGE_STYLE); 139766ce4d0SZheng Fan maNumberVS.StateChanged(STATE_CHANGE_INITSHOW); 140766ce4d0SZheng Fan 141*7aed46aaSOliver-Rainer Wittmann const sal_uInt16 nTypeIndex = mrParaPropertyPanel.GetNumTypeIndex(); 142766ce4d0SZheng Fan if ( nTypeIndex != (sal_uInt16)0xFFFF ) 143766ce4d0SZheng Fan maNumberVS.SelectItem( nTypeIndex ); 144766ce4d0SZheng Fan else 145766ce4d0SZheng Fan { 146766ce4d0SZheng Fan maNumberVS.SelectItem(0); 147766ce4d0SZheng Fan } 148766ce4d0SZheng Fan maMoreButton.GrabFocus(); 149766ce4d0SZheng Fan } 150766ce4d0SZheng Fan 151766ce4d0SZheng Fan }} // end of namespace sidebar 152766ce4d0SZheng Fan 153766ce4d0SZheng Fan 154766ce4d0SZheng Fan 155