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