diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-05-05 00:50:08 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-06-18 17:01:59 +0200 |
commit | 755a7b74b44a8dadc403f94dda0e3450df1daa17 (patch) | |
tree | 5e0193be671c7da49e9a0c88f31b3dda54ddf1b8 /sc/source/ui/uitest/uiobject.cxx | |
parent | a86405470fafd86132b8452746a86b54f2396fff (diff) |
uitest: add wrapper for calc's gridwindow
It already supports selecting cell ranges.
Change-Id: I8c3e4a42dea8956e2429b82b50ff8506c1774bbb
Diffstat (limited to 'sc/source/ui/uitest/uiobject.cxx')
-rw-r--r-- | sc/source/ui/uitest/uiobject.cxx | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/sc/source/ui/uitest/uiobject.cxx b/sc/source/ui/uitest/uiobject.cxx new file mode 100644 index 000000000000..f9b8127b12fb --- /dev/null +++ b/sc/source/ui/uitest/uiobject.cxx @@ -0,0 +1,108 @@ +/* -*- 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 "uiobject.hxx" + +#include "rangeutl.hxx" +#include "gridwin.hxx" + +#include "viewdata.hxx" +#include "dbfunc.hxx" + +namespace { + +ScAddress get_address_from_string(const OUString& rStr) +{ + ScAddress aAddr; + sal_Int32 nOffset = 0; + ScRangeStringConverter::GetAddressFromString(aAddr, rStr, nullptr, formula::FormulaGrammar::CONV_OOO, nOffset); + return aAddr; +} + +ScRange get_range_from_string(const OUString& rStr) +{ + ScRange aRange; + sal_Int32 nOffset = 0; + ScRangeStringConverter::GetRangeFromString(aRange, rStr, nullptr, formula::FormulaGrammar::CONV_OOO, nOffset); + + return aRange; +} + +} + +ScGridWinUIObject::ScGridWinUIObject(VclPtr<ScGridWindow> xGridWin): + WindowUIObject(xGridWin), + mxGridWindow(xGridWin) +{ +} + +StringMap ScGridWinUIObject::get_state() +{ + StringMap aMap = WindowUIObject::get_state(); + + aMap["SelectedTable"] = OUString::number(0); + return aMap; +} + +ScDBFunc* ScGridWinUIObject::getDBFunc() +{ + ScViewData* pViewData = mxGridWindow->getViewData(); + ScDBFunc* pFunc = pViewData->GetView(); + + return pFunc; +} + +void ScGridWinUIObject::execute(const OUString& rAction, + const StringMap& rParameters) +{ + if (rAction == "SELECT") + { + if (rParameters.find("CELL") != rParameters.end()) + { + auto itr = rParameters.find("CELL"); + const OUString& rStr = itr->second; + ScAddress aAddr = get_address_from_string(rStr); + ScDBFunc* pFunc = getDBFunc(); + pFunc->MarkRange(ScRange(aAddr)); + mxGridWindow->CursorChanged(); + } + else if (rParameters.find("RANGE") != rParameters.end()) + { + auto itr = rParameters.find("RANGE"); + const OUString rStr = itr->second; + ScRange aRange = get_range_from_string(rStr); + ScDBFunc* pFunc = getDBFunc(); + pFunc->MarkRange(aRange); + mxGridWindow->CursorChanged(); + } + } + else + { + WindowUIObject::execute(rAction, rParameters); + } +} + +std::unique_ptr<UIObject> ScGridWinUIObject::get_child(const OUString& /*rID*/) +{ + return nullptr; +} + +std::unique_ptr<UIObject> ScGridWinUIObject::create(vcl::Window* pWindow) +{ + ScGridWindow* pGridWin = dynamic_cast<ScGridWindow*>(pWindow); + assert(pGridWin); + return std::unique_ptr<UIObject>(new ScGridWinUIObject(pGridWin)); +} + +OUString ScGridWinUIObject::get_name() const +{ + return OUString("ScGridWinUIObject"); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |