LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/sidebar/paragraph - ParaNumberingControl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 54 1.9 %
Date: 2013-07-09 Functions: 2 11 18.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * This file is part of the LibreOffice project.
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * This file incorporates work covered by the following license notice:
       9             :  *
      10             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      11             :  *   contributor license agreements. See the NOTICE file distributed
      12             :  *   with this work for additional information regarding copyright
      13             :  *   ownership. The ASF licenses this file to you under the Apache
      14             :  *   License, Version 2.0 (the "License"); you may not use this file
      15             :  *   except in compliance with the License. You may obtain a copy of
      16             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      17             :  */
      18             : #include "ParaNumberingControl.hxx"
      19             : #include "ParaPropertyPanel.hrc"
      20             : #include <sfx2/sidebar/ResourceDefinitions.hrc>
      21             : #include <svx/dialogs.hrc>
      22             : #include <svx/dialmgr.hxx>
      23             : #include <unotools/viewoptions.hxx>
      24             : #include <editeng/kernitem.hxx>
      25             : #include <sfx2/bindings.hxx>
      26             : #include <sfx2/dispatch.hxx>
      27             : #include <sfx2/sidebar/Theme.hxx>
      28             : #include <svtools/unitconv.hxx>
      29             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      30             : #include <com/sun/star/text/DefaultNumberingProvider.hpp>
      31             : #include <com/sun/star/text/XNumberingFormatter.hpp>
      32             : #include <com/sun/star/beans/PropertyValue.hpp>
      33             : #include <comphelper/processfactory.hxx>
      34             : #include <svx/nbdtmg.hxx>
      35             : #include <svx/nbdtmgfact.hxx>
      36             : #include <editeng/unolingu.hxx>
      37             : using namespace com::sun::star;
      38             : using namespace com::sun::star::uno;
      39             : using namespace com::sun::star::beans;
      40             : using namespace com::sun::star::lang;
      41             : using namespace com::sun::star::text;
      42             : 
      43             : namespace svx { namespace sidebar {
      44             : 
      45           0 : Reference<XDefaultNumberingProvider> lcl_GetNumberingProvider()
      46             : {
      47           0 :     return DefaultNumberingProvider::create( comphelper::getProcessComponentContext() );
      48             : }
      49             : 
      50           0 : ParaNumberingControl::ParaNumberingControl(
      51             :     Window* pParent,
      52             :     svx::sidebar::ParaPropertyPanel& rPanel )
      53           0 :     : PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_NUMBERING) )
      54           0 :     , maNumberVS( this,SVX_RES(VS_NUMBERING) )
      55           0 :     , maMoreButton( this,SVX_RES(CB_NUMBERING_MORE) )
      56             :     , mrParaPropertyPanel( rPanel )
      57           0 :     , mpBindings( mrParaPropertyPanel.GetBindings() )
      58             : {
      59           0 :     FreeResource();
      60             : 
      61           0 :     maNumberVS.SetStyle( maNumberVS.GetStyle() | WB_NO_DIRECTSELECT );
      62           0 :     maNumberVS.SetExtraSpacing( NUM_IMAGE_SPACING );
      63           0 :     maNumberVS.SetItemWidth(NUM_IMAGE_WIDTH);
      64           0 :     maNumberVS.SetItemHeight(NUM_IMAGE_HEIGHT);
      65             : 
      66           0 :     Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider();
      67           0 :     if(xDefNum.is())
      68             :     {
      69           0 :         Sequence< Sequence< PropertyValue > > aNumberings;
      70           0 :         Locale aLocale = GetSettings().GetLanguageTag().getLocale();
      71             :         try
      72             :         {
      73           0 :             aNumberings = xDefNum->getDefaultContinuousNumberingLevels( aLocale );
      74             :         }
      75           0 :         catch(Exception&)
      76             :         {
      77             :         }
      78           0 :         Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY);
      79           0 :         maNumberVS.SetNumberingSettings(aNumberings, xFormat, aLocale);
      80             :     }
      81             : 
      82           0 :     maNumberVS.Show();
      83           0 :     maNumberVS.SetSelectHdl( LINK(this, ParaNumberingControl, NumSelectHdl_Impl) );
      84             : 
      85           0 :     maNumberVS.SetColor( GetSettings().GetStyleSettings().GetHighContrastMode()
      86           0 :                          ? GetSettings().GetStyleSettings().GetMenuColor()
      87           0 :                          : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ) );
      88           0 :     maNumberVS.SetBackground( GetSettings().GetStyleSettings().GetHighContrastMode()
      89           0 :                               ? GetSettings().GetStyleSettings().GetMenuColor()
      90           0 :                               : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ) );
      91             : 
      92           0 :     maMoreButton.SetClickHdl(LINK(this, ParaNumberingControl, MoreButtonClickHdl_Impl));
      93           0 : }
      94             : 
      95             : 
      96           0 : ParaNumberingControl::~ParaNumberingControl()
      97             : {
      98           0 : }
      99             : 
     100             : 
     101           0 : IMPL_LINK(ParaNumberingControl, NumSelectHdl_Impl, ValueSet*, EMPTYARG)
     102             : {
     103           0 :     const sal_uInt16 nIdx = maNumberVS.GetSelectItemId();
     104           0 :     SfxUInt16Item aItem( FN_SVX_SET_NUMBER, nIdx );
     105           0 :     if (mpBindings)
     106           0 :         mpBindings->GetDispatcher()->Execute( FN_SVX_SET_NUMBER, SFX_CALLMODE_RECORD, &aItem, 0L );
     107             : 
     108           0 :     mrParaPropertyPanel.EndNumberingPopupMode();
     109             : 
     110           0 :     return 0;
     111             : }
     112             : 
     113             : 
     114           0 : IMPL_LINK(ParaNumberingControl, MoreButtonClickHdl_Impl, void*, EMPTYARG)
     115             : {
     116           0 :     if (mpBindings)
     117           0 :         mpBindings->GetDispatcher()->Execute( SID_OUTLINE_BULLET, SFX_CALLMODE_ASYNCHRON );
     118             : 
     119           0 :     mrParaPropertyPanel.EndNumberingPopupMode();
     120             : 
     121           0 :     return 0;
     122             : }
     123             : 
     124             : 
     125           0 : void ParaNumberingControl::UpdateValueSet()
     126             : {
     127           0 :     maNumberVS.StateChanged(STATE_CHANGE_STYLE);
     128           0 :     maNumberVS.StateChanged(STATE_CHANGE_INITSHOW);
     129             : 
     130           0 :     const sal_uInt16 nTypeIndex = mrParaPropertyPanel.GetNumTypeIndex();
     131           0 :     if ( nTypeIndex != (sal_uInt16)0xFFFF )
     132           0 :         maNumberVS.SelectItem( nTypeIndex );
     133             :     else
     134             :     {
     135           0 :         maNumberVS.SelectItem(0);
     136             :     }
     137           0 :     maMoreButton.GrabFocus();
     138           0 : }
     139             : 
     140         216 : }} // end of namespace sidebar
     141             : 
     142             : 
     143             : 

Generated by: LCOV version 1.10