1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <swtypes.hxx> // for pathfinder
21 #include <navicfg.hxx>
23 #include <osl/diagnose.h>
24 #include <com/sun/star/uno/Any.hxx>
25 #include <com/sun/star/uno/Sequence.hxx>
29 using namespace ::utl
;
30 using namespace ::rtl
;
31 using namespace ::com::sun::star::uno
;
33 Sequence
<OUString
> SwNavigationConfig::GetPropertyNames()
35 static const char* aPropNames
[] =
38 "SelectedPosition", //1
46 Sequence
<OUString
> aNames(nCount
);
47 OUString
* pNames
= aNames
.getArray();
48 for(int i
= 0; i
< nCount
; i
++)
50 pNames
[i
] = OUString::createFromAscii(aPropNames
[i
]);
55 SwNavigationConfig::SwNavigationConfig() :
56 utl::ConfigItem("Office.Writer/Navigator"),
59 nOutlineLevel(MAXLEVEL
),
60 nRegionMode(REGION_MODE_NONE
),
63 bIsGlobalActive(sal_True
)
65 Sequence
<OUString
> aNames
= GetPropertyNames();
66 Sequence
<Any
> aValues
= GetProperties(aNames
);
67 const Any
* pValues
= aValues
.getConstArray();
68 OSL_ENSURE(aValues
.getLength() == aNames
.getLength(), "GetProperties failed");
69 if(aValues
.getLength() == aNames
.getLength())
71 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
73 if(pValues
[nProp
].hasValue())
77 case 0: pValues
[nProp
] >>= nRootType
; break;
78 case 1: pValues
[nProp
] >>= nSelectedPos
; break;
79 case 2: pValues
[nProp
] >>= nOutlineLevel
; break;
80 case 3: pValues
[nProp
] >>= nRegionMode
; break;
81 case 4: pValues
[nProp
] >>= nActiveBlock
; break;
82 case 5: bIsSmall
= *(sal_Bool
*)pValues
[nProp
].getValue(); break;
83 case 6: bIsGlobalActive
= *(sal_Bool
*)pValues
[nProp
].getValue(); break;
90 SwNavigationConfig::~SwNavigationConfig()
94 void SwNavigationConfig::Commit()
96 Sequence
<OUString
> aNames
= GetPropertyNames();
97 Sequence
<Any
> aValues(aNames
.getLength());
98 Any
* pValues
= aValues
.getArray();
99 const Type
& rType
= ::getBooleanCppuType();
101 for(int nProp
= 0; nProp
< aNames
.getLength(); nProp
++)
105 case 0: pValues
[nProp
] <<= nRootType
; break;
106 case 1: pValues
[nProp
] <<= nSelectedPos
; break;
107 case 2: pValues
[nProp
] <<= nOutlineLevel
; break;
108 case 3: pValues
[nProp
] <<= nRegionMode
; break;
109 case 4: pValues
[nProp
] <<= nActiveBlock
; break;
110 case 5: pValues
[nProp
].setValue(&bIsSmall
, rType
); break;
111 case 6: pValues
[nProp
].setValue(&bIsGlobalActive
, rType
); break;
114 PutProperties(aNames
, aValues
);
117 void SwNavigationConfig::Notify( const ::com::sun::star::uno::Sequence
< OUString
>& ) {}
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */