Update to m13
[ooovba.git] / applied_patches / 0450-vba-commandbar-rework.diff
blob96b3bbc4ef9b3e6ae8260553f220323f6082c189
1 diff --git oovbaapi/ooo/vba/XCommandBarControl.idl oovbaapi/ooo/vba/XCommandBarControl.idl
2 index ea0c612..167bce8 100644
3 --- oovbaapi/ooo/vba/XCommandBarControl.idl
4 +++ oovbaapi/ooo/vba/XCommandBarControl.idl
5 @@ -54,6 +54,7 @@ interface XCommandBarControl
6 [attribute] string Caption;
7 [attribute] string OnAction;
8 [attribute] boolean Visible;
9 + [attribute, readonly] long Type;
11 void Delete() raises ( com::sun::star::script::BasicErrorException );
12 any Controls( [in] any Index ) raises ( com::sun::star::script::BasicErrorException );
13 diff --git vbahelper/inc/vbahelper/vbahelper.hxx vbahelper/inc/vbahelper/vbahelper.hxx
14 index d8e5a22..3773474 100644
15 --- vbahelper/inc/vbahelper/vbahelper.hxx
16 +++ vbahelper/inc/vbahelper/vbahelper.hxx
17 @@ -95,6 +95,8 @@ namespace ooo
18 VBAHELPER_DLLPUBLIC sal_Int32 getPointerStyle( const css::uno::Reference< css::frame::XModel >& );
19 VBAHELPER_DLLPUBLIC void setCursorHelper( const css::uno::Reference< css::frame::XModel >& xModel, const Pointer& rPointer, sal_Bool bOverWrite );
20 VBAHELPER_DLLPUBLIC void setDefaultPropByIntrospection( const css::uno::Any& aObj, const css::uno::Any& aValue ) throw ( css::uno::RuntimeException );
21 + VBAHELPER_DLLPUBLIC css::uno::Any getPropertyValue( const css::uno::Sequence< css::beans::PropertyValue >& aProp, const rtl::OUString& aName );
22 + VBAHELPER_DLLPUBLIC sal_Bool setPropertyValue( css::uno::Sequence< css::beans::PropertyValue >& aProp, const rtl::OUString& aName, const css::uno::Any& aValue );
24 class VBAHELPER_DLLPUBLIC Millimeter
26 diff --git vbahelper/source/vbahelper/makefile.mk vbahelper/source/vbahelper/makefile.mk
27 index 61155e6..bd57415 100644
28 --- vbahelper/source/vbahelper/makefile.mk
29 +++ vbahelper/source/vbahelper/makefile.mk
30 @@ -46,6 +46,7 @@ SLOFILES=\
31 $(SLO)$/vbacommandbar.obj \
32 $(SLO)$/vbacommandbarcontrols.obj \
33 $(SLO)$/vbacommandbarcontrol.obj \
34 + $(SLO)$/vbacommandbarhelper.obj \
35 $(SLO)$/vbaapplicationbase.obj \
36 $(SLO)$/vbawindowbase.obj \
37 $(SLO)$/vbadocumentbase.obj \
38 diff --git vbahelper/source/vbahelper/vbacommandbar.cxx vbahelper/source/vbahelper/vbacommandbar.cxx
39 index a74ccd5..43abe41 100644
40 --- vbahelper/source/vbahelper/vbacommandbar.cxx
41 +++ vbahelper/source/vbahelper/vbacommandbar.cxx
42 @@ -32,6 +32,8 @@
43 * MA 02111-1307 USA
45 ************************************************************************/
46 +#include "vbacommandbar.hxx"
47 +#include "vbacommandbarcontrols.hxx"
48 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
49 #include <com/sun/star/frame/XFrame.hpp>
50 #include <com/sun/star/frame/XDesktop.hpp>
51 @@ -40,141 +42,13 @@
52 #include <com/sun/star/container/XNameContainer.hpp>
53 #include <ooo/vba/office/MsoBarType.hpp>
55 -#include "vbacommandbar.hxx"
56 -#include "vbacommandbarcontrols.hxx"
58 using namespace com::sun::star;
59 using namespace ooo::vba;
61 -ScVbaCommandBar::ScVbaCommandBar( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< frame::XModel >& xModel, sal_Int32 nModuleType ) throw (uno::RuntimeException) : CommandBar_BASE( xParent, xContext ), m_xModel( xModel )
63 - // it's a menu bar
64 - // only supporting factory menus ( no custom menus )
65 - m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
66 - initCommandBar();
67 - switch( nModuleType )
68 - {
69 - case 0:
70 - m_sMenuModuleName = rtl::OUString::createFromAscii( "com.sun.star.sheet.SpreadsheetDocument" );
71 - break;
72 - case 1:
73 - m_sMenuModuleName = rtl::OUString::createFromAscii( "com.sun.star.text.TextDocument" );
74 - break;
75 - default:
76 - m_sMenuModuleName = rtl::OUString::createFromAscii( "com.sun.star.text.TextDocument" );
77 - }
78 - getMenuSettings();
79 - m_bIsMenu = sal_True;
80 - m_bCustom = sal_False;
82 -ScVbaCommandBar::ScVbaCommandBar( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< frame::XModel >& xModel, rtl::OUString sToolBarName, sal_Bool bTemporary, sal_Bool bCreate ) throw (uno::RuntimeException) : CommandBar_BASE( xParent, xContext ), m_xModel( xModel )
83 +ScVbaCommandBar::ScVbaCommandBar( const uno::Reference< ov::XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, VbaCommandBarHelperRef pHelper, const uno::Reference< container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Bool bIsMenu, sal_Bool bTemporary ) throw( uno::RuntimeException ) : CommandBar_BASE( xParent, xContext ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl ), m_bIsMenu( bIsMenu ), m_bTemporary( bTemporary )
85 - // it's a tool bar
86 - m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
87 - initCommandBar();
88 - m_bTemporary = bTemporary;
89 - m_bCreate = bCreate;
90 - // get OOo ToolBarName
91 - CommandBarNameMap::const_iterator iter = mCommandBarNameMap.find( sToolBarName.toAsciiLowerCase() );
92 - if( iter != mCommandBarNameMap.end() )
93 - {
94 - m_sToolBarName = iter->second;
95 - }
96 - else
97 - {
98 - m_sToolBarName = sToolBarName;
99 - }
100 - m_sUIName = m_sToolBarName;
101 - m_bIsMenu = sal_False;
102 - getToolBarSettings( m_sToolBarName );
104 -void
105 -ScVbaCommandBar::initCommandBar() throw (uno::RuntimeException)
107 - m_pScVbaCommandBars = dynamic_cast< ScVbaCommandBars* >( m_xParentHardRef.get() );
108 - if ( !m_pScVbaCommandBars )
109 - throw uno::RuntimeException( rtl::OUString::createFromAscii( "Parent needs to be a ScVbaCommandBars"), uno::Reference< uno::XInterface >() );
110 - m_bIsMenu = sal_False;
111 - m_bCustom = sal_False;
112 - m_bTemporary = sal_True;
113 - m_sToolBarName = rtl::OUString::createFromAscii("");
114 - m_sUIName = rtl::OUString::createFromAscii("");
115 - m_sMenuModuleName = m_pScVbaCommandBars->GetModuleName();
117 -void
118 -ScVbaCommandBar::getToolBarSettings( rtl::OUString sToolBarName ) throw( uno::RuntimeException )
120 - rtl::OUString sFactoryToolBar = rtl::OUString::createFromAscii("private:resource/toolbar/") + sToolBarName.toAsciiLowerCase();
121 - rtl::OUString sCustomToolBar = rtl::OUString::createFromAscii("private:resource/toolbar/custom_toolbar_") + sToolBarName;
122 - uno::Reference< lang::XMultiServiceFactory > xMSF( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
123 - uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xUICfgManagerSup( xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier") ), uno::UNO_QUERY_THROW );
124 - m_xUICfgManager.set( xUICfgManagerSup->getUIConfigurationManager( m_pScVbaCommandBars->GetModuleName() ), uno::UNO_QUERY_THROW );
125 - m_xUICfgPers.set( m_xUICfgManager, uno::UNO_QUERY_THROW );
126 - if( m_xUICfgManager->hasSettings( sFactoryToolBar ) )
128 - // exsiting standard ToolBar
129 - m_xBarSettings.set( m_xUICfgManager->getSettings( sFactoryToolBar, sal_True ), uno::UNO_QUERY_THROW );
130 - m_sToolBarName = sFactoryToolBar;
132 - else if( m_xUICfgManager->hasSettings( sCustomToolBar ) )
134 - // exisiting custom ToolBar
135 - m_xBarSettings.set( m_xUICfgManager->getSettings( sCustomToolBar, sal_True ), uno::UNO_QUERY_THROW );
136 - m_sToolBarName = sCustomToolBar;
137 - m_bCustom = sal_True;
139 - else if( m_bCreate )
141 - // new custom ToolBar
142 - m_xBarSettings.set( m_xUICfgManager->createSettings(), uno::UNO_QUERY_THROW );
143 - m_sToolBarName = sCustomToolBar;
144 - m_bCustom = sal_True;
145 - addCustomBar();
147 - else
148 - throw uno::RuntimeException( rtl::OUString::createFromAscii("ToolBar do not exist"), uno::Reference< uno::XInterface >() );
149 - if( m_pScVbaCommandBars->GetWindows()->hasByName( m_sToolBarName ) )
151 - uno::Any aToolBar = m_pScVbaCommandBars->GetWindows()->getByName( m_sToolBarName );
152 - aToolBar >>= m_aToolBar;
155 -void
156 -ScVbaCommandBar::addCustomBar()
158 - uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
159 - xPropertySet->setPropertyValue(rtl::OUString::createFromAscii("UIName"), uno::makeAny( m_sUIName ));
161 - if( m_xUICfgManager->hasSettings(m_sToolBarName) )
163 - m_xUICfgManager->replaceSettings( m_sToolBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
165 - else
167 - m_xUICfgManager->insertSettings( m_sToolBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
169 - if( !m_bTemporary )
171 - m_xUICfgPers->store();
174 -void
175 -ScVbaCommandBar::getMenuSettings()
177 - try
179 - rtl::OUString sMenuBar = rtl::OUString::createFromAscii( "private:resource/menubar/menubar" );
180 - uno::Reference< lang::XMultiServiceFactory > xMSF( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
181 - uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xUICfgManagerSup( xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier") ), uno::UNO_QUERY_THROW );
182 - m_xUICfgManager.set( xUICfgManagerSup->getUIConfigurationManager( m_sMenuModuleName ), uno::UNO_QUERY_THROW );
183 - m_xUICfgPers.set( m_xUICfgManager, uno::UNO_QUERY_THROW );
184 - m_xBarSettings.set( m_xUICfgManager->getSettings( sMenuBar, sal_True ), uno::UNO_QUERY_THROW );
185 - }
186 - catch ( uno::Exception e)
188 - OSL_TRACE( "getMenuSetting got a error\n" );
191 ::rtl::OUString SAL_CALL
192 ScVbaCommandBar::getName() throw ( uno::RuntimeException )
194 @@ -183,25 +57,27 @@ ScVbaCommandBar::getName() throw ( uno::RuntimeException )
195 uno::Any aName = xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("UIName") );
196 rtl::OUString sName;
197 aName >>= sName;
198 - if( sName.getLength() < 1 && !m_bIsMenu )
199 + if( sName.getLength() < 1 )
201 - uno::Reference< container::XNameAccess > xNameAccess( m_pScVbaCommandBars->GetWindows(), uno::UNO_QUERY_THROW );
202 - if( xNameAccess->hasByName( m_sToolBarName ) )
203 + if( m_bIsMenu )
205 - beans::PropertyValues aToolBar;
206 - xNameAccess->getByName( m_sToolBarName ) >>= aToolBar;
207 - sal_Int32 nCount = aToolBar.getLength();
208 - beans::PropertyValue aPropertyValue;
209 - for( sal_Int32 i = 0; i < nCount; i++ )
210 + if( m_sResourceUrl.equals( VbaCommandBarHelper::getMenuBarUrl() ) )
212 - aPropertyValue = aToolBar[i];
213 - if( aPropertyValue.Name.equals( rtl::OUString::createFromAscii("UIName") ) )
215 - aPropertyValue.Value >>= sName;
216 - return sName;
218 + if( pCBarHelper->getModuleId().equalsAscii("com.sun.star.sheet.SpreadsheetDocument") )
219 + sName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Worksheet Menu Bar") );
220 + else if( pCBarHelper->getModuleId().equalsAscii("com.sun.star.text.TextDocument") )
221 + sName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Menu Bar") );
222 + return sName;
225 + // Toolbar name
226 + uno::Reference< container::XNameAccess > xNameAccess = pCBarHelper->getPersistentWindowState();
227 + if( xNameAccess->hasByName( m_sResourceUrl ) )
229 + uno::Sequence< beans::PropertyValue > aToolBar;
230 + xNameAccess->getByName( m_sResourceUrl ) >>= aToolBar;
231 + getPropertyValue( aToolBar, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UIName") ) ) >>= sName;
234 return sName;
236 @@ -210,33 +86,37 @@ ScVbaCommandBar::setName( const ::rtl::OUString& _name ) throw (uno::RuntimeExce
238 uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
239 xPropertySet->setPropertyValue( rtl::OUString::createFromAscii("UIName"), uno::makeAny( _name ) );
240 - uno::Reference< container::XIndexAccess > xIndexAccess( m_xBarSettings, uno::UNO_QUERY_THROW );
242 - if( m_xUICfgManager->hasSettings( m_sToolBarName ) )
243 + if( pCBarHelper->getAppCfgManager()->hasSettings( m_sResourceUrl ) )
245 - m_xUICfgManager->replaceSettings( m_sToolBarName, xIndexAccess );
246 + pCBarHelper->getAppCfgManager()->replaceSettings( m_sResourceUrl, m_xBarSettings );
248 else
250 - // toolbar not found
251 + pCBarHelper->getAppCfgManager()->insertSettings( m_sResourceUrl, m_xBarSettings );
253 if( !m_bTemporary )
255 - m_xUICfgPers->store();
256 + pCBarHelper->persistChanges();
259 ::sal_Bool SAL_CALL
260 ScVbaCommandBar::getVisible() throw (uno::RuntimeException)
262 + // menu bar is allways visible in OOo
263 + if( m_bIsMenu )
264 + return sal_True;
266 sal_Bool bVisible = sal_False;
269 - sal_Int32 i = 0;
270 - while( !m_aToolBar[i].Name.equals( rtl::OUString::createFromAscii( "Visible" ) ) )
271 + uno::Reference< container::XNameAccess > xNameAccess = pCBarHelper->getPersistentWindowState();
272 + if( xNameAccess->hasByName( m_sResourceUrl ) )
274 - i++;
275 + uno::Sequence< beans::PropertyValue > aToolBar;
276 + xNameAccess->getByName( m_sResourceUrl ) >>= aToolBar;
277 + getPropertyValue( aToolBar, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Visible") ) ) >>= bVisible;
279 - m_aToolBar[i].Value >>= bVisible;
281 catch ( uno::Exception e )
283 @@ -248,18 +128,18 @@ ScVbaCommandBar::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
287 - uno::Reference< frame::XFrame > xFrame( m_xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
288 + uno::Reference< frame::XFrame > xFrame( pCBarHelper->getModel()->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
289 uno::Reference< beans::XPropertySet > xPropertySet( xFrame, uno::UNO_QUERY_THROW );
290 uno::Reference< frame::XLayoutManager > xLayoutManager( xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("LayoutManager") ), uno::UNO_QUERY_THROW );
291 if( _visible )
293 - xLayoutManager->createElement( m_sToolBarName );
294 - xLayoutManager->showElement( m_sToolBarName );
295 + xLayoutManager->createElement( m_sResourceUrl );
296 + xLayoutManager->showElement( m_sResourceUrl );
298 else
300 - xLayoutManager->hideElement( m_sToolBarName );
301 - xLayoutManager->destroyElement( m_sToolBarName );
302 + xLayoutManager->hideElement( m_sResourceUrl );
303 + xLayoutManager->destroyElement( m_sResourceUrl );
306 catch( uno::Exception e )
307 @@ -284,45 +164,35 @@ ScVbaCommandBar::setEnabled( sal_Bool/* _enabled */ ) throw (uno::RuntimeExcepti
310 void SAL_CALL
311 -ScVbaCommandBar::Delete( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
312 +ScVbaCommandBar::Delete( ) throw (script::BasicErrorException, uno::RuntimeException)
314 - if( m_bCustom )
315 + if( pCBarHelper->getAppCfgManager()->hasSettings( m_sResourceUrl ) )
317 - if( m_xUICfgManager->hasSettings( m_sToolBarName ) )
319 - m_xUICfgManager->removeSettings(m_sToolBarName);
320 - // make it permanent
321 - if( !m_bTemporary )
323 - m_xUICfgPers->store();
326 - else
327 + pCBarHelper->getAppCfgManager()->removeSettings(m_sResourceUrl);
328 + // make it permanent
329 + if( !m_bTemporary )
331 - // toolbar not found
332 - // TODO throw Error
334 - uno::Reference< container::XNameContainer > xNameContainer( m_pScVbaCommandBars->GetWindows(), uno::UNO_QUERY_THROW );
335 - if( xNameContainer->hasByName( m_sToolBarName ) )
337 - xNameContainer->removeByName( m_sToolBarName );
338 + pCBarHelper->persistChanges();
341 + else
343 + // toolbar not found
344 + // TODO throw Error
346 + uno::Reference< container::XNameContainer > xNameContainer( pCBarHelper->getPersistentWindowState(), uno::UNO_QUERY_THROW );
347 + if( xNameContainer->hasByName( m_sResourceUrl ) )
349 + xNameContainer->removeByName( m_sResourceUrl );
352 uno::Any SAL_CALL
353 ScVbaCommandBar::Controls( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException)
355 - sal_Int32 nIndex;
356 - uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, uno::Reference< container::XIndexAccess >(), m_xModel ) );
357 + uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, m_xBarSettings, pCBarHelper, m_xBarSettings, m_sResourceUrl ) );
358 if( aIndex.hasValue() )
360 - if( aIndex >>= nIndex )
362 - uno::Reference< XCommandBarControl > xCommandBarControl( xCommandBarControls->Item( aIndex, uno::Any() ), uno::UNO_QUERY_THROW );
363 - return uno::makeAny( xCommandBarControl );
365 - else
366 - throw uno::RuntimeException( rtl::OUString::createFromAscii( "invalid index" ), uno::Reference< uno::XInterface >() );
367 + return xCommandBarControls->Item( aIndex, uno::Any() );
369 return uno::makeAny( xCommandBarControls );
371 diff --git vbahelper/source/vbahelper/vbacommandbar.hxx vbahelper/source/vbahelper/vbacommandbar.hxx
372 index 52f63bc..5c9b13e 100644
373 --- vbahelper/source/vbahelper/vbacommandbar.hxx
374 +++ vbahelper/source/vbahelper/vbacommandbar.hxx
375 @@ -42,52 +42,25 @@
376 #include <com/sun/star/beans/PropertyValues.hpp>
378 #include <vbahelper/vbahelperinterface.hxx>
379 -#include "vbacommandbars.hxx"
380 +#include "vbacommandbarhelper.hxx"
382 #include <map>
383 -typedef std::map< const rtl::OUString, rtl::OUString > CommandBarNameMap;
384 -typedef std::pair< const rtl::OUString, rtl::OUString > CommandBarNamePair;
385 -const CommandBarNamePair namePair[] = {
386 - CommandBarNamePair( rtl::OUString::createFromAscii("standard"), rtl::OUString::createFromAscii("standardbar") ),
387 - CommandBarNamePair( rtl::OUString::createFromAscii("formatting"), rtl::OUString::createFromAscii("formatobjectbar") ),
389 -static const CommandBarNameMap mCommandBarNameMap( namePair, ( namePair + sizeof(namePair) / sizeof(namePair[0]) ) );
392 typedef InheritedHelperInterfaceImpl1< ov::XCommandBar > CommandBar_BASE;
394 class ScVbaCommandBar : public CommandBar_BASE
396 private:
397 - rtl::OUString m_sToolBarName;
398 - rtl::OUString m_sMenuModuleName;
399 - rtl::OUString m_sUIName;
400 - sal_Bool m_bTemporary;
401 - sal_Bool m_bIsMenu;
402 - sal_Bool m_bCustom;
403 - sal_Bool m_bCreate;
404 - ScVbaCommandBars* m_pScVbaCommandBars;
405 - css::beans::PropertyValues m_aToolBar;
406 - // hard reference for parent
407 - css::uno::Reference< ov::XHelperInterface > m_xParentHardRef;
408 - css::uno::Reference< css::ui::XUIConfigurationManager > m_xUICfgManager;
409 - css::uno::Reference< css::ui::XUIConfigurationPersistence > m_xUICfgPers;
410 - css::uno::Reference< css::container::XIndexContainer > m_xBarSettings;
411 - void initCommandBar() throw( css::uno::RuntimeException );
412 -protected:
413 - void getToolBarSettings( rtl::OUString sToolBarName ) throw( css::uno::RuntimeException );
414 - void getMenuSettings();
415 - void addCustomBar();
416 - css::uno::Reference< css::frame::XModel > m_xModel;
417 + VbaCommandBarHelperRef pCBarHelper;
418 + css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
419 + rtl::OUString m_sResourceUrl;
420 + sal_Bool m_bIsMenu;
421 + sal_Bool m_bTemporary;
423 public:
424 - ScVbaCommandBar( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nModuleType ) throw( css::uno::RuntimeException );
425 - ScVbaCommandBar( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::frame::XModel >& xModel, rtl::OUString sToolBarName, sal_Bool bTemporary, sal_Bool bCreate ) throw( css::uno::RuntimeException );
426 + ScVbaCommandBar( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Bool bIsMenu, sal_Bool bTemporary = sal_True ) throw( css::uno::RuntimeException );
428 - sal_Bool IsMenu() { return m_bIsMenu; };
429 - css::uno::Reference< css::ui::XUIConfigurationManager > GetUICfgManager() { return m_xUICfgManager; };
430 - css::uno::Reference< css::ui::XUIConfigurationPersistence > GetUICfgPers() { return m_xUICfgPers; };
431 - css::uno::Reference< css::container::XIndexContainer > GetBarSettings() { return m_xBarSettings; };
432 - rtl::OUString GetToolBarName() { return m_sToolBarName; };
433 + sal_Bool IsMenu() { return m_bIsMenu; }
435 // Attributes
436 virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
437 diff --git vbahelper/source/vbahelper/vbacommandbarcontrol.cxx vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
438 index 1bea689..dd20256 100644
439 --- vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
440 +++ vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
441 @@ -33,198 +33,29 @@
443 ************************************************************************/
444 #include "vbacommandbarcontrol.hxx"
445 -#include <basic/sbstar.hxx>
446 -#include <basic/sbmod.hxx>
447 -#include <basic/sbmeth.hxx>
448 +#include "vbacommandbarcontrols.hxx"
449 #include <vbahelper/vbahelper.hxx>
450 #include <svx/msvbahelper.hxx>
452 using namespace com::sun::star;
453 using namespace ooo::vba;
455 -uno::Any lcl_getPropertyValue( beans::PropertyValues aPropertyValues, rtl::OUString sPropertyName )
456 +ScVbaCommandBarControl::ScVbaCommandBarControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl ) throw (css::uno::RuntimeException) : CommandBarControl_BASE( xParent, xContext ), pCBarHelper( pHelper ), m_sResourceUrl( sResourceUrl ), m_xCurrentSettings( xSettings ), m_xBarSettings( xBarSettings ), m_nPosition( 0 ), m_bTemporary( sal_True )
458 - sal_Int32 nCount = aPropertyValues.getLength();
459 - for( sal_Int32 i = 0; i < nCount; i++ )
461 - if( aPropertyValues[i].Name.equalsIgnoreAsciiCase( sPropertyName ) )
463 - return aPropertyValues[i].Value;
466 - return uno::Any();
469 -beans::PropertyValues lcl_repalcePropertyValue( beans::PropertyValues aPropertyValues, rtl::OUString sPropertyName, uno::Any aValue )
471 - sal_Int32 nCount = aPropertyValues.getLength();
472 - for( sal_Int32 i = 0; i < nCount; i++ )
474 - if( aPropertyValues[i].Name.equalsIgnoreAsciiCase( sPropertyName ) )
476 - aPropertyValues[i].Value = aValue;
477 - return aPropertyValues;
480 - return aPropertyValues;
483 -ScVbaCommandBarControl::ScVbaCommandBarControl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, sal_Int32 nPosition, sal_Int32 nType ) throw (uno::RuntimeException) : CommandBarControl_BASE( xParent, xContext ), m_sName( sName ), m_nPosition( nPosition ), m_nType( nType )
485 - // exsiting CommandBarBarControl
486 - m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
487 - initObjects();
488 - if( m_xBarSettings->hasElements() )
490 - ScVbaCommandBarControl* pParentCommandBarControl = m_pCommandBarControls->GetParentCommandBarControl();
491 - if( pParentCommandBarControl )
493 - beans::PropertyValues aPropertyValues;
494 - pParentCommandBarControl->GetCurrentSettings()->getByIndex( pParentCommandBarControl->GetPosition() ) >>= aPropertyValues;
495 - pParentCommandBarControl->SetPropertyValues( aPropertyValues );
496 - m_xCurrentSettings.set( lcl_getPropertyValue( pParentCommandBarControl->GetPropertyValues(), rtl::OUString::createFromAscii( "ItemDescriptorContainer" ) ), uno::UNO_QUERY_THROW );
498 - if( !m_xCurrentSettings.is() )
500 - m_xCurrentSettings.set( m_xUICfgManager->getSettings( m_pCommandBarControls->GetParentToolBarName(), sal_True ), uno::UNO_QUERY_THROW );
503 - if( m_bIsMenu )
505 - m_sBarName = rtl::OUString::createFromAscii("private:resource/menubar/menubar");
507 - else
509 - m_sBarName = m_pCommandBarControls->GetParentToolBarName();
511 - m_bTemporary = sal_True;
513 -ScVbaCommandBarControl::ScVbaCommandBarControl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, sal_Int32 nPosition, sal_Bool bTemporary, sal_Int32 nType) throw (uno::RuntimeException) : CommandBarControl_BASE( xParent, xContext ), m_nPosition( nPosition ), m_bTemporary( bTemporary ), m_nType( nType )
515 - m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
516 - initObjects();
517 - if( sName.getLength() > 0 )
519 - m_sName = sName;
521 - m_sCommand = rtl::OUString::createFromAscii("vnd.openoffice.org:") + sName;
522 - if( m_bIsMenu )
524 - m_sBarName = rtl::OUString::createFromAscii("private:resource/menubar/menubar");
525 - createNewMenuBarControl();
527 - else
529 - m_sBarName = m_pCommandBarControls->GetParentToolBarName();
530 - createNewToolBarControl();
534 -void
535 -ScVbaCommandBarControl::initObjects() throw (uno::RuntimeException)
536 +ScVbaCommandBarControl::ScVbaCommandBarControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException) : CommandBarControl_BASE( xParent, xContext ), pCBarHelper( pHelper ), m_sResourceUrl( sResourceUrl ), m_xCurrentSettings( xSettings ), m_xBarSettings( xBarSettings ), m_nPosition( nPosition ), m_bTemporary( bTemporary )
538 - m_pCommandBarControls = dynamic_cast< ScVbaCommandBarControls* >( m_xParentHardRef.get() );
539 - if( !m_pCommandBarControls )
540 - throw uno::RuntimeException( rtl::OUString::createFromAscii( "Parent needs to be a ScVbaCommandBarControls"), uno::Reference< uno::XInterface >() );
541 - m_xUICfgManager.set( m_pCommandBarControls->GetUICfgManager(), uno::UNO_QUERY_THROW );
542 - m_xUICfgPers.set( m_pCommandBarControls->GetUICfgPers(), uno::UNO_QUERY_THROW );
543 - m_xBarSettings.set( m_pCommandBarControls->GetBarSettings(), uno::UNO_QUERY_THROW );
544 - m_bIsMenu = m_pCommandBarControls->IsMenu();
545 - m_sName = rtl::OUString::createFromAscii( "Custom" );
548 -void
549 -ScVbaCommandBarControl::createNewMenuBarControl()
551 - uno::Reference< lang::XSingleComponentFactory > xMenuMSF( m_xBarSettings, uno::UNO_QUERY_THROW );
553 - uno::Sequence< beans::PropertyValue > aPropertys;
554 - if( m_nType == office::MsoControlType::msoControlPopup )
555 - aPropertys = uno::Sequence< beans::PropertyValue >( 4 );
556 - else
557 - aPropertys = uno::Sequence< beans::PropertyValue >( 3 );
559 - aPropertys[0].Name = rtl::OUString::createFromAscii("CommandURL");
560 - aPropertys[0].Value <<= m_sCommand;
561 - aPropertys[1].Name = rtl::OUString::createFromAscii("Label");
562 - aPropertys[1].Value <<= m_sName;
563 - aPropertys[2].Name = rtl::OUString::createFromAscii("Type");
564 - aPropertys[2].Value <<= sal_Int32(0);
566 - if( m_nType == office::MsoControlType::msoControlPopup )
568 - aPropertys[3].Name = rtl::OUString::createFromAscii("ItemDescriptorContainer");
569 - aPropertys[3].Value <<= xMenuMSF->createInstanceWithContext( mxContext );
570 - }
572 - if( m_pCommandBarControls->GetParentCommandBar() != NULL )
574 - // create a new menu
575 - m_xBarSettings->insertByIndex( m_nPosition, uno::makeAny( aPropertys ) );
576 - m_xCurrentSettings.set( m_xBarSettings, uno::UNO_QUERY_THROW );
578 - else if( m_pCommandBarControls->GetParentCommandBarControl() != NULL )
580 - // create a new menu entry
581 - ScVbaCommandBarControl* pPc = m_pCommandBarControls->GetParentCommandBarControl();
582 - beans::PropertyValues aPropertyValues;
583 - pPc->GetCurrentSettings()->getByIndex( pPc->GetPosition() ) >>= aPropertyValues;
584 - pPc->SetPropertyValues( aPropertyValues );
586 - // has the property already been set?
587 - if( lcl_getPropertyValue( pPc->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") ).hasValue() )
589 - lcl_repalcePropertyValue( pPc->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer"), uno::makeAny( xMenuMSF->createInstanceWithContext( mxContext ) ) );
590 - pPc->GetCurrentSettings()->replaceByIndex( pPc->GetPosition(), uno::makeAny( pPc->GetPropertyValues() ) );
592 - m_xCurrentSettings.set( lcl_getPropertyValue( pPc->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") ), uno::UNO_QUERY_THROW );
593 - m_xCurrentSettings->insertByIndex( m_nPosition, uno::makeAny( aPropertys ) );
595 - if( m_xUICfgManager->hasSettings( m_sBarName ) )
597 - m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
599 - else
601 - m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
603 - if( !m_bTemporary )
605 - m_xUICfgPers->store();
607 + m_xCurrentSettings->getByIndex( nPosition ) >>= m_aPropertyValues;
610 -void
611 -ScVbaCommandBarControl::createNewToolBarControl()
612 +void ScVbaCommandBarControl::ApplyChange() throw ( uno::RuntimeException )
614 - uno::Sequence< beans::PropertyValue > aPropertys(4);
615 - aPropertys[0].Name = rtl::OUString::createFromAscii("CommandURL");
616 - aPropertys[0].Value <<= m_sCommand;
617 - aPropertys[1].Name = rtl::OUString::createFromAscii("Label");
618 - aPropertys[1].Value <<= m_sName;
619 - aPropertys[2].Name = rtl::OUString::createFromAscii("Type");
620 - aPropertys[2].Value <<= sal_Int32(0);
621 - aPropertys[3].Name = rtl::OUString::createFromAscii("IsVisible");
622 - aPropertys[3].Value <<= sal_True;
624 - m_xBarSettings->insertByIndex( m_nPosition, uno::makeAny( aPropertys ) );
625 - uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
626 - rtl::OUString sUIName;
627 - xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("UIName") ) >>= sUIName;
629 - m_xCurrentSettings.set( m_xBarSettings, uno::UNO_QUERY_THROW );
630 - if( m_xUICfgManager->hasSettings( m_sBarName ) )
632 - m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
634 - else
636 - m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
638 + uno::Reference< container::XIndexContainer > xIndexContainer( m_xCurrentSettings, uno::UNO_QUERY_THROW );
639 + xIndexContainer->replaceByIndex( m_nPosition, uno::makeAny( m_aPropertyValues ) );
640 + pCBarHelper->getAppCfgManager()->replaceSettings( m_sResourceUrl, m_xBarSettings );
641 if( !m_bTemporary )
643 - m_xUICfgPers->store();
645 + pCBarHelper->persistChanges();
648 ::rtl::OUString SAL_CALL
649 @@ -232,145 +63,109 @@ ScVbaCommandBarControl::getCaption() throw ( uno::RuntimeException )
651 // "Label" always empty
652 rtl::OUString sCaption;
653 - beans::PropertyValues aPropertyValues;
654 - if( m_xCurrentSettings.is() )
656 - m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
657 - lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii("Label") ) >>= sCaption;
659 - else if( m_xBarSettings.is() )
661 - m_xBarSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
662 - lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii("Label") ) >>= sCaption;
664 + getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("Label") ) >>= sCaption;
665 return sCaption;
668 void SAL_CALL
669 ScVbaCommandBarControl::setCaption( const ::rtl::OUString& _caption ) throw (uno::RuntimeException)
671 - if( m_xCurrentSettings.is() )
673 - beans::PropertyValues aPropertyValues;
674 - m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
675 - beans::PropertyValues aNewPropertyValues;
676 - aNewPropertyValues = lcl_repalcePropertyValue( aPropertyValues, rtl::OUString::createFromAscii("Label"), uno::makeAny( _caption ) );
677 - m_xCurrentSettings->replaceByIndex( m_nPosition, uno::makeAny( aNewPropertyValues ) );
678 - if( m_xUICfgManager->hasSettings( m_sBarName ) )
680 - m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
682 - else
684 - m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
686 - // make it permanent
687 - if( !m_bTemporary )
689 - m_xUICfgPers->store();
692 + rtl::OUString sCaption = _caption.replace('&','~');
693 + setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("Label"), uno::makeAny( sCaption ) );
694 + ApplyChange();
697 ::rtl::OUString SAL_CALL
698 ScVbaCommandBarControl::getOnAction() throw (uno::RuntimeException)
700 - if( m_xCurrentSettings.is() )
702 - beans::PropertyValues aPropertyValues;
703 - m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
704 - rtl::OUString sCommandURL;
705 - lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "CommandURL" ) ) >>= sCommandURL;
706 - return sCommandURL;
708 - return ::rtl::OUString();
709 + rtl::OUString sCommandURL;
710 + getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL") ) >>= sCommandURL;
711 + return sCommandURL;
714 void SAL_CALL
715 ScVbaCommandBarControl::setOnAction( const ::rtl::OUString& _onaction ) throw (uno::RuntimeException)
717 - if( m_xCurrentSettings.is() )
718 + // get the current model
719 + uno::Reference< frame::XModel > xModel( pCBarHelper->getModel() );
720 + VBAMacroResolvedInfo aResolvedMacro = ooo::vba::resolveVBAMacro( getSfxObjShell( xModel ), _onaction, true );
721 + if ( aResolvedMacro.IsResolved() )
723 - // get the current model
724 - VBAMacroResolvedInfo aResolvedMacro = ooo::vba::resolveVBAMacro( getSfxObjShell( m_pCommandBarControls->GetModel() ), _onaction, true );
725 - if ( aResolvedMacro.IsResolved() )
727 - rtl::OUString aCommandURL = ooo::vba::makeMacroURL( aResolvedMacro.ResolvedMacro() );
728 + rtl::OUString aCommandURL = ooo::vba::makeMacroURL( aResolvedMacro.ResolvedMacro() );
729 OSL_TRACE(" ScVbaCommandBarControl::setOnAction: %s", rtl::OUStringToOString( aCommandURL, RTL_TEXTENCODING_UTF8 ).getStr() );
730 - beans::PropertyValues aPropertyValues;
731 - m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
732 - beans::PropertyValues aNewPropertyValues;
733 - aNewPropertyValues = lcl_repalcePropertyValue( aPropertyValues, rtl::OUString::createFromAscii("CommandURL"), uno::makeAny( aCommandURL ) );
734 - m_xCurrentSettings->replaceByIndex( m_nPosition, uno::makeAny( aNewPropertyValues ) );
735 - if( m_xUICfgManager->hasSettings( m_sBarName ) )
737 - m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
739 - else
741 - m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
743 - // make it permanent
744 - if( !m_bTemporary )
746 - m_xUICfgPers->store();
749 + setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL"), uno::makeAny( aCommandURL ) );
750 + ApplyChange();
754 ::sal_Bool SAL_CALL
755 ScVbaCommandBarControl::getVisible() throw (uno::RuntimeException)
757 - // not possible in UNO?
758 - return sal_True;
759 + sal_Bool bVisible = sal_True;
760 + uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible") );
761 + if( aValue.hasValue() )
762 + aValue >>= bVisible;
763 + return bVisible;
765 void SAL_CALL
766 -ScVbaCommandBarControl::setVisible( ::sal_Bool /*_visible*/ ) throw (uno::RuntimeException)
767 +ScVbaCommandBarControl::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
769 - // "IsVisilbe"
770 + uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible") );
771 + if( aValue.hasValue() )
773 + setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible"), uno::makeAny( _visible ) );
774 + ApplyChange();
778 void SAL_CALL
779 -ScVbaCommandBarControl::Delete( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
780 +ScVbaCommandBarControl::Delete( ) throw (script::BasicErrorException, uno::RuntimeException)
782 if( m_xCurrentSettings.is() )
784 - m_xCurrentSettings->removeByIndex( m_nPosition );
785 + uno::Reference< container::XIndexContainer > xIndexContainer( m_xCurrentSettings, uno::UNO_QUERY_THROW );
786 + xIndexContainer->removeByIndex( m_nPosition );
788 - if( m_xUICfgManager->hasSettings( m_sBarName ) )
789 + if( pCBarHelper->getAppCfgManager()->hasSettings( m_sResourceUrl ) )
791 - m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
792 + pCBarHelper->getAppCfgManager()->replaceSettings( m_sResourceUrl, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
794 else
796 - m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
797 + pCBarHelper->getAppCfgManager()->insertSettings( m_sResourceUrl, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
799 // make it permanent
800 if( !m_bTemporary )
802 - m_xUICfgPers->store();
803 + pCBarHelper->persistChanges();
808 uno::Any SAL_CALL
809 ScVbaCommandBarControl::Controls( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException)
811 - sal_Int32 nIndex;
812 - uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, uno::Reference< container::XIndexAccess >(), m_pCommandBarControls->GetModel() ) );
813 + // only Popup Menu has controls
814 + uno::Reference< container::XIndexAccess > xSubMenu;
815 + getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_CONTAINER ) ) >>= xSubMenu;
816 + if( !xSubMenu.is() )
817 + throw uno::RuntimeException();
819 + uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, xSubMenu, pCBarHelper, m_xBarSettings, m_sResourceUrl ) );
820 if( aIndex.hasValue() )
822 - if( aIndex >>= nIndex )
824 - uno::Reference< XCommandBarControl > xCommandBarControl( xCommandBarControls->Item( aIndex, uno::Any() ), uno::UNO_QUERY_THROW );
825 - return uno::makeAny( xCommandBarControl );
827 - else
828 - throw uno::RuntimeException( rtl::OUString::createFromAscii( "invalid index" ), uno::Reference< uno::XInterface >() );
829 + return xCommandBarControls->Item( aIndex, uno::Any() );
831 return uno::makeAny( xCommandBarControls );
834 rtl::OUString&
835 ScVbaCommandBarControl::getServiceImplName()
837 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBarControl") );
838 return sImplName;
841 uno::Sequence<rtl::OUString>
842 ScVbaCommandBarControl::getServiceNames()
844 @@ -384,12 +179,11 @@ ScVbaCommandBarControl::getServiceNames()
847 //////////// ScVbaCommandBarPopup //////////////////////////////
848 -ScVbaCommandBarPopup::ScVbaCommandBarPopup( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, sal_Int32 nPosition ) throw (uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, sName, nPosition, office::MsoControlType::msoControlPopup )
852 -ScVbaCommandBarPopup::ScVbaCommandBarPopup( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, sal_Int32 nPosition, sal_Bool bTemporary ) throw (uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, sName, nPosition, bTemporary, office::MsoControlType::msoControlPopup )
853 +ScVbaCommandBarPopup::ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
855 + m_nPosition = nPosition;
856 + m_bTemporary = bTemporary;
857 + m_xCurrentSettings->getByIndex( m_nPosition ) >>= m_aPropertyValues;
860 rtl::OUString&
861 @@ -411,12 +205,11 @@ ScVbaCommandBarPopup::getServiceNames()
864 //////////// ScVbaCommandBarButton //////////////////////////////
865 -ScVbaCommandBarButton::ScVbaCommandBarButton( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, sal_Int32 nPosition ) throw (uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, sName, nPosition, office::MsoControlType::msoControlButton )
869 -ScVbaCommandBarButton::ScVbaCommandBarButton( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, sal_Int32 nPosition, sal_Bool bTemporary ) throw (uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, sName, nPosition, bTemporary, office::MsoControlType::msoControlButton)
870 +ScVbaCommandBarButton::ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
872 + m_nPosition = nPosition;
873 + m_bTemporary = bTemporary;
874 + m_xCurrentSettings->getByIndex( m_nPosition ) >>= m_aPropertyValues;
877 rtl::OUString&
878 diff --git vbahelper/source/vbahelper/vbacommandbarcontrol.hxx vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
879 index c1a8b07..f40ad82 100644
880 --- vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
881 +++ vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
882 @@ -39,44 +39,30 @@
883 #include <ooo/vba/XCommandBarPopup.hpp>
884 #include <ooo/vba/XCommandBarButton.hpp>
885 #include <ooo/vba/office/MsoControlType.hpp>
887 #include <vbahelper/vbahelperinterface.hxx>
888 -#include "vbacommandbarcontrols.hxx"
889 +#include "vbacommandbarhelper.hxx"
890 +#include <cppuhelper/implbase1.hxx>
892 typedef InheritedHelperInterfaceImpl1< ov::XCommandBarControl > CommandBarControl_BASE;
894 class ScVbaCommandBarControl : public CommandBarControl_BASE
896 -private:
897 - rtl::OUString m_sName;
898 - rtl::OUString m_sBarName;
899 - rtl::OUString m_sCommand;
900 +protected:
901 + VbaCommandBarHelperRef pCBarHelper;
902 + rtl::OUString m_sResourceUrl;
903 + css::uno::Reference< css::container::XIndexAccess > m_xCurrentSettings;
904 + css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
905 + css::uno::Sequence< css::beans::PropertyValue > m_aPropertyValues;
907 sal_Int32 m_nPosition;
908 sal_Bool m_bTemporary;
909 - sal_Int32 m_nType;
910 - sal_Bool m_bIsMenu;
911 - ScVbaCommandBarControls* m_pCommandBarControls;
912 - css::uno::Reference< ov::XHelperInterface > m_xParentHardRef;
913 - css::uno::Reference< css::ui::XUIConfigurationManager > m_xUICfgManager;
914 - css::uno::Reference< css::ui::XUIConfigurationPersistence > m_xUICfgPers;
915 - css::uno::Reference< css::container::XIndexContainer > m_xBarSettings;
916 - css::uno::Reference< css::container::XIndexContainer > m_xCurrentSettings;
917 - css::beans::PropertyValues m_aPropertyValues;
919 - void initObjects() throw (css::uno::RuntimeException);
920 - void createNewMenuBarControl();
921 - void createNewToolBarControl();
923 +private:
924 + void ApplyChange() throw (css::uno::RuntimeException);
926 public:
927 - ScVbaCommandBarControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString& sName, sal_Int32 nPosition = 0, sal_Int32 nType = ov::office::MsoControlType::msoControlButton ) throw (css::uno::RuntimeException);
928 - ScVbaCommandBarControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString& sName, sal_Int32 nPosition, sal_Bool bTemporary, sal_Int32 nType = ov::office::MsoControlType::msoControlButton ) throw (css::uno::RuntimeException);
929 - css::uno::Reference< css::ui::XUIConfigurationManager > GetUICfgManager() { return m_xUICfgManager; };
930 - css::uno::Reference< css::ui::XUIConfigurationPersistence > GetUICfgPers() { return m_xUICfgPers; };
931 - css::uno::Reference< css::container::XIndexContainer > GetBarSettings() { return m_xBarSettings; };
932 - sal_Bool IsMenu() { return m_bIsMenu; };
933 - sal_Int32 GetPosition() { return m_nPosition; };
934 - css::uno::Reference< css::container::XIndexContainer > GetCurrentSettings() { return m_xCurrentSettings; };
935 - css::beans::PropertyValues GetPropertyValues() { return m_aPropertyValues; };
936 - void SetPropertyValues( css::beans::PropertyValues aPropertyValues ) { m_aPropertyValues = aPropertyValues; };
937 + ScVbaCommandBarControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl ) throw (css::uno::RuntimeException);
938 + ScVbaCommandBarControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
940 // Attributes
941 virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
942 @@ -85,6 +71,10 @@ public:
943 virtual void SAL_CALL setOnAction( const ::rtl::OUString& _onaction ) throw (css::uno::RuntimeException);
944 virtual ::sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
945 virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (css::uno::RuntimeException);
946 + virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException)
948 + return ov::office::MsoControlType::msoControlButton;
951 // Methods
952 virtual void SAL_CALL Delete( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
953 @@ -99,8 +89,12 @@ typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarPop
954 class ScVbaCommandBarPopup : public CommandBarPopup_BASE
956 public:
957 - ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString& sName, sal_Int32 nPosition = 0 ) throw (css::uno::RuntimeException);
958 - ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString& sName, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
959 + ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
961 + virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException)
963 + return ov::office::MsoControlType::msoControlPopup;
965 // XHelperInterface
966 virtual rtl::OUString& getServiceImplName();
967 virtual css::uno::Sequence<rtl::OUString> getServiceNames();
968 @@ -110,8 +104,12 @@ typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarBut
969 class ScVbaCommandBarButton : public CommandBarButton_BASE
971 public:
972 - ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString& sName, sal_Int32 nPosition = 0 ) throw (css::uno::RuntimeException);
973 - ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString& sName, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
974 + ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
976 + virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException)
978 + return ov::office::MsoControlType::msoControlButton;
980 // XHelperInterface
981 virtual rtl::OUString& getServiceImplName();
982 virtual css::uno::Sequence<rtl::OUString> getServiceNames();
983 diff --git vbahelper/source/vbahelper/vbacommandbarcontrols.cxx vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
984 index c6adbc2..ea56a09 100644
985 --- vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
986 +++ vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
987 @@ -38,8 +38,6 @@
988 using namespace com::sun::star;
989 using namespace ooo::vba;
991 -uno::Any lcl_getPropertyValue( beans::PropertyValues aPropertyValues, rtl::OUString sPropertyName );
993 typedef ::cppu::WeakImplHelper1< container::XEnumeration > CommandBarControlEnumeration_BASE;
994 class CommandBarControlEnumeration : public CommandBarControlEnumeration_BASE
996 @@ -58,272 +56,183 @@ public:
998 if( hasMoreElements() )
1000 - rtl::OUString sName = m_pCommandBarControls->GetControlNameByIndex( m_nCurrentPosition );
1001 - m_nCurrentPosition = m_nCurrentPosition + 1;
1002 - if( sName.getLength() > 0 )
1003 - return m_pCommandBarControls->createCollectionObject( uno::makeAny( sName ) );
1004 - else
1005 - return nextElement();
1006 + return m_pCommandBarControls->createCollectionObject( uno::makeAny( m_nCurrentPosition++ ) );
1008 else
1009 throw container::NoSuchElementException();
1013 -ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< container::XIndexAccess> xIndexAccess, const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), m_xModel( xModel )
1014 +ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess>& xIndexAccess, VbaCommandBarHelperRef pHelper, const uno::Reference< container::XIndexAccess>& xBarSettings, const rtl::OUString& sResourceUrl ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl )
1016 - m_bIsMenu = sal_False;
1017 - m_bHasElements = sal_False;
1018 - m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
1019 - m_pCommandBar = dynamic_cast< ScVbaCommandBar* >( m_xParentHardRef.get() );
1020 - m_pCommandBarControl = dynamic_cast< ScVbaCommandBarControl* >( m_xParentHardRef.get() );
1021 - if( m_pCommandBar )
1023 - m_xUICfgManager.set( m_pCommandBar->GetUICfgManager(), uno::UNO_QUERY_THROW );
1024 - m_xUICfgPers.set( m_pCommandBar->GetUICfgPers(), uno::UNO_QUERY_THROW );
1025 - m_xBarSettings.set( m_pCommandBar->GetBarSettings(), uno::UNO_QUERY_THROW );
1026 - m_bIsMenu = m_pCommandBar->IsMenu();
1027 - if( m_xBarSettings->hasElements() )
1029 - m_bHasElements = sal_True;
1032 - else if( m_pCommandBarControl )
1034 - m_xUICfgManager.set( m_pCommandBarControl->GetUICfgManager(), uno::UNO_QUERY_THROW );
1035 - m_xUICfgPers.set( m_pCommandBarControl->GetUICfgPers(), uno::UNO_QUERY_THROW );
1036 - beans::PropertyValues aPropertyValues;
1037 - m_pCommandBarControl->GetCurrentSettings()->getByIndex( m_pCommandBarControl->GetPosition() ) >>= aPropertyValues;
1038 - m_pCommandBarControl->SetPropertyValues( aPropertyValues );
1039 - m_xBarSettings.set( m_pCommandBarControl->GetCurrentSettings(), uno::UNO_QUERY_THROW );
1041 - uno::Any aValue = lcl_getPropertyValue( m_pCommandBarControl->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") );
1042 - if( aValue.hasValue() )
1044 - m_xCurrentSettings = m_pCommandBarControl->GetCurrentSettings();
1045 - m_bHasElements = sal_True;
1047 - else
1049 - m_bHasElements = sal_False;
1051 - m_bIsMenu = m_pCommandBarControl->IsMenu();
1053 - else
1055 - throw uno::RuntimeException( rtl::OUString::createFromAscii("Parent needs to be a ScVbaCommandBar or a ScVbaCommandBarControl"), uno::Reference< uno::XInterface >() );
1057 + m_bIsMenu = sResourceUrl.equalsAscii( ITEM_MENUBAR_URL ) ? sal_True : sal_False;
1059 -rtl::OUString
1060 -ScVbaCommandBarControls::GetControlNameByIndex( const sal_Int32 nIndex ) throw ( uno::RuntimeException )
1062 +uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const uno::Any& aSubMenu )
1064 - sal_Int32 nCount = 0;
1065 - if( m_bHasElements )
1067 - sal_Int32 nBarSettingsCount = m_xBarSettings->getCount();
1068 - for( sal_Int32 i = 0; i < nBarSettingsCount; i++ )
1070 - beans::PropertyValues aMenuValues;
1071 - m_xBarSettings->getByIndex( i ) >>= aMenuValues;
1072 - for( sal_Int32 j = 0; j < aMenuValues.getLength(); j++ )
1074 - if( aMenuValues[j].Name.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii( "CommandURL" ) ) )
1076 - nCount++;
1077 - if( nIndex == nCount )
1079 - rtl::OUString sCommandURL;
1080 - aMenuValues[j].Value >>= sCommandURL;
1081 - sal_Int32 nLastIndex = sCommandURL.lastIndexOf( rtl::OUString::createFromAscii(":") );
1082 - if( ( nLastIndex != -1 ) && ( ( nLastIndex +1 ) < sCommandURL.getLength() ) )
1084 - sCommandURL = sCommandURL.copy( nLastIndex + 1 );
1085 - return sCommandURL;
1090 - }
1092 - else
1093 - throw uno::RuntimeException( rtl::OUString::createFromAscii( "Out of bound" ), uno::Reference< uno::XInterface >() );
1094 - return rtl::OUString();
1095 + uno::Sequence< beans::PropertyValue > aProps(5);
1097 + aProps[0].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_COMMANDURL );
1098 + aProps[0].Value <<= sCommandURL;
1099 + aProps[1].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_HELPURL );
1100 + aProps[1].Value <<= sHelpURL;
1101 + aProps[2].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_LABEL );
1102 + aProps[2].Value <<= sLabel;
1103 + aProps[3].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_TYPE );
1104 + aProps[3].Value <<= nType;
1105 + aProps[4].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_CONTAINER );
1106 + aProps[4].Value = aSubMenu;
1108 + return aProps;
1111 -// Attributes
1112 -sal_Int32 SAL_CALL
1113 -ScVbaCommandBarControls::getCount() throw (uno::RuntimeException)
1114 +uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateToolbarItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const uno::Any& aSubMenu, sal_Bool isVisible, sal_Int32 nStyle )
1116 - sal_Int32 nCount = 0;
1117 - if( m_bHasElements )
1119 - sal_Int32 nBarSettingsCount = m_xBarSettings->getCount();
1120 - for( sal_Int32 i = 0; i < nBarSettingsCount; i++ )
1122 - beans::PropertyValues aMenuValues;
1123 - m_xBarSettings->getByIndex( i ) >>= aMenuValues;
1124 - for( sal_Int32 j = 0; j < aMenuValues.getLength(); j++ )
1126 - if( aMenuValues[j].Name.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii( "CommandURL" ) ) )
1128 - nCount++;
1131 - }
1133 - return nCount;
1134 + uno::Sequence< beans::PropertyValue > aProps(7);
1136 + aProps[0].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_COMMANDURL );
1137 + aProps[0].Value <<= sCommandURL;
1138 + aProps[1].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_HELPURL );
1139 + aProps[1].Value <<= sHelpURL;
1140 + aProps[2].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_LABEL );
1141 + aProps[2].Value <<= sLabel;
1142 + aProps[3].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_TYPE );
1143 + aProps[3].Value <<= nType;
1144 + aProps[4].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_CONTAINER );
1145 + aProps[4].Value = aSubMenu;
1146 + aProps[5].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE );
1147 + aProps[5].Value <<= isVisible;
1148 + aProps[6].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_STYLE );
1149 + aProps[6].Value <<= nStyle;
1151 + return aProps;
1154 // XEnumerationAccess
1155 uno::Type SAL_CALL
1156 ScVbaCommandBarControls::getElementType() throw ( uno::RuntimeException )
1158 - return XCommandBarControls::static_type( 0 );
1159 + return XCommandBarControl::static_type( 0 );
1162 uno::Reference< container::XEnumeration >
1163 ScVbaCommandBarControls::createEnumeration() throw ( uno::RuntimeException )
1165 return uno::Reference< container::XEnumeration >( new CommandBarControlEnumeration( this ) );
1168 uno::Any
1169 ScVbaCommandBarControls::createCollectionObject( const uno::Any& aSource )
1171 - // only surport the aSource as a name string, because this class is a API wrapper
1172 - rtl::OUString sName;
1173 - if( aSource >>= sName )
1175 - uno::Reference< container::XIndexContainer > xCurrentSettings;
1176 - beans::PropertyValues aPropertyValues;
1177 - if( m_pCommandBarControl )
1179 - m_pCommandBarControl->GetCurrentSettings()->getByIndex( m_pCommandBarControl->GetPosition() ) >>= aPropertyValues;
1180 - xCurrentSettings.set( lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "ItemDescriptorContainer" ) ), uno::UNO_QUERY );
1181 - if( !xCurrentSettings.is() )
1183 - xCurrentSettings.set( m_xUICfgManager->getSettings( GetParentToolBarName(), sal_True ), uno::UNO_QUERY );
1187 - sal_Int32 nPosition = -1;
1188 - for( sal_Int32 i = 0; i < xCurrentSettings->getCount(); i++ )
1190 - xCurrentSettings->getByIndex( i ) >>= aPropertyValues;
1191 - // Label always empty in OOo
1192 - rtl::OUString sLabel;
1193 - lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "Label" ) ) >>= sLabel;
1194 - if( sLabel.equalsIgnoreAsciiCase( sName ) )
1196 - nPosition = i;
1197 - break;
1199 - // using CammandURL to find
1200 - rtl::OUString sCommandURL;
1201 - lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "CommandURL" ) ) >>= sCommandURL;
1202 - sal_Int32 nLastIndex = sCommandURL.lastIndexOf( rtl::OUString::createFromAscii(":") );
1203 - if( ( nLastIndex != -1 ) && ( ( nLastIndex + 1 ) < sCommandURL.getLength() ) )
1205 - sCommandURL = sCommandURL.copy( nLastIndex + 1 );
1207 - if( sCommandURL.equalsIgnoreAsciiCase( sName ) )
1209 - nPosition = i;
1210 - break;
1214 - if( nPosition != -1 )
1216 - uno::Reference< container::XIndexContainer > xSubMenu;
1217 - lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "ItemDescriptorContainer" ) ) >>= xSubMenu;
1218 - ScVbaCommandBarControl* pNewCommandBarControl = NULL;
1219 - if( xSubMenu.is() )
1220 - pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, sName, nPosition );
1221 - else
1222 - pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, sName, nPosition );
1223 + sal_Int32 nPosition = -1;
1224 + aSource >>= nPosition;
1225 + uno::Sequence< beans::PropertyValue > aProps;
1226 + m_xIndexAccess->getByIndex( nPosition ) >>= aProps;
1227 + uno::Reference< container::XIndexAccess > xSubMenu;
1228 + getPropertyValue( aProps, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_CONTAINER ) ) >>= xSubMenu;
1229 + ScVbaCommandBarControl* pNewCommandBarControl = NULL;
1230 + if( xSubMenu.is() )
1231 + pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True );
1232 + else
1233 + pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True );
1235 - return uno::makeAny( uno::Reference< XCommandBarControl > ( pNewCommandBarControl ) );
1237 - else
1238 - throw uno::RuntimeException( rtl::OUString::createFromAscii("The CommandBarControl do not exist"), uno::Reference< uno::XInterface >() );
1241 - return uno::Any();
1242 + return uno::makeAny( uno::Reference< XCommandBarControl > ( pNewCommandBarControl ) );
1245 // Methods
1246 uno::Any SAL_CALL
1247 ScVbaCommandBarControls::Item( const uno::Any& aIndex, const uno::Any& /*aIndex*/ ) throw (uno::RuntimeException)
1249 + sal_Int32 nPosition = -1;
1250 if( aIndex.getValueTypeClass() == uno::TypeClass_STRING )
1252 - return createCollectionObject( aIndex );
1253 + rtl::OUString sName;
1254 + aIndex >>= sName;
1255 + nPosition = VbaCommandBarHelper::findControlByName( m_xIndexAccess, sName );
1257 - sal_Int32 nIndex = 0;
1258 - if( aIndex >>= nIndex )
1259 + else
1261 + aIndex >>= nPosition;
1264 + if( nPosition < 0 || nPosition >= getCount() )
1266 - return createCollectionObject( uno::makeAny( GetControlNameByIndex( nIndex ) ) );
1267 + throw uno::RuntimeException();
1270 - return uno::Any();
1271 + return createCollectionObject( uno::makeAny( nPosition ) );
1274 uno::Reference< XCommandBarControl > SAL_CALL
1275 -ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const uno::Any& /*Parameter*/, const uno::Any& Before, const uno::Any& Temporary ) throw (script::BasicErrorException, uno::RuntimeException)
1276 +ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const uno::Any& Parameter, const uno::Any& Before, const uno::Any& Temporary ) throw (script::BasicErrorException, uno::RuntimeException)
1278 // Parameter is not supported
1279 // the following name needs to be individually created;
1280 - rtl::OUString sCaption( rtl::OUString::createFromAscii("custom Control") );
1281 - rtl::OUString sCommand( rtl::OUString::createFromAscii("macro:///Standard.Module1.Test()") );
1282 - sal_Int32 nType =0;
1283 + rtl::OUString sLabel( rtl::OUString::createFromAscii("Custom") );
1284 + rtl::OUString sCommandUrl = rtl::OUString::createFromAscii( CUSTOM_MENU_STR ) + sLabel;
1285 + sal_Int32 nType = office::MsoControlType::msoControlButton;
1286 sal_Int32 nPosition = 0;
1287 - sal_Int32 nId;
1288 sal_Bool bTemporary = sal_True;
1290 if( Type.hasValue() )
1291 - if( Type >>= nType )
1293 - // evalute the type of the new control
1295 - if( Id.hasValue() )
1296 - if( Id >>= nId )
1298 - // evalute the action of the new control
1301 + Type >>= nType;
1304 + if( nType != office::MsoControlType::msoControlButton &&
1305 + nType != office::MsoControlType::msoControlPopup )
1306 + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
1308 + if( Id.hasValue() || Parameter.hasValue( ) )
1310 + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
1313 if( Before.hasValue() )
1314 Before >>= nPosition;
1315 else
1317 - // if Before is ignore, the new control should be placed at the end of the commandbars;
1318 - if( m_pCommandBar )
1319 - nPosition = getCount();
1320 - else if ( m_pCommandBarControl )
1322 - css::uno::Reference< css::container::XIndexContainer > xCurrentSettings;
1323 - xCurrentSettings.set( lcl_getPropertyValue( m_pCommandBarControl->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") ), uno::UNO_QUERY );
1324 - if( xCurrentSettings.is() )
1326 - nPosition = xCurrentSettings->getCount();
1330 + nPosition = m_xIndexAccess->getCount();
1332 if( Temporary.hasValue() )
1333 - if( Temporary >>= bTemporary )
1335 - // evalute the temporary of the new Control
1337 + Temporary >>= bTemporary;
1339 - ScVbaCommandBarControl* pNewCommandBarControl = NULL;
1340 - if( nType == office::MsoControlType::msoControlButton )
1341 + uno::Any aSubMenu;
1342 + if( nType == office::MsoControlType::msoControlPopup )
1344 - pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, sCaption, nPosition, bTemporary );
1345 + // it is a Popmenu
1346 + uno::Reference< lang::XSingleComponentFactory > xSCF( m_xBarSettings, uno::UNO_QUERY_THROW );
1347 + aSubMenu <<= xSCF->createInstanceWithContext( mxContext );
1349 - else if ( nType == office::MsoControlType::msoControlPopup )
1351 + // create control
1352 + uno::Sequence< beans::PropertyValue > aProps;
1353 + rtl::OUString sHelpUrl;
1354 + sal_Int32 nItemType = 0;
1355 + if( IsMenu() )
1357 - pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, sCaption, nPosition, bTemporary );
1358 + aProps = CreateMenuItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu );
1360 else
1362 - pNewCommandBarControl = new ScVbaCommandBarControl( this, mxContext, sCaption, nPosition, bTemporary );
1363 + sal_Bool isVisible = sal_True;
1364 + sal_Int32 nStyle = 0;
1365 + aProps = CreateToolbarItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu, isVisible, nStyle );
1369 + uno::Reference< container::XIndexContainer > xIndexContainer( m_xIndexAccess, uno::UNO_QUERY_THROW );
1370 + xIndexContainer->insertByIndex( nPosition, uno::makeAny( aProps ) );
1372 + pCBarHelper->getAppCfgManager()->replaceSettings( m_sResourceUrl, m_xBarSettings );
1373 + if( !bTemporary )
1374 + pCBarHelper->persistChanges();
1376 + ScVbaCommandBarControl* pNewCommandBarControl = NULL;
1377 + if( nType == office::MsoControlType::msoControlPopup )
1378 + pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary );
1379 + else
1380 + pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary );
1382 return uno::Reference< XCommandBarControl >( pNewCommandBarControl );
1385 diff --git vbahelper/source/vbahelper/vbacommandbarcontrols.hxx vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
1386 index f9ebe25..fa37f10 100644
1387 --- vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
1388 +++ vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
1389 @@ -36,47 +36,27 @@
1390 #define SC_VBA_COMMANDBARCONTROLS_HXX
1392 #include <ooo/vba/XCommandBarControls.hpp>
1394 #include <vbahelper/vbahelperinterface.hxx>
1395 -#include "vbacommandbar.hxx"
1396 #include <vbahelper/vbacollectionimpl.hxx>
1398 -class ScVbaCommandBarControl;
1399 +#include "vbacommandbarhelper.hxx"
1401 typedef CollTestImplHelper< ov::XCommandBarControls > CommandBarControls_BASE;
1403 class ScVbaCommandBarControls : public CommandBarControls_BASE
1405 private:
1406 - sal_Bool m_bIsMenu;
1407 - sal_Bool m_bHasElements;
1408 - ScVbaCommandBar* m_pCommandBar;
1409 - ScVbaCommandBarControl* m_pCommandBarControl;
1410 - css::uno::Reference< ov::XHelperInterface > m_xParentHardRef;
1411 - css::uno::Reference< css::ui::XUIConfigurationManager > m_xUICfgManager;
1412 - css::uno::Reference< css::ui::XUIConfigurationPersistence > m_xUICfgPers;
1413 - css::uno::Reference< css::container::XIndexContainer > m_xBarSettings;
1414 - css::uno::Reference< css::container::XIndexContainer > m_xCurrentSettings;
1415 - css::uno::Reference< css::frame::XModel > m_xModel;
1416 + VbaCommandBarHelperRef pCBarHelper;
1417 + css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
1418 + rtl::OUString m_sResourceUrl;
1419 + sal_Bool m_bIsMenu;
1421 + css::uno::Sequence< css::beans::PropertyValue > CreateMenuItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const css::uno::Any& aSubMenu );
1422 + css::uno::Sequence< css::beans::PropertyValue > CreateToolbarItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const css::uno::Any& aSubMenu, sal_Bool isVisible, sal_Int32 nStyle );
1424 public:
1425 - ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::container::XIndexAccess > xIndexAccess, const css::uno::Reference< css::frame::XModel >& xModel ) throw( css::uno::RuntimeException );
1426 - css::uno::Reference< css::ui::XUIConfigurationManager > GetUICfgManager() { return m_xUICfgManager; };
1427 - css::uno::Reference< css::ui::XUIConfigurationPersistence > GetUICfgPers() { return m_xUICfgPers; };
1428 - css::uno::Reference< css::container::XIndexContainer > GetBarSettings() { return m_xBarSettings; };
1429 - sal_Bool IsMenu() { return m_bIsMenu; };
1430 - ScVbaCommandBar* GetParentCommandBar() { return m_pCommandBar; };
1431 - ScVbaCommandBarControl* GetParentCommandBarControl() { return m_pCommandBarControl; };
1432 - rtl::OUString GetParentToolBarName()
1433 - {
1434 - if( m_pCommandBar ) return m_pCommandBar->GetToolBarName();
1435 - else return rtl::OUString();
1437 - rtl::OUString GetControlNameByIndex( const sal_Int32 nIndex ) throw ( css::uno::RuntimeException );
1438 + ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl ) throw( css::uno::RuntimeException );
1439 + sal_Bool IsMenu(){ return m_bIsMenu; }
1441 - css::uno::Reference< css::frame::XModel > GetModel() { return m_xModel; }
1442 - // Attributes
1443 - virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
1444 // XEnumerationAccess
1445 virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
1446 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
1447 diff --git vbahelper/source/vbahelper/vbacommandbarhelper.cxx vbahelper/source/vbahelper/vbacommandbarhelper.cxx
1448 new file mode 100644
1449 index 0000000..7c59107
1450 --- /dev/null
1451 +++ vbahelper/source/vbahelper/vbacommandbarhelper.cxx
1452 @@ -0,0 +1,175 @@
1453 +/*************************************************************************
1455 + * OpenOffice.org - a multi-platform office productivity suite
1457 + * $RCSfile$
1459 + * $Revision$
1461 + * last change: $Author$ $Date$
1463 + * The Contents of this file are made available subject to
1464 + * the terms of GNU Lesser General Public License Version 2.1.
1467 + * GNU Lesser General Public License Version 2.1
1468 + * =============================================
1469 + * Copyright 2005 by Sun Microsystems, Inc.
1470 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
1472 + * This library is free software; you can redistribute it and/or
1473 + * modify it under the terms of the GNU Lesser General Public
1474 + * License version 2.1, as published by the Free Software Foundation.
1476 + * This library is distributed in the hope that it will be useful,
1477 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1478 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1479 + * Lesser General Public License for more details.
1481 + * You should have received a copy of the GNU Lesser General Public
1482 + * License along with this library; if not, write to the Free Software
1483 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1484 + * MA 02111-1307 USA
1486 + ************************************************************************/
1487 +#include "vbacommandbarhelper.hxx"
1488 +#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
1489 +#include <com/sun/star/ui/XUIConfigurationStorage.hpp>
1490 +#include <com/sun/star/ui/XModuleUIConfigurationManager.hpp>
1491 +#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
1492 +#include <com/sun/star/ui/XUIElement.hpp>
1493 +#ifndef _COM_SUN_STAR_UI_UIElementType_HPP_
1494 +#include <com/sun/star/ui/UIElementType.hpp>
1495 +#endif
1496 +#include <comphelper/processfactory.hxx>
1497 +#include <vbahelper/vbahelper.hxx>
1498 +#include <time.h>
1500 +using namespace com::sun::star;
1501 +using namespace ooo::vba;
1504 +VbaCommandBarHelper::VbaCommandBarHelper( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException) : mxContext( xContext ), mxModel( xModel )
1506 + Init();
1509 +void VbaCommandBarHelper::Init( ) throw (css::uno::RuntimeException)
1511 + uno::Reference< css::ui::XUIConfigurationManagerSupplier > xUICfgSupplier( mxModel, uno::UNO_QUERY_THROW );
1512 + m_xDocCfgMgr = xUICfgSupplier->getUIConfigurationManager();
1514 + uno::Reference< lang::XServiceInfo > xServiceInfo( mxModel, uno::UNO_QUERY_THROW );
1515 + if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument") ) ) )
1517 + maModuleId = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument") );
1519 + else if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument" ) ) ) )
1521 + maModuleId = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument") );
1524 + if( maModuleId.getLength() == 0 )
1526 + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
1529 + uno::Reference< lang::XMultiServiceFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
1531 + css::uno::Reference< css::ui::XModuleUIConfigurationManagerSupplier > xUICfgMgrSupp( xServiceManager->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ))), uno::UNO_QUERY_THROW );
1533 + m_xAppCfgMgr.set( xUICfgMgrSupp->getUIConfigurationManager( maModuleId ), uno::UNO_QUERY_THROW );
1535 + css::uno::Reference< css::container::XNameAccess > xNameAccess( xServiceManager->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.WindowStateConfiguration" ))), uno::UNO_QUERY_THROW );
1537 + m_xWindowState.set( xNameAccess->getByName( maModuleId ), uno::UNO_QUERY_THROW );
1540 +css::uno::Reference< css::container::XIndexAccess > VbaCommandBarHelper::getMenuBarSettings() throw (css::uno::RuntimeException)
1542 + return m_xAppCfgMgr->getSettings( getMenuBarUrl(), sal_True );
1545 +sal_Bool VbaCommandBarHelper::persistChanges() throw (css::uno::RuntimeException)
1547 + uno::Reference< css::ui::XUIConfigurationPersistence > xConfigPersistence( m_xAppCfgMgr, uno::UNO_QUERY_THROW );
1548 + sal_Bool result = sal_False;
1549 + if( xConfigPersistence->isModified() )
1551 + xConfigPersistence->store();
1552 + result = sal_True;
1554 + return result;
1557 +rtl::OUString VbaCommandBarHelper::getMenuBarUrl()
1559 + static const rtl::OUString sMenuBarUrl( RTL_CONSTASCII_USTRINGPARAM( ITEM_MENUBAR_URL ) );
1560 + return sMenuBarUrl;
1563 +// return the resource url if found
1564 +rtl::OUString VbaCommandBarHelper::findToolbarByName( const css::uno::Reference< css::container::XNameAccess >& xNameAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException)
1566 + rtl::OUString sUIName;
1567 + rtl::OUString sResourceUrl;
1568 + uno::Sequence< ::rtl::OUString > allNames = xNameAccess->getElementNames();
1569 + for( sal_Int32 i = 0; i < allNames.getLength(); i++ )
1571 + sResourceUrl = allNames[i];
1572 + if(sResourceUrl.indexOf( rtl::OUString::createFromAscii( ITEM_TOOLBAR_URL ) ) == 0 )
1574 + //OSL_TRACE("VbaCommandBarHelper::findToolbarByName, toolbar resource url: %s", rtl::OUStringToOString( sResourceUrl, RTL_TEXTENCODING_UTF8 ).getStr() );
1575 + if( m_xAppCfgMgr->hasSettings( sResourceUrl ) )
1577 + uno::Reference< beans::XPropertySet > xPropertySet( m_xAppCfgMgr->getSettings( sResourceUrl, sal_False ), uno::UNO_QUERY_THROW );
1578 + xPropertySet->getPropertyValue( rtl::OUString::createFromAscii(ITEM_DESCRIPTOR_UINAME) ) >>= sUIName;
1579 + // OSL_TRACE("VbaCommandBarHelper::findToolbarByName, toolbar ui name: %s", rtl::OUStringToOString( sUIName, RTL_TEXTENCODING_UTF8 ).getStr() );
1580 + if( sName.equalsIgnoreAsciiCase( sUIName ) )
1581 + return sResourceUrl;
1585 + return rtl::OUString();
1588 +// if found, return the position of the control. if not found, return -1
1589 +sal_Int32 VbaCommandBarHelper::findControlByName( const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException)
1591 + sal_Int32 nCount = xIndexAccess->getCount();
1592 + css::uno::Sequence< css::beans::PropertyValue > aProps;
1593 + for( sal_Int32 i = 0; i < nCount; i++ )
1595 + rtl::OUString sLabel;
1596 + xIndexAccess->getByIndex( i ) >>= aProps;
1597 + getPropertyValue( aProps, rtl::OUString::createFromAscii(ITEM_DESCRIPTOR_LABEL) ) >>= sLabel;
1598 + // handle the hotkey character '~'
1599 + rtl::OUString sNewLabel;
1600 + sal_Int32 index = sLabel.indexOf( sal_Unicode('~') );
1601 + if( index < 0 )
1602 + sNewLabel = sLabel;
1603 + else if( index == 0 )
1604 + sNewLabel = sLabel.copy( index + 1);
1605 + else if( index == sNewLabel.getLength() - 1 )
1606 + sNewLabel = sLabel.copy(0, index );
1607 + else
1608 + sNewLabel = sLabel.copy( 0, index ) + sLabel.copy( index + 1 );
1609 + OSL_TRACE("VbaCommandBarHelper::findControlByName, control name: %s", rtl::OUStringToOString( sNewLabel, RTL_TEXTENCODING_UTF8 ).getStr() );
1610 + if( sName.equalsIgnoreAsciiCase( sNewLabel ) )
1611 + return i;
1614 + // not found
1615 + return -1;
1618 +rtl::OUString VbaCommandBarHelper::generateCustomURL()
1620 + rtl::OUString url = rtl::OUString::createFromAscii( ITEM_TOOLBAR_URL );
1621 + url += rtl::OUString::createFromAscii( CUSTOM_TOOLBAR_STR );
1623 + // use a random number to minimize possible clash with existing custom toolbars
1624 + srand( unsigned( time( NULL ) ));
1625 + url += rtl::OUString::valueOf( sal_Int64( rand() ), 16 );
1626 + return url;
1628 diff --git vbahelper/source/vbahelper/vbacommandbarhelper.hxx vbahelper/source/vbahelper/vbacommandbarhelper.hxx
1629 new file mode 100644
1630 index 0000000..a6304bc
1631 --- /dev/null
1632 +++ vbahelper/source/vbahelper/vbacommandbarhelper.hxx
1633 @@ -0,0 +1,105 @@
1634 +/*************************************************************************
1636 + * OpenOffice.org - a multi-platform office productivity suite
1638 + * $RCSfile$
1640 + * $Revision$
1642 + * last change: $Author$ $Date$
1644 + * The Contents of this file are made available subject to
1645 + * the terms of GNU Lesser General Public License Version 2.1.
1648 + * GNU Lesser General Public License Version 2.1
1649 + * =============================================
1650 + * Copyright 2005 by Sun Microsystems, Inc.
1651 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
1653 + * This library is free software; you can redistribute it and/or
1654 + * modify it under the terms of the GNU Lesser General Public
1655 + * License version 2.1, as published by the Free Software Foundation.
1657 + * This library is distributed in the hope that it will be useful,
1658 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1659 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1660 + * Lesser General Public License for more details.
1662 + * You should have received a copy of the GNU Lesser General Public
1663 + * License along with this library; if not, write to the Free Software
1664 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1665 + * MA 02111-1307 USA
1667 + ************************************************************************/
1668 +#ifndef VBA_COMMANDBARHELPER_HXX
1669 +#define VBA_COMMANDBARHELPER_HXX
1671 +#include <vbahelper/vbahelperinterface.hxx>
1672 +#include <com/sun/star/frame/XModel.hpp>
1673 +#include <com/sun/star/uno/XComponentContext.hpp>
1674 +#include <com/sun/star/ui/XUIConfigurationManager.hpp>
1675 +#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
1676 +#include <com/sun/star/container/XIndexAccess.hpp>
1677 +#include <com/sun/star/container/XNameAccess.hpp>
1678 +#include <boost/shared_ptr.hpp>
1681 +static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
1682 +static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL";
1683 +static const char ITEM_DESCRIPTOR_CONTAINER[] = "ItemDescriptorContainer";
1684 +static const char ITEM_DESCRIPTOR_LABEL[] = "Label";
1685 +static const char ITEM_DESCRIPTOR_TYPE[] = "Type";
1686 +static const char ITEM_DESCRIPTOR_STYLE[] = "Style";
1687 +static const char ITEM_DESCRIPTOR_ISVISIBLE[] = "IsVisible";
1688 +static const char ITEM_DESCRIPTOR_RESOURCEURL[] = "ResourceURL";
1689 +static const char ITEM_DESCRIPTOR_UINAME[] = "UIName";
1691 +static const char ITEM_MENUBAR_URL[] = "private:resource/menubar/menubar";
1692 +static const char ITEM_TOOLBAR_URL[] = "private:resource/toolbar/";
1694 +static const char CUSTOM_TOOLBAR_STR[] = "custom_toolbar_";
1695 +static const char CUSTOM_MENU_STR[] = "vnd.openoffice.org:CustomMenu";
1697 +class VbaCommandBarHelper;
1698 +typedef ::boost::shared_ptr< VbaCommandBarHelper > VbaCommandBarHelperRef;
1700 +class VbaCommandBarHelper
1702 +private:
1703 + css::uno::Reference< css::uno::XComponentContext > mxContext;
1704 + css::uno::Reference< css::frame::XModel > mxModel;
1705 + css::uno::Reference< css::ui::XUIConfigurationManager > m_xDocCfgMgr; // current document
1706 + css::uno::Reference< css::ui::XUIConfigurationManager > m_xAppCfgMgr;
1707 + css::uno::Reference< css::container::XNameAccess > m_xWindowState;
1708 + rtl::OUString maModuleId;
1710 + void Init() throw (css::uno::RuntimeException);
1711 +public:
1712 + VbaCommandBarHelper( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::frame::XModel >& xModel ) throw( css::uno::RuntimeException );
1714 + css::uno::Reference< css::frame::XModel > getModel() { return mxModel; }
1716 + css::uno::Reference< css::ui::XUIConfigurationManager > getDocCfgManager() throw (css::uno::RuntimeException)
1718 + return m_xDocCfgMgr;
1720 + css::uno::Reference< css::ui::XUIConfigurationManager > getAppCfgManager() throw (css::uno::RuntimeException)
1722 + return m_xAppCfgMgr;
1724 + css::uno::Reference< css::container::XIndexAccess > getMenuBarSettings() throw (css::uno::RuntimeException);
1725 + css::uno::Reference< css::container::XNameAccess > getPersistentWindowState() throw (css::uno::RuntimeException)
1727 + return m_xWindowState;
1729 + sal_Bool persistChanges() throw (css::uno::RuntimeException);
1731 + const rtl::OUString getModuleId(){ return maModuleId; }
1732 + static rtl::OUString getMenuBarUrl();
1733 + rtl::OUString findToolbarByName( const css::uno::Reference< css::container::XNameAccess >& xNameAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException);
1734 + static sal_Int32 findControlByName( const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException);
1735 + static rtl::OUString generateCustomURL();
1738 +#endif//VBA_COMMANDBARHELPER_HXX
1739 diff --git vbahelper/source/vbahelper/vbacommandbars.cxx vbahelper/source/vbahelper/vbacommandbars.cxx
1740 index 3aae99b..0f7881e 100644
1741 --- vbahelper/source/vbahelper/vbacommandbars.cxx
1742 +++ vbahelper/source/vbahelper/vbacommandbars.cxx
1743 @@ -35,6 +35,10 @@
1744 #include <com/sun/star/lang/XServiceInfo.hpp>
1745 #include <com/sun/star/frame/XDesktop.hpp>
1746 #include <com/sun/star/container/XNameAccess.hpp>
1747 +#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
1748 +#include <com/sun/star/ui/XUIConfigurationStorage.hpp>
1749 +#include <com/sun/star/ui/XModuleUIConfigurationManager.hpp>
1750 +#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
1752 #include "vbacommandbars.hxx"
1753 #include "vbacommandbar.hxx"
1754 @@ -42,22 +46,21 @@
1755 using namespace com::sun::star;
1756 using namespace ooo::vba;
1758 -typedef ::cppu::WeakImplHelper1< container::XEnumeration > CommandBarEnumeration_BASE;
1760 -static rtl::OUString sSpreadsheetDocumentUrl( rtl::OUString::createFromAscii( "com.sun.star.sheet.SpreadsheetDocument" ) );
1761 -static rtl::OUString sTextDocumentUrl( rtl::OUString::createFromAscii( "com.sun.star.text.TextDocument" ) );
1762 -static rtl::OUString sWindowStateConfUrl( rtl::OUString::createFromAscii( "com.sun.star.ui.WindowStateConfiguration" ) );
1763 +typedef ::cppu::WeakImplHelper1< container::XEnumeration > CommandBarEnumeration_BASE;
1765 class CommandBarEnumeration : public CommandBarEnumeration_BASE
1767 + uno::Reference< XHelperInterface > m_xParent;
1768 uno::Reference< uno::XComponentContext > m_xContext;
1769 - uno::Reference< XCommandBars > m_xCommandBars;
1770 + VbaCommandBarHelperRef pCBarHelper;
1771 uno::Sequence< rtl::OUString > m_sNames;
1772 sal_Int32 m_nCurrentPosition;
1773 - uno::Reference< frame::XModel > m_xModel;
1774 public:
1775 - CommandBarEnumeration( const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< XCommandBars > xCommandBars, const uno::Sequence< rtl::OUString > sNames, const uno::Reference< frame::XModel >& xModel ) : m_xContext( xContext ), m_xCommandBars( xCommandBars ), m_sNames( sNames ), m_nCurrentPosition( 0 ), m_xModel( xModel )
1776 + CommandBarEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, VbaCommandBarHelperRef pHelper) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), pCBarHelper( pHelper ) , m_nCurrentPosition( 0 )
1778 + uno::Reference< container::XNameAccess > xNameAccess = pCBarHelper->getPersistentWindowState();
1779 + m_sNames = xNameAccess->getElementNames();
1781 virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException )
1783 @@ -67,28 +70,14 @@ public:
1785 virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
1787 + // FIXME: should be add menubar
1788 if( hasMoreElements() )
1790 - rtl::OUString sName( m_sNames[ m_nCurrentPosition ] );
1791 - m_nCurrentPosition = m_nCurrentPosition + 1;
1792 - if( sName.indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 )
1793 + rtl::OUString sResourceUrl( m_sNames[ m_nCurrentPosition++ ] );
1794 + if( sResourceUrl.indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 )
1796 - sal_Int32 nLastIndex = sName.lastIndexOf( rtl::OUString::createFromAscii( "/" ) );
1797 - if( ( nLastIndex != -1 ) && ( ( nLastIndex + 1 ) < sName.getLength() ) )
1799 - sName = sName.copy( nLastIndex + 1);
1800 - if( sName.getLength() > 0 )
1802 - uno::Reference< XHelperInterface > xHelperInterface( m_xCommandBars, uno::UNO_QUERY_THROW );
1803 - uno::Reference< XCommandBar > xCommandBar( new ScVbaCommandBar( xHelperInterface, m_xContext, m_xModel, sName, sal_True, sal_False ) );
1804 - if( xCommandBar.is() )
1805 - return uno::makeAny( xCommandBar );
1806 - else
1807 - return nextElement();
1809 - else
1810 - return nextElement();
1812 + uno::Reference< container::XIndexAccess > xCBarSetting = pCBarHelper->getAppCfgManager()->getSettings( sResourceUrl, sal_True );
1813 + uno::Reference< XCommandBar > xCommandBar( new ScVbaCommandBar( m_xParent, m_xContext, pCBarHelper, xCBarSetting, sResourceUrl, sal_False, sal_False ) );
1815 else
1816 return nextElement();
1817 @@ -99,90 +88,99 @@ public:
1822 -ScVbaCommandBars::ScVbaCommandBars( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< container::XIndexAccess > xIndexAccess, const uno::Reference< frame::XModel >& xModel ) : CommandBars_BASE( xParent, xContext, xIndexAccess ), m_xModel( xModel )
1823 +ScVbaCommandBars::ScVbaCommandBars( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : CommandBars_BASE( xParent, xContext, xIndexAccess )
1825 - retrieveObjects();
1826 + pCBarHelper.reset( new VbaCommandBarHelper( mxContext, xModel ) );
1827 + m_xNameAccess = pCBarHelper->getPersistentWindowState();
1829 -void
1830 -ScVbaCommandBars::retrieveObjects() throw ( uno::RuntimeException )
1832 +ScVbaCommandBars::~ScVbaCommandBars()
1834 - uno::Reference< lang::XServiceInfo > xServiceInfo( m_xModel, uno::UNO_QUERY_THROW );
1835 - if( xServiceInfo->supportsService( sSpreadsheetDocumentUrl ) )
1837 - m_sModuleName = sSpreadsheetDocumentUrl;
1839 - else if( xServiceInfo->supportsService( sTextDocumentUrl ) )
1841 - m_sModuleName = sTextDocumentUrl;
1843 - else
1844 - throw uno::RuntimeException( rtl::OUString::createFromAscii( "Unsupported Document" ), uno::Reference< uno::XInterface >() );
1846 - uno::Reference < lang::XMultiServiceFactory > xMSF( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
1847 - uno::Reference < container::XNameAccess > xNameAccess( xMSF->createInstance( sWindowStateConfUrl ), uno::UNO_QUERY_THROW );
1848 - m_xNameAccess.set( xNameAccess->getByName( m_sModuleName ), uno::UNO_QUERY_THROW );
1851 // XEnumerationAccess
1852 uno::Type SAL_CALL
1853 ScVbaCommandBars::getElementType() throw ( uno::RuntimeException )
1855 - return XCommandBars::static_type( 0 );
1856 + return XCommandBar::static_type( 0 );
1859 uno::Reference< container::XEnumeration >
1860 ScVbaCommandBars::createEnumeration() throw ( uno::RuntimeException )
1862 - return uno::Reference< container::XEnumeration >( new CommandBarEnumeration( mxContext, this, m_xNameAccess->getElementNames(), m_xModel ) );
1863 + return uno::Reference< container::XEnumeration >( new CommandBarEnumeration( this, mxContext, pCBarHelper ) );
1866 uno::Any
1867 ScVbaCommandBars::createCollectionObject( const uno::Any& aSource )
1869 // aSource should be a name at this time, because of the class is API wrapper.
1870 - rtl::OUString sToolBarName;
1871 - if( aSource >>= sToolBarName )
1872 + rtl::OUString sResourceUrl;
1873 + uno::Reference< container::XIndexAccess > xBarSettings;
1874 + rtl::OUString sBarName;
1875 + sal_Bool bMenu = sal_False;
1876 + if( aSource >>= sBarName )
1878 - sToolBarName = sToolBarName.toAsciiLowerCase();
1879 - if( sToolBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Worksheet Menu Bar") ) )
1881 - return uno::makeAny( uno::Reference< XCommandBar > ( new ScVbaCommandBar( this, mxContext, m_xModel, 0 ) ) );
1883 - else if( sToolBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Menu Bar") ) )
1884 + if( sBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Worksheet Menu Bar") )
1885 + || sBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Menu Bar") ) )
1887 - return uno::makeAny( uno::Reference< XCommandBar > ( new ScVbaCommandBar( this, mxContext, m_xModel, 1 ) ) );
1888 + // menu bar
1889 + sResourceUrl = pCBarHelper->getMenuBarUrl();
1890 + bMenu = sal_True;
1892 - else if( checkToolBarExist( sToolBarName ) )
1893 + else
1895 - return uno::makeAny( uno::Reference< XCommandBar > (new ScVbaCommandBar( this, mxContext, m_xModel, sToolBarName, sal_True, sal_False ) ) );
1896 + sResourceUrl = pCBarHelper->findToolbarByName( m_xNameAccess, sBarName );
1897 + bMenu = sal_False;
1900 - return uno::Any();
1902 + if( sResourceUrl.getLength() )
1903 + xBarSettings = pCBarHelper->getAppCfgManager()->getSettings( sResourceUrl, sal_True );
1904 + else
1905 + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toolbar do not exist") ), uno::Reference< uno::XInterface >() );
1907 + return uno::Any( uno::Reference< XCommandBar >( new ScVbaCommandBar( this, mxContext, pCBarHelper, xBarSettings, sResourceUrl, bMenu, sal_False ) ) );
1910 // XCommandBars
1911 uno::Reference< XCommandBar > SAL_CALL
1912 ScVbaCommandBars::Add( const css::uno::Any& Name, const css::uno::Any& /*Position*/, const css::uno::Any& /*MenuBar*/, const css::uno::Any& Temporary ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
1914 + // FIXME: only support to add Toolbar
1915 // Position - MsoBar MenuBar - sal_Bool
1916 // Currently only the Name is supported.
1917 rtl::OUString sName;
1918 - if( !( Name >>= sName ) )
1919 + if( Name.hasValue() )
1920 + Name >>= sName;
1922 + rtl::OUString sResourceUrl;
1923 + if( sName.getLength() )
1925 - sName = rtl::OUString::createFromAscii("Custom1");
1926 + sResourceUrl = pCBarHelper->findToolbarByName( m_xNameAccess, sName );
1927 + if( sResourceUrl.getLength() )
1928 + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toolbar exists") ), uno::Reference< uno::XInterface >() );
1930 - sal_Bool bTemporary = false;
1931 - if( !( Temporary >>= bTemporary ) )
1932 + else
1934 - bTemporary = sal_True;
1936 - return uno::Reference< XCommandBar >( new ScVbaCommandBar( this, mxContext, m_xModel, sName.toAsciiLowerCase(), bTemporary, sal_True ) );
1937 + sName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Custom1") );
1938 + }
1940 + sal_Bool bTemporary = sal_False;
1941 + if( Temporary.hasValue() )
1942 + Temporary >>= bTemporary;
1944 + sResourceUrl = VbaCommandBarHelper::generateCustomURL();
1945 + uno::Reference< container::XIndexAccess > xBarSettings( pCBarHelper->getAppCfgManager()->createSettings(), uno::UNO_QUERY_THROW );
1946 + uno::Reference< XCommandBar > xCBar( new ScVbaCommandBar( this, mxContext, pCBarHelper, xBarSettings, sResourceUrl, sal_False, bTemporary ) );
1947 + xCBar->setName( sName );
1948 + return xCBar;
1950 sal_Int32 SAL_CALL
1951 ScVbaCommandBars::getCount() throw(css::uno::RuntimeException)
1953 // Filter out all toolbars from the window collection
1954 - sal_Int32 nCount = 0;
1955 + sal_Int32 nCount = 1; // there is a Menubar in OOo
1956 uno::Sequence< ::rtl::OUString > allNames = m_xNameAccess->getElementNames();
1957 for( sal_Int32 i = 0; i < allNames.getLength(); i++ )
1959 @@ -209,9 +207,9 @@ ScVbaCommandBars::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) th
1960 if( nIndex == 1 )
1962 uno::Any aSource;
1963 - if( m_sModuleName.equalsIgnoreAsciiCase( sSpreadsheetDocumentUrl ) )
1964 + if( pCBarHelper->getModuleId().equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" ) )
1965 aSource <<= rtl::OUString::createFromAscii( "Worksheet Menu Bar" );
1966 - else if( m_sModuleName.equalsIgnoreAsciiCase( sTextDocumentUrl ) )
1967 + else if( pCBarHelper->getModuleId().equalsAscii("com.sun.star.text.TextDocument") )
1968 aSource <<= rtl::OUString::createFromAscii( "Menu Bar" );
1969 if( aSource.hasValue() )
1970 return createCollectionObject( aSource );
1971 @@ -219,28 +217,6 @@ ScVbaCommandBars::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) th
1972 return uno::Any();
1975 -sal_Bool
1976 -ScVbaCommandBars::checkToolBarExist( rtl::OUString sToolBarName )
1978 - CommandBarNameMap::const_iterator iter = mCommandBarNameMap.find( sToolBarName.toAsciiLowerCase() );
1979 - if( iter != mCommandBarNameMap.end() )
1981 - return sal_True;
1982 - }
1983 - uno::Sequence< ::rtl::OUString > allNames = m_xNameAccess->getElementNames();
1984 - for( sal_Int32 i = 0; i < allNames.getLength(); i++ )
1986 - if(allNames[i].indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 )
1988 - if( allNames[i].indexOf( sToolBarName ) != -1 )
1990 - return sal_True;
1994 - return sal_False;
1997 // XHelperInterface
1998 rtl::OUString&
1999 ScVbaCommandBars::getServiceImplName()
2000 diff --git vbahelper/source/vbahelper/vbacommandbars.hxx vbahelper/source/vbahelper/vbacommandbars.hxx
2001 index d1ebf4b..2c0cc3f 100644
2002 --- vbahelper/source/vbahelper/vbacommandbars.hxx
2003 +++ vbahelper/source/vbahelper/vbacommandbars.hxx
2004 @@ -38,32 +38,22 @@
2005 #include <ooo/vba/XCommandBar.hpp>
2006 #include <ooo/vba/XCommandBars.hpp>
2007 #include <com/sun/star/container/XNameAccess.hpp>
2009 #include <cppuhelper/implbase1.hxx>
2011 #include <vbahelper/vbahelperinterface.hxx>
2012 #include <vbahelper/vbacollectionimpl.hxx>
2013 +#include "vbacommandbarhelper.hxx"
2015 typedef CollTestImplHelper< ov::XCommandBars > CommandBars_BASE;
2017 class ScVbaCommandBars : public CommandBars_BASE
2019 private:
2020 - css::uno::Reference< css::container::XNameAccess > m_xNameAccess;
2021 - rtl::OUString m_sModuleName;
2022 - void retrieveObjects() throw( css::uno::RuntimeException );
2023 -protected:
2024 - css::uno::Reference< css::frame::XModel > m_xModel;
2025 + VbaCommandBarHelperRef pCBarHelper;
2027 public:
2028 - ScVbaCommandBars( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::container::XIndexAccess > xIndexAccess, const css::uno::Reference< css::frame::XModel >& xModel );
2029 + ScVbaCommandBars( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
2030 + virtual ~ScVbaCommandBars();
2032 - sal_Bool checkToolBarExist( rtl::OUString sToolBarName );
2033 - rtl::OUString GetModuleName(){ return m_sModuleName; };
2034 - css::uno::Reference< css::container::XNameAccess > GetWindows()
2035 - {
2036 - retrieveObjects();
2037 - return m_xNameAccess;
2038 - };
2039 // XCommandBars
2040 virtual css::uno::Reference< ov::XCommandBar > SAL_CALL Add( const css::uno::Any& Name, const css::uno::Any& Position, const css::uno::Any& MenuBar, const css::uno::Any& Temporary ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
2041 // XEnumerationAccess
2042 diff --git vbahelper/source/vbahelper/vbahelper.cxx vbahelper/source/vbahelper/vbahelper.cxx
2043 index 2a51ee4..8290f66 100644
2044 --- vbahelper/source/vbahelper/vbahelper.cxx
2045 +++ vbahelper/source/vbahelper/vbahelper.cxx
2046 @@ -917,6 +917,33 @@ void setDefaultPropByIntrospection( const uno::Any& aObj, const uno::Any& aValue
2047 throw uno::RuntimeException();
2050 +uno::Any getPropertyValue( const uno::Sequence< beans::PropertyValue >& aProp, const rtl::OUString& aName )
2052 + uno::Any result;
2053 + for ( sal_Int32 i = 0; i < aProp.getLength(); i++ )
2055 + if ( aProp[i].Name.equals(aName) )
2057 + aProp[i].Value >>= result;
2058 + return result;
2061 + return result;
2064 +sal_Bool setPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, const rtl::OUString& aName, const uno::Any& aValue )
2066 + for ( sal_Int32 i = 0; i < aProp.getLength(); i++ )
2068 + if ( aProp[i].Name.equals(aName) )
2070 + aProp[i].Value = aValue;
2071 + return sal_True;
2074 + return sal_False;
2077 #define VBA_LEFT "PositionX"
2078 #define VBA_TOP "PositionY"
2079 UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl )