1*d4aefcaeSZheng Fan /**************************************************************
2*d4aefcaeSZheng Fan  *
3*d4aefcaeSZheng Fan  * Licensed to the Apache Software Foundation (ASF) under one
4*d4aefcaeSZheng Fan  * or more contributor license agreements.  See the NOTICE file
5*d4aefcaeSZheng Fan  * distributed with this work for additional information
6*d4aefcaeSZheng Fan  * regarding copyright ownership.  The ASF licenses this file
7*d4aefcaeSZheng Fan  * to you under the Apache License, Version 2.0 (the
8*d4aefcaeSZheng Fan  * "License"); you may not use this file except in compliance
9*d4aefcaeSZheng Fan  * with the License.  You may obtain a copy of the License at
10*d4aefcaeSZheng Fan  *
11*d4aefcaeSZheng Fan  *   http://www.apache.org/licenses/LICENSE-2.0
12*d4aefcaeSZheng Fan  *
13*d4aefcaeSZheng Fan  * Unless required by applicable law or agreed to in writing,
14*d4aefcaeSZheng Fan  * software distributed under the License is distributed on an
15*d4aefcaeSZheng Fan  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d4aefcaeSZheng Fan  * KIND, either express or implied.  See the License for the
17*d4aefcaeSZheng Fan  * specific language governing permissions and limitations
18*d4aefcaeSZheng Fan  * under the License.
19*d4aefcaeSZheng Fan  *
20*d4aefcaeSZheng Fan  *************************************************************/
21*d4aefcaeSZheng Fan 
22*d4aefcaeSZheng Fan #include "TextCharacterSpacingPopup.hxx"
23*d4aefcaeSZheng Fan #include "TextCharacterSpacingControl.hxx"
24*d4aefcaeSZheng Fan #include <boost/bind.hpp>
25*d4aefcaeSZheng Fan #include <unotools/viewoptions.hxx>
26*d4aefcaeSZheng Fan 
27*d4aefcaeSZheng Fan namespace svx { namespace sidebar {
28*d4aefcaeSZheng Fan 
TextCharacterSpacingPopup(Window * pParent,const::boost::function<PopupControl * (PopupContainer *)> & rControlCreator)29*d4aefcaeSZheng Fan TextCharacterSpacingPopup::TextCharacterSpacingPopup (
30*d4aefcaeSZheng Fan     Window* pParent,
31*d4aefcaeSZheng Fan     const ::boost::function<PopupControl*(PopupContainer*)>& rControlCreator)
32*d4aefcaeSZheng Fan     : Popup(
33*d4aefcaeSZheng Fan         pParent,
34*d4aefcaeSZheng Fan         rControlCreator,
35*d4aefcaeSZheng Fan         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Character Spacing")))
36*d4aefcaeSZheng Fan {
37*d4aefcaeSZheng Fan 	SetPopupModeEndHandler(::boost::bind(&TextCharacterSpacingPopup::PopupModeEndCallback, this));
38*d4aefcaeSZheng Fan }
39*d4aefcaeSZheng Fan 
40*d4aefcaeSZheng Fan 
41*d4aefcaeSZheng Fan 
42*d4aefcaeSZheng Fan 
~TextCharacterSpacingPopup(void)43*d4aefcaeSZheng Fan TextCharacterSpacingPopup::~TextCharacterSpacingPopup (void)
44*d4aefcaeSZheng Fan {
45*d4aefcaeSZheng Fan }
46*d4aefcaeSZheng Fan 
47*d4aefcaeSZheng Fan 
48*d4aefcaeSZheng Fan 
49*d4aefcaeSZheng Fan 
Rearrange(bool bLBAvailable,bool bAvailable,long nKerning)50*d4aefcaeSZheng Fan void TextCharacterSpacingPopup::Rearrange (bool bLBAvailable,bool bAvailable, long nKerning)
51*d4aefcaeSZheng Fan {
52*d4aefcaeSZheng Fan     ProvideContainerAndControl();
53*d4aefcaeSZheng Fan 
54*d4aefcaeSZheng Fan     TextCharacterSpacingControl* pControl = dynamic_cast<TextCharacterSpacingControl*>(mpControl.get());
55*d4aefcaeSZheng Fan     if (pControl != NULL)
56*d4aefcaeSZheng Fan         pControl->Rearrange(bLBAvailable,bAvailable,nKerning);
57*d4aefcaeSZheng Fan }
58*d4aefcaeSZheng Fan 
PopupModeEndCallback(void)59*d4aefcaeSZheng Fan void TextCharacterSpacingPopup::PopupModeEndCallback (void)
60*d4aefcaeSZheng Fan {
61*d4aefcaeSZheng Fan 	ProvideContainerAndControl();
62*d4aefcaeSZheng Fan 	TextCharacterSpacingControl* pControl = dynamic_cast<TextCharacterSpacingControl*>(mpControl.get());
63*d4aefcaeSZheng Fan 	if (pControl == NULL)
64*d4aefcaeSZheng Fan 		return;
65*d4aefcaeSZheng Fan 
66*d4aefcaeSZheng Fan 	if( pControl->GetLastCustomState() == SPACING_CLOSE_BY_CUS_EDIT)
67*d4aefcaeSZheng Fan 	{
68*d4aefcaeSZheng Fan 		SvtViewOptions aWinOpt( E_WINDOW, SIDEBAR_SPACING_GLOBAL_VALUE );
69*d4aefcaeSZheng Fan 		::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
70*d4aefcaeSZheng Fan 		aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Spacing") );
71*d4aefcaeSZheng Fan 		aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt32( pControl->GetLastCustomValue() ));
72*d4aefcaeSZheng Fan 		aWinOpt.SetUserData( aSeq );
73*d4aefcaeSZheng Fan 
74*d4aefcaeSZheng Fan 	}
75*d4aefcaeSZheng Fan }
76*d4aefcaeSZheng Fan 
77*d4aefcaeSZheng Fan 
78*d4aefcaeSZheng Fan } } // end of namespace svx::sidebar
79*d4aefcaeSZheng Fan 
80