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