summaryrefslogtreecommitdiff
path: root/test/source/sheet/sheetfilterdescriptor.cxx
blob: b5618e75d62aba2e23b8de7b1ed6cf3d7d0771d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <test/cppunitasserthelper.hxx>
#include <test/sheet/sheetfilterdescriptor.hxx>

#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/TableOrientation.hpp>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.hxx>

#include <cppunit/extensions/HelperMacros.h>

using namespace com::sun::star;
using namespace com::sun::star::uno;

namespace apitest
{
void SheetFilterDescriptor::testSheetFilterDescriptorProperties()
{
    uno::Reference<beans::XPropertySet> xSheetFilterDescriptor(init(), UNO_QUERY_THROW);
    OUString propName;
    uno::Any aNewValue;

    propName = "IsCaseSensitive";
    bool bIsCaseSensitiveGet = false;
    bool bIsCaseSensitiveSet = false;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsCaseSensitive",
                           xSheetFilterDescriptor->getPropertyValue(propName)
                           >>= bIsCaseSensitiveGet);

    aNewValue <<= !bIsCaseSensitiveGet;
    xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bIsCaseSensitiveSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue IsCaseSensitive",
                                 !bIsCaseSensitiveGet, bIsCaseSensitiveSet);

    propName = "SkipDuplicates";
    bool bSkipDuplicatesGet = false;
    bool bSkipDuplicatesSet = false;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue SkipDuplicates",
                           xSheetFilterDescriptor->getPropertyValue(propName)
                           >>= bSkipDuplicatesGet);

    aNewValue <<= !bSkipDuplicatesGet;
    xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bSkipDuplicatesSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue SkipDuplicates", !bSkipDuplicatesGet,
                                 bSkipDuplicatesSet);

    propName = "UseRegularExpressions";
    bool bUseRegularExpressionsGet = false;
    bool bUseRegularExpressionsSet = false;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue UseRegularExpressions",
                           xSheetFilterDescriptor->getPropertyValue(propName)
                           >>= bUseRegularExpressionsGet);

    aNewValue <<= !bUseRegularExpressionsGet;
    xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName)
                   >>= bUseRegularExpressionsSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue UseRegularExpressions",
                                 !bUseRegularExpressionsGet, bUseRegularExpressionsSet);

    propName = "SaveOutputPosition";
    bool bSaveOutputPositionGet = false;
    bool bSaveOutputPositionSet = false;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue SaveOutputPosition",
                           xSheetFilterDescriptor->getPropertyValue(propName)
                           >>= bSaveOutputPositionGet);

    aNewValue <<= !bSaveOutputPositionGet;
    xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bSaveOutputPositionSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue SaveOutputPosition",
                                 !bSaveOutputPositionGet, bSaveOutputPositionSet);

    propName = "Orientation";
    table::TableOrientation aOrientationGet;
    table::TableOrientation aOrientationSet;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Orientation",
                           xSheetFilterDescriptor->getPropertyValue(propName) >>= aOrientationGet);

    aNewValue <<= table::TableOrientation_COLUMNS;
    xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= aOrientationSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Orientation",
                                 table::TableOrientation_COLUMNS, aOrientationSet);

    propName = "ContainsHeader";
    bool bContainsHeaderGet = false;
    bool bContainsHeaderSet = false;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ContainsHeader",
                           xSheetFilterDescriptor->getPropertyValue(propName)
                           >>= bContainsHeaderGet);

    aNewValue <<= !bContainsHeaderGet;
    xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bContainsHeaderSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ContainsHeader", !bContainsHeaderGet,
                                 bContainsHeaderSet);

    propName = "CopyOutputData";
    bool bCopyOutputDataGet = false;
    bool bCopyOutputDataSet = false;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue CopyOutputData",
                           xSheetFilterDescriptor->getPropertyValue(propName)
                           >>= bCopyOutputDataGet);

    aNewValue <<= !bCopyOutputDataGet;
    xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bCopyOutputDataSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue CopyOutputData", !bCopyOutputDataGet,
                                 bCopyOutputDataSet);

    propName = "OutputPosition";
    table::CellAddress aCellAddressGet;
    table::CellAddress aCellAddressSet;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue OutputPosition",
                           xSheetFilterDescriptor->getPropertyValue(propName) >>= aCellAddressGet);

    aCellAddressGet = table::CellAddress(0, 42, 42);
    aNewValue <<= aCellAddressGet;
    xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= aCellAddressSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue OutputPosition", aCellAddressGet,
                                 aCellAddressSet);

    propName = "MaxFieldCount";
    sal_Int32 nMaxFieldCountGet = 0;
    sal_Int32 nMaxFieldCountSet = 0;
    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue MaxFieldCount",
                           xSheetFilterDescriptor->getPropertyValue(propName)
                           >>= nMaxFieldCountGet);

    aNewValue <<= nMaxFieldCountGet + 42;
    xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
    CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= nMaxFieldCountSet);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue MaxFieldCount", nMaxFieldCountGet,
                                 nMaxFieldCountSet);
}
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */