Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / core / tool / filtopt.cxx
blobf87a68b15c9c2dc677cefc6ea93cac614580c796
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/uno/Any.hxx>
21 #include <com/sun/star/uno/Sequence.hxx>
23 #include "filtopt.hxx"
24 #include "miscuno.hxx"
26 using namespace utl;
27 using namespace com::sun::star::uno;
29 #define CFGPATH_FILTER "Office.Calc/Filter/Import"
31 #define SCFILTOPT_COLSCALE 0
32 #define SCFILTOPT_ROWSCALE 1
33 #define SCFILTOPT_WK3 2
34 #define SCFILTOPT_COUNT 3
36 Sequence<OUString> ScFilterOptions::GetPropertyNames()
38 static const char* aPropNames[] =
40 "MS_Excel/ColScale", // SCFILTOPT_COLSCALE
41 "MS_Excel/RowScale", // SCFILTOPT_ROWSCALE
42 "Lotus123/WK3" // SCFILTOPT_WK3
44 Sequence<OUString> aNames(SCFILTOPT_COUNT);
45 OUString* pNames = aNames.getArray();
46 for(int i = 0; i < SCFILTOPT_COUNT; i++)
47 pNames[i] = OUString::createFromAscii(aPropNames[i]);
49 return aNames;
52 ScFilterOptions::ScFilterOptions() :
53 ConfigItem( OUString( CFGPATH_FILTER ) ),
54 bWK3Flag( false ),
55 fExcelColScale( 0 ),
56 fExcelRowScale( 0 )
58 Sequence<OUString> aNames = GetPropertyNames();
59 Sequence<Any> aValues = GetProperties(aNames);
60 const Any* pValues = aValues.getConstArray();
61 OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
62 if(aValues.getLength() == aNames.getLength())
64 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
66 OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
67 if(pValues[nProp].hasValue())
69 switch(nProp)
71 case SCFILTOPT_COLSCALE:
72 pValues[nProp] >>= fExcelColScale;
73 break;
74 case SCFILTOPT_ROWSCALE:
75 pValues[nProp] >>= fExcelRowScale;
76 break;
77 case SCFILTOPT_WK3:
78 bWK3Flag = ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] );
79 break;
86 void ScFilterOptions::Commit()
88 // options are never modified from office
90 OSL_FAIL("trying to commit changed ScFilterOptions?");
93 void ScFilterOptions::Notify( const Sequence<OUString>& /* aPropertyNames */ )
95 OSL_FAIL("properties have been changed");
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */