Line data Source code
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 <com/sun/star/uno/Any.hxx>
21 : #include <com/sun/star/uno/Sequence.hxx>
22 :
23 : #include "filtopt.hxx"
24 : #include "miscuno.hxx"
25 :
26 : using namespace utl;
27 : using namespace com::sun::star::uno;
28 :
29 : using ::rtl::OUString;
30 :
31 : //------------------------------------------------------------------
32 :
33 : #define CFGPATH_FILTER "Office.Calc/Filter/Import"
34 :
35 : #define SCFILTOPT_COLSCALE 0
36 : #define SCFILTOPT_ROWSCALE 1
37 : #define SCFILTOPT_WK3 2
38 : #define SCFILTOPT_COUNT 3
39 :
40 1 : Sequence<OUString> ScFilterOptions::GetPropertyNames()
41 : {
42 : static const char* aPropNames[] =
43 : {
44 : "MS_Excel/ColScale", // SCFILTOPT_COLSCALE
45 : "MS_Excel/RowScale", // SCFILTOPT_ROWSCALE
46 : "Lotus123/WK3" // SCFILTOPT_WK3
47 : };
48 1 : Sequence<OUString> aNames(SCFILTOPT_COUNT);
49 1 : OUString* pNames = aNames.getArray();
50 4 : for(int i = 0; i < SCFILTOPT_COUNT; i++)
51 3 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
52 :
53 1 : return aNames;
54 : }
55 :
56 1 : ScFilterOptions::ScFilterOptions() :
57 : ConfigItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_FILTER )) ),
58 : bWK3Flag( false ),
59 : fExcelColScale( 0 ),
60 1 : fExcelRowScale( 0 )
61 : {
62 1 : Sequence<OUString> aNames = GetPropertyNames();
63 1 : Sequence<Any> aValues = GetProperties(aNames);
64 1 : const Any* pValues = aValues.getConstArray();
65 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
66 1 : if(aValues.getLength() == aNames.getLength())
67 : {
68 4 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
69 : {
70 : OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
71 3 : if(pValues[nProp].hasValue())
72 : {
73 3 : switch(nProp)
74 : {
75 : case SCFILTOPT_COLSCALE:
76 1 : pValues[nProp] >>= fExcelColScale;
77 1 : break;
78 : case SCFILTOPT_ROWSCALE:
79 1 : pValues[nProp] >>= fExcelRowScale;
80 1 : break;
81 : case SCFILTOPT_WK3:
82 1 : bWK3Flag = ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] );
83 1 : break;
84 : }
85 : }
86 : }
87 1 : }
88 1 : }
89 :
90 :
91 0 : void ScFilterOptions::Commit()
92 : {
93 : // options are never modified from office
94 :
95 : OSL_FAIL("trying to commit changed ScFilterOptions?");
96 0 : }
97 :
98 0 : void ScFilterOptions::Notify( const Sequence<OUString>& /* aPropertyNames */ )
99 : {
100 : OSL_FAIL("properties have been changed");
101 0 : }
102 :
103 :
104 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|