xref: /AOO41X/main/svl/qa/complex/ConfigItems/helper/HistoryOptTest.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include "HistoryOptTest.hxx"
29*cdf0e10cSrcweir #include <unotools/historyoptions_const.hxx>
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
32*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx>
38*cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx>
39*cdf0e10cSrcweir #include <unotools/processfactory.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir namespace css = ::com::sun::star;
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir //=============================================================================
44*cdf0e10cSrcweir static const ::rtl::OUString MESSAGE_CLEAR_FAILED       = ::rtl::OUString::createFromAscii("Clearing the list failed.");
45*cdf0e10cSrcweir static const ::rtl::OUString MESSAGE_SETSIZE_FAILED     = ::rtl::OUString::createFromAscii("Setting a new size for a list failed.");
46*cdf0e10cSrcweir static const ::rtl::OUString MESSAGE_MISS_HISTORY       = ::rtl::OUString::createFromAscii("Could not get config access to history list inside config.");
47*cdf0e10cSrcweir static const ::rtl::OUString MESSAGE_MISS_ITEMLIST      = ::rtl::OUString::createFromAscii("Could not get config access to item list inside config.");
48*cdf0e10cSrcweir static const ::rtl::OUString MESSAGE_MISS_ORDERLIST     = ::rtl::OUString::createFromAscii("Could not get config access to order list inside config.");
49*cdf0e10cSrcweir static const ::rtl::OUString MESSAGE_MISS_ITEM          = ::rtl::OUString::createFromAscii("Could not locate item.");
50*cdf0e10cSrcweir static const ::rtl::OUString MESSAGE_UNEXPECTED_ITEM    = ::rtl::OUString::createFromAscii("Found an unexpected item.");
51*cdf0e10cSrcweir static const ::rtl::OUString MESSAGE_WRONG_ORDER        = ::rtl::OUString::createFromAscii("Wrong order in history list.");
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir //=============================================================================
54*cdf0e10cSrcweir HistoryOptTest::HistoryOptTest()
55*cdf0e10cSrcweir     : m_aConfigItem  (         )
56*cdf0e10cSrcweir     , m_eList        (ePICKLIST)
57*cdf0e10cSrcweir     , m_xHistoriesXCU(         )
58*cdf0e10cSrcweir     , m_xCommonXCU   (         )
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir }
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir //=============================================================================
63*cdf0e10cSrcweir HistoryOptTest::~HistoryOptTest()
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir     m_xHistoriesXCU.clear();
66*cdf0e10cSrcweir     m_xCommonXCU.clear();
67*cdf0e10cSrcweir }
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir //=============================================================================
70*cdf0e10cSrcweir void HistoryOptTest::checkPicklist()
71*cdf0e10cSrcweir {
72*cdf0e10cSrcweir     impl_testHistory(ePICKLIST, 4);
73*cdf0e10cSrcweir }
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir //=============================================================================
76*cdf0e10cSrcweir void HistoryOptTest::checkURLHistory()
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir     impl_testHistory(eHISTORY, 10);
79*cdf0e10cSrcweir }
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir //=============================================================================
82*cdf0e10cSrcweir void HistoryOptTest::checkHelpBookmarks()
83*cdf0e10cSrcweir {
84*cdf0e10cSrcweir     impl_testHistory(eHELPBOOKMARKS, 100);
85*cdf0e10cSrcweir }
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir //=============================================================================
88*cdf0e10cSrcweir void HistoryOptTest::impl_testHistory(EHistoryType eHistory ,
89*cdf0e10cSrcweir                                       ::sal_Int32  nMaxItems)
90*cdf0e10cSrcweir {
91*cdf0e10cSrcweir 	try
92*cdf0e10cSrcweir 	{
93*cdf0e10cSrcweir 		m_eList       = eHistory;
94*cdf0e10cSrcweir 		::sal_Int32 c = nMaxItems;
95*cdf0e10cSrcweir 		::sal_Int32 i = 0;
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 		impl_clearList( );
98*cdf0e10cSrcweir 		impl_setSize  (c);
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 		// a) fill list completely and check if all items could be realy created.
101*cdf0e10cSrcweir 		//    But dont check its order here! Because every new item will change that order.
102*cdf0e10cSrcweir 		for (i=0; i<c; ++i)
103*cdf0e10cSrcweir 		{
104*cdf0e10cSrcweir 			impl_appendItem(i);
105*cdf0e10cSrcweir 			if ( ! impl_existsItem(i))
106*cdf0e10cSrcweir 				throw css::uno::Exception(MESSAGE_MISS_ITEM, 0);
107*cdf0e10cSrcweir 		}
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 		// b) Check order of all items in list now.
110*cdf0e10cSrcweir 		//    It must be reverse to the item number ...
111*cdf0e10cSrcweir 		//      item max   = index 0
112*cdf0e10cSrcweir 		//      item max-1 = index 1
113*cdf0e10cSrcweir 		//      ...
114*cdf0e10cSrcweir 		for (i=0; i<c; ++i)
115*cdf0e10cSrcweir 		{
116*cdf0e10cSrcweir 			::sal_Int32 nExpectedIndex = (c-1)-i;
117*cdf0e10cSrcweir 			if ( ! impl_existsItemAtIndex(i, nExpectedIndex))
118*cdf0e10cSrcweir 				throw css::uno::Exception(MESSAGE_WRONG_ORDER, 0);
119*cdf0e10cSrcweir 		}
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 		// c) increase prio of "first" item so it will switch
122*cdf0e10cSrcweir 		//    to "second" and "second" will switch to "first" :-)
123*cdf0e10cSrcweir 		//    Check also if all other items was not touched.
124*cdf0e10cSrcweir 		::sal_Int32 nFirstItem  = (c-1);
125*cdf0e10cSrcweir 		::sal_Int32 nSecondItem = (c-2);
126*cdf0e10cSrcweir 		impl_appendItem(nSecondItem);
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 		if (
129*cdf0e10cSrcweir 			( ! impl_existsItemAtIndex(nSecondItem, 0)) ||
130*cdf0e10cSrcweir 			( ! impl_existsItemAtIndex(nFirstItem , 1))
131*cdf0e10cSrcweir 		   )
132*cdf0e10cSrcweir 			throw css::uno::Exception(MESSAGE_WRONG_ORDER, 0);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 		for (i=0; i<nSecondItem; ++i)
135*cdf0e10cSrcweir 		{
136*cdf0e10cSrcweir 			::sal_Int32 nExpectedIndex = (c-1)-i;
137*cdf0e10cSrcweir 			if ( ! impl_existsItemAtIndex(i, nExpectedIndex))
138*cdf0e10cSrcweir 				throw css::uno::Exception(MESSAGE_WRONG_ORDER, 0);
139*cdf0e10cSrcweir 		}
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 		// d) Check if appending new items will destroy the oldest one.
142*cdf0e10cSrcweir 		::sal_Int32 nNewestItem = c;
143*cdf0e10cSrcweir 		::sal_Int32 nOldestItem = 0;
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 		impl_appendItem(nNewestItem);
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 		if ( ! impl_existsItemAtIndex(nNewestItem, 0))
148*cdf0e10cSrcweir 			throw css::uno::Exception(MESSAGE_WRONG_ORDER, 0);
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 		if (impl_existsItem(nOldestItem))
151*cdf0e10cSrcweir 			throw css::uno::Exception(MESSAGE_UNEXPECTED_ITEM, 0);
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 		// e) Check if decreasing list size will remove oldest items.
154*cdf0e10cSrcweir 		//    Note: impl_setSize() will make sure that 3 items exists only.
155*cdf0e10cSrcweir 		//    Otherwhise it throws an exception. If we further check
156*cdf0e10cSrcweir 		//    positions of three items no further items must be checked.
157*cdf0e10cSrcweir 		//    They cant exists :-)
158*cdf0e10cSrcweir 		::sal_Int32 nNewSize = 3;
159*cdf0e10cSrcweir 		impl_setSize(nNewSize);
160*cdf0e10cSrcweir 		if (
161*cdf0e10cSrcweir 			( ! impl_existsItemAtIndex(nNewestItem, 0)) ||
162*cdf0e10cSrcweir 			( ! impl_existsItemAtIndex(nSecondItem, 1)) ||
163*cdf0e10cSrcweir 			( ! impl_existsItemAtIndex(nFirstItem , 2))
164*cdf0e10cSrcweir 		   )
165*cdf0e10cSrcweir 			throw css::uno::Exception(MESSAGE_WRONG_ORDER, 0);
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 		// finaly we should try to clean up all used structures so the same office can be used
168*cdf0e10cSrcweir 		// without problems :-)
169*cdf0e10cSrcweir 		impl_clearList();
170*cdf0e10cSrcweir 	}
171*cdf0e10cSrcweir 	catch (const css::uno::Exception& ex)
172*cdf0e10cSrcweir 	{
173*cdf0e10cSrcweir 		impl_clearList();
174*cdf0e10cSrcweir 		throw ex;
175*cdf0e10cSrcweir 	}
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir //=============================================================================
180*cdf0e10cSrcweir void HistoryOptTest::impl_clearList()
181*cdf0e10cSrcweir {
182*cdf0e10cSrcweir     m_aConfigItem.Clear(m_eList);
183*cdf0e10cSrcweir     ::sal_Int32 nCount = m_aConfigItem.GetList(m_eList).getLength();
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     if (nCount != 0)
186*cdf0e10cSrcweir         throw css::uno::Exception(MESSAGE_CLEAR_FAILED, 0);
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > xList;
189*cdf0e10cSrcweir     xList  = impl_getItemList();
190*cdf0e10cSrcweir     nCount = xList->getElementNames().getLength();
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir     if (nCount != 0)
193*cdf0e10cSrcweir         throw css::uno::Exception(MESSAGE_CLEAR_FAILED, 0);
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir     xList  = impl_getOrderList();
196*cdf0e10cSrcweir     nCount = xList->getElementNames().getLength();
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     if (nCount != 0)
199*cdf0e10cSrcweir         throw css::uno::Exception(MESSAGE_CLEAR_FAILED, 0);
200*cdf0e10cSrcweir }
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir //=============================================================================
203*cdf0e10cSrcweir void HistoryOptTest::impl_setSize(::sal_Int32 nSize)
204*cdf0e10cSrcweir {
205*cdf0e10cSrcweir     m_aConfigItem.SetSize (m_eList, nSize);
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 	// a) size info returned by GetSize() means "MaxSize"
208*cdf0e10cSrcweir 	//    so it must match exactly !
209*cdf0e10cSrcweir     ::sal_Int32 nCheck = m_aConfigItem.GetSize(m_eList);
210*cdf0e10cSrcweir     if (nCheck != nSize)
211*cdf0e10cSrcweir         throw css::uno::Exception(MESSAGE_SETSIZE_FAILED, 0);
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 	// b) current size of used XCU lists reflects the current state of
214*cdf0e10cSrcweir 	//    history list and not max size. So it can be less then size !
215*cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > xList;
216*cdf0e10cSrcweir     xList  = impl_getItemList();
217*cdf0e10cSrcweir     nCheck = xList->getElementNames().getLength();
218*cdf0e10cSrcweir     if (nCheck > nSize)
219*cdf0e10cSrcweir         throw css::uno::Exception(MESSAGE_SETSIZE_FAILED, 0);
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir     xList  = impl_getOrderList();
222*cdf0e10cSrcweir     nCheck = xList->getElementNames().getLength();
223*cdf0e10cSrcweir     if (nCheck > nSize)
224*cdf0e10cSrcweir         throw css::uno::Exception(MESSAGE_SETSIZE_FAILED, 0);
225*cdf0e10cSrcweir }
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir //=============================================================================
228*cdf0e10cSrcweir void HistoryOptTest::impl_appendItem(::sal_Int32 nItem)
229*cdf0e10cSrcweir {
230*cdf0e10cSrcweir     const ::rtl::OUString sURL      = impl_createItemURL     (nItem);
231*cdf0e10cSrcweir     const ::rtl::OUString sTitle    = impl_createItemTitle   (nItem);
232*cdf0e10cSrcweir     const ::rtl::OUString sPassword = impl_createItemPassword(nItem);
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir     m_aConfigItem.AppendItem(m_eList, sURL, ::rtl::OUString(), sTitle, sPassword);
235*cdf0e10cSrcweir }
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir //=============================================================================
238*cdf0e10cSrcweir ::rtl::OUString HistoryOptTest::impl_createItemURL(::sal_Int32 nItem)
239*cdf0e10cSrcweir {
240*cdf0e10cSrcweir     ::rtl::OUStringBuffer sURL(256);
241*cdf0e10cSrcweir     sURL.appendAscii("file:///ooo_api_test/non_existing_test_url_");
242*cdf0e10cSrcweir     sURL.append     ((::sal_Int32)nItem  );
243*cdf0e10cSrcweir     sURL.appendAscii(".odt"              );
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir     return sURL.makeStringAndClear();
246*cdf0e10cSrcweir }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir //=============================================================================
249*cdf0e10cSrcweir ::rtl::OUString HistoryOptTest::impl_createItemTitle(::sal_Int32 nItem)
250*cdf0e10cSrcweir {
251*cdf0e10cSrcweir     ::rtl::OUStringBuffer sTitle(256);
252*cdf0e10cSrcweir     sTitle.appendAscii("Non Existing Test Item Nr ");
253*cdf0e10cSrcweir     sTitle.append     ((::sal_Int32)nItem          );
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     return sTitle.makeStringAndClear();
256*cdf0e10cSrcweir }
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir //=============================================================================
259*cdf0e10cSrcweir ::rtl::OUString HistoryOptTest::impl_createItemPassword(::sal_Int32 nItem)
260*cdf0e10cSrcweir {
261*cdf0e10cSrcweir     ::rtl::OUStringBuffer sPassword(256);
262*cdf0e10cSrcweir     sPassword.appendAscii("Password_"       );
263*cdf0e10cSrcweir     sPassword.append     ((::sal_Int32)nItem);
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir     return sPassword.makeStringAndClear();
266*cdf0e10cSrcweir }
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir //=============================================================================
269*cdf0e10cSrcweir ::sal_Bool HistoryOptTest::impl_existsItem(::sal_Int32 nItem)
270*cdf0e10cSrcweir {
271*cdf0e10cSrcweir     const ::rtl::OUString                                                       sURL     = impl_createItemURL(nItem);
272*cdf0e10cSrcweir     const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > lItems   = m_aConfigItem.GetList(m_eList);
273*cdf0e10cSrcweir     const ::sal_Int32                                                           c        = lItems.getLength ();
274*cdf0e10cSrcweir           ::sal_Int32                                                           i        = 0;
275*cdf0e10cSrcweir           ::sal_Bool                                                            bFound   = sal_False;
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir     for (i=0; i<c; ++i)
278*cdf0e10cSrcweir     {
279*cdf0e10cSrcweir         const ::comphelper::SequenceAsHashMap aItem(lItems[i]);
280*cdf0e10cSrcweir         const ::rtl::OUString&                sCheck = aItem.getUnpackedValueOrDefault(s_sURL, ::rtl::OUString());
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir         bFound = sCheck.equals(sURL);
283*cdf0e10cSrcweir         if (bFound)
284*cdf0e10cSrcweir             break;
285*cdf0e10cSrcweir     }
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir     if ( ! bFound)
288*cdf0e10cSrcweir         return sal_False;
289*cdf0e10cSrcweir     bFound = sal_False;
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir     try
292*cdf0e10cSrcweir     {
293*cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > xItemList = impl_getItemList();
294*cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > xItem     ;
295*cdf0e10cSrcweir         xItemList->getByName(sURL) >>= xItem;
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir         bFound = xItem.is();
298*cdf0e10cSrcweir     }
299*cdf0e10cSrcweir     catch(const css::container::NoSuchElementException&)
300*cdf0e10cSrcweir         {}
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir     return bFound;
303*cdf0e10cSrcweir }
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir //=============================================================================
306*cdf0e10cSrcweir ::sal_Bool HistoryOptTest::impl_existsItemAtIndex(::sal_Int32 nItem ,
307*cdf0e10cSrcweir                                                   ::sal_Int32 nIndex)
308*cdf0e10cSrcweir {
309*cdf0e10cSrcweir     const ::rtl::OUString                                                       sURL     = impl_createItemURL(nItem);
310*cdf0e10cSrcweir     const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > lItems   = m_aConfigItem.GetList(m_eList);
311*cdf0e10cSrcweir     const ::sal_Int32                                                           c        = lItems.getLength ();
312*cdf0e10cSrcweir           ::sal_Bool                                                            bFound   = sal_False;
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir     if (nIndex >= c)
315*cdf0e10cSrcweir         return sal_False;
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir     const ::comphelper::SequenceAsHashMap aItem(lItems[nIndex]);
318*cdf0e10cSrcweir           ::rtl::OUString                 sCheck = aItem.getUnpackedValueOrDefault(s_sURL, ::rtl::OUString());
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir     bFound = sCheck.equals(sURL);
321*cdf0e10cSrcweir     if ( ! bFound)
322*cdf0e10cSrcweir         return sal_False;
323*cdf0e10cSrcweir     bFound = sal_False;
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir     try
326*cdf0e10cSrcweir     {
327*cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > xItemList = impl_getItemList();
328*cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > xItem     ;
329*cdf0e10cSrcweir         xItemList->getByName(sURL) >>= xItem;
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir         bFound = xItem.is();
332*cdf0e10cSrcweir     }
333*cdf0e10cSrcweir     catch(const css::container::NoSuchElementException&)
334*cdf0e10cSrcweir         {}
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir     if ( ! bFound)
337*cdf0e10cSrcweir         return sal_False;
338*cdf0e10cSrcweir     bFound = sal_False;
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir     try
341*cdf0e10cSrcweir     {
342*cdf0e10cSrcweir         const ::rtl::OUString                              sOrder     = ::rtl::OUString::valueOf(nIndex);
343*cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > xOrderList = impl_getOrderList();
344*cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > xOrder     ;
345*cdf0e10cSrcweir         xOrderList->getByName(sOrder) >>= xOrder;
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir         if (xOrder.is())
348*cdf0e10cSrcweir         {
349*cdf0e10cSrcweir             xOrder->getByName(s_sHistoryItemRef) >>= sCheck;
350*cdf0e10cSrcweir             bFound = sCheck.equals(sURL);
351*cdf0e10cSrcweir         }
352*cdf0e10cSrcweir     }
353*cdf0e10cSrcweir     catch(const css::container::NoSuchElementException&)
354*cdf0e10cSrcweir         {}
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir     return bFound;
357*cdf0e10cSrcweir }
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir //=============================================================================
360*cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > HistoryOptTest::impl_getItemList()
361*cdf0e10cSrcweir {
362*cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > xHistory = impl_getNewHistory();
363*cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > xList    ;
364*cdf0e10cSrcweir     xHistory->getByName (s_sItemList) >>= xList;
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir     if ( ! xList.is())
367*cdf0e10cSrcweir         throw css::uno::Exception(MESSAGE_MISS_ITEMLIST, 0);
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir     return xList;
370*cdf0e10cSrcweir }
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir //=============================================================================
373*cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > HistoryOptTest::impl_getOrderList()
374*cdf0e10cSrcweir {
375*cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > xHistory = impl_getNewHistory();
376*cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > xList    ;
377*cdf0e10cSrcweir     xHistory->getByName (s_sOrderList) >>= xList;
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir     if ( ! xList.is())
380*cdf0e10cSrcweir         throw css::uno::Exception(MESSAGE_MISS_ORDERLIST, 0);
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir     return xList;
383*cdf0e10cSrcweir }
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir //=============================================================================
386*cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > HistoryOptTest::impl_getNewHistory()
387*cdf0e10cSrcweir {
388*cdf0e10cSrcweir     if ( ! m_xHistoriesXCU.is())
389*cdf0e10cSrcweir     {
390*cdf0e10cSrcweir         m_xHistoriesXCU = css::uno::Reference< css::container::XNameAccess >(
391*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::openConfig(
392*cdf0e10cSrcweir             ::utl::getProcessServiceFactory(),
393*cdf0e10cSrcweir             s_sHistories,
394*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::E_STANDARD),
395*cdf0e10cSrcweir             css::uno::UNO_QUERY_THROW);
396*cdf0e10cSrcweir     }
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > xHistory;
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir     switch (m_eList)
401*cdf0e10cSrcweir     {
402*cdf0e10cSrcweir         case ePICKLIST :
403*cdf0e10cSrcweir                 m_xHistoriesXCU->getByName(s_sPickList) >>= xHistory;
404*cdf0e10cSrcweir                 break;
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir         case eHISTORY :
407*cdf0e10cSrcweir                 m_xHistoriesXCU->getByName(s_sURLHistory) >>= xHistory;
408*cdf0e10cSrcweir                 break;
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir         case eHELPBOOKMARKS :
411*cdf0e10cSrcweir                 m_xHistoriesXCU->getByName(s_sHelpBookmarks) >>= xHistory;
412*cdf0e10cSrcweir                 break;
413*cdf0e10cSrcweir     }
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir     if ( ! xHistory.is())
416*cdf0e10cSrcweir         throw css::uno::Exception(MESSAGE_MISS_HISTORY, 0);
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir     return xHistory;
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir //=============================================================================
422*cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > HistoryOptTest::impl_getOldHistory()
423*cdf0e10cSrcweir {
424*cdf0e10cSrcweir     if ( ! m_xCommonXCU.is())
425*cdf0e10cSrcweir     {
426*cdf0e10cSrcweir         m_xCommonXCU = css::uno::Reference< css::container::XNameAccess >(
427*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::openConfig(
428*cdf0e10cSrcweir             ::utl::getProcessServiceFactory(),
429*cdf0e10cSrcweir             s_sCommonHistory,
430*cdf0e10cSrcweir             ::comphelper::ConfigurationHelper::E_STANDARD),
431*cdf0e10cSrcweir             css::uno::UNO_QUERY_THROW);
432*cdf0e10cSrcweir     }
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir     css::uno::Reference< css::container::XNameAccess > xHistory;
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir     switch (m_eList)
437*cdf0e10cSrcweir     {
438*cdf0e10cSrcweir         case ePICKLIST :
439*cdf0e10cSrcweir                 m_xCommonXCU->getByName(s_sPickList) >>= xHistory;
440*cdf0e10cSrcweir                 break;
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir         case eHISTORY :
443*cdf0e10cSrcweir                 m_xCommonXCU->getByName(s_sURLHistory) >>= xHistory;
444*cdf0e10cSrcweir                 break;
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir         case eHELPBOOKMARKS :
447*cdf0e10cSrcweir                 m_xCommonXCU->getByName(s_sHelpBookmarks) >>= xHistory;
448*cdf0e10cSrcweir                 break;
449*cdf0e10cSrcweir     }
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir     if ( ! xHistory.is())
452*cdf0e10cSrcweir         throw css::uno::Exception(MESSAGE_MISS_HISTORY, 0);
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir     return xHistory;
455*cdf0e10cSrcweir }
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir /*
458*cdf0e10cSrcweir //=============================================================================
459*cdf0e10cSrcweir // clear the list in XML directly when using the new Histories.xcs
460*cdf0e10cSrcweir void HistoryOptTest::impl_clearList(const ::rtl::OUString& sList)
461*cdf0e10cSrcweir {
462*cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameAccess >    xListAccess;
463*cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameContainer > xItemOrder;
464*cdf0e10cSrcweir 	css::uno::Reference< css::beans::XPropertySet >       xFirstItem;
465*cdf0e10cSrcweir 	css::uno::Sequence< ::rtl::OUString >                 sFileList;
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir 	if (sList.equalsAscii("PickList"))
468*cdf0e10cSrcweir 		m_xCfg->getByName(s_sPickList) >>= xListAccess;
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir 	else if (sList.equalsAscii("URLHistory"))
471*cdf0e10cSrcweir 		m_xCfg->getByName(s_sURLHistory) >>= xListAccess;
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir 	else if (sList.equalsAscii("HelpBookmarks"))
474*cdf0e10cSrcweir 		m_xCfg->getByName(s_sHelpBookmarks) >>= xListAccess;
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir 	if (xListAccess.is())
477*cdf0e10cSrcweir 	{
478*cdf0e10cSrcweir 		xListAccess->getByName(s_sItemList)  >>= xItemOrder  ;
479*cdf0e10cSrcweir 		sFileList = xItemOrder->getElementNames();
480*cdf0e10cSrcweir 		for(sal_Int32 i=0; i<sFileList.getLength(); ++i)
481*cdf0e10cSrcweir 			xItemOrder->removeByName(sFileList[i]);
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir 		xListAccess->getByName(s_sOrderList) >>= xItemOrder ;
484*cdf0e10cSrcweir 		sFileList = xItemOrder->getElementNames();
485*cdf0e10cSrcweir 		for(sal_Int32 j=0; j<sFileList.getLength(); ++j)
486*cdf0e10cSrcweir 			xItemOrder->removeByName(sFileList[j]);
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir 		xFirstItem = css::uno::Reference< css::beans::XPropertySet >(xListAccess, css::uno::UNO_QUERY);
489*cdf0e10cSrcweir 		xFirstItem->setPropertyValue( s_sFirstItem, css::uno::makeAny((sal_Int32)0) );
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir 		::comphelper::ConfigurationHelper::flush(m_xCfg);
492*cdf0e10cSrcweir 	}
493*cdf0e10cSrcweir }
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir //=============================================================================
496*cdf0e10cSrcweir // use configuration API (not ConfigItem!) to verify the results within XML !
497*cdf0e10cSrcweir sal_Bool HistoryOptTest::impl_isListEmpty(const ::rtl::OUString& sList)
498*cdf0e10cSrcweir {
499*cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameAccess > xListAccess;
500*cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameAccess > xItemList;
501*cdf0e10cSrcweir 	css::uno::Reference< css::container::XNameAccess > xOrderList;
502*cdf0e10cSrcweir 	sal_Bool bRet = sal_True;
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir 	if (sList.equalsAscii("PickList"))
505*cdf0e10cSrcweir 		m_xCfg->getByName(s_sPickList) >>= xListAccess;
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir 	else if (sList.equalsAscii("URLHistory"))
508*cdf0e10cSrcweir 		m_xCfg->getByName(s_sURLHistory) >>= xListAccess;
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir 	else if (sList.equalsAscii("HelpBookmarks"))
511*cdf0e10cSrcweir 		m_xCfg->getByName(s_sHelpBookmarks) >>= xListAccess;
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir 	if (xListAccess.is())
514*cdf0e10cSrcweir 	{
515*cdf0e10cSrcweir 		xListAccess->getByName(s_sItemList)  >>= xItemList;
516*cdf0e10cSrcweir 		xListAccess->getByName(s_sOrderList) >>= xOrderList;
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir 		css::uno::Sequence< ::rtl::OUString > sItemList  = xItemList->getElementNames();
519*cdf0e10cSrcweir 		css::uno::Sequence< ::rtl::OUString > sOrderList = xOrderList->getElementNames();
520*cdf0e10cSrcweir 		if (sItemList.getLength()!=0 || sOrderList.getLength()!=0)
521*cdf0e10cSrcweir 			bRet = sal_False;
522*cdf0e10cSrcweir 	}
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir 	return bRet;
525*cdf0e10cSrcweir }
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir //=============================================================================
528*cdf0e10cSrcweir // append a item: use configuration API (not ConfigItem!) to verify the results within XML !
529*cdf0e10cSrcweir void HistoryOptTest::impl_appendItem(const ::rtl::OUString& sList)
530*cdf0e10cSrcweir {//to do...
531*cdf0e10cSrcweir }
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir //=============================================================================
534*cdf0e10cSrcweir // test SvtHistoryOptions::GetSize()
535*cdf0e10cSrcweir void HistoryOptTest::impl_checkGetSize(const ::rtl::OUString& sList)
536*cdf0e10cSrcweir {
537*cdf0e10cSrcweir 	css::uno::Reference< css::beans::XPropertySet > xSet(m_xCommonXCU, css::uno::UNO_QUERY);
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir 	sal_uInt32 nSize  = 0;
540*cdf0e10cSrcweir 	sal_uInt32 nSize_ = 0;
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 	if (sList.equalsAscii("PickList"))
543*cdf0e10cSrcweir 	{
544*cdf0e10cSrcweir 		nSize  = aHistoryOpt.GetSize(ePICKLIST);
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir 		xSet->setPropertyValue(s_sPickListSize, css::uno::makeAny(nSize+1));
547*cdf0e10cSrcweir 		::comphelper::ConfigurationHelper::flush(m_xCommonXCU);
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir 		nSize_ = aHistoryOpt.GetSize(ePICKLIST);
550*cdf0e10cSrcweir 		if (nSize_ == nSize)
551*cdf0e10cSrcweir 			throw css::uno::RuntimeException(
552*cdf0e10cSrcweir 			::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetSize(ePICKLIST) error!")), 0);
553*cdf0e10cSrcweir 	}
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir 	else if (sList.equalsAscii("URLHistory"))
556*cdf0e10cSrcweir 	{
557*cdf0e10cSrcweir 		nSize  = aHistoryOpt.GetSize(eHISTORY);
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir 		xSet->setPropertyValue(s_sURLHistorySize, css::uno::makeAny(nSize+1));
560*cdf0e10cSrcweir 		::comphelper::ConfigurationHelper::flush(m_xCommonXCU);
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir 		nSize_ = aHistoryOpt.GetSize(eHISTORY);
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir 		if (nSize_ == nSize)
565*cdf0e10cSrcweir 			throw css::uno::RuntimeException(
566*cdf0e10cSrcweir 			::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetSize(eHISTORY) error!")), 0);
567*cdf0e10cSrcweir 	}
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir 	else if (sList.equalsAscii("HelpBookmarks"))
570*cdf0e10cSrcweir 	{
571*cdf0e10cSrcweir 		nSize  = aHistoryOpt.GetSize(eHELPBOOKMARKS);
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir 		xSet->setPropertyValue(s_sHelpBookmarksSize, css::uno::makeAny(nSize+1));
574*cdf0e10cSrcweir 		::comphelper::ConfigurationHelper::flush(m_xCommonXCU);
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir 		nSize_ = aHistoryOpt.GetSize(eHELPBOOKMARKS);
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir 		if (nSize_ == nSize)
579*cdf0e10cSrcweir 			throw css::uno::RuntimeException(
580*cdf0e10cSrcweir 			::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetSize(eHELPBOOKMARKS) error!")), 0);
581*cdf0e10cSrcweir 	}
582*cdf0e10cSrcweir }
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir //=============================================================================
585*cdf0e10cSrcweir // test SvtHistoryOptions::SetSize()
586*cdf0e10cSrcweir void HistoryOptTest::impl_checkSetSize(const ::rtl::OUString& sList)
587*cdf0e10cSrcweir {
588*cdf0e10cSrcweir 	css::uno::Reference< css::beans::XPropertySet > xSet(m_xCommonXCU, css::uno::UNO_QUERY);
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir 	sal_uInt32 nSize  = 0;
591*cdf0e10cSrcweir 	sal_uInt32 nSize_ = 0;
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir 	if (sList.equalsAscii("PickList"))
594*cdf0e10cSrcweir 	{
595*cdf0e10cSrcweir 		xSet->getPropertyValue(s_sPickListSize) >>= nSize;
596*cdf0e10cSrcweir 		aHistoryOpt.SetSize(ePICKLIST, (nSize+1));
597*cdf0e10cSrcweir 		xSet->getPropertyValue(s_sPickListSize) >>= nSize_;
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir 		if (nSize_ == nSize) //old config item will throw error
600*cdf0e10cSrcweir 			throw css::uno::RuntimeException(
601*cdf0e10cSrcweir 			::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetSize(ePICKLIST) error!")), 0);
602*cdf0e10cSrcweir 	}
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir 	else if (sList.equalsAscii("URLHistory"))
605*cdf0e10cSrcweir 	{
606*cdf0e10cSrcweir 		xSet->getPropertyValue(s_sURLHistorySize) >>= nSize;
607*cdf0e10cSrcweir 		aHistoryOpt.SetSize(eHISTORY, (nSize+1));
608*cdf0e10cSrcweir 		xSet->getPropertyValue(s_sURLHistorySize) >>= nSize_;
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir 		if (nSize_ == nSize) //old config item will throw error
611*cdf0e10cSrcweir 			throw css::uno::RuntimeException(
612*cdf0e10cSrcweir 			::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetSize(eHISTORY) error!")), 0);
613*cdf0e10cSrcweir 	}
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir 	else if (sList.equalsAscii("HelpBookmarks"))
616*cdf0e10cSrcweir 	{
617*cdf0e10cSrcweir 		xSet->getPropertyValue(s_sHelpBookmarksSize) >>= nSize;
618*cdf0e10cSrcweir 		aHistoryOpt.SetSize(eHELPBOOKMARKS, (nSize+1));
619*cdf0e10cSrcweir 		xSet->getPropertyValue(s_sHelpBookmarksSize) >>= nSize_;
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir 		if (nSize_ == nSize) //old config item will throw error
622*cdf0e10cSrcweir 			throw css::uno::RuntimeException(
623*cdf0e10cSrcweir 			::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SetSize(eHELPBOOKMARKS) error!")), 0);
624*cdf0e10cSrcweir 	}
625*cdf0e10cSrcweir }
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir //=============================================================================
628*cdf0e10cSrcweir // test SvtHistoryOptions::Clear()
629*cdf0e10cSrcweir void HistoryOptTest::impl_checkClear(const ::rtl::OUString& sList)
630*cdf0e10cSrcweir {
631*cdf0e10cSrcweir 	if (sList.equalsAscii("PickList"))
632*cdf0e10cSrcweir 	{
633*cdf0e10cSrcweir 		aHistoryOpt.Clear(ePICKLIST);
634*cdf0e10cSrcweir 		if ( !impl_isListEmpty(s_sPickList) )
635*cdf0e10cSrcweir 			throw css::uno::RuntimeException(
636*cdf0e10cSrcweir 			::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Clear(ePICKLIST) error!")), 0);
637*cdf0e10cSrcweir 	}
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir 	else if (sList.equalsAscii("URLHistory"))
640*cdf0e10cSrcweir 	{
641*cdf0e10cSrcweir 		aHistoryOpt.Clear(eHISTORY);
642*cdf0e10cSrcweir 		if ( !impl_isListEmpty(s_sURLHistory) )
643*cdf0e10cSrcweir 			throw css::uno::RuntimeException(
644*cdf0e10cSrcweir 			::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Clear(eHISTORY) error!")), 0);
645*cdf0e10cSrcweir 	}
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir 	else if (sList.equalsAscii("HelpBookmarks"))
648*cdf0e10cSrcweir 	{
649*cdf0e10cSrcweir 		aHistoryOpt.Clear(eHELPBOOKMARKS);
650*cdf0e10cSrcweir 		if ( !impl_isListEmpty(s_sHelpBookmarks) )
651*cdf0e10cSrcweir 			throw css::uno::RuntimeException(
652*cdf0e10cSrcweir 			::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Clear(eHELPBOOKMARKS) error!")), 0);
653*cdf0e10cSrcweir 	}
654*cdf0e10cSrcweir }
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir //=============================================================================
657*cdf0e10cSrcweir // test SvtHistoryOptions::GetList()
658*cdf0e10cSrcweir void HistoryOptTest::impl_checkGetList(const ::rtl::OUString& sList)
659*cdf0e10cSrcweir {
660*cdf0e10cSrcweir 	if (sList.equalsAscii("PickList"))
661*cdf0e10cSrcweir 	{
662*cdf0e10cSrcweir 		impl_clearList(s_sPickList);
663*cdf0e10cSrcweir 		aHistoryOpt.AppendItem( ePICKLIST  ,
664*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii("file:///c/test1"),
665*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
666*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
667*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii("") );
668*cdf0e10cSrcweir 		css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aHistoryList = aHistoryOpt.GetList( ePICKLIST );
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir 		if ( aHistoryList.getLength()==0 )
671*cdf0e10cSrcweir 			throw css::uno::RuntimeException(
672*cdf0e10cSrcweir 			::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetList(ePICKLIST) error!")), 0);
673*cdf0e10cSrcweir 	}
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir 	else if (sList.equalsAscii("URLHistory"))
676*cdf0e10cSrcweir 	{
677*cdf0e10cSrcweir 		impl_clearList(s_sURLHistory);
678*cdf0e10cSrcweir 		aHistoryOpt.AppendItem( eHISTORY  ,
679*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii("file:///c/test1"),
680*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
681*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
682*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii("") );
683*cdf0e10cSrcweir 		css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aHistoryList = aHistoryOpt.GetList( eHISTORY );
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir 		if ( aHistoryList.getLength()==0 )
686*cdf0e10cSrcweir 			throw css::uno::RuntimeException(
687*cdf0e10cSrcweir 			::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetList(eHISTORY) error!")), 0);
688*cdf0e10cSrcweir 	}
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir 	else if (sList.equalsAscii("HelpBookmarks"))
691*cdf0e10cSrcweir 	{
692*cdf0e10cSrcweir 		impl_clearList(s_sHelpBookmarks);
693*cdf0e10cSrcweir 		aHistoryOpt.AppendItem( eHELPBOOKMARKS  ,
694*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii("file:///c/test1"),
695*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
696*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
697*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii("") );
698*cdf0e10cSrcweir 		css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aHistoryList = aHistoryOpt.GetList( eHELPBOOKMARKS );
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir 		if ( aHistoryList.getLength()==0 )
701*cdf0e10cSrcweir 			throw css::uno::RuntimeException(
702*cdf0e10cSrcweir 			::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GetList(eHELPBOOKMARKS) error!")), 0);
703*cdf0e10cSrcweir 	}
704*cdf0e10cSrcweir }
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir void HistoryOptTest::impl_checkAppendItem(const ::rtl::OUString& sList)
707*cdf0e10cSrcweir {
708*cdf0e10cSrcweir 	if (sList.equalsAscii("PickList"))
709*cdf0e10cSrcweir 	{
710*cdf0e10cSrcweir 		impl_clearList(s_sPickList);
711*cdf0e10cSrcweir 		sal_Int32 nListSize = aHistoryOpt.GetSize(ePICKLIST);
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir 		for (sal_Int32 i=0; i<nListSize; ++i)
714*cdf0e10cSrcweir 			aHistoryOpt.AppendItem( ePICKLIST  ,
715*cdf0e10cSrcweir 			::rtl::OUString::valueOf(i),
716*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
717*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
718*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii("") );
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir 		aHistoryOpt.AppendItem( ePICKLIST  ,
721*cdf0e10cSrcweir 			::rtl::OUString::valueOf(nListSize),
722*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
723*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
724*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii("") );
725*cdf0e10cSrcweir 	}
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir 	else if (sList.equalsAscii("URLHistory"))
728*cdf0e10cSrcweir 	{
729*cdf0e10cSrcweir 		impl_clearList(s_sURLHistory);
730*cdf0e10cSrcweir 		sal_Int32 nListSize = aHistoryOpt.GetSize(eHISTORY);
731*cdf0e10cSrcweir 
732*cdf0e10cSrcweir 		for (sal_Int32 i=0; i<nListSize; ++i)
733*cdf0e10cSrcweir 			aHistoryOpt.AppendItem( eHISTORY  ,
734*cdf0e10cSrcweir 			::rtl::OUString::valueOf(i),
735*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
736*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
737*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii("") );
738*cdf0e10cSrcweir 
739*cdf0e10cSrcweir 		aHistoryOpt.AppendItem( eHISTORY  ,
740*cdf0e10cSrcweir 			::rtl::OUString::valueOf(nListSize),
741*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
742*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(""),
743*cdf0e10cSrcweir 			::rtl::OUString::createFromAscii("") );
744*cdf0e10cSrcweir 	}
745*cdf0e10cSrcweir 
746*cdf0e10cSrcweir 	else if (sList.equalsAscii("HelpBookmarks"))
747*cdf0e10cSrcweir 	{
748*cdf0e10cSrcweir 		//impl_clearList(s_sHelpBookmarks);
749*cdf0e10cSrcweir 		//sal_Int32 nListSize = aHistoryOpt.GetSize(eHELPBOOKMARKS);
750*cdf0e10cSrcweir 
751*cdf0e10cSrcweir 		//for (sal_Int32 i=0; i<nListSize; ++i)
752*cdf0e10cSrcweir 		//	aHistoryOpt.AppendItem( eHELPBOOKMARKS  ,
753*cdf0e10cSrcweir 		//	::rtl::OUString::valueOf(i),
754*cdf0e10cSrcweir 		//	::rtl::OUString::createFromAscii(""),
755*cdf0e10cSrcweir 		//	::rtl::OUString::createFromAscii(""),
756*cdf0e10cSrcweir 		//	::rtl::OUString::createFromAscii("") );
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir 		//aHistoryOpt.AppendItem( eHELPBOOKMARKS  ,
759*cdf0e10cSrcweir 		//	::rtl::OUString::valueOf(nListSize),
760*cdf0e10cSrcweir 		//	::rtl::OUString::createFromAscii(""),
761*cdf0e10cSrcweir 		//	::rtl::OUString::createFromAscii(""),
762*cdf0e10cSrcweir 		//	::rtl::OUString::createFromAscii("") );
763*cdf0e10cSrcweir 	}
764*cdf0e10cSrcweir }
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir //=============================================================================
767*cdf0e10cSrcweir void HistoryOptTest::impl_checkPicklist()
768*cdf0e10cSrcweir {
769*cdf0e10cSrcweir 	impl_checkGetSize(s_sPickList);
770*cdf0e10cSrcweir 	impl_checkSetSize(s_sPickList);
771*cdf0e10cSrcweir 
772*cdf0e10cSrcweir 	impl_checkClear(s_sPickList);
773*cdf0e10cSrcweir 	impl_checkGetList(s_sPickList);
774*cdf0e10cSrcweir 	impl_checkAppendItem(s_sPickList);
775*cdf0e10cSrcweir }
776*cdf0e10cSrcweir 
777*cdf0e10cSrcweir //=============================================================================
778*cdf0e10cSrcweir void HistoryOptTest::impl_checkURLHistory()
779*cdf0e10cSrcweir {
780*cdf0e10cSrcweir 	impl_checkGetSize(s_sURLHistory);
781*cdf0e10cSrcweir 	impl_checkSetSize(s_sURLHistory);
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir 	impl_checkClear(s_sURLHistory);
784*cdf0e10cSrcweir 	impl_checkGetList(s_sURLHistory);
785*cdf0e10cSrcweir 	impl_checkAppendItem(s_sURLHistory);
786*cdf0e10cSrcweir }
787*cdf0e10cSrcweir 
788*cdf0e10cSrcweir //=============================================================================
789*cdf0e10cSrcweir void HistoryOptTest::impl_checkHelpBookmarks()
790*cdf0e10cSrcweir {
791*cdf0e10cSrcweir 	impl_checkGetSize(s_sHelpBookmarks);
792*cdf0e10cSrcweir 	impl_checkSetSize(s_sHelpBookmarks);
793*cdf0e10cSrcweir 
794*cdf0e10cSrcweir 	impl_checkClear(s_sHelpBookmarks);
795*cdf0e10cSrcweir 	impl_checkGetList(s_sHelpBookmarks);
796*cdf0e10cSrcweir 	impl_checkAppendItem(s_sHelpBookmarks);
797*cdf0e10cSrcweir }
798*cdf0e10cSrcweir */
799