Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <swtypes.hxx>
21 : #include <navicfg.hxx>
22 : #include <swcont.hxx>
23 : #include <osl/diagnose.h>
24 : #include <com/sun/star/uno/Any.hxx>
25 : #include <com/sun/star/uno/Sequence.hxx>
26 :
27 : #include <unomid.h>
28 :
29 : using namespace ::utl;
30 : using namespace ::com::sun::star::uno;
31 :
32 2 : Sequence<OUString> SwNavigationConfig::GetPropertyNames()
33 : {
34 : static const char* aPropNames[] =
35 : {
36 : "RootType", //0
37 : "SelectedPosition", //1
38 : "OutlineLevel", //2
39 : "InsertMode", //3
40 : "ActiveBlock", //4
41 : "ShowListBox", //5
42 : "GlobalDocMode" //6
43 : };
44 2 : const int nCount = 7;
45 2 : Sequence<OUString> aNames(nCount);
46 2 : OUString* pNames = aNames.getArray();
47 16 : for(int i = 0; i < nCount; i++)
48 : {
49 14 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
50 : }
51 2 : return aNames;
52 : }
53 :
54 2 : SwNavigationConfig::SwNavigationConfig() :
55 : utl::ConfigItem("Office.Writer/Navigator"),
56 : nRootType(0xffff),
57 : nSelectedPos(0),
58 : nOutlineLevel(MAXLEVEL),
59 : nRegionMode(REGION_MODE_NONE),
60 : nActiveBlock(0),
61 : bIsSmall(false),
62 2 : bIsGlobalActive(true)
63 : {
64 2 : Sequence<OUString> aNames = GetPropertyNames();
65 4 : Sequence<Any> aValues = GetProperties(aNames);
66 2 : const Any* pValues = aValues.getConstArray();
67 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
68 2 : if(aValues.getLength() == aNames.getLength())
69 : {
70 16 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
71 : {
72 14 : if(pValues[nProp].hasValue())
73 : {
74 14 : switch(nProp)
75 : {
76 2 : case 0: pValues[nProp] >>= nRootType; break;
77 2 : case 1: pValues[nProp] >>= nSelectedPos; break;
78 2 : case 2: pValues[nProp] >>= nOutlineLevel; break;
79 2 : case 3: pValues[nProp] >>= nRegionMode; break;
80 2 : case 4: pValues[nProp] >>= nActiveBlock; break;
81 2 : case 5: bIsSmall = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break;
82 2 : case 6: bIsGlobalActive = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break;
83 : }
84 : }
85 : }
86 2 : }
87 2 : }
88 :
89 4 : SwNavigationConfig::~SwNavigationConfig()
90 : {
91 4 : }
92 :
93 0 : void SwNavigationConfig::ImplCommit()
94 : {
95 0 : Sequence<OUString> aNames = GetPropertyNames();
96 0 : Sequence<Any> aValues(aNames.getLength());
97 0 : Any* pValues = aValues.getArray();
98 :
99 0 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
100 : {
101 0 : switch(nProp)
102 : {
103 0 : case 0: pValues[nProp] <<= nRootType; break;
104 0 : case 1: pValues[nProp] <<= nSelectedPos; break;
105 0 : case 2: pValues[nProp] <<= nOutlineLevel; break;
106 0 : case 3: pValues[nProp] <<= nRegionMode; break;
107 0 : case 4: pValues[nProp] <<= nActiveBlock; break;
108 0 : case 5: pValues[nProp] <<= bIsSmall; break;
109 0 : case 6: pValues[nProp] <<= bIsGlobalActive; break;
110 : }
111 : }
112 0 : PutProperties(aNames, aValues);
113 0 : }
114 :
115 0 : void SwNavigationConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
116 :
117 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|