LibreOffice Module sw (master)  1
navicfg.cxx
Go to the documentation of this file.
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 <o3tl/any.hxx>
24 #include <osl/diagnose.h>
25 #include <sal/log.hxx>
26 #include <com/sun/star/uno/Sequence.hxx>
27 
28 #include <unomid.h>
29 
30 using namespace ::utl;
31 using namespace ::com::sun::star::uno;
32 
34 {
35  return css::uno::Sequence<OUString>{
36  OUString("RootType"),
37  OUString("SelectedPosition"),
38  OUString("OutlineLevel"),
39  OUString("InsertMode"),
40  OUString("ActiveBlock"),
41  OUString("ShowListBox"),
42  OUString("GlobalDocMode")};
43 }
44 
46  utl::ConfigItem("Office.Writer/Navigator"),
47  nRootType(ContentTypeId::UNKNOWN),
48  nSelectedPos(0),
49  nOutlineLevel(MAXLEVEL),
50  nRegionMode(RegionMode::NONE),
51  nActiveBlock(0),
52  bIsSmall(false),
53  bIsGlobalActive(true)
54 {
56  Sequence<Any> aValues = GetProperties(aNames);
57  const Any* pValues = aValues.getConstArray();
58  OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
59  if(aValues.getLength() == aNames.getLength())
60  {
61  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
62  {
63  if(pValues[nProp].hasValue())
64  {
65  switch(nProp)
66  {
67  case 0:
68  {
69  sal_Int32 nTmp;
70  if (pValues[nProp] >>= nTmp)
71  {
72  if (nTmp < sal_Int32(ContentTypeId::UNKNOWN)
73  || nTmp > sal_Int32(ContentTypeId::LAST))
74  {
75  SAL_WARN(
76  "sw",
77  "out-of-bounds ContentTypeId " << nTmp);
78  nTmp = sal_Int32(ContentTypeId::UNKNOWN);
79  }
80  nRootType = static_cast<ContentTypeId>(nTmp);
81  }
82  break;
83  }
84  case 1: pValues[nProp] >>= nSelectedPos; break;
85  case 2: pValues[nProp] >>= nOutlineLevel; break;
86  case 3:
87  {
88  sal_uInt16 nTmp;
89  if (pValues[nProp] >>= nTmp)
90  nRegionMode = static_cast<RegionMode>(nTmp);
91  break;
92  }
93  case 4: pValues[nProp] >>= nActiveBlock; break;
94  case 5: bIsSmall = *o3tl::doAccess<bool>(pValues[nProp]); break;
95  case 6: bIsGlobalActive = *o3tl::doAccess<bool>(pValues[nProp]); break;
96  }
97  }
98  }
99  }
100 }
101 
103 {
104 }
105 
107 {
109  Sequence<Any> aValues(aNames.getLength());
110  Any* pValues = aValues.getArray();
111 
112  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
113  {
114  switch(nProp)
115  {
116  case 0: pValues[nProp] <<= static_cast<sal_Int32>(nRootType); break;
117  case 1: pValues[nProp] <<= nSelectedPos; break;
118  case 2: pValues[nProp] <<= nOutlineLevel; break;
119  case 3: pValues[nProp] <<= static_cast<sal_uInt16>(nRegionMode); break;
120  case 4: pValues[nProp] <<= nActiveBlock; break;
121  case 5: pValues[nProp] <<= bIsSmall; break;
122  case 6: pValues[nProp] <<= bIsGlobalActive; break;
123  }
124  }
125  PutProperties(aNames, aValues);
126 }
127 
128 void SwNavigationConfig::Notify( const css::uno::Sequence< OUString >& ) {}
129 
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ContentTypeId
Definition: swcont.hxx:28
sal_Int32 nOutlineLevel
Definition: navicfg.hxx:31
sal_Int32 nActiveBlock
Definition: navicfg.hxx:33
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: navicfg.cxx:128
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
virtual ~SwNavigationConfig() override
Definition: navicfg.cxx:102
virtual void ImplCommit() override
Definition: navicfg.cxx:106
UNKNOWN
static css::uno::Sequence< OUString > GetPropertyNames()
Definition: navicfg.cxx:33
bool PutProperties(const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues)
RegionMode
Definition: swcont.hxx:51
css::uno::Sequence< css::uno::Any > GetProperties(const css::uno::Sequence< OUString > &rNames)
RegionMode nRegionMode
Definition: navicfg.hxx:32
ContentTypeId nRootType
Definition: navicfg.hxx:29
sal_Int32 nSelectedPos
Definition: navicfg.hxx:30
#define SAL_WARN(area, stream)