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: itemholder2.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 #ifdef SVL_DLLIMPLEMENTATION
35 #undef SVL_DLLIMPLEMENTATION
37 #define SVT_DLLIMPLEMENTATION
39 #include "itemholder2.hxx"
41 //-----------------------------------------------
43 #include <comphelper/processfactory.hxx>
44 #include <com/sun/star/lang/XComponent.hpp>
46 #include <svtools/accessibilityoptions.hxx>
47 #include <apearcfg.hxx>
48 #include <svtools/cjkoptions.hxx>
49 #include <svtools/colorcfg.hxx>
50 #include <svtools/ctloptions.hxx>
51 #include <fontsubstconfig.hxx>
52 #include <svtools/helpopt.hxx>
53 #include <svtools/languageoptions.hxx>
54 #include <misccfg.hxx>
55 #include <svtools/printoptions.hxx>
56 #include <svtools/syslocaleoptions.hxx>
57 #include <svtools/undoopt.hxx>
58 #include <svtools/useroptions.hxx>
59 #include <svtools/options.hxx>
60 #include <svtools/miscopt.hxx>
63 #include <tools/debug.hxx>
65 //-----------------------------------------------
68 namespace css
= ::com::sun::star
;
70 //-----------------------------------------------
73 //-----------------------------------------------
74 ItemHolder2::ItemHolder2()
75 : ItemHolderMutexBase()
79 css::uno::Reference
< css::lang::XMultiServiceFactory
> xSMGR
= ::comphelper::getProcessServiceFactory();
80 css::uno::Reference
< css::lang::XComponent
> xCfg(
81 xSMGR
->createInstance(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
84 xCfg
->addEventListener(static_cast< css::lang::XEventListener
* >(this));
86 // #i37892 got errorhandling from ConfigManager::GetConfigurationProvider()
87 catch(css::uno::RuntimeException
& rREx
)
92 catch(css::uno::Exception
& rEx
)
94 static sal_Bool bMessage
= sal_True
;
98 ::rtl::OString
sMsg("CreateInstance with arguments exception: ");
99 sMsg
+= ::rtl::OString(rEx
.Message
.getStr(),
100 rEx
.Message
.getLength(),
101 RTL_TEXTENCODING_ASCII_US
);
102 DBG_ERROR(sMsg
.getStr());
106 catch(css::uno::Exception
&){}
110 //-----------------------------------------------
111 ItemHolder2::~ItemHolder2()
113 impl_releaseAllItems();
116 //-----------------------------------------------
117 void ItemHolder2::holdConfigItem(EItem eItem
)
119 static ItemHolder2
* pHolder
= new ItemHolder2();
120 pHolder
->impl_addItem(eItem
);
123 //-----------------------------------------------
124 void SAL_CALL
ItemHolder2::disposing(const css::lang::EventObject
&)
125 throw(css::uno::RuntimeException
)
127 impl_releaseAllItems();
130 //-----------------------------------------------
131 void ItemHolder2::impl_addItem(EItem eItem
)
133 ::osl::ResettableMutexGuard
aLock(m_aLock
);
135 TItems::const_iterator pIt
;
136 for ( pIt
= m_lItems
.begin();
137 pIt
!= m_lItems
.end() ;
140 const TItemInfo
& rInfo
= *pIt
;
141 if (rInfo
.eItem
== eItem
)
146 aNewItem
.eItem
= eItem
;
147 impl_newItem(aNewItem
);
149 m_lItems
.push_back(aNewItem
);
152 //-----------------------------------------------
153 void ItemHolder2::impl_releaseAllItems()
155 ::osl::ResettableMutexGuard
aLock(m_aLock
);
157 TItems::iterator pIt
;
158 for ( pIt
= m_lItems
.begin();
159 pIt
!= m_lItems
.end() ;
162 TItemInfo
& rInfo
= *pIt
;
163 impl_deleteItem(rInfo
);
168 //-----------------------------------------------
169 void ItemHolder2::impl_newItem(TItemInfo
& rItem
)
173 case E_ACCESSIBILITYOPTIONS
:
174 rItem
.pItem
= new SvtAccessibilityOptions();
178 // no ref count rItem.pItem = new SvtTabAppearanceCfg();
182 rItem
.pItem
= new SvtCJKOptions();
186 rItem
.pItem
= new ::svtools::ColorConfig();
190 rItem
.pItem
= new SvtCTLOptions();
193 case E_FONTSUBSTCONFIG
:
194 // no ref count rItem.pItem = new SvtFontSubstConfig();
198 rItem
.pItem
= new SvtHelpOptions();
201 case E_LANGUAGEOPTIONS
:
202 // capsulate CTL and CJL options ! rItem.pItem = new SvtLanguageOptions();
206 // no ref count rItem.pItem = new SfxMiscCfg();
209 case E_PRINTOPTIONS
:
210 rItem
.pItem
= new SvtPrinterOptions();
213 case E_PRINTFILEOPTIONS
:
214 rItem
.pItem
= new SvtPrintFileOptions();
217 case E_SYSLOCALEOPTIONS
:
218 rItem
.pItem
= new SvtSysLocaleOptions();
222 rItem
.pItem
= new SvtUndoOptions();
226 rItem
.pItem
= new SvtUserOptions();
229 rItem
.pItem
= new SvtMiscOptions();
238 //-----------------------------------------------
239 void ItemHolder2::impl_deleteItem(TItemInfo
& rItem
)