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  OUString("OutlineTracking"),
42  OUString("TableTracking"),
43  OUString("SectionTracking")};
44 }
45 
47  utl::ConfigItem("Office.Writer/Navigator"),
48  m_nRootType(ContentTypeId::UNKNOWN),
49  m_nSelectedPos(0),
50  m_nOutlineLevel(MAXLEVEL),
51  m_nRegionMode(RegionMode::NONE),
52  m_nActiveBlock(0),
53  m_bIsSmall(false),
54  m_bIsGlobalActive(true),
55  m_nOutlineTracking(1),
56  m_bIsTableTracking(true),
57  m_bIsSectionTracking(true)
58 {
60  Sequence<Any> aValues = GetProperties(aNames);
61  const Any* pValues = aValues.getConstArray();
62  OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
63  if(aValues.getLength() != aNames.getLength())
64  return;
65 
66  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
67  {
68  if(pValues[nProp].hasValue())
69  {
70  switch(nProp)
71  {
72  case 0:
73  {
74  sal_Int32 nTmp = {}; // spurious -Werror=maybe-uninitialized
75  if (pValues[nProp] >>= nTmp)
76  {
77  if (nTmp < sal_Int32(ContentTypeId::UNKNOWN)
78  || nTmp > sal_Int32(ContentTypeId::LAST))
79  {
80  SAL_WARN(
81  "sw",
82  "out-of-bounds ContentTypeId " << nTmp);
83  nTmp = sal_Int32(ContentTypeId::UNKNOWN);
84  }
85  m_nRootType = static_cast<ContentTypeId>(nTmp);
86  }
87  break;
88  }
89  case 1: pValues[nProp] >>= m_nSelectedPos; break;
90  case 2: pValues[nProp] >>= m_nOutlineLevel; break;
91  case 3:
92  {
93  sal_uInt16 nTmp;
94  if (pValues[nProp] >>= nTmp)
95  m_nRegionMode = static_cast<RegionMode>(nTmp);
96  break;
97  }
98  case 4: pValues[nProp] >>= m_nActiveBlock; break;
99  case 5: m_bIsSmall = *o3tl::doAccess<bool>(pValues[nProp]); break;
100  case 6: m_bIsGlobalActive = *o3tl::doAccess<bool>(pValues[nProp]); break;
101  case 7: pValues[nProp] >>= m_nOutlineTracking; break;
102  case 8: m_bIsTableTracking = *o3tl::doAccess<bool>(pValues[nProp]); break;
103  case 9: m_bIsSectionTracking = *o3tl::doAccess<bool>(pValues[nProp]); break;
104  }
105  }
106  }
107 }
108 
110 {
111 }
112 
114 {
116  Sequence<Any> aValues(aNames.getLength());
117  Any* pValues = aValues.getArray();
118 
119  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
120  {
121  switch(nProp)
122  {
123  case 0: pValues[nProp] <<= static_cast<sal_Int32>(m_nRootType); break;
124  case 1: pValues[nProp] <<= m_nSelectedPos; break;
125  case 2: pValues[nProp] <<= m_nOutlineLevel; break;
126  case 3: pValues[nProp] <<= static_cast<sal_uInt16>(m_nRegionMode); break;
127  case 4: pValues[nProp] <<= m_nActiveBlock; break;
128  case 5: pValues[nProp] <<= m_bIsSmall; break;
129  case 6: pValues[nProp] <<= m_bIsGlobalActive; break;
130  case 7: pValues[nProp] <<= m_nOutlineTracking; break;
131  case 8: pValues[nProp] <<= m_bIsTableTracking; break;
132  case 9: pValues[nProp] <<= m_bIsSectionTracking; break;
133  }
134  }
135  PutProperties(aNames, aValues);
136 }
137 
138 void SwNavigationConfig::Notify( const css::uno::Sequence< OUString >& ) {}
139 
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ContentTypeId
Definition: swcont.hxx:29
sal_Int32 m_nOutlineTracking
Definition: navicfg.hxx:36
bool m_bIsSectionTracking
Definition: navicfg.hxx:38
bool m_bIsGlobalActive
Definition: navicfg.hxx:35
bool m_bIsTableTracking
Definition: navicfg.hxx:37
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:93
ContentTypeId m_nRootType
Definition: navicfg.hxx:29
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: navicfg.cxx:138
RegionMode m_nRegionMode
Definition: navicfg.hxx:32
virtual ~SwNavigationConfig() override
Definition: navicfg.cxx:109
virtual void ImplCommit() override
Definition: navicfg.cxx:113
UNKNOWN
static bool PutProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues, bool bAllLocales)
static css::uno::Sequence< OUString > GetPropertyNames()
Definition: navicfg.cxx:31
static css::uno::Sequence< css::uno::Any > GetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, bool bAllLocales)
sal_Int32 m_nOutlineLevel
Definition: navicfg.hxx:31
sal_Int32 m_nSelectedPos
Definition: navicfg.hxx:30
RegionMode
Definition: swcont.hxx:54
sal_Int32 m_nActiveBlock
Definition: navicfg.hxx:33
const PropertyValue * pValues
#define SAL_WARN(area, stream)