1 diff --git vbahelper/source/vbahelper/vbacommandbar.cxx vbahelper/source/vbahelper/vbacommandbar.cxx
2 index 8c10277..63af635 100644
3 --- vbahelper/source/vbahelper/vbacommandbar.cxx
4 +++ vbahelper/source/vbahelper/vbacommandbar.cxx
5 @@ -61,7 +61,7 @@ ScVbaCommandBar::getName() throw ( uno::RuntimeException )
9 - if( m_sResourceUrl.equals( VbaCommandBarHelper::getMenuBarUrl() ) )
10 + if( m_sResourceUrl.equalsAscii( ITEM_MENUBAR_URL ) )
12 if( pCBarHelper->getModuleId().equalsAscii("com.sun.star.sheet.SpreadsheetDocument") )
13 sName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Worksheet Menu Bar") );
14 @@ -87,18 +87,7 @@ ScVbaCommandBar::setName( const ::rtl::OUString& _name ) throw (uno::RuntimeExce
15 uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
16 xPropertySet->setPropertyValue( rtl::OUString::createFromAscii("UIName"), uno::makeAny( _name ) );
18 - if( pCBarHelper->getAppCfgManager()->hasSettings( m_sResourceUrl ) )
20 - pCBarHelper->getAppCfgManager()->replaceSettings( m_sResourceUrl, m_xBarSettings );
24 - pCBarHelper->getAppCfgManager()->insertSettings( m_sResourceUrl, m_xBarSettings );
28 - pCBarHelper->persistChanges();
30 + pCBarHelper->ApplyChange( m_sResourceUrl, m_xBarSettings );
33 ScVbaCommandBar::getVisible() throw (uno::RuntimeException)
34 @@ -163,20 +152,7 @@ ScVbaCommandBar::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException)
36 ScVbaCommandBar::Delete( ) throw (script::BasicErrorException, uno::RuntimeException)
38 - if( pCBarHelper->getAppCfgManager()->hasSettings( m_sResourceUrl ) )
40 - pCBarHelper->getAppCfgManager()->removeSettings(m_sResourceUrl);
41 - // make it permanent
44 - pCBarHelper->persistChanges();
49 - // toolbar not found
52 + pCBarHelper->removeSettings( m_sResourceUrl );
53 uno::Reference< container::XNameContainer > xNameContainer( pCBarHelper->getPersistentWindowState(), uno::UNO_QUERY_THROW );
54 if( xNameContainer->hasByName( m_sResourceUrl ) )
56 diff --git vbahelper/source/vbahelper/vbacommandbarcontrol.cxx vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
57 index 050af79..f6eb381 100644
58 --- vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
59 +++ vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
60 @@ -53,9 +53,7 @@ void ScVbaCommandBarControl::ApplyChange() throw ( uno::RuntimeException )
62 uno::Reference< container::XIndexContainer > xIndexContainer( m_xCurrentSettings, uno::UNO_QUERY_THROW );
63 xIndexContainer->replaceByIndex( m_nPosition, uno::makeAny( m_aPropertyValues ) );
64 - pCBarHelper->getAppCfgManager()->replaceSettings( m_sResourceUrl, m_xBarSettings );
66 - pCBarHelper->persistChanges();
67 + pCBarHelper->ApplyChange( m_sResourceUrl, m_xBarSettings );
70 ::rtl::OUString SAL_CALL
71 @@ -159,19 +157,7 @@ ScVbaCommandBarControl::Delete( ) throw (script::BasicErrorException, uno::Runt
72 uno::Reference< container::XIndexContainer > xIndexContainer( m_xCurrentSettings, uno::UNO_QUERY_THROW );
73 xIndexContainer->removeByIndex( m_nPosition );
75 - if( pCBarHelper->getAppCfgManager()->hasSettings( m_sResourceUrl ) )
77 - pCBarHelper->getAppCfgManager()->replaceSettings( m_sResourceUrl, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
81 - pCBarHelper->getAppCfgManager()->insertSettings( m_sResourceUrl, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
83 - // make it permanent
86 - pCBarHelper->persistChanges();
88 + pCBarHelper->ApplyChange( m_sResourceUrl, m_xBarSettings );
92 diff --git vbahelper/source/vbahelper/vbacommandbarcontrols.cxx vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
93 index 488b56a..1aa7d7e 100644
94 --- vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
95 +++ vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
96 @@ -223,9 +223,7 @@ ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const un
97 uno::Reference< container::XIndexContainer > xIndexContainer( m_xIndexAccess, uno::UNO_QUERY_THROW );
98 xIndexContainer->insertByIndex( nPosition, uno::makeAny( aProps ) );
100 - pCBarHelper->getAppCfgManager()->replaceSettings( m_sResourceUrl, m_xBarSettings );
102 - pCBarHelper->persistChanges();
103 + pCBarHelper->ApplyChange( m_sResourceUrl, m_xBarSettings );
105 // sometimes it would crash if passing m_xMenu instead of uno::Reference< awt::XMenu >() in Linux.
106 ScVbaCommandBarControl* pNewCommandBarControl = NULL;
107 diff --git vbahelper/source/vbahelper/vbacommandbarhelper.cxx vbahelper/source/vbahelper/vbacommandbarhelper.cxx
108 index 034e506..3cf12f6 100644
109 --- vbahelper/source/vbahelper/vbacommandbarhelper.cxx
110 +++ vbahelper/source/vbahelper/vbacommandbarhelper.cxx
111 @@ -138,14 +138,48 @@ void VbaCommandBarHelper::Init( ) throw (css::uno::RuntimeException)
112 m_xWindowState.set( xNameAccess->getByName( maModuleId ), uno::UNO_QUERY_THROW );
115 -css::uno::Reference< css::container::XIndexAccess > VbaCommandBarHelper::getMenuBarSettings() throw (css::uno::RuntimeException)
116 +css::uno::Reference< css::container::XIndexAccess > VbaCommandBarHelper::getSettings( const rtl::OUString& sResourceUrl ) throw (css::uno::RuntimeException)
118 - return m_xAppCfgMgr->getSettings( getMenuBarUrl(), sal_True );
119 + if( m_xDocCfgMgr->hasSettings( sResourceUrl ) )
120 + return m_xDocCfgMgr->getSettings( sResourceUrl, sal_True );
121 + else if( m_xAppCfgMgr->hasSettings( sResourceUrl ) )
122 + return m_xAppCfgMgr->getSettings( sResourceUrl, sal_True );
125 + css::uno::Reference< css::container::XIndexAccess > xSettings( m_xAppCfgMgr->createSettings( ), uno::UNO_QUERY_THROW );
130 +void VbaCommandBarHelper::removeSettings( const rtl::OUString& sResourceUrl ) throw (css::uno::RuntimeException)
132 + if( m_xDocCfgMgr->hasSettings( sResourceUrl ) )
133 + m_xDocCfgMgr->removeSettings( sResourceUrl );
134 + else if( m_xAppCfgMgr->hasSettings( sResourceUrl ) )
135 + m_xAppCfgMgr->removeSettings( sResourceUrl );
137 + // persistChanges();
140 +void VbaCommandBarHelper::ApplyChange( const rtl::OUString& sResourceUrl, const css::uno::Reference< css::container::XIndexAccess >& xSettings, sal_Bool bTemporary ) throw (css::uno::RuntimeException)
142 + if( m_xDocCfgMgr->hasSettings( sResourceUrl ) )
144 + m_xDocCfgMgr->replaceSettings( sResourceUrl, xSettings );
148 + m_xDocCfgMgr->insertSettings( sResourceUrl, xSettings );
156 sal_Bool VbaCommandBarHelper::persistChanges() throw (css::uno::RuntimeException)
158 - uno::Reference< css::ui::XUIConfigurationPersistence > xConfigPersistence( m_xAppCfgMgr, uno::UNO_QUERY_THROW );
159 + uno::Reference< css::ui::XUIConfigurationPersistence > xConfigPersistence( m_xDocCfgMgr, uno::UNO_QUERY_THROW );
160 sal_Bool result = sal_False;
161 if( xConfigPersistence->isModified() )
163 @@ -163,12 +197,6 @@ uno::Reference< frame::XLayoutManager > VbaCommandBarHelper::getLayoutManager()
164 return xLayoutManager;
167 -rtl::OUString VbaCommandBarHelper::getMenuBarUrl()
169 - static const rtl::OUString sMenuBarUrl( RTL_CONSTASCII_USTRINGPARAM( ITEM_MENUBAR_URL ) );
170 - return sMenuBarUrl;
173 // return the resource url if found
174 rtl::OUString VbaCommandBarHelper::findToolbarByName( const css::uno::Reference< css::container::XNameAccess >& xNameAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException)
176 @@ -187,9 +215,9 @@ rtl::OUString VbaCommandBarHelper::findToolbarByName( const css::uno::Reference<
177 if(sResourceUrl.indexOf( rtl::OUString::createFromAscii( ITEM_TOOLBAR_URL ) ) == 0 )
179 //OSL_TRACE("VbaCommandBarHelper::findToolbarByName, toolbar resource url: %s", rtl::OUStringToOString( sResourceUrl, RTL_TEXTENCODING_UTF8 ).getStr() );
180 - if( m_xAppCfgMgr->hasSettings( sResourceUrl ) )
181 + if( m_xDocCfgMgr->hasSettings( sResourceUrl ) )
183 - uno::Reference< beans::XPropertySet > xPropertySet( m_xAppCfgMgr->getSettings( sResourceUrl, sal_False ), uno::UNO_QUERY_THROW );
184 + uno::Reference< beans::XPropertySet > xPropertySet( m_xDocCfgMgr->getSettings( sResourceUrl, sal_False ), uno::UNO_QUERY_THROW );
185 xPropertySet->getPropertyValue( rtl::OUString::createFromAscii(ITEM_DESCRIPTOR_UINAME) ) >>= sUIName;
186 // OSL_TRACE("VbaCommandBarHelper::findToolbarByName, toolbar ui name: %s", rtl::OUStringToOString( sUIName, RTL_TEXTENCODING_UTF8 ).getStr() );
187 if( sName.equalsIgnoreAsciiCase( sUIName ) )
188 diff --git vbahelper/source/vbahelper/vbacommandbarhelper.hxx vbahelper/source/vbahelper/vbacommandbarhelper.hxx
189 index 64a808d..10ed441 100644
190 --- vbahelper/source/vbahelper/vbacommandbarhelper.hxx
191 +++ vbahelper/source/vbahelper/vbacommandbarhelper.hxx
192 @@ -89,17 +89,18 @@ public:
196 - css::uno::Reference< css::container::XIndexAccess > getMenuBarSettings() throw (css::uno::RuntimeException);
197 css::uno::Reference< css::container::XNameAccess > getPersistentWindowState() throw (css::uno::RuntimeException)
199 return m_xWindowState;
201 sal_Bool persistChanges() throw (css::uno::RuntimeException);
202 + css::uno::Reference< css::container::XIndexAccess > getSettings( const rtl::OUString& sResourceUrl ) throw (css::uno::RuntimeException);
203 + void removeSettings( const rtl::OUString& sResourceUrl ) throw (css::uno::RuntimeException);
204 + void ApplyChange( const rtl::OUString& sResourceUrl, const css::uno::Reference< css::container::XIndexAccess >& xSettings, sal_Bool bTemporary = sal_True ) throw (css::uno::RuntimeException);
206 css::uno::Reference< css::frame::XLayoutManager > getLayoutManager() throw (css::uno::RuntimeException);
208 const rtl::OUString getModuleId(){ return maModuleId; }
209 - static rtl::OUString getMenuBarUrl();
210 rtl::OUString findToolbarByName( const css::uno::Reference< css::container::XNameAccess >& xNameAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException);
211 static sal_Int32 findControlByName( const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException);
212 static rtl::OUString generateCustomURL();
213 diff --git vbahelper/source/vbahelper/vbacommandbars.cxx vbahelper/source/vbahelper/vbacommandbars.cxx
214 index 0f7881e..e87e4a3 100644
215 --- vbahelper/source/vbahelper/vbacommandbars.cxx
216 +++ vbahelper/source/vbahelper/vbacommandbars.cxx
217 @@ -76,7 +76,7 @@ public:
218 rtl::OUString sResourceUrl( m_sNames[ m_nCurrentPosition++ ] );
219 if( sResourceUrl.indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 )
221 - uno::Reference< container::XIndexAccess > xCBarSetting = pCBarHelper->getAppCfgManager()->getSettings( sResourceUrl, sal_True );
222 + uno::Reference< container::XIndexAccess > xCBarSetting = pCBarHelper->getSettings( sResourceUrl );
223 uno::Reference< XCommandBar > xCommandBar( new ScVbaCommandBar( m_xParent, m_xContext, pCBarHelper, xCBarSetting, sResourceUrl, sal_False, sal_False ) );
226 @@ -125,7 +125,7 @@ ScVbaCommandBars::createCollectionObject( const uno::Any& aSource )
227 || sBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Menu Bar") ) )
230 - sResourceUrl = pCBarHelper->getMenuBarUrl();
231 + sResourceUrl = rtl::OUString::createFromAscii( ITEM_MENUBAR_URL );
235 @@ -136,7 +136,7 @@ ScVbaCommandBars::createCollectionObject( const uno::Any& aSource )
238 if( sResourceUrl.getLength() )
239 - xBarSettings = pCBarHelper->getAppCfgManager()->getSettings( sResourceUrl, sal_True );
240 + xBarSettings = pCBarHelper->getSettings( sResourceUrl );
242 throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toolbar do not exist") ), uno::Reference< uno::XInterface >() );
244 @@ -171,7 +171,7 @@ ScVbaCommandBars::Add( const css::uno::Any& Name, const css::uno::Any& /*Positio
245 Temporary >>= bTemporary;
247 sResourceUrl = VbaCommandBarHelper::generateCustomURL();
248 - uno::Reference< container::XIndexAccess > xBarSettings( pCBarHelper->getAppCfgManager()->createSettings(), uno::UNO_QUERY_THROW );
249 + uno::Reference< container::XIndexAccess > xBarSettings( pCBarHelper->getSettings( sResourceUrl ), uno::UNO_QUERY_THROW );
250 uno::Reference< XCommandBar > xCBar( new ScVbaCommandBar( this, mxContext, pCBarHelper, xBarSettings, sResourceUrl, sal_False, bTemporary ) );
251 xCBar->setName( sName );