2 * This file is part of the LibreOffice project.
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/.
8 * This file incorporates work covered by the following license notice:
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 .
19 #include "WrapPropertyPanel.hxx"
20 #include "WrapPropertyPanel.hrc"
21 #include "PropertyPanel.hrc"
24 #include <swtypes.hxx>
26 #include <sfx2/bindings.hxx>
27 #include <sfx2/dispatch.hxx>
28 #include <sfx2/sidebar/ControlFactory.hxx>
29 #include <sfx2/imagemgr.hxx>
30 #include <svl/eitem.hxx>
31 #include <vcl/svapp.hxx>
33 #include "com/sun/star/lang/IllegalArgumentException.hpp"
35 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
38 namespace sw
{ namespace sidebar
{
40 WrapPropertyPanel
* WrapPropertyPanel::Create (
42 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rxFrame
,
43 SfxBindings
* pBindings
)
46 throw ::com::sun::star::lang::IllegalArgumentException(A2S("no parent Window given to WrapPropertyPanel::Create"), NULL
, 0);
48 throw ::com::sun::star::lang::IllegalArgumentException(A2S("no XFrame given to WrapPropertyPanel::Create"), NULL
, 1);
49 if (pBindings
== NULL
)
50 throw ::com::sun::star::lang::IllegalArgumentException(A2S("no SfxBindings given to WrapPropertyPanel::Create"), NULL
, 2);
52 return new WrapPropertyPanel(
59 WrapPropertyPanel::WrapPropertyPanel(
61 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rxFrame
,
62 SfxBindings
* pBindings
)
63 : Control(pParent
, SW_RES(RID_PROPERTYPANEL_SWOBJWRAP_PAGE
))
65 , mpBindings(pBindings
)
67 , mpRBNoWrap( ::sfx2::sidebar::ControlFactory::CreateCustomImageRadionButton( this, SW_RES(RB_NO_WRAP
) ) )
68 , mpRBWrapLeft( ::sfx2::sidebar::ControlFactory::CreateCustomImageRadionButton( this, SW_RES(RB_WRAP_LEFT
) ) )
69 , mpRBWrapRight( ::sfx2::sidebar::ControlFactory::CreateCustomImageRadionButton( this, SW_RES(RB_WRAP_RIGHT
) ) )
70 , mpRBWrapParallel( ::sfx2::sidebar::ControlFactory::CreateCustomImageRadionButton( this, SW_RES(RB_WRAP_PARALLEL
) ) )
71 , mpRBWrapThrough( ::sfx2::sidebar::ControlFactory::CreateCustomImageRadionButton( this, SW_RES(RB_WRAP_THROUGH
) ) )
72 , mpRBIdealWrap( ::sfx2::sidebar::ControlFactory::CreateCustomImageRadionButton( this, SW_RES(RB_WRAP_IDEAL
) ) )
76 , maSwNoWrapControl(FN_FRAME_NOWRAP
, *pBindings
, *this)
77 , maSwWrapLeftControl(FN_FRAME_WRAP
, *pBindings
, *this)
78 , maSwWrapRightControl(FN_FRAME_WRAP_RIGHT
, *pBindings
, *this)
79 , maSwWrapParallelControl(FN_FRAME_WRAP_LEFT
, *pBindings
, *this)
80 , maSwWrapThroughControl(FN_FRAME_WRAPTHRU
, *pBindings
, *this)
81 , maSwWrapIdealControl(FN_FRAME_WRAP_IDEAL
, *pBindings
, *this)
88 WrapPropertyPanel::~WrapPropertyPanel()
93 void WrapPropertyPanel::Initialize()
95 Link aLink
= LINK(this, WrapPropertyPanel
, WrapTypeHdl
);
96 mpRBNoWrap
->SetClickHdl(aLink
);
97 mpRBWrapLeft
->SetClickHdl(aLink
);
98 mpRBWrapRight
->SetClickHdl(aLink
);
99 mpRBWrapParallel
->SetClickHdl(aLink
);
100 mpRBWrapThrough
->SetClickHdl(aLink
);
101 mpRBIdealWrap
->SetClickHdl(aLink
);
103 aWrapIL
.AddImage( IMG_NONE
,
104 ::GetImage( mxFrame
, A2S(".uno:WrapOff"), sal_False
) );
105 aWrapIL
.AddImage( IMG_LEFT
,
106 ::GetImage( mxFrame
, A2S(".uno:WrapLeft"), sal_False
) );
107 aWrapIL
.AddImage( IMG_RIGHT
,
108 ::GetImage( mxFrame
, A2S(".uno:WrapRight"), sal_False
) );
109 aWrapIL
.AddImage( IMG_PARALLEL
,
110 ::GetImage( mxFrame
, A2S(".uno:WrapOn"), sal_False
) );
111 aWrapIL
.AddImage( IMG_THROUGH
,
112 ::GetImage( mxFrame
, A2S(".uno:WrapThrough"), sal_False
) );
113 aWrapIL
.AddImage( IMG_IDEAL
,
114 ::GetImage( mxFrame
, A2S(".uno:WrapIdeal"), sal_False
) );
116 mpRBNoWrap
->SetModeRadioImage( aWrapIL
.GetImage(IMG_NONE
) );
117 if ( Application::GetSettings().GetLayoutRTL() )
119 mpRBWrapLeft
->SetModeRadioImage( aWrapIL
.GetImage(IMG_RIGHT
) );
120 mpRBWrapRight
->SetModeRadioImage( aWrapIL
.GetImage(IMG_LEFT
) );
124 mpRBWrapLeft
->SetModeRadioImage( aWrapIL
.GetImage(IMG_LEFT
) );
125 mpRBWrapRight
->SetModeRadioImage( aWrapIL
.GetImage(IMG_RIGHT
) );
127 mpRBWrapParallel
->SetModeRadioImage( aWrapIL
.GetImage(IMG_PARALLEL
) );
128 mpRBWrapThrough
->SetModeRadioImage( aWrapIL
.GetImage(IMG_THROUGH
) );
129 mpRBIdealWrap
->SetModeRadioImage( aWrapIL
.GetImage(IMG_IDEAL
) );
131 mpRBNoWrap
->SetAccessibleName(mpRBNoWrap
->GetQuickHelpText());
132 mpRBWrapLeft
->SetAccessibleName(mpRBWrapLeft
->GetQuickHelpText());
133 mpRBWrapRight
->SetAccessibleName(mpRBWrapRight
->GetQuickHelpText());
134 mpRBWrapParallel
->SetAccessibleName(mpRBWrapParallel
->GetQuickHelpText());
135 mpRBWrapThrough
->SetAccessibleName(mpRBWrapThrough
->GetQuickHelpText());
136 mpRBIdealWrap
->SetAccessibleName(mpRBIdealWrap
->GetQuickHelpText());
138 mpBindings
->Update( FN_FRAME_NOWRAP
);
139 mpBindings
->Update( FN_FRAME_WRAP
);
140 mpBindings
->Update( FN_FRAME_WRAP_RIGHT
);
141 mpBindings
->Update( FN_FRAME_WRAP_LEFT
);
142 mpBindings
->Update( FN_FRAME_WRAPTHRU
);
143 mpBindings
->Update( FN_FRAME_WRAP_IDEAL
);
147 IMPL_LINK(WrapPropertyPanel
, WrapTypeHdl
, void *, EMPTYARG
)
149 sal_uInt16 nSlot
= 0;
150 if ( mpRBWrapLeft
->IsChecked() )
152 nSlot
= FN_FRAME_WRAP_LEFT
;
154 else if( mpRBWrapRight
->IsChecked() )
156 nSlot
= FN_FRAME_WRAP_RIGHT
;
158 else if ( mpRBWrapParallel
->IsChecked() )
160 nSlot
= FN_FRAME_WRAP
;
162 else if( mpRBWrapThrough
->IsChecked() )
164 nSlot
= FN_FRAME_WRAPTHRU
;
166 else if( mpRBIdealWrap
->IsChecked() )
168 nSlot
= FN_FRAME_WRAP_IDEAL
;
172 nSlot
= FN_FRAME_NOWRAP
;
174 SfxBoolItem
bStateItem( nSlot
, sal_True
);
175 mpBindings
->GetDispatcher()->Execute( nSlot
, SFX_CALLMODE_RECORD
, &bStateItem
, 0L );
181 void WrapPropertyPanel::NotifyItemUpdate(
182 const sal_uInt16 nSId
,
183 const SfxItemState eState
,
184 const SfxPoolItem
* pState
,
185 const bool bIsEnabled
)
189 if ( eState
== SFX_ITEM_AVAILABLE
&&
190 pState
->ISA(SfxBoolItem
) )
192 //Set Radio Button enable
193 mpRBNoWrap
->Enable(true);
194 mpRBWrapLeft
->Enable(true);
195 mpRBWrapRight
->Enable(true);
196 mpRBWrapParallel
->Enable(true);
197 mpRBWrapThrough
->Enable(true);
198 mpRBIdealWrap
->Enable(true);
200 const SfxBoolItem
* pBoolItem
= static_cast< const SfxBoolItem
* >( pState
);
203 case FN_FRAME_WRAP_RIGHT
:
204 mpRBWrapRight
->Check( pBoolItem
->GetValue() );
206 case FN_FRAME_WRAP_LEFT
:
207 mpRBWrapLeft
->Check( pBoolItem
->GetValue() );
209 case FN_FRAME_WRAPTHRU
:
210 mpRBWrapThrough
->Check( pBoolItem
->GetValue() );
212 case FN_FRAME_WRAP_IDEAL
:
213 mpRBIdealWrap
->Check( pBoolItem
->GetValue() );
216 mpRBWrapParallel
->Check( pBoolItem
->GetValue() );
218 case FN_FRAME_NOWRAP
:
220 mpRBNoWrap
->Check( pBoolItem
->GetValue() );
226 mpRBNoWrap
->Enable(false);
227 mpRBWrapLeft
->Enable(false);
228 mpRBWrapRight
->Enable(false);
229 mpRBWrapParallel
->Enable(false);
230 mpRBWrapThrough
->Enable(false);
231 mpRBIdealWrap
->Enable(false);
233 mpRBNoWrap
->Check( sal_False
);
234 mpRBWrapLeft
->Check( sal_False
);
235 mpRBWrapRight
->Check( sal_False
);
236 mpRBWrapParallel
->Check( sal_False
);
237 mpRBWrapThrough
->Check( sal_False
);
238 mpRBIdealWrap
->Check( sal_False
);
242 } } // end of namespace ::sw::sidebar