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