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  return;
59 
60  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
61  {
62  if(pValues[nProp].hasValue())
63  {
64  switch(nProp)
65  {
66  case 0:
67  {
68  sal_Int32 nTmp = {}; // spurious -Werror=maybe-uninitialized
69  if (pValues[nProp] >>= nTmp)
70  {
71  if (nTmp < sal_Int32(ContentTypeId::UNKNOWN)
72  || nTmp > sal_Int32(ContentTypeId::LAST))
73  {
74  SAL_WARN(
75  "sw",
76  "out-of-bounds ContentTypeId " << nTmp);
77  nTmp = sal_Int32(ContentTypeId::UNKNOWN);
78  }
79  nRootType = static_cast<ContentTypeId>(nTmp);
80  }
81  break;
82  }
83  case 1: pValues[nProp] >>= nSelectedPos; break;
84  case 2: pValues[nProp] >>= nOutlineLevel; break;
85  case 3:
86  {
87  sal_uInt16 nTmp;
88  if (pValues[nProp] >>= nTmp)
89  nRegionMode = static_cast<RegionMode>(nTmp);
90  break;
91  }
92  case 4: pValues[nProp] >>= nActiveBlock; break;
93  case 5: bIsSmall = *o3tl::doAccess<bool>(pValues[nProp]); break;
94  case 6: bIsGlobalActive = *o3tl::doAccess<bool>(pValues[nProp]); break;
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
virtual void ImplCommit() override
Definition: navicfg.cxx:104
UNKNOWN
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)