xref: /AOO41X/main/sw/source/ui/utlui/navicfg.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <swtypes.hxx>  // fuer Pathfinder
29 #include <navicfg.hxx>
30 #include <swcont.hxx>
31 #include <tools/debug.hxx>
32 #include <com/sun/star/uno/Any.hxx>
33 #include <com/sun/star/uno/Sequence.hxx>
34 
35 #include <unomid.h>
36 
37 using namespace ::utl;
38 using namespace ::rtl;
39 using namespace ::com::sun::star::uno;
40 
41 /* -----------------------------08.09.00 16:30--------------------------------
42 
43  ---------------------------------------------------------------------------*/
GetPropertyNames()44 Sequence<OUString> SwNavigationConfig::GetPropertyNames()
45 {
46     static const char* aPropNames[] =
47     {
48         "RootType",             //0
49         "SelectedPosition",     //1
50         "OutlineLevel",         //2
51         "InsertMode",           //3
52         "ActiveBlock",          //4
53         "ShowListBox",          //5
54         "GlobalDocMode"         //6
55     };
56     const int nCount = 7;
57     Sequence<OUString> aNames(nCount);
58     OUString* pNames = aNames.getArray();
59     for(int i = 0; i < nCount; i++)
60     {
61         pNames[i] = OUString::createFromAscii(aPropNames[i]);
62     }
63     return aNames;
64 }
65 /*-----------------13.11.96 11.03-------------------
66 
67 --------------------------------------------------*/
68 
SwNavigationConfig()69 SwNavigationConfig::SwNavigationConfig() :
70     utl::ConfigItem(C2U("Office.Writer/Navigator")),
71     nRootType(0xffff),
72     nSelectedPos(0),
73     nOutlineLevel(MAXLEVEL),
74     nRegionMode(REGION_MODE_NONE),
75     nActiveBlock(0),
76     bIsSmall(sal_False),
77     bIsGlobalActive(sal_True)
78 {
79     Sequence<OUString> aNames = GetPropertyNames();
80     Sequence<Any> aValues = GetProperties(aNames);
81 //  EnableNotification(aNames);
82     const Any* pValues = aValues.getConstArray();
83     DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
84     if(aValues.getLength() == aNames.getLength())
85     {
86         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
87         {
88             if(pValues[nProp].hasValue())
89             {
90                 switch(nProp)
91                 {
92                     case 0: pValues[nProp] >>= nRootType;      break;
93                     case 1: pValues[nProp] >>= nSelectedPos;   break;
94                     case 2: pValues[nProp] >>= nOutlineLevel;  break;
95                     case 3: pValues[nProp] >>= nRegionMode;    break;
96                     case 4: pValues[nProp] >>= nActiveBlock;    break;
97                     case 5: bIsSmall        = *(sal_Bool*)pValues[nProp].getValue();  break;
98                     case 6: bIsGlobalActive = *(sal_Bool*)pValues[nProp].getValue();  break;
99                 }
100             }
101         }
102     }
103 }
104 /* -----------------------------08.09.00 16:35--------------------------------
105 
106  ---------------------------------------------------------------------------*/
~SwNavigationConfig()107 SwNavigationConfig::~SwNavigationConfig()
108 {}
109 /* -----------------------------08.09.00 16:35--------------------------------
110 
111  ---------------------------------------------------------------------------*/
Commit()112 void SwNavigationConfig::Commit()
113 {
114     Sequence<OUString> aNames = GetPropertyNames();
115     Sequence<Any> aValues(aNames.getLength());
116     Any* pValues = aValues.getArray();
117     const Type& rType = ::getBooleanCppuType();
118 
119     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
120     {
121         switch(nProp)
122         {
123             case 0: pValues[nProp] <<= nRootType;     break;
124             case 1: pValues[nProp] <<= nSelectedPos;  break;
125             case 2: pValues[nProp] <<= nOutlineLevel; break;
126             case 3: pValues[nProp] <<= nRegionMode;   break;
127             case 4: pValues[nProp] <<= nActiveBlock;    break;
128             case 5: pValues[nProp].setValue(&bIsSmall, rType);          break;
129             case 6: pValues[nProp].setValue(&bIsGlobalActive, rType);   break;
130         }
131     }
132     PutProperties(aNames, aValues);
133 }
134 
Notify(const::com::sun::star::uno::Sequence<rtl::OUString> &)135 void SwNavigationConfig::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
136 
137 
138