Lines 25-75
Link Here
|
25 |
* |
25 |
* |
26 |
************************************************************************/ |
26 |
************************************************************************/ |
27 |
|
27 |
|
28 |
|
|
|
29 |
#include "ListenerHelper.h" |
28 |
#include "ListenerHelper.h" |
30 |
#include "MyProtocolHandler.h" |
29 |
#include "MyProtocolHandler.h" |
31 |
#include <com/sun/star/beans/PropertyValue.hpp> |
30 |
|
32 |
#include <com/sun/star/frame/XFrame.hpp> |
31 |
#include <com/sun/star/awt/MessageBoxButtons.hpp> |
33 |
#include <com/sun/star/frame/XController.hpp> |
32 |
#include <com/sun/star/awt/XMessageBoxFactory.hpp> |
34 |
#include <com/sun/star/frame/DispatchDescriptor.hpp> |
33 |
#include <com/sun/star/frame/ControlCommand.hpp> |
35 |
#include <com/sun/star/text/XTextViewCursorSupplier.hpp> |
34 |
#include <com/sun/star/text/XTextViewCursorSupplier.hpp> |
36 |
#include <com/sun/star/text/XTextViewCursor.hpp> |
|
|
37 |
#include <com/sun/star/text/XTextCursor.hpp> |
38 |
#include <com/sun/star/text/XTextDocument.hpp> |
39 |
#include <com/sun/star/sheet/XSpreadsheetView.hpp> |
35 |
#include <com/sun/star/sheet/XSpreadsheetView.hpp> |
40 |
#include <com/sun/star/frame/ControlCommand.hpp> |
|
|
41 |
#include <com/sun/star/frame/ControlEvent.hpp> |
42 |
#include <com/sun/star/frame/XModel.hpp> |
43 |
#include <com/sun/star/frame/XControlNotificationListener.hpp> |
44 |
#include <com/sun/star/beans/PropertyValue.hpp> |
45 |
#include <com/sun/star/awt/XWindowPeer.hpp> |
46 |
#include <com/sun/star/awt/WindowAttribute.hpp> |
47 |
#include <com/sun/star/awt/XMessageBox.hpp> |
48 |
#include <com/sun/star/frame/XComponentLoader.hpp> |
49 |
#include <com/sun/star/view/XSelectionSupplier.hpp> |
50 |
#include <com/sun/star/system/XSystemShellExecute.hpp> |
51 |
#include <com/sun/star/system/SystemShellExecuteFlags.hpp> |
36 |
#include <com/sun/star/system/SystemShellExecuteFlags.hpp> |
52 |
#include <com/sun/star/frame/XStorable.hpp> |
37 |
#include <com/sun/star/system/XSystemShellExecute.hpp> |
53 |
#include <com/sun/star/container/XContainerQuery.hpp> |
|
|
54 |
|
38 |
|
55 |
#include <osl/file.hxx> |
|
|
56 |
|
39 |
|
57 |
using namespace com::sun::star::uno; |
40 |
using namespace com::sun::star::awt; |
58 |
using namespace com::sun::star::frame; |
41 |
using namespace com::sun::star::frame; |
59 |
using com::sun::star::lang::XMultiServiceFactory; |
42 |
using namespace com::sun::star::system; |
|
|
43 |
using namespace com::sun::star::uno; |
44 |
|
45 |
using com::sun::star::beans::NamedValue; |
60 |
using com::sun::star::beans::PropertyValue; |
46 |
using com::sun::star::beans::PropertyValue; |
61 |
using com::sun::star::util::URL; |
47 |
using com::sun::star::lang::XMultiServiceFactory; |
62 |
using com::sun::star::text::XTextViewCursorSupplier; |
|
|
63 |
using com::sun::star::text::XTextViewCursor; |
64 |
using com::sun::star::text::XTextCursor; |
65 |
using com::sun::star::sheet::XSpreadsheetView; |
48 |
using com::sun::star::sheet::XSpreadsheetView; |
66 |
using com::sun::star::frame::XModel; |
49 |
using com::sun::star::text::XTextViewCursorSupplier; |
67 |
using com::sun::star::text::XTextRange; |
50 |
using com::sun::star::util::URL; |
68 |
using com::sun::star::text::XTextDocument; |
|
|
69 |
using com::sun::star::beans::NamedValue; |
70 |
using namespace com::sun::star::awt; |
71 |
using com::sun::star::view::XSelectionSupplier; |
72 |
using namespace com::sun::star::system; |
73 |
|
51 |
|
74 |
ListenerHelper aListenerHelper; |
52 |
ListenerHelper aListenerHelper; |
75 |
|
53 |
|
Lines 77-106
void BaseDispatch::ShowMessageBox( const Reference< XFrame >& rFrame, const ::rt
Link Here
|
77 |
{ |
55 |
{ |
78 |
if ( !mxToolkit.is() ) |
56 |
if ( !mxToolkit.is() ) |
79 |
mxToolkit = Reference< XToolkit > ( mxMSF->createInstance( |
57 |
mxToolkit = Reference< XToolkit > ( mxMSF->createInstance( |
80 |
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( |
58 |
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" ))), UNO_QUERY ); |
81 |
"com.sun.star.awt.Toolkit" ))), UNO_QUERY ); |
59 |
|
82 |
if ( rFrame.is() && mxToolkit.is() ) |
60 |
Reference< XMessageBoxFactory > xMsgBoxFactory( mxToolkit, UNO_QUERY ); |
|
|
61 |
if ( rFrame.is() && xMsgBoxFactory.is() ) |
83 |
{ |
62 |
{ |
84 |
// describe window properties. |
63 |
Reference< XMessageBox > xMsgBox = xMsgBoxFactory->createMessageBox( |
85 |
WindowDescriptor aDescriptor; |
64 |
Reference< XWindowPeer >( rFrame->getContainerWindow(), UNO_QUERY ), |
86 |
aDescriptor.Type = WindowClass_MODALTOP; |
65 |
Rectangle(0,0,300,200), |
87 |
aDescriptor.WindowServiceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "infobox" )); |
66 |
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "infobox" ) ), |
88 |
aDescriptor.ParentIndex = -1; |
67 |
MessageBoxButtons::BUTTONS_OK, |
89 |
aDescriptor.Parent = Reference< XWindowPeer >( rFrame->getContainerWindow(), UNO_QUERY ); |
68 |
aTitle, |
90 |
aDescriptor.Bounds = Rectangle(0,0,300,200); |
69 |
aMsgText ); |
91 |
aDescriptor.WindowAttributes = WindowAttribute::BORDER | WindowAttribute::MOVEABLE | WindowAttribute::CLOSEABLE; |
70 |
|
92 |
|
71 |
if ( xMsgBox.is() ) |
93 |
Reference< XWindowPeer > xPeer = mxToolkit->createWindow( aDescriptor ); |
72 |
xMsgBox->execute(); |
94 |
if ( xPeer.is() ) |
|
|
95 |
{ |
96 |
Reference< XMessageBox > xMsgBox( xPeer, UNO_QUERY ); |
97 |
if ( xMsgBox.is() ) |
98 |
{ |
99 |
xMsgBox->setCaptionText( aTitle ); |
100 |
xMsgBox->setMessageText( aMsgText ); |
101 |
xMsgBox->execute(); |
102 |
} |
103 |
} |
104 |
} |
73 |
} |
105 |
} |
74 |
} |
106 |
|
75 |
|
Lines 161-167
Reference< XDispatch > SAL_CALL MyProtocolHandler::queryDispatch( const URL& aUR
Link Here
|
161 |
return 0; |
130 |
return 0; |
162 |
|
131 |
|
163 |
Reference < XController > xCtrl = mxFrame->getController(); |
132 |
Reference < XController > xCtrl = mxFrame->getController(); |
164 |
if ( xCtrl.is() && !aURL.Protocol.compareToAscii("vnd.demo.complextoolbarcontrols.demoaddon:") ) |
133 |
if ( xCtrl.is() && !aURL.Protocol.compareToAscii( |
|
|
134 |
RTL_CONSTASCII_STRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) ) ) |
165 |
{ |
135 |
{ |
166 |
Reference < XTextViewCursorSupplier > xCursor( xCtrl, UNO_QUERY ); |
136 |
Reference < XTextViewCursorSupplier > xCursor( xCtrl, UNO_QUERY ); |
167 |
Reference < XSpreadsheetView > xView( xCtrl, UNO_QUERY ); |
137 |
Reference < XSpreadsheetView > xView( xCtrl, UNO_QUERY ); |
Lines 169-181
Reference< XDispatch > SAL_CALL MyProtocolHandler::queryDispatch( const URL& aUR
Link Here
|
169 |
// ohne ein entsprechendes Dokument funktioniert der Handler nicht |
139 |
// ohne ein entsprechendes Dokument funktioniert der Handler nicht |
170 |
return xRet; |
140 |
return xRet; |
171 |
|
141 |
|
172 |
if ( aURL.Path.equalsAscii("Command1" ) || |
142 |
if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ImageButtonCmd" ) ) || |
173 |
aURL.Path.equalsAscii("Command2" ) || |
143 |
aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ComboboxCmd" ) ) || |
174 |
aURL.Path.equalsAscii("Command3" ) || |
144 |
aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ToggleDropdownButtonCmd" ) ) || |
175 |
aURL.Path.equalsAscii("Command4" ) || |
145 |
aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DropdownButtonCmd" ) ) || |
176 |
aURL.Path.equalsAscii("Command5" ) || |
146 |
aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "SpinfieldCmd" ) ) || |
177 |
aURL.Path.equalsAscii("Command6" ) || |
147 |
aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "EditfieldCmd" ) ) || |
178 |
aURL.Path.equalsAscii("Command7" ) ) |
148 |
aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DropdownboxCmd" ) ) ) |
179 |
{ |
149 |
{ |
180 |
xRet = aListenerHelper.GetDispatch( mxFrame, aURL.Path ); |
150 |
xRet = aListenerHelper.GetDispatch( mxFrame, aURL.Path ); |
181 |
if ( !xRet.is() ) |
151 |
if ( !xRet.is() ) |
Lines 205-219
Sequence < Reference< XDispatch > > SAL_CALL MyProtocolHandler::queryDispatches(
Link Here
|
205 |
::rtl::OUString MyProtocolHandler_getImplementationName () |
175 |
::rtl::OUString MyProtocolHandler_getImplementationName () |
206 |
throw (RuntimeException) |
176 |
throw (RuntimeException) |
207 |
{ |
177 |
{ |
208 |
return ::rtl::OUString::createFromAscii(MYPROTOCOLHANDLER_IMPLEMENTATIONNAME); |
178 |
return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYPROTOCOLHANDLER_IMPLEMENTATIONNAME ) ); |
209 |
} |
179 |
} |
210 |
|
180 |
|
211 |
sal_Bool SAL_CALL MyProtocolHandler_supportsService( const ::rtl::OUString& ServiceName ) |
181 |
sal_Bool SAL_CALL MyProtocolHandler_supportsService( const ::rtl::OUString& ServiceName ) |
212 |
throw (RuntimeException) |
182 |
throw (RuntimeException) |
213 |
{ |
183 |
{ |
214 |
return ( |
184 |
return ( |
215 |
ServiceName.equalsAscii(MYPROTOCOLHANDLER_SERVICENAME ) || |
185 |
ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MYPROTOCOLHANDLER_SERVICENAME ) ) || |
216 |
ServiceName.equalsAscii("com.sun.star.frame.ProtocolHandler") |
186 |
ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.frame.ProtocolHandler" ) ) |
217 |
); |
187 |
); |
218 |
} |
188 |
} |
219 |
|
189 |
|
Lines 221-227
Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler_getSupportedServiceNames(
Link Here
|
221 |
throw (RuntimeException) |
191 |
throw (RuntimeException) |
222 |
{ |
192 |
{ |
223 |
Sequence < ::rtl::OUString > aRet(1); |
193 |
Sequence < ::rtl::OUString > aRet(1); |
224 |
aRet[0] = ::rtl::OUString::createFromAscii(MYPROTOCOLHANDLER_SERVICENAME); |
194 |
aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYPROTOCOLHANDLER_SERVICENAME ) ); |
225 |
return aRet; |
195 |
return aRet; |
226 |
} |
196 |
} |
227 |
|
197 |
|
Lines 263-296
void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < Property
Link Here
|
263 |
*/ |
233 |
*/ |
264 |
Reference< XInterface > xSelfHold(static_cast< XDispatch* >(this), UNO_QUERY); |
234 |
Reference< XInterface > xSelfHold(static_cast< XDispatch* >(this), UNO_QUERY); |
265 |
|
235 |
|
266 |
if ( !aURL.Protocol.compareToAscii("vnd.demo.complextoolbarcontrols.demoaddon:") ) |
236 |
if ( !aURL.Protocol.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) ) ) |
267 |
{ |
237 |
{ |
268 |
if ( !aURL.Path.compareToAscii("Command1" ) ) |
238 |
if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ImageButtonCmd" ) ) ) |
269 |
{ |
239 |
{ |
270 |
// open the OpenOffice.org web page |
240 |
// open the OpenOffice.org web page |
271 |
::rtl::OUString sURL(::rtl::OUString::createFromAscii("http://www.openoffice.org")); |
241 |
::rtl::OUString sURL( RTL_CONSTASCII_USTRINGPARAM( "http://www.openoffice.org" ) ); |
272 |
Reference< XSystemShellExecute > xSystemShellExecute( mxMSF->createInstance( |
242 |
Reference< XSystemShellExecute > xSystemShellExecute( mxMSF->createInstance( |
273 |
::rtl::OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" )), UNO_QUERY ); |
243 |
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.system.SystemShellExecute" ) ) ), UNO_QUERY ); |
274 |
if ( xSystemShellExecute.is() ) |
244 |
if ( xSystemShellExecute.is() ) |
275 |
{ |
245 |
{ |
276 |
try |
246 |
try |
277 |
|
|
|
278 |
{ |
247 |
{ |
279 |
xSystemShellExecute->execute( sURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS ); |
248 |
xSystemShellExecute->execute( sURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS ); |
280 |
} |
249 |
} |
281 |
catch( Exception& rEx ) |
250 |
catch( Exception& rEx ) |
282 |
{ |
251 |
{ |
283 |
(void)rEx; |
252 |
(void)rEx; |
284 |
} |
253 |
} |
285 |
} |
254 |
} |
286 |
} |
255 |
} |
287 |
else if ( !aURL.Path.compareToAscii("Command2" ) ) |
256 |
else if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ComboboxCmd" ) ) ) |
288 |
{ |
257 |
{ |
289 |
// remove the text if it's in our list |
258 |
// remove the text if it's in our list |
290 |
Sequence< NamedValue > aRemoveArgs( 1 ); |
259 |
Sequence< NamedValue > aRemoveArgs( 1 ); |
291 |
aRemoveArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )); |
260 |
aRemoveArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )); |
292 |
aRemoveArgs[0].Value <<= maComboBoxText; |
261 |
aRemoveArgs[0].Value <<= maComboBoxText; |
293 |
SendCommand( aURL, ::rtl::OUString::createFromAscii( "RemoveEntryText" ), aRemoveArgs, sal_True ); |
262 |
SendCommand( aURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RemoveEntryText" ) ), aRemoveArgs, sal_True ); |
294 |
|
263 |
|
295 |
// add the new text to the start of the list |
264 |
// add the new text to the start of the list |
296 |
Sequence< NamedValue > aInsertArgs( 2 ); |
265 |
Sequence< NamedValue > aInsertArgs( 2 ); |
Lines 298-312
void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < Property
Link Here
|
298 |
aInsertArgs[0].Value <<= sal_Int32( 0 ); |
267 |
aInsertArgs[0].Value <<= sal_Int32( 0 ); |
299 |
aInsertArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )); |
268 |
aInsertArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" )); |
300 |
aInsertArgs[1].Value <<= maComboBoxText; |
269 |
aInsertArgs[1].Value <<= maComboBoxText; |
301 |
SendCommand( aURL, ::rtl::OUString::createFromAscii( "InsertEntry" ), aInsertArgs, sal_True ); |
270 |
SendCommand( aURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InsertEntry" ) ), aInsertArgs, sal_True ); |
302 |
} |
271 |
} |
303 |
else if ( !aURL.Path.compareToAscii("Command3" ) ) |
272 |
else if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ToggleDropdownButtonCmd" ) ) ) |
304 |
{ |
273 |
{ |
305 |
// Retrieve the text argument from the sequence property value |
274 |
// Retrieve the text argument from the sequence property value |
306 |
rtl::OUString aText; |
275 |
rtl::OUString aText; |
307 |
for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ ) |
276 |
for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ ) |
308 |
{ |
277 |
{ |
309 |
if ( lArgs[i].Name.equalsAsciiL( "Text", 4 )) |
278 |
if ( lArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Text" ) ) ) |
310 |
{ |
279 |
{ |
311 |
lArgs[i].Value >>= aText; |
280 |
lArgs[i].Value >>= aText; |
312 |
break; |
281 |
break; |
Lines 315-337
void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < Property
Link Here
|
315 |
|
284 |
|
316 |
// create new URL to address the combox box |
285 |
// create new URL to address the combox box |
317 |
URL aCmdURL; |
286 |
URL aCmdURL; |
318 |
aCmdURL.Path = rtl::OUString::createFromAscii( "Command2" ); |
287 |
aCmdURL.Path = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ComboboxCmd" ) ); |
319 |
aCmdURL.Protocol = rtl::OUString::createFromAscii( "vnd.demo.complextoolbarcontrols.demoaddon:" ); |
288 |
aCmdURL.Protocol = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) ); |
320 |
aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol; |
289 |
aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol; |
321 |
|
290 |
|
322 |
// set the selected item as text into the combobox |
291 |
// set the selected item as text into the combobox |
323 |
Sequence< NamedValue > aArgs( 1 ); |
292 |
Sequence< NamedValue > aArgs( 1 ); |
324 |
aArgs[0].Name = rtl::OUString::createFromAscii( "Text" ); |
293 |
aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ); |
325 |
aArgs[0].Value <<= aText; |
294 |
aArgs[0].Value <<= aText; |
326 |
SendCommand( aCmdURL, ::rtl::OUString::createFromAscii( "SetText" ), aArgs, sal_True ); |
295 |
SendCommand( aCmdURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SetText" ) ), aArgs, sal_True ); |
327 |
} |
296 |
} |
328 |
else if ( !aURL.Path.compareToAscii("Command4" ) ) |
297 |
else if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "DropdownButtonCmd" ) ) ) |
329 |
{ |
298 |
{ |
330 |
// Retrieve the text argument from the sequence property value |
299 |
// Retrieve the text argument from the sequence property value |
331 |
rtl::OUString aText; |
300 |
rtl::OUString aText; |
332 |
for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ ) |
301 |
for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ ) |
333 |
{ |
302 |
{ |
334 |
if ( lArgs[i].Name.equalsAsciiL( "Text", 4 )) |
303 |
if ( lArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Text" ) ) ) |
335 |
{ |
304 |
{ |
336 |
lArgs[i].Value >>= aText; |
305 |
lArgs[i].Value >>= aText; |
337 |
break; |
306 |
break; |
Lines 341-357
void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < Property
Link Here
|
341 |
// just enable this command |
310 |
// just enable this command |
342 |
|
311 |
|
343 |
// set enable flag according to selection |
312 |
// set enable flag according to selection |
344 |
if ( aText.equalsAscii( "Button Disabled" )) |
313 |
if ( aText.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Button Disabled" ) )) |
345 |
mbButtonEnabled = sal_False; |
314 |
mbButtonEnabled = sal_False; |
346 |
else |
315 |
else |
347 |
mbButtonEnabled = sal_True; |
316 |
mbButtonEnabled = sal_True; |
348 |
|
317 |
|
349 |
// create new URL to address the image button |
318 |
// create new URL to address the image button |
350 |
URL aCmdURL; |
319 |
URL aCmdURL; |
351 |
aCmdURL.Path = rtl::OUString::createFromAscii( "Command1" ); |
320 |
aCmdURL.Path = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ImageButtonCmd" ) ); |
352 |
aCmdURL.Protocol = rtl::OUString::createFromAscii( "vnd.demo.complextoolbarcontrols.demoaddon:" ); |
321 |
aCmdURL.Protocol = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) ); |
353 |
aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol; |
322 |
aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol; |
354 |
|
323 |
|
355 |
// create and initialize FeatureStateEvent with IsEnabled |
324 |
// create and initialize FeatureStateEvent with IsEnabled |
356 |
::com::sun::star::frame::FeatureStateEvent aEvent; |
325 |
::com::sun::star::frame::FeatureStateEvent aEvent; |
357 |
aEvent.FeatureURL = aCmdURL; |
326 |
aEvent.FeatureURL = aCmdURL; |
Lines 359-380
void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < Property
Link Here
|
359 |
aEvent.IsEnabled = mbButtonEnabled; |
328 |
aEvent.IsEnabled = mbButtonEnabled; |
360 |
aEvent.Requery = sal_False; |
329 |
aEvent.Requery = sal_False; |
361 |
aEvent.State <<= Any(); |
330 |
aEvent.State <<= Any(); |
362 |
|
331 |
|
363 |
// Notify listener about new state |
332 |
// Notify listener about new state |
364 |
Reference < XDispatch > xDispatch = aListenerHelper.GetDispatch( mxFrame, aURL.Path ); |
333 |
Reference < XDispatch > xDispatch = aListenerHelper.GetDispatch( mxFrame, aURL.Path ); |
365 |
aListenerHelper.Notify( mxFrame, aEvent.FeatureURL.Path, aEvent ); |
334 |
aListenerHelper.Notify( mxFrame, aEvent.FeatureURL.Path, aEvent ); |
366 |
} |
335 |
} |
367 |
else if ( !aURL.Path.compareToAscii("Command5" ) ) |
336 |
else if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "SpinfieldCmd" ) ) ) |
368 |
{ |
337 |
{ |
369 |
} |
338 |
} |
|
|
339 |
else if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "DropdownboxCmd" ) ) ) |
340 |
{ |
341 |
// Retrieve the text argument from the sequence property value |
342 |
rtl::OUString aText; |
343 |
for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ ) |
344 |
{ |
345 |
if ( lArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Text" ) ) ) |
346 |
{ |
347 |
lArgs[i].Value >>= aText; |
348 |
break; |
349 |
} |
350 |
} |
351 |
OSL_TRACE( "Dropdownbox control - selected entry text : %s", |
352 |
rtl::OUStringToOString( aText, RTL_TEXTENCODING_UTF8 ).getStr() ); |
353 |
} |
370 |
} |
354 |
} |
371 |
} |
355 |
} |
372 |
|
356 |
|
373 |
void SAL_CALL BaseDispatch::addStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) throw (RuntimeException) |
357 |
void SAL_CALL BaseDispatch::addStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) throw (RuntimeException) |
374 |
{ |
358 |
{ |
375 |
if ( aURL.Protocol.equalsAscii("vnd.demo.complextoolbarcontrols.demoaddon:") ) |
359 |
if ( aURL.Protocol.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) ) ) |
376 |
{ |
360 |
{ |
377 |
if ( aURL.Path.equalsAscii("Command1" ) ) |
361 |
if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ImageButtonCmd" ) ) ) |
378 |
{ |
362 |
{ |
379 |
// just enable this command |
363 |
// just enable this command |
380 |
::com::sun::star::frame::FeatureStateEvent aEvent; |
364 |
::com::sun::star::frame::FeatureStateEvent aEvent; |
Lines 385-391
void SAL_CALL BaseDispatch::addStatusListener( const Reference< XStatusListener
Link Here
|
385 |
aEvent.State <<= Any(); |
369 |
aEvent.State <<= Any(); |
386 |
xControl->statusChanged( aEvent ); |
370 |
xControl->statusChanged( aEvent ); |
387 |
} |
371 |
} |
388 |
else if ( aURL.Path.equalsAscii("Command2" ) ) |
372 |
else if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ComboboxCmd" ) ) ) |
389 |
{ |
373 |
{ |
390 |
// just enable this command |
374 |
// just enable this command |
391 |
::com::sun::star::frame::FeatureStateEvent aEvent; |
375 |
::com::sun::star::frame::FeatureStateEvent aEvent; |
Lines 396-488
void SAL_CALL BaseDispatch::addStatusListener( const Reference< XStatusListener
Link Here
|
396 |
aEvent.State <<= Any(); |
380 |
aEvent.State <<= Any(); |
397 |
xControl->statusChanged( aEvent ); |
381 |
xControl->statusChanged( aEvent ); |
398 |
} |
382 |
} |
399 |
else if ( aURL.Path.equalsAscii("Command3" ) ) |
383 |
else if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ToggleDropdownButtonCmd" ) ) ) |
400 |
{ |
384 |
{ |
401 |
// A toggle dropdown box is normally used for a group of commands |
385 |
// A toggle dropdown box is normally used for a group of commands |
402 |
// where the user can select the last issued command easily. |
386 |
// where the user can select the last issued command easily. |
403 |
// E.g. a typical command group would be "Insert shape" |
387 |
// E.g. a typical command group would be "Insert shape" |
404 |
Sequence< NamedValue > aArgs( 1 ); |
388 |
Sequence< NamedValue > aArgs( 1 ); |
405 |
|
389 |
|
406 |
// send command to set context menu content |
390 |
// send command to set context menu content |
407 |
Sequence< rtl::OUString > aContextMenu( 3 ); |
391 |
Sequence< rtl::OUString > aContextMenu( 3 ); |
408 |
aContextMenu[0] = rtl::OUString::createFromAscii( "Command 1" ); |
392 |
aContextMenu[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Command 1" ) ); |
409 |
aContextMenu[1] = rtl::OUString::createFromAscii( "Command 2" ); |
393 |
aContextMenu[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Command 2" ) ); |
410 |
aContextMenu[2] = rtl::OUString::createFromAscii( "Command 3" ); |
394 |
aContextMenu[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Command 3" ) ); |
411 |
|
395 |
|
412 |
aArgs[0].Name = rtl::OUString::createFromAscii( "List" ); |
396 |
aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ); |
413 |
aArgs[0].Value <<= aContextMenu; |
397 |
aArgs[0].Value <<= aContextMenu; |
414 |
SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetList" ), aArgs, sal_True ); |
398 |
SendCommandTo( xControl, aURL, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SetList" ) ), aArgs, sal_True ); |
415 |
|
399 |
|
416 |
// send command to check item on pos=0 |
400 |
// send command to check item on pos=0 |
417 |
aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" )); |
401 |
aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" )); |
418 |
aArgs[0].Value <<= sal_Int32( 0 ); |
402 |
aArgs[0].Value <<= sal_Int32( 0 ); |
419 |
SendCommandTo( xControl, aURL, ::rtl::OUString::createFromAscii( "CheckItemPos" ), aArgs, sal_True ); |
403 |
SendCommandTo( xControl, aURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CheckItemPos" ) ), aArgs, sal_True ); |
420 |
} |
404 |
} |
421 |
else if ( aURL.Path.equalsAscii("Command4" ) ) |
405 |
else if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DropdownButtonCmd" ) ) ) |
422 |
{ |
406 |
{ |
423 |
// A dropdown box is normally used for a group of dependent modes, where |
407 |
// A dropdown box is normally used for a group of dependent modes, where |
424 |
// the user can only select one. The modes cannot be combined. |
408 |
// the user can only select one. The modes cannot be combined. |
425 |
// E.g. a typical group would be left,right,center,block. |
409 |
// E.g. a typical group would be left,right,center,block. |
426 |
Sequence< NamedValue > aArgs( 1 ); |
410 |
Sequence< NamedValue > aArgs( 1 ); |
427 |
|
411 |
|
428 |
// send command to set context menu content |
412 |
// send command to set context menu content |
429 |
Sequence< rtl::OUString > aContextMenu( 2 ); |
413 |
Sequence< rtl::OUString > aContextMenu( 2 ); |
430 |
aContextMenu[0] = rtl::OUString::createFromAscii( "Button Enabled" ); |
414 |
aContextMenu[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Button Enabled" ) ); |
431 |
aContextMenu[1] = rtl::OUString::createFromAscii( "Button Disabled" ); |
415 |
aContextMenu[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Button Disabled" ) ); |
432 |
|
416 |
|
433 |
aArgs[0].Name = rtl::OUString::createFromAscii( "List" ); |
417 |
aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ); |
434 |
aArgs[0].Value <<= aContextMenu; |
418 |
aArgs[0].Value <<= aContextMenu; |
435 |
SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetList" ), aArgs, sal_True ); |
419 |
SendCommandTo( xControl, aURL, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SetList" ) ), aArgs, sal_True ); |
436 |
|
420 |
|
437 |
// set position according to enable/disable state of button |
421 |
// set position according to enable/disable state of button |
438 |
sal_Int32 nPos( mbButtonEnabled ? 0 : 1 ); |
422 |
sal_Int32 nPos( mbButtonEnabled ? 0 : 1 ); |
439 |
|
423 |
|
440 |
// send command to check item on pos=0 |
424 |
// send command to check item on pos=0 |
441 |
aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" )); |
425 |
aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" ) ); |
442 |
aArgs[0].Value <<= nPos; |
426 |
aArgs[0].Value <<= nPos; |
443 |
SendCommandTo( xControl, aURL, ::rtl::OUString::createFromAscii( "CheckItemPos" ), aArgs, sal_True ); |
427 |
SendCommandTo( xControl, aURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CheckItemPos" ) ), aArgs, sal_True ); |
444 |
} |
428 |
} |
445 |
else if ( aURL.Path.equalsAscii("Command5" ) ) |
429 |
else if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "SpinfieldCmd" ) ) ) |
446 |
{ |
430 |
{ |
447 |
// A spin button |
431 |
// A spin button |
448 |
Sequence< NamedValue > aArgs( 5 ); |
432 |
Sequence< NamedValue > aArgs( 5 ); |
449 |
|
433 |
|
450 |
// send command to initialize spin button |
434 |
// send command to initialize spin button |
451 |
aArgs[0].Name = rtl::OUString::createFromAscii( "Value" ); |
435 |
aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value" ) ); |
452 |
aArgs[0].Value <<= double( 0.0 ); |
436 |
aArgs[0].Value <<= double( 0.0 ); |
453 |
aArgs[1].Name = rtl::OUString::createFromAscii( "UpperLimit" ); |
437 |
aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UpperLimit" ) ); |
454 |
aArgs[1].Value <<= double( 10.0 ); |
438 |
aArgs[1].Value <<= double( 10.0 ); |
455 |
aArgs[2].Name = rtl::OUString::createFromAscii( "LowerLimit" ); |
439 |
aArgs[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LowerLimit" ) ); |
456 |
aArgs[2].Value <<= double( 0.0 ); |
440 |
aArgs[2].Value <<= double( 0.0 ); |
457 |
aArgs[3].Name = rtl::OUString::createFromAscii( "Step" ); |
441 |
aArgs[3].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Step" ) ); |
458 |
aArgs[3].Value <<= double( 0.1 ); |
442 |
aArgs[3].Value <<= double( 0.1 ); |
459 |
aArgs[4].Name = rtl::OUString::createFromAscii( "OutputFormat" ); |
443 |
aArgs[4].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OutputFormat" ) ); |
460 |
aArgs[4].Value <<= rtl::OUString::createFromAscii( "%.2f cm" ); |
444 |
aArgs[4].Value <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "%.2f cm" ) ); |
461 |
|
445 |
|
462 |
SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetValues" ), aArgs, sal_True ); |
446 |
SendCommandTo( xControl, aURL, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SetValues" ) ), aArgs, sal_True ); |
463 |
} |
447 |
} |
464 |
else if ( aURL.Path.equalsAscii("Command7" ) ) |
448 |
else if ( aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DropdownboxCmd" ) ) ) |
465 |
{ |
449 |
{ |
466 |
// A dropdown box is normally used for a group of commands |
450 |
// A dropdown box is normally used for a group of commands |
467 |
// where the user can select one of a defined set. |
451 |
// where the user can select one of a defined set. |
468 |
Sequence< NamedValue > aArgs( 1 ); |
452 |
Sequence< NamedValue > aArgs( 1 ); |
469 |
|
453 |
|
470 |
// send command to set context menu content |
454 |
// send command to set context menu content |
471 |
Sequence< rtl::OUString > aList( 10 ); |
455 |
Sequence< rtl::OUString > aList( 10 ); |
472 |
aList[0] = rtl::OUString::createFromAscii( "White" ); |
456 |
aList[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "White" ) ); |
473 |
aList[1] = rtl::OUString::createFromAscii( "Black" ); |
457 |
aList[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Black" ) ); |
474 |
aList[2] = rtl::OUString::createFromAscii( "Red" ); |
458 |
aList[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Red" ) ); |
475 |
aList[3] = rtl::OUString::createFromAscii( "Blue" ); |
459 |
aList[3] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Blue" ) ); |
476 |
aList[4] = rtl::OUString::createFromAscii( "Green" ); |
460 |
aList[4] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Green" ) ); |
477 |
aList[5] = rtl::OUString::createFromAscii( "Grey" ); |
461 |
aList[5] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Grey" ) ); |
478 |
aList[6] = rtl::OUString::createFromAscii( "Yellow" ); |
462 |
aList[6] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Yellow" ) ); |
479 |
aList[7] = rtl::OUString::createFromAscii( "Orange" ); |
463 |
aList[7] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Orange" ) ); |
480 |
aList[8] = rtl::OUString::createFromAscii( "Brown" ); |
464 |
aList[8] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Brown" ) ); |
481 |
aList[9] = rtl::OUString::createFromAscii( "Pink" ); |
465 |
aList[9] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pink" ) ); |
482 |
|
466 |
|
483 |
aArgs[0].Name = rtl::OUString::createFromAscii( "List" ); |
467 |
aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ); |
484 |
aArgs[0].Value <<= aList; |
468 |
aArgs[0].Value <<= aList; |
485 |
SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetList" ), aArgs, sal_True ); |
469 |
SendCommandTo( xControl, aURL, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SetList" ) ), aArgs, sal_True ); |
486 |
} |
470 |
} |
487 |
|
471 |
|
488 |
aListenerHelper.AddListener( mxFrame, xControl, aURL.Path ); |
472 |
aListenerHelper.AddListener( mxFrame, xControl, aURL.Path ); |
Lines 496-529
void SAL_CALL BaseDispatch::removeStatusListener( const Reference< XStatusListen
Link Here
|
496 |
|
480 |
|
497 |
void SAL_CALL BaseDispatch::controlEvent( const ControlEvent& Event ) throw (RuntimeException) |
481 |
void SAL_CALL BaseDispatch::controlEvent( const ControlEvent& Event ) throw (RuntimeException) |
498 |
{ |
482 |
{ |
499 |
if ( Event.aURL.Protocol.equalsAscii("vnd.demo.complextoolbarcontrols.demoaddon:" )) |
483 |
if ( Event.aURL.Protocol.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) ) ) |
500 |
{ |
484 |
{ |
501 |
if ( Event.aURL.Path.equalsAscii( "Command2" )) |
485 |
if ( Event.aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ComboboxCmd" ) ) ) |
502 |
{ |
486 |
{ |
503 |
// We get notifications whenever the text inside the combobox has been changed. |
487 |
// We get notifications whenever the text inside the combobox has been changed. |
504 |
// We store the new text into a member. |
488 |
// We store the new text into a member. |
505 |
if ( Event.Event.equalsAscii( "TextChanged" )) |
489 |
if ( Event.Event.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "TextChanged" ) ) ) |
506 |
{ |
490 |
{ |
507 |
rtl::OUString aNewText; |
491 |
rtl::OUString aNewText; |
508 |
sal_Bool bHasText( sal_False ); |
492 |
sal_Bool bHasText( sal_False ); |
509 |
for ( sal_Int32 i = 0; i < Event.aInformation.getLength(); i++ ) |
493 |
for ( sal_Int32 i = 0; i < Event.aInformation.getLength(); i++ ) |
510 |
{ |
494 |
{ |
511 |
if ( Event.aInformation[i].Name.equalsAsciiL( "Text", 4 )) |
495 |
if ( Event.aInformation[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Text" ) ) ) |
512 |
{ |
496 |
{ |
513 |
bHasText = Event.aInformation[i].Value >>= aNewText; |
497 |
bHasText = Event.aInformation[i].Value >>= aNewText; |
514 |
break; |
498 |
break; |
515 |
} |
499 |
} |
516 |
} |
500 |
} |
517 |
|
501 |
|
518 |
if ( bHasText ) |
502 |
if ( bHasText ) |
519 |
maComboBoxText = aNewText; |
503 |
maComboBoxText = aNewText; |
520 |
} |
504 |
} |
521 |
} |
505 |
} |
522 |
} |
506 |
} |
523 |
} |
507 |
} |
524 |
|
508 |
|
525 |
BaseDispatch::BaseDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF, |
509 |
BaseDispatch::BaseDispatch( const Reference< XMultiServiceFactory > &rxMSF, |
526 |
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, const ::rtl::OUString& rServiceName ) |
510 |
const Reference< XFrame >& xFrame, const rtl::OUString& rServiceName ) |
527 |
: mxMSF( rxMSF ) |
511 |
: mxMSF( rxMSF ) |
528 |
, mxFrame( xFrame ) |
512 |
, mxFrame( xFrame ) |
529 |
, msDocService( rServiceName ) |
513 |
, msDocService( rServiceName ) |