1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "itemholder1.hxx"
23 #include <comphelper/processfactory.hxx>
24 #include <com/sun/star/lang/XComponent.hpp>
25 #include <com/sun/star/configuration/theDefaultProvider.hpp>
27 #include <unotools/misccfg.hxx>
28 #include <unotools/useroptions.hxx>
29 #include <unotools/accelcfg.hxx>
30 #include <unotools/cmdoptions.hxx>
31 #include <unotools/compatibility.hxx>
32 #include <unotools/defaultoptions.hxx>
33 #include <unotools/dynamicmenuoptions.hxx>
34 #include <unotools/eventcfg.hxx>
35 #include <unotools/extendedsecurityoptions.hxx>
36 #include <unotools/fltrcfg.hxx>
37 #include <unotools/fontoptions.hxx>
38 #include <unotools/historyoptions.hxx>
39 #include <unotools/internaloptions.hxx>
40 #include <unotools/lingucfg.hxx>
41 #include <unotools/localisationoptions.hxx>
42 #include <unotools/moduleoptions.hxx>
43 #include <unotools/pathoptions.hxx>
44 #include <unotools/printwarningoptions.hxx>
45 #include <unotools/optionsdlg.hxx>
46 #include <unotools/saveopt.hxx>
47 #include <unotools/searchopt.hxx>
48 #include <unotools/securityoptions.hxx>
49 #include <unotools/viewoptions.hxx>
50 #include <unotools/workingsetoptions.hxx>
51 #include <unotools/xmlaccelcfg.hxx>
52 #include <unotools/options.hxx>
53 #include <unotools/syslocaleoptions.hxx>
55 //-----------------------------------------------
56 ItemHolder1::ItemHolder1()
57 : ItemHolderMutexBase()
61 css::uno::Reference
< css::uno::XComponentContext
> xContext
= ::comphelper::getProcessComponentContext();
62 css::uno::Reference
< css::lang::XComponent
> xCfg(
63 css::configuration::theDefaultProvider::get( xContext
),
64 css::uno::UNO_QUERY_THROW
);
65 xCfg
->addEventListener(static_cast< css::lang::XEventListener
* >(this));
68 catch(const css::uno::Exception
& rEx
)
70 static sal_Bool bMessage
= sal_True
;
74 ::rtl::OString
sMsg("CreateInstance with arguments exception: ");
75 sMsg
+= ::rtl::OString(rEx
.Message
.getStr(),
76 rEx
.Message
.getLength(),
77 RTL_TEXTENCODING_ASCII_US
);
78 OSL_FAIL(sMsg
.getStr());
82 catch(css::uno::Exception
&){}
86 //-----------------------------------------------
87 ItemHolder1::~ItemHolder1()
89 impl_releaseAllItems();
92 //-----------------------------------------------
93 void ItemHolder1::holdConfigItem(EItem eItem
)
95 static ItemHolder1
* pHolder
= new ItemHolder1();
96 pHolder
->impl_addItem(eItem
);
99 //-----------------------------------------------
100 void SAL_CALL
ItemHolder1::disposing(const css::lang::EventObject
&)
101 throw(css::uno::RuntimeException
)
103 css::uno::Reference
< css::uno::XInterface
> xSelfHold(static_cast< css::lang::XEventListener
* >(this), css::uno::UNO_QUERY
);
104 impl_releaseAllItems();
107 //-----------------------------------------------
108 void ItemHolder1::impl_addItem(EItem eItem
)
110 ::osl::ResettableMutexGuard
aLock(m_aLock
);
112 TItems::const_iterator pIt
;
113 for ( pIt
= m_lItems
.begin();
114 pIt
!= m_lItems
.end() ;
117 const TItemInfo
& rInfo
= *pIt
;
118 if (rInfo
.eItem
== eItem
)
123 aNewItem
.eItem
= eItem
;
124 impl_newItem(aNewItem
);
126 m_lItems
.push_back(aNewItem
);
129 //-----------------------------------------------
130 void ItemHolder1::impl_releaseAllItems()
132 ::osl::ResettableMutexGuard
aLock(m_aLock
);
134 TItems::iterator pIt
;
135 for ( pIt
= m_lItems
.begin();
136 pIt
!= m_lItems
.end() ;
139 TItemInfo
& rInfo
= *pIt
;
140 impl_deleteItem(rInfo
);
145 //-----------------------------------------------
146 void ItemHolder1::impl_newItem(TItemInfo
& rItem
)
151 rItem
.pItem
= new SvtAcceleratorConfiguration();
155 rItem
.pItem
= new SvtCommandOptions();
158 case E_COMPATIBILITY
:
159 rItem
.pItem
= new SvtCompatibilityOptions();
162 case E_DEFAULTOPTIONS
:
163 rItem
.pItem
= new SvtDefaultOptions();
166 case E_DYNAMICMENUOPTIONS
:
167 rItem
.pItem
= new SvtDynamicMenuOptions();
171 //rItem.pItem = new GlobalEventConfig();
174 case E_EXTENDEDSECURITYOPTIONS
:
175 rItem
.pItem
= new SvtExtendedSecurityOptions();
179 // no ref count rItem.pItem = new SvtFilterOptions();
183 rItem
.pItem
= new SvtFontOptions();
186 case E_HISTORYOPTIONS
:
187 rItem
.pItem
= new SvtHistoryOptions();
190 case E_INTERNALOPTIONS
:
191 rItem
.pItem
= new SvtInternalOptions();
195 // no ref count rItem.pItem = new SvtJavaOptions();
199 rItem
.pItem
= new SvtLinguConfig();
202 case E_LOCALISATIONOPTIONS
:
203 rItem
.pItem
= new SvtLocalisationOptions();
206 case E_MODULEOPTIONS
:
207 rItem
.pItem
= new SvtModuleOptions();
210 case E_OPTIONSDLGOPTIONS
:
211 rItem
.pItem
= new SvtOptionsDialogOptions();
215 rItem
.pItem
= new SvtPathOptions();
218 case E_PRINTWARNINGOPTIONS
:
219 rItem
.pItem
= new SvtPrintWarningOptions();
223 rItem
.pItem
= new ::utl::MiscCfg();
227 rItem
.pItem
= new SvtSaveOptions();
231 // no ref count rItem.pItem = new SvtSearchOptions();
234 case E_SECURITYOPTIONS
:
235 rItem
.pItem
= new SvtSecurityOptions();
238 case E_VIEWOPTIONS_DIALOG
:
239 rItem
.pItem
= new SvtViewOptions(E_DIALOG
, ::rtl::OUString());
242 case E_VIEWOPTIONS_TABDIALOG
:
243 rItem
.pItem
= new SvtViewOptions(E_TABDIALOG
, ::rtl::OUString());
246 case E_VIEWOPTIONS_TABPAGE
:
247 rItem
.pItem
= new SvtViewOptions(E_TABPAGE
, ::rtl::OUString());
250 case E_VIEWOPTIONS_WINDOW
:
251 rItem
.pItem
= new SvtViewOptions(E_WINDOW
, ::rtl::OUString());
254 case E_WORKINGSETOPTIONS
:
255 rItem
.pItem
= new SvtWorkingSetOptions();
263 rItem
.pItem
= new SvtUserOptions();
266 case E_SYSLOCALEOPTIONS
:
267 rItem
.pItem
= new SvtSysLocaleOptions();
271 OSL_FAIL( "unknown item type" );
276 //-----------------------------------------------
277 void ItemHolder1::impl_deleteItem(TItemInfo
& rItem
)
286 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */