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 : #include <vcl/settings.hxx>
38 :
39 : using namespace com::sun::star;
40 : using namespace com::sun::star::uno;
41 : using namespace com::sun::star::beans;
42 : using namespace com::sun::star::lang;
43 : using namespace com::sun::star::text;
44 :
45 : namespace svx { namespace sidebar {
46 :
47 0 : Reference<XDefaultNumberingProvider> lcl_GetNumberingProvider()
48 : {
49 0 : return DefaultNumberingProvider::create( comphelper::getProcessComponentContext() );
50 : }
51 :
52 0 : ParaNumberingControl::ParaNumberingControl(
53 : Window* pParent,
54 : svx::sidebar::ParaPropertyPanel& rPanel )
55 0 : : PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_NUMBERING) )
56 0 : , maNumberVS( this,SVX_RES(VS_NUMBERING) )
57 0 : , maMoreButton( this,SVX_RES(CB_NUMBERING_MORE) )
58 : , mrParaPropertyPanel( rPanel )
59 0 : , mpBindings( mrParaPropertyPanel.GetBindings() )
60 : {
61 0 : FreeResource();
62 :
63 0 : maNumberVS.SetStyle( maNumberVS.GetStyle() | WB_NO_DIRECTSELECT );
64 0 : maNumberVS.SetExtraSpacing( NUM_IMAGE_SPACING );
65 0 : maNumberVS.SetItemWidth(NUM_IMAGE_WIDTH);
66 0 : maNumberVS.SetItemHeight(NUM_IMAGE_HEIGHT);
67 :
68 0 : Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider();
69 0 : if(xDefNum.is())
70 : {
71 0 : Sequence< Sequence< PropertyValue > > aNumberings;
72 0 : Locale aLocale = GetSettings().GetLanguageTag().getLocale();
73 : try
74 : {
75 0 : aNumberings = xDefNum->getDefaultContinuousNumberingLevels( aLocale );
76 : }
77 0 : catch(Exception&)
78 : {
79 : }
80 0 : Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY);
81 0 : maNumberVS.SetNumberingSettings(aNumberings, xFormat, aLocale);
82 : }
83 :
84 0 : maNumberVS.Show();
85 0 : maNumberVS.SetSelectHdl( LINK(this, ParaNumberingControl, NumSelectHdl_Impl) );
86 :
87 0 : maNumberVS.SetColor( GetSettings().GetStyleSettings().GetHighContrastMode()
88 0 : ? GetSettings().GetStyleSettings().GetMenuColor()
89 0 : : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ) );
90 0 : maNumberVS.SetBackground( GetSettings().GetStyleSettings().GetHighContrastMode()
91 0 : ? GetSettings().GetStyleSettings().GetMenuColor()
92 0 : : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ) );
93 :
94 0 : maMoreButton.SetClickHdl(LINK(this, ParaNumberingControl, MoreButtonClickHdl_Impl));
95 0 : }
96 :
97 :
98 0 : ParaNumberingControl::~ParaNumberingControl()
99 : {
100 0 : }
101 :
102 :
103 0 : IMPL_LINK(ParaNumberingControl, NumSelectHdl_Impl, ValueSet*, EMPTYARG)
104 : {
105 0 : const sal_uInt16 nIdx = maNumberVS.GetSelectItemId();
106 0 : SfxUInt16Item aItem( FN_SVX_SET_NUMBER, nIdx );
107 0 : if (mpBindings)
108 0 : mpBindings->GetDispatcher()->Execute( FN_SVX_SET_NUMBER, SFX_CALLMODE_RECORD, &aItem, 0L );
109 :
110 0 : mrParaPropertyPanel.EndNumberingPopupMode();
111 :
112 0 : return 0;
113 : }
114 :
115 :
116 0 : IMPL_LINK(ParaNumberingControl, MoreButtonClickHdl_Impl, void*, EMPTYARG)
117 : {
118 0 : if (mpBindings)
119 0 : mpBindings->GetDispatcher()->Execute( SID_OUTLINE_BULLET, SFX_CALLMODE_ASYNCHRON );
120 :
121 0 : mrParaPropertyPanel.EndNumberingPopupMode();
122 :
123 0 : return 0;
124 : }
125 :
126 :
127 0 : void ParaNumberingControl::UpdateValueSet()
128 : {
129 0 : maNumberVS.StateChanged(STATE_CHANGE_STYLE);
130 0 : maNumberVS.StateChanged(STATE_CHANGE_INITSHOW);
131 :
132 0 : const sal_uInt16 nTypeIndex = mrParaPropertyPanel.GetNumTypeIndex();
133 0 : if ( nTypeIndex != (sal_uInt16)0xFFFF )
134 0 : maNumberVS.SelectItem( nTypeIndex );
135 : else
136 : {
137 0 : maNumberVS.SelectItem(0);
138 : }
139 0 : maMoreButton.GrabFocus();
140 0 : }
141 :
142 : }} // end of namespace sidebar
143 :
144 :
145 :
|