xref: /AOO41X/main/sw/source/ui/utlui/navicfg.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 
32 #include <swtypes.hxx>	// fuer Pathfinder
33 #include <navicfg.hxx>
34 #include <swcont.hxx>
35 #include <tools/debug.hxx>
36 #include <com/sun/star/uno/Any.hxx>
37 #include <com/sun/star/uno/Sequence.hxx>
38 
39 #include <unomid.h>
40 
41 using namespace ::utl;
42 using namespace ::rtl;
43 using namespace ::com::sun::star::uno;
44 
45 /* -----------------------------08.09.00 16:30--------------------------------
46 
47  ---------------------------------------------------------------------------*/
48 Sequence<OUString> SwNavigationConfig::GetPropertyNames()
49 {
50 	static const char* aPropNames[] =
51 	{
52 		"RootType",     		//0
53 		"SelectedPosition",     //1
54 		"OutlineLevel",         //2
55 		"InsertMode",           //3
56 		"ActiveBlock",          //4
57 		"ShowListBox",          //5
58 		"GlobalDocMode"         //6
59 	};
60 	const int nCount = 7;
61 	Sequence<OUString> aNames(nCount);
62 	OUString* pNames = aNames.getArray();
63 	for(int i = 0; i < nCount; i++)
64 	{
65 		pNames[i] = OUString::createFromAscii(aPropNames[i]);
66 	}
67 	return aNames;
68 }
69 /*-----------------13.11.96 11.03-------------------
70 
71 --------------------------------------------------*/
72 
73 SwNavigationConfig::SwNavigationConfig() :
74 	utl::ConfigItem(C2U("Office.Writer/Navigator")),
75     nRootType(0xffff),
76 	nSelectedPos(0),
77 	nOutlineLevel(MAXLEVEL),
78 	nRegionMode(REGION_MODE_NONE),
79     nActiveBlock(0),
80     bIsSmall(sal_False),
81     bIsGlobalActive(sal_True)
82 {
83 	Sequence<OUString> aNames = GetPropertyNames();
84 	Sequence<Any> aValues = GetProperties(aNames);
85 //	EnableNotification(aNames);
86 	const Any* pValues = aValues.getConstArray();
87 	DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
88 	if(aValues.getLength() == aNames.getLength())
89 	{
90 		for(int nProp = 0; nProp < aNames.getLength(); nProp++)
91 		{
92 			if(pValues[nProp].hasValue())
93 			{
94 				switch(nProp)
95 				{
96 					case 0: pValues[nProp] >>= nRootType;	   break;
97 					case 1: pValues[nProp] >>= nSelectedPos;   break;
98 					case 2: pValues[nProp] >>= nOutlineLevel;  break;
99 					case 3: pValues[nProp] >>= nRegionMode;    break;
100 					case 4: pValues[nProp] >>= nActiveBlock;	break;
101 					case 5: bIsSmall		= *(sal_Bool*)pValues[nProp].getValue();  break;
102 					case 6: bIsGlobalActive = *(sal_Bool*)pValues[nProp].getValue();  break;
103 				}
104 			}
105 		}
106 	}
107 }
108 /* -----------------------------08.09.00 16:35--------------------------------
109 
110  ---------------------------------------------------------------------------*/
111 SwNavigationConfig::~SwNavigationConfig()
112 {}
113 /* -----------------------------08.09.00 16:35--------------------------------
114 
115  ---------------------------------------------------------------------------*/
116 void SwNavigationConfig::Commit()
117 {
118 	Sequence<OUString> aNames = GetPropertyNames();
119 	Sequence<Any> aValues(aNames.getLength());
120 	Any* pValues = aValues.getArray();
121 	const Type& rType = ::getBooleanCppuType();
122 
123 	for(int nProp = 0; nProp < aNames.getLength(); nProp++)
124 	{
125 		switch(nProp)
126 		{
127 			case 0: pValues[nProp] <<= nRootType;	  break;
128 			case 1: pValues[nProp] <<= nSelectedPos;  break;
129 			case 2: pValues[nProp] <<= nOutlineLevel; break;
130 			case 3: pValues[nProp] <<= nRegionMode;   break;
131 			case 4: pValues[nProp] <<= nActiveBlock;	break;
132 			case 5: pValues[nProp].setValue(&bIsSmall, rType);			break;
133 			case 6: pValues[nProp].setValue(&bIsGlobalActive, rType);	break;
134 		}
135 	}
136 	PutProperties(aNames, aValues);
137 }
138 
139 void SwNavigationConfig::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
140 
141 
142