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