10#include <config_folders.h>
14#include <rtl/bootstrap.hxx>
15#include <rtl/ustrbuf.hxx>
16#include <osl/file.hxx>
22#include <com/sun/star/beans/PropertyValue.hpp>
55 if (isDialogWindow(pWindow) || isTopWindow(pWindow))
62 return get_top_parent(pParent);
68 static const char* pFile = std::getenv(
"LO_COLLECT_UIINFO");
71 OUString aDirPath(
"${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER
73 rtl::Bootstrap::expandMacros(aDirPath);
74 osl::Directory::createPath(aDirPath);
75 OUString aFilePath = aDirPath + OUString::fromUtf8(pFile);
77 maStream.
Open(aFilePath, StreamMode::READWRITE | StreamMode::TRUNC);
83 const css::uno::Sequence<css::beans::PropertyValue>& rArgs)
88 OUStringBuffer
aBuffer(rAction);
90 if (rArgs.hasElements())
93 for (
const css::beans::PropertyValue& rProp : rArgs)
95 OUString aTypeName = rProp.Value.getValueTypeName();
97 if (aTypeName ==
"long" || aTypeName ==
"short")
101 aBuffer.append(
"\"" + rProp.Name +
"\": " + OUString::number(
nValue) +
", ");
103 else if (aTypeName ==
"unsigned long")
107 aBuffer.append(
"\"" + rProp.Name +
"\": " + OUString::number(
nValue) +
", ");
109 else if (aTypeName ==
"boolean")
112 rProp.Value >>= bValue;
113 aBuffer.append(
"\"" + rProp.Name +
"\": ");
133 for (sal_Int32 i = 0;
i <
nCount; ++
i)
152 if (xUIElement->
get_id().isEmpty())
156 OUString aAction = pUIObject->get_action(nEvent);
157 if (!xUIElement->
HasFocus() && !child_windows_have_focus(xUIElement))
162 if (!aAction.isEmpty())
171 if (xUIWin->
get_id().isEmpty())
175 OUString aAction = pUIObject->get_action(nEvent);
177 if (!aAction.isEmpty())
210 std::map<OUString, sal_uInt16> aKeyMap
218 for (
const auto& itr : aKeyMap)
220 if (itr.second == nKeyCode)
228 if (!aFound.isEmpty() || bShift || bMod1 || bMod2 || bMod3)
230 aKeyCode =
"{\"KEYCODE\": \"";
232 aKeyCode +=
"SHIFT+";
240 if (aFound.isEmpty())
241 aKeyCode += OUStringChar(nChar) +
"\"}";
243 aKeyCode += aFound +
"\"}";
247 aKeyCode =
"{\"TEXT\": \"" + OUStringChar(nChar) +
"\"}";
259 OUString aParentID = pParent ? pParent->
get_id() : OUString();
263 if (pUIObject->get_type() ==
"EditUIObject")
265 if (aParentID.isEmpty())
268 aParentID = pParent_top->
get_id();
270 if (aParentID.isEmpty())
272 aContent +=
"Type on '" + rID +
"' " + aKeyCode;
276 aContent +=
"Type on '" + rID +
"' " + aKeyCode +
" from " + aParentID;
279 else if (pUIObject->get_type() ==
"SwEditWinUIObject" && rID ==
"writer_edit")
281 aContent =
"Type on writer " + aKeyCode;
283 else if (pUIObject->get_type() ==
"ScGridWinUIObject" && rID ==
"grid_window")
285 aContent =
"Type on current cell " + aKeyCode;
287 else if (pUIObject->get_type() ==
"ImpressWindowUIObject" && rID ==
"impress_win")
289 aContent =
"Type on impress " + aKeyCode;
291 else if (pUIObject->get_type() ==
"WindowUIObject" && rID ==
"math_edit")
293 aContent =
"Type on math " + aKeyCode;
295 else if (rID ==
"draw_win")
297 aContent =
"Type on draw " + aKeyCode;
301 if (aParentID.isEmpty())
304 aParentID = pParent_top->
get_id();
306 if (aParentID.isEmpty())
308 aContent =
"Type on '" + rID +
"' " + aKeyCode;
312 aContent =
"Type on '" + rID +
"' " + aKeyCode +
" from " + aParentID;
320OUString StringMapToOUString(
const std::map<OUString, OUString>& rParameters)
322 if (rParameters.empty())
325 OUStringBuffer aParameterString(
static_cast<int>(rParameters.size() * 32));
326 aParameterString.append(
" {");
328 for (std::map<OUString, OUString>::const_iterator itr = rParameters.begin();
329 itr != rParameters.end(); ++itr)
331 if (itr != rParameters.begin())
332 aParameterString.append(
", ");
333 aParameterString.append(
"\"" + itr->first +
"\": \"" + itr->second +
"\"");
336 aParameterString.append(
"}");
338 return aParameterString.makeStringAndClear();
341const OUString& GetValueInMapWithIndex(
const std::map<OUString, OUString>& rParameters,
346 std::map<OUString, OUString>::const_iterator itr = rParameters.begin();
348 for (; itr != rParameters.end() && j < index; ++itr, ++j)
351 assert(itr != rParameters.end());
356const OUString& GetKeyInMapWithIndex(
const std::map<OUString, OUString>& rParameters,
361 std::map<OUString, OUString>::const_iterator itr = rParameters.begin();
363 for (; itr != rParameters.end() && j < index; ++itr, ++j)
366 assert(itr != rParameters.end());
374 OUString aParameterString = StringMapToOUString(rDescription.
aParameters);
379 if (rDescription.
aAction ==
"SET")
381 aLogLine =
"Set Zoom to " + GetValueInMapWithIndex(rDescription.
aParameters, 0);
383 else if (rDescription.
aAction ==
"SIDEBAR")
385 aLogLine =
"From SIDEBAR Choose " + aParameterString;
387 else if (rDescription.
aKeyWord ==
"ValueSet")
389 aLogLine =
"Choose element with position "
390 + GetValueInMapWithIndex(rDescription.
aParameters, 0) +
" in '"
391 + rDescription.
aID +
"' from '" + rDescription.
aParent +
"'";
393 else if (rDescription.
aAction ==
"SELECT" && rDescription.
aID.isEmpty())
395 aLogLine =
"Select " + aParameterString;
397 else if (rDescription.
aID ==
"writer_edit")
399 if (rDescription.
aAction ==
"GOTO")
401 aLogLine =
"GOTO page number " + GetValueInMapWithIndex(rDescription.
aParameters, 0);
403 else if (rDescription.
aAction ==
"SELECT")
405 OUString
to = GetValueInMapWithIndex(rDescription.
aParameters, 0);
407 aLogLine =
"Select from Pos " +
from +
" to Pos " +
to;
409 else if (rDescription.
aAction ==
"CREATE_TABLE")
412 aLogLine =
"Create Table with " +
size;
415 else if (rDescription.
aAction ==
"COPY")
417 aLogLine =
"Copy the Selected Text";
419 else if (rDescription.
aAction ==
"CUT")
421 aLogLine =
"Cut the Selected Text";
423 else if (rDescription.
aAction ==
"PASTE")
425 aLogLine =
"Paste in the Current Cursor Location";
427 else if (rDescription.
aAction ==
"BREAK_PAGE")
429 aLogLine =
"Insert Break Page";
432 else if (rDescription.
aID ==
"grid_window")
434 if (rDescription.
aAction ==
"SELECT")
437 if (
type ==
"CELL" ||
type ==
"RANGE")
439 aLogLine =
"Select from calc" + aParameterString;
441 else if (
type ==
"TABLE")
443 aLogLine =
"Switch to sheet number "
444 + GetValueInMapWithIndex(rDescription.
aParameters, 0);
447 else if (rDescription.
aAction ==
"LAUNCH")
449 aLogLine =
"Launch" + GetKeyInMapWithIndex(rDescription.
aParameters, 2) +
" from Col "
450 + GetValueInMapWithIndex(rDescription.
aParameters, 2) +
" and Row "
451 + GetValueInMapWithIndex(rDescription.
aParameters, 1);
453 else if (rDescription.
aAction ==
"DELETE_CONTENT")
455 aLogLine =
"Remove Content from This " + aParameterString;
457 else if (rDescription.
aAction ==
"DELETE_CELLS")
459 aLogLine =
"Delete The Cells in" + aParameterString;
461 else if (rDescription.
aAction ==
"INSERT_CELLS")
463 aLogLine =
"Insert Cell around the " + aParameterString;
465 else if (rDescription.
aAction ==
"CUT")
467 aLogLine =
"CUT the selected " + aParameterString;
469 else if (rDescription.
aAction ==
"COPY")
471 aLogLine =
"COPY the selected " + aParameterString;
473 else if (rDescription.
aAction ==
"PASTE")
475 aLogLine =
"Paste in the " + aParameterString;
477 else if (rDescription.
aAction ==
"MERGE_CELLS")
479 aLogLine =
"Merge " + aParameterString;
481 else if (rDescription.
aAction ==
"UNMERGE_CELL")
483 aLogLine =
"Delete the merged " + aParameterString;
485 else if (rDescription.
aAction ==
"Rename_Sheet")
487 aLogLine =
"Rename The Selected Tab to \""
488 + GetValueInMapWithIndex(rDescription.
aParameters, 0) +
"\"";
490 else if (rDescription.
aAction ==
"InsertTab")
492 aLogLine =
"Insert New Tab ";
494 else if (rDescription.
aAction ==
"COMMENT")
499 aLogLine =
"Open Comment";
501 else if (
type ==
"CLOSE")
503 aLogLine =
"Close Comment";
507 else if (rDescription.
aID ==
"impress_win_or_draw_win")
509 if (rDescription.
aAction ==
"Insert_New_Page_or_Slide")
513 aLogLine =
"Insert New Slide at Position "
514 + GetValueInMapWithIndex(rDescription.
aParameters, 0);
518 aLogLine =
"Insert New Page at Position "
519 + GetValueInMapWithIndex(rDescription.
aParameters, 0);
522 else if (rDescription.
aAction ==
"Delete_Slide_or_Page")
527 =
"Delete Slide number " + GetValueInMapWithIndex(rDescription.
aParameters, 0);
532 =
"Delete Page number " + GetValueInMapWithIndex(rDescription.
aParameters, 0);
535 else if (rDescription.
aAction ==
"Duplicate")
537 aLogLine =
"Duplicate The Selected Slide ";
539 else if (rDescription.
aAction ==
"RENAME")
543 aLogLine =
"Rename The Selected Slide from \""
544 + GetValueInMapWithIndex(rDescription.
aParameters, 1) +
"\" to \""
545 + GetValueInMapWithIndex(rDescription.
aParameters, 0) +
"\"";
549 aLogLine =
"Rename The Selected Page from \""
550 + GetValueInMapWithIndex(rDescription.
aParameters, 1) +
"\" to \""
551 + GetValueInMapWithIndex(rDescription.
aParameters, 0) +
"\"";
555 else if (rDescription.
aKeyWord ==
"SwEditWinUIObject")
557 if (rDescription.
aAction ==
"LEAVE")
559 aLogLine =
"Leave '" + rDescription.
aID +
"'";
561 else if (rDescription.
aAction ==
"SHOW")
563 aLogLine =
"Show '" + rDescription.
aID +
"'";
565 else if (rDescription.
aAction ==
"HIDE")
567 aLogLine =
"Hide '" + rDescription.
aID +
"'";
569 else if (rDescription.
aAction ==
"DELETE")
571 aLogLine =
"Delete '" + rDescription.
aID +
"'";
573 else if (rDescription.
aAction ==
"SETRESOLVED")
575 aLogLine =
"Resolve '" + rDescription.
aID +
"'";
578 else if (rDescription.
aParent ==
"element_selector")
580 aLogLine =
"Select element no " + rDescription.
aID +
" From " + rDescription.
aParent;
582 else if (rDescription.
aKeyWord ==
"MenuButton")
584 if (rDescription.
aAction ==
"OPENLIST")
586 aLogLine =
"Open List From " + rDescription.
aID;
588 else if (rDescription.
aAction ==
"CLOSELIST")
590 aLogLine =
"Close List From " + rDescription.
aID;
592 else if (rDescription.
aAction ==
"OPENFROMLIST")
594 aLogLine =
"Select item no " + GetValueInMapWithIndex(rDescription.
aParameters, 0)
595 +
" From List of " + rDescription.
aID;
598 else if (rDescription.
aKeyWord ==
"VerticalTab")
600 aLogLine =
"Choose Tab number " + GetValueInMapWithIndex(rDescription.
aParameters, 0)
601 +
" in '" + rDescription.
aID +
"'";
605 aLogLine = rDescription.
aKeyWord +
" Action:" + rDescription.
aAction +
" Id:"
606 + rDescription.
aID +
" Parent:" + rDescription.
aParent + aParameterString;
sal_Unicode GetCharCode() const
const vcl::KeyCode & GetKeyCode() const
void Open(const OUString &rFileName, StreamMode eOpenMode)
bool WriteLine(std::string_view rStr)
void logCommand(std::u16string_view rAction, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
void logAction(VclPtr< Control > const &xUIElement, VclEventId nEvent)
const OUString & getAppName() const
void log(std::u16string_view rString)
static UITestLogger & getInstance()
void logKeyInput(VclPtr< vcl::Window > const &xUIElement, const KeyEvent &rEvent)
void logEvent(const EventDescription &rDescription)
reference_type * get() const
Get the body.
sal_uInt16 GetCode() const
vcl::Window * GetParent() const
const OUString & get_id() const
Get the ID of the window.
sal_uInt16 GetChildCount() const
WindowType GetType() const
vcl::Window * GetChild(sal_uInt16 nChild) const
virtual FactoryFunction GetUITestFactory() const
#define SAL_CONFIGFILE(name)
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_HOME
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_PAGEDOWN
constexpr sal_uInt16 KEY_TAB
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_RIGHT
constexpr sal_uInt16 KEY_DELETE
constexpr sal_uInt16 KEY_DOWN
constexpr sal_uInt16 KEY_PAGEUP
constexpr sal_uInt16 KEY_INSERT
constexpr sal_uInt16 KEY_BACKSPACE
constexpr sal_uInt16 KEY_END
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::map< OUString, OUString > aParameters
ImplSVFrameData maFrameData
std::unique_ptr< UITestLogger > m_pUITestLogger
ImplSVData * ImplGetSVData()
WinBits const WB_SYSTEMFLOATWIN
std::unique_ptr< char[]> aBuffer