LCOV - code coverage report
Current view: top level - svx/source/sidebar/paragraph - ParaNumberingControl.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 54 1.9 %
Date: 2014-11-03 Functions: 2 11 18.2 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10