xref: /AOO41X/main/sc/source/core/tool/filtopt.cxx (revision b3f79822e811ac3493b185030a72c3c5a51f32d8)
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_sc.hxx"
26 
27 
28 
29 //------------------------------------------------------------------
30 
31 #include <tools/debug.hxx>
32 
33 #include <com/sun/star/uno/Any.hxx>
34 #include <com/sun/star/uno/Sequence.hxx>
35 
36 #include "filtopt.hxx"
37 #include "miscuno.hxx"
38 
39 using namespace utl;
40 using namespace rtl;
41 using namespace com::sun::star::uno;
42 
43 //------------------------------------------------------------------
44 
45 #define CFGPATH_FILTER          "Office.Calc/Filter/Import"
46 
47 #define SCFILTOPT_COLSCALE      0
48 #define SCFILTOPT_ROWSCALE      1
49 #define SCFILTOPT_WK3           2
50 #define SCFILTOPT_COUNT         3
51 
GetPropertyNames()52 Sequence<OUString> ScFilterOptions::GetPropertyNames()
53 {
54     static const char* aPropNames[] =
55     {
56         "MS_Excel/ColScale",            // SCFILTOPT_COLSCALE
57         "MS_Excel/RowScale",            // SCFILTOPT_ROWSCALE
58         "Lotus123/WK3"                  // SCFILTOPT_WK3
59     };
60     Sequence<OUString> aNames(SCFILTOPT_COUNT);
61     OUString* pNames = aNames.getArray();
62     for(int i = 0; i < SCFILTOPT_COUNT; i++)
63         pNames[i] = OUString::createFromAscii(aPropNames[i]);
64 
65     return aNames;
66 }
67 
ScFilterOptions()68 ScFilterOptions::ScFilterOptions() :
69     ConfigItem( OUString::createFromAscii( CFGPATH_FILTER ) ),
70     bWK3Flag( sal_False ),
71     fExcelColScale( 0 ),
72     fExcelRowScale( 0 )
73 {
74     Sequence<OUString> aNames = GetPropertyNames();
75     Sequence<Any> aValues = GetProperties(aNames);
76 //  EnableNotification(aNames);
77     const Any* pValues = aValues.getConstArray();
78     DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
79     if(aValues.getLength() == aNames.getLength())
80     {
81         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
82         {
83             DBG_ASSERT(pValues[nProp].hasValue(), "property value missing");
84             if(pValues[nProp].hasValue())
85             {
86                 switch(nProp)
87                 {
88                     case SCFILTOPT_COLSCALE:
89                         pValues[nProp] >>= fExcelColScale;
90                         break;
91                     case SCFILTOPT_ROWSCALE:
92                         pValues[nProp] >>= fExcelRowScale;
93                         break;
94                     case SCFILTOPT_WK3:
95                         bWK3Flag = ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] );
96                         break;
97                 }
98             }
99         }
100     }
101 }
102 
103 
Commit()104 void ScFilterOptions::Commit()
105 {
106     // options are never modified from office
107 
108     DBG_ERROR("trying to commit changed ScFilterOptions?");
109 }
110 
Notify(const Sequence<rtl::OUString> &)111 void ScFilterOptions::Notify( const Sequence<rtl::OUString>& /* aPropertyNames */ )
112 {
113     DBG_ERROR("properties have been changed");
114 }
115 
116 
117