1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: itemholder1.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #include "itemholder1.hxx"
36 //-----------------------------------------------
38 #include <comphelper/processfactory.hxx>
39 #include <com/sun/star/lang/XComponent.hpp>
41 #include <svtools/accelcfg.hxx>
42 #include <svtools/addxmltostorageoptions.hxx>
43 #include <cacheoptions.hxx>
44 #include <svtools/cmdoptions.hxx>
45 #include <svtools/compatibility.hxx>
46 #include <svtools/defaultoptions.hxx>
47 #include <svtools/dynamicmenuoptions.hxx>
48 #include <eventcfg.hxx>
49 #include <svtools/extendedsecurityoptions.hxx>
50 #include <fltrcfg.hxx>
51 #include <svtools/fontoptions.hxx>
52 #include <svtools/historyoptions.hxx>
53 #include <svtools/inetoptions.hxx>
54 #include <svtools/internaloptions.hxx>
55 #include <javaoptions.hxx>
56 #include <svtools/lingucfg.hxx>
57 #include <svtools/localisationoptions.hxx>
58 #include <svtools/menuoptions.hxx>
59 #include <svtools/moduleoptions.hxx>
60 #include <svtools/pathoptions.hxx>
61 #include <svtools/printwarningoptions.hxx>
62 #include <regoptions.hxx>
63 #include <svtools/optionsdlg.hxx>
64 #include <svtools/saveopt.hxx>
65 #include <searchopt.hxx>
66 #include <svtools/securityoptions.hxx>
67 #include <svtools/sourceviewconfig.hxx>
68 #include <svtools/startoptions.hxx>
69 #include <svtools/viewoptions.hxx>
70 #include <svtools/workingsetoptions.hxx>
71 #include <xmlaccelcfg.hxx>
72 #include <svtools/options.hxx>
74 //-----------------------------------------------
77 namespace css
= ::com::sun::star
;
79 //-----------------------------------------------
82 //-----------------------------------------------
83 ItemHolder1::ItemHolder1()
84 : ItemHolderMutexBase()
88 css::uno::Reference
< css::lang::XMultiServiceFactory
> xSMGR
= ::comphelper::getProcessServiceFactory();
89 css::uno::Reference
< css::lang::XComponent
> xCfg(
90 xSMGR
->createInstance(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
93 xCfg
->addEventListener(static_cast< css::lang::XEventListener
* >(this));
95 // #i37892 got errorhandling from ConfigManager::GetConfigurationProvider()
97 catch(css::uno::Exception
& rEx
)
99 static sal_Bool bMessage
= sal_True
;
102 bMessage
= sal_False
;
103 ::rtl::OString
sMsg("CreateInstance with arguments exception: ");
104 sMsg
+= ::rtl::OString(rEx
.Message
.getStr(),
105 rEx
.Message
.getLength(),
106 RTL_TEXTENCODING_ASCII_US
);
107 OSL_ENSURE(sal_False
, sMsg
.getStr());
111 catch(css::uno::Exception
&){}
115 //-----------------------------------------------
116 ItemHolder1::~ItemHolder1()
118 impl_releaseAllItems();
121 //-----------------------------------------------
122 void ItemHolder1::holdConfigItem(EItem eItem
)
124 static ItemHolder1
* pHolder
= new ItemHolder1();
125 pHolder
->impl_addItem(eItem
);
128 //-----------------------------------------------
129 void SAL_CALL
ItemHolder1::disposing(const css::lang::EventObject
&)
130 throw(css::uno::RuntimeException
)
132 css::uno::Reference
< css::uno::XInterface
> xSelfHold(static_cast< css::lang::XEventListener
* >(this), css::uno::UNO_QUERY
);
133 impl_releaseAllItems();
136 //-----------------------------------------------
137 void ItemHolder1::impl_addItem(EItem eItem
)
139 ::osl::ResettableMutexGuard
aLock(m_aLock
);
141 TItems::const_iterator pIt
;
142 for ( pIt
= m_lItems
.begin();
143 pIt
!= m_lItems
.end() ;
146 const TItemInfo
& rInfo
= *pIt
;
147 if (rInfo
.eItem
== eItem
)
152 aNewItem
.eItem
= eItem
;
153 impl_newItem(aNewItem
);
155 m_lItems
.push_back(aNewItem
);
158 //-----------------------------------------------
159 void ItemHolder1::impl_releaseAllItems()
161 ::osl::ResettableMutexGuard
aLock(m_aLock
);
163 TItems::iterator pIt
;
164 for ( pIt
= m_lItems
.begin();
165 pIt
!= m_lItems
.end() ;
168 TItemInfo
& rInfo
= *pIt
;
169 impl_deleteItem(rInfo
);
174 //-----------------------------------------------
175 void ItemHolder1::impl_newItem(TItemInfo
& rItem
)
180 rItem
.pItem
= new SvtAcceleratorConfiguration();
183 case E_ADDXMLTOSTORAGEOPTIONS
:
184 rItem
.pItem
= new SvtAddXMLToStorageOptions();
188 rItem
.pItem
= new SvtCommandOptions();
191 case E_COMPATIBILITY
:
192 rItem
.pItem
= new SvtCompatibilityOptions();
195 case E_DEFAULTOPTIONS
:
196 rItem
.pItem
= new SvtDefaultOptions();
199 case E_DYNAMICMENUOPTIONS
:
200 rItem
.pItem
= new SvtDynamicMenuOptions();
204 //rItem.pItem = new GlobalEventConfig();
207 case E_EXTENDEDSECURITYOPTIONS
:
208 rItem
.pItem
= new SvtExtendedSecurityOptions();
212 // no ref count rItem.pItem = new SvtFilterOptions();
216 rItem
.pItem
= new SvtFontOptions();
219 case E_HISTORYOPTIONS
:
220 rItem
.pItem
= new SvtHistoryOptions();
224 rItem
.pItem
= new SvtInetOptions();
227 case E_INTERNALOPTIONS
:
228 rItem
.pItem
= new SvtInternalOptions();
232 // no ref count rItem.pItem = new SvtJavaOptions();
236 rItem
.pItem
= new SvtLinguConfig();
239 case E_LOCALISATIONOPTIONS
:
240 rItem
.pItem
= new SvtLocalisationOptions();
244 rItem
.pItem
= new SvtMenuOptions();
247 case E_MODULEOPTIONS
:
248 rItem
.pItem
= new SvtModuleOptions();
251 case E_OPTIONSDLGOPTIONS
:
252 rItem
.pItem
= new SvtOptionsDialogOptions();
256 rItem
.pItem
= new SvtPathOptions();
259 case E_PRINTWARNINGOPTIONS
:
260 rItem
.pItem
= new SvtPrintWarningOptions();
264 // no ref count rItem.pItem = new ::svt::RegOptions();
268 rItem
.pItem
= new SvtSaveOptions();
272 // no ref count rItem.pItem = new SvtSearchOptions();
275 case E_SECURITYOPTIONS
:
276 rItem
.pItem
= new SvtSecurityOptions();
279 case E_SOURCEVIEWCONFIG
:
280 rItem
.pItem
= new ::svt::SourceViewConfig();
283 case E_STARTOPTIONS
:
284 rItem
.pItem
= new SvtStartOptions();
287 case E_VIEWOPTIONS_DIALOG
:
288 rItem
.pItem
= new SvtViewOptions(E_DIALOG
, ::rtl::OUString());
291 case E_VIEWOPTIONS_TABDIALOG
:
292 rItem
.pItem
= new SvtViewOptions(E_TABDIALOG
, ::rtl::OUString());
295 case E_VIEWOPTIONS_TABPAGE
:
296 rItem
.pItem
= new SvtViewOptions(E_TABPAGE
, ::rtl::OUString());
299 case E_VIEWOPTIONS_WINDOW
:
300 rItem
.pItem
= new SvtViewOptions(E_WINDOW
, ::rtl::OUString());
303 case E_WORKINGSETOPTIONS
:
304 rItem
.pItem
= new SvtWorkingSetOptions();
311 OSL_ASSERT( "unknown item type" );
316 //-----------------------------------------------
317 void ItemHolder1::impl_deleteItem(TItemInfo
& rItem
)