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 "ParaBulletsControl.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 <svx/nbdtmg.hxx>
30 : #include <svx/nbdtmgfact.hxx>
31 :
32 : namespace svx { namespace sidebar {
33 :
34 0 : ParaBulletsControl::ParaBulletsControl(
35 : Window* pParent,
36 : svx::sidebar::ParaPropertyPanel& rPanel )
37 0 : : PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_BULLETS) )
38 0 : , maBulletsVS( this,SVX_RES(VS_VALUES) )
39 0 : , maMoreButton( this,SVX_RES(CB_BULLET_MORE) )
40 : , mrParaPropertyPanel( rPanel )
41 0 : , mpBindings( mrParaPropertyPanel.GetBindings() )
42 : {
43 0 : FreeResource();
44 :
45 0 : maBulletsVS.SetColCount(3);
46 0 : maBulletsVS.SetLineCount(3);
47 0 : maBulletsVS.SetStyle( maBulletsVS.GetStyle() | WB_ITEMBORDER |WB_NO_DIRECTSELECT);
48 0 : maBulletsVS.SetExtraSpacing(BULLET_IMAGE_SPACING);
49 0 : maBulletsVS.SetItemWidth(BULLET_IMAGE_WIDTH);
50 0 : maBulletsVS.SetItemHeight(BULLET_IMAGE_HEIGHT);
51 0 : maBulletsVS.InsertItem( DEFAULT_NONE );
52 0 : for( sal_uInt16 nVSIdx = 1; nVSIdx <= DEFAULT_BULLET_TYPES; ++nVSIdx )
53 : {
54 0 : maBulletsVS.InsertItem( nVSIdx );
55 : }
56 :
57 0 : maBulletsVS.SetItemText( DEFAULT_NONE, SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE ));
58 0 : NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
59 0 : if ( pBullets )
60 : {
61 0 : for( sal_uInt16 nIndex = 0; nIndex < DEFAULT_BULLET_TYPES; ++nIndex )
62 : {
63 0 : maBulletsVS.SetItemText( nIndex + 1, pBullets->GetDescription(nIndex) );
64 : }
65 : }
66 :
67 0 : maBulletsVS.Show();
68 0 : maBulletsVS.SetSelectHdl(LINK(this, ParaBulletsControl, BulletSelectHdl_Impl));
69 :
70 0 : maBulletsVS.SetColor( GetSettings().GetStyleSettings().GetHighContrastMode()
71 0 : ? GetSettings().GetStyleSettings().GetMenuColor()
72 0 : : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ) );
73 0 : maBulletsVS.SetBackground( GetSettings().GetStyleSettings().GetHighContrastMode()
74 0 : ? GetSettings().GetStyleSettings().GetMenuColor()
75 0 : : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ) );
76 :
77 0 : maMoreButton.SetClickHdl(LINK(this, ParaBulletsControl, MoreButtonClickHdl_Impl));
78 :
79 0 : }
80 :
81 :
82 0 : ParaBulletsControl::~ParaBulletsControl()
83 : {
84 0 : }
85 :
86 :
87 0 : void ParaBulletsControl::UpdateValueSet()
88 : {
89 0 : maBulletsVS.StateChanged(STATE_CHANGE_STYLE);
90 0 : maBulletsVS.StateChanged(STATE_CHANGE_INITSHOW);
91 :
92 0 : const sal_uInt16 nTypeIndex = mrParaPropertyPanel.GetBulletTypeIndex();
93 0 : if ( nTypeIndex != (sal_uInt16)0xFFFF )
94 0 : maBulletsVS.SelectItem( nTypeIndex );
95 : else
96 : {
97 0 : maBulletsVS.SelectItem(0);
98 : }
99 0 : maMoreButton.GrabFocus();
100 0 : }
101 :
102 :
103 0 : IMPL_LINK(ParaBulletsControl, BulletSelectHdl_Impl, ValueSet*, EMPTYARG)
104 : {
105 0 : const sal_uInt16 nIdx = maBulletsVS.GetSelectItemId();
106 0 : SfxUInt16Item aItem( FN_SVX_SET_BULLET, nIdx );
107 0 : if (mpBindings)
108 0 : mpBindings->GetDispatcher()->Execute( FN_SVX_SET_BULLET, SFX_CALLMODE_RECORD, &aItem, 0L );
109 :
110 0 : mrParaPropertyPanel.EndBulletsPopupMode();
111 :
112 0 : return 0;
113 : }
114 :
115 :
116 0 : IMPL_LINK(ParaBulletsControl, MoreButtonClickHdl_Impl, void*, EMPTYARG)
117 : {
118 0 : if (mpBindings)
119 0 : mpBindings->GetDispatcher()->Execute( SID_OUTLINE_BULLET, SFX_CALLMODE_ASYNCHRON );
120 :
121 0 : mrParaPropertyPanel.EndBulletsPopupMode();
122 :
123 0 : return 0;
124 : }
125 :
126 216 : }} // end of namespace sidebar
127 :
128 :
|