summaryrefslogtreecommitdiff
path: root/svtools/source/uitest/uiobject.cxx
blob: 0e0df658f06a4cc9b5231cf24559fab4a8699d11 (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
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * 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 <memory>
#include <uitest/uiobject.hxx>

#include <svtools/valueset.hxx>

ValueSetUIObject::ValueSetUIObject(const VclPtr<ValueSet>& xValueSet)
    : WindowUIObject(xValueSet)
    , mxValueSet(xValueSet)
{
}

ValueSetUIObject::~ValueSetUIObject() {}

void ValueSetUIObject::execute(const OUString& rAction, const StringMap& rParameters)
{
    if (!mxValueSet->IsEnabled() || !mxValueSet->IsReallyVisible())
        return;

    if (rAction == "SELECT")
    {
        if (rParameters.find("POS") != rParameters.end())
        {
            auto aPos = rParameters.find("POS");
            OUString aVal = aPos->second;
            sal_Int32 nPos = aVal.toInt32();
            mxValueSet->SelectItem(nPos);
            mxValueSet->Select();
        }
    }
    else
        WindowUIObject::execute(rAction, rParameters);
}

StringMap ValueSetUIObject::get_state()
{
    StringMap aMap = WindowUIObject::get_state();
    aMap["EntryCount"] = OUString::number(mxValueSet->GetItemCount());

    return aMap;
}

OUString ValueSetUIObject::get_name() const { return "ValueSetUIObject"; }

OUString ValueSetUIObject::get_action(VclEventId /*nEvent*/) const
{
    // No action for this control that trigger item selection after mouse tracking end
    return OUString();
}

std::unique_ptr<UIObject> ValueSetUIObject::create(vcl::Window* pWindow)
{
    ValueSet* pValueSet = dynamic_cast<ValueSet*>(pWindow);
    assert(pValueSet);
    return std::unique_ptr<UIObject>(new ValueSetUIObject(pValueSet));
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */