[Libreoffice-commits] core.git: include/vcl sc/source sd/source sfx2/source starmath/source svx/source sw/source vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Jul 30 22:36:04 UTC 2018


 include/vcl/uitest/eventdescription.hxx   |   18 ++++++
 include/vcl/uitest/logger.hxx             |   11 +++-
 sc/source/ui/view/gridwin.cxx             |   17 ++++++
 sc/source/ui/view/tabview3.cxx            |   33 ++++++++++++
 sd/source/ui/view/drviews1.cxx            |   19 +++++++
 sfx2/source/control/unoctitm.cxx          |    6 +-
 sfx2/source/sidebar/SidebarController.cxx |   18 ++++++
 starmath/source/ElementsDockingWindow.cxx |   22 +++++++-
 svx/source/svdraw/svdmrkv.cxx             |   22 ++++++++
 sw/source/core/crsr/crsrsh.cxx            |   19 +++++++
 sw/source/uibase/uiview/viewmdi.cxx       |   20 +++++++
 sw/source/uibase/wrtsh/select.cxx         |   23 ++++++++
 vcl/source/uitest/logger.cxx              |   81 +++++++++++++++++++++++++++++-
 13 files changed, 302 insertions(+), 7 deletions(-)

New commits:
commit 7e65a0794b7c57210779bb9a6d1f2b2e49eb86e9
Author:     Saurav Chirania <saurav.chir at gmail.com>
AuthorDate: Fri Jul 13 01:13:11 2018 +0530
Commit:     Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Tue Jul 31 00:35:42 2018 +0200

    uitest logger: log more events
    
    Logging for the following:
    
    1) Object Selection
    2) Sidebar / Deck opening
    3) Parameters of UNO commands
    4) Element Selection (Math)
    5) Set Zoom (Impress)
    6) Calc -
        a) Autofilter Launch
        b) Select Cell / Range of cells
        c) Switch table
    7) Writer -
        a) Goto page
        b) Set Zoom
    
    Change-Id: Ifc7f603f62d10cfd1062923ded68203e574aebb6
    Reviewed-on: https://gerrit.libreoffice.org/57368
    Tested-by: Jenkins
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/include/vcl/uitest/eventdescription.hxx b/include/vcl/uitest/eventdescription.hxx
new file mode 100644
index 000000000000..7c5eec65b2a6
--- /dev/null
+++ b/include/vcl/uitest/eventdescription.hxx
@@ -0,0 +1,18 @@
+/* -*- 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 <map>
+
+struct EventDescription
+{
+    OUString aKeyWord, aAction, aID, aParent;
+    std::map<OUString, OUString> aParameters;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/include/vcl/uitest/logger.hxx b/include/vcl/uitest/logger.hxx
index 997bc3be866a..18fadd77aad2 100644
--- a/include/vcl/uitest/logger.hxx
+++ b/include/vcl/uitest/logger.hxx
@@ -11,6 +11,13 @@
 
 #include <tools/stream.hxx>
 #include <vcl/ctrl.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+namespace com { namespace sun { namespace star {
+    namespace beans { struct PropertyValue; }
+} } }
+
+struct EventDescription;
 
 class UITEST_DLLPUBLIC UITestLogger
 {
@@ -24,7 +31,7 @@ public:
 
     UITestLogger();
 
-    void logCommand(const OUString& rAction);
+    void logCommand(const OUString& rAction, const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
 
     void logAction(VclPtr<Control> const & xUIElement, VclEventId nEvent);
 
@@ -32,6 +39,8 @@ public:
 
     void logKeyInput(VclPtr<vcl::Window> const & xUIElement, const KeyEvent& rEvent);
 
+    void logEvent(const EventDescription& rDescription);
+
     static UITestLogger& getInstance();
 
 };
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 9280eea07be7..6106ca423a7f 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -140,6 +140,8 @@
 #include <svx/sdrpagewindow.hxx>
 #include <svx/sdr/overlay/overlaymanager.hxx>
 #include <vcl/svapp.hxx>
+#include <vcl/uitest/logger.hxx>
+#include <vcl/uitest/eventdescription.hxx>
 #include <svx/sdr/overlay/overlayselection.hxx>
 #include <comphelper/string.hxx>
 #include <comphelper/lok.hxx>
@@ -619,6 +621,19 @@ public:
     }
 };
 
+void collectUIInformation(const OUString& aRow, const OUString& aCol)
+{
+    EventDescription aDescription;
+    aDescription.aAction = "LAUNCH";
+    aDescription.aID = "grid_window";
+    aDescription.aParameters = {{"AUTOFILTER", ""},
+        {"ROW", aRow}, {"COL", aCol}};
+    aDescription.aParent = "MainWindow";
+    aDescription.aKeyWord = "ScGridWinUIObject";
+
+    UITestLogger::getInstance().logEvent(aDescription);
+}
+
 }
 
 void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
@@ -705,6 +720,8 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
     aConfig.mbRTL = pViewData->GetDocument()->IsLayoutRTL(pViewData->GetTabNo());
     mpAutoFilterPopup->setConfig(aConfig);
     mpAutoFilterPopup->launch(aCellRect);
+
+    collectUIInformation(OUString::number(nRow), OUString::number(nCol));
 }
 
 void ScGridWindow::RefreshAutoFilterButton(const ScAddress& rPos)
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 7030f1b31cdd..fe4292c7d4e3 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -30,6 +30,8 @@
 #include <sfx2/lokhelper.hxx>
 #include <sfx2/viewfrm.hxx>
 #include <vcl/cursor.hxx>
+#include <vcl/uitest/logger.hxx>
+#include <vcl/uitest/eventdescription.hxx>
 
 #include <tabview.hxx>
 #include <tabvwsh.hxx>
@@ -326,6 +328,22 @@ void ScTabView::InvalidateAttribs()
     rBindings.Invalidate( SID_NUMBER_THOUSANDS );
 }
 
+namespace {
+
+void collectUIInformation(const std::map<OUString, OUString>& aParameters)
+{
+    EventDescription aDescription;
+    aDescription.aID = "grid_window";
+    aDescription.aAction = "SELECT";
+    aDescription.aParameters = aParameters;
+    aDescription.aParent = "MainWindow";
+    aDescription.aKeyWord = "ScGridWinUIObject";
+
+    UITestLogger::getInstance().logEvent(aDescription);
+}
+
+}
+
 // SetCursor - Cursor, set, draw, update InputWin
 // or send reference
 // Optimising breaks the functionality
@@ -361,6 +379,9 @@ void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew )
 
         CursorPosChanged();
 
+        OUString aCurrAddress = ScAddress(nPosX,nPosY,0).GetColRowString();
+        collectUIInformation({{"CELL", aCurrAddress}});
+
         if (comphelper::LibreOfficeKit::isActive())
         {
             if (nPosX > aViewData.GetMaxTiledCol() - 10 || nPosY > aViewData.GetMaxTiledRow() - 25)
@@ -430,6 +451,17 @@ void ScTabView::CheckSelectionTransfer()
 
             pScMod->SetSelectionTransfer( pNew.get() );
             pNew->CopyToSelection( GetActiveWin() );                    // may delete pOld
+
+            // Log the selection change
+            ScMarkData& rMark = aViewData.GetMarkData();
+            if (rMark.IsMarked())
+            {
+                ScRange aMarkRange;
+                rMark.GetMarkArea( aMarkRange );
+                OUString aStartAddress =  aMarkRange.aStart.GetColRowString();
+                OUString aEndAddress = aMarkRange.aEnd.GetColRowString();
+                collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}});
+            }
         }
         else if ( pOld && pOld->GetView() == this )
         {
@@ -1868,6 +1900,7 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSa
         }
 
         TabChanged(bSameTabButMoved);                                       // DrawView
+        collectUIInformation({{"TABLE", OUString::number(nTab)}});
         UpdateVisibleRange();
 
         aViewData.GetViewShell()->WindowChanged();          // if the active window has changed
diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx
index aee53381ebc9..98a39465d8e5 100644
--- a/sd/source/ui/view/drviews1.cxx
+++ b/sd/source/ui/view/drviews1.cxx
@@ -79,6 +79,8 @@
 #include <sfx2/request.hxx>
 #include <comphelper/lok.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <vcl/uitest/logger.hxx>
+#include <vcl/uitest/eventdescription.hxx>
 
 using namespace com::sun::star;
 
@@ -262,6 +264,22 @@ void DrawViewShell::SelectionHasChanged()
     GetViewShellBase().GetDrawController().FireSelectionChangeListener();
 }
 
+namespace {
+
+void collectUIInformation(const OUString& aZoom)
+{
+    EventDescription aDescription;
+    aDescription.aID = "impress_win";
+    aDescription.aParameters = {{"ZOOM", aZoom}};
+    aDescription.aAction = "SET";
+    aDescription.aKeyWord = "ImpressWindowUIObject";
+    aDescription.aParent = "MainWindow";
+
+    UITestLogger::getInstance().logEvent(aDescription);
+}
+
+}
+
 /**
  * set zoom factor
  */
@@ -274,6 +292,7 @@ void DrawViewShell::SetZoom( long nZoom )
     GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
     GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
     mpViewOverlayManager->onZoomChanged();
+    collectUIInformation(OUString::number(nZoom));
 }
 
 /**
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 2bf002844284..819d3c4cb238 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -594,13 +594,13 @@ void collectUsageInformation(const util::URL& rURL, const uno::Sequence<beans::P
     theUsageInfo::get().increment(aCommand);
 }
 
-void collectUIInformation(const util::URL& rURL)
+void collectUIInformation(const util::URL& rURL, const css::uno::Sequence< css::beans::PropertyValue >& rArgs)
 {
     static const char* pFile = std::getenv("LO_COLLECT_UIINFO");
     if (!pFile)
         return;
 
-    UITestLogger::getInstance().logCommand("CommandSent Name:" + rURL.Complete);
+    UITestLogger::getInstance().logCommand("CommandSent Name:" + rURL.Complete, rArgs);
 }
 
 }
@@ -610,7 +610,7 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
         const css::uno::Reference< css::frame::XDispatchResultListener >& rListener )
 {
     collectUsageInformation(aURL, aArgs);
-    collectUIInformation(aURL);
+    collectUIInformation(aURL,aArgs);
 
     SolarMutexGuard aGuard;
     if (
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 4f2b3e900d6a..b7b604869213 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -37,6 +37,8 @@
 #include <framework/ContextChangeEventMultiplexerTunnel.hxx>
 #include <vcl/floatwin.hxx>
 #include <vcl/fixed.hxx>
+#include <vcl/uitest/logger.hxx>
+#include <vcl/uitest/eventdescription.hxx>
 #include <splitwin.hxx>
 #include <tools/link.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
@@ -514,6 +516,21 @@ void SidebarController::UpdateConfigurations()
     }
 }
 
+namespace {
+
+void collectUIInformation(const OUString& rDeckId)
+{
+    EventDescription aDescription;
+    aDescription.aAction = "SIDEBAR";
+    aDescription.aParent = "MainWindow";
+    aDescription.aParameters = {{"PANEL", rDeckId}};
+    aDescription.aKeyWord = "CurrentApp";
+
+    UITestLogger::getInstance().logEvent(aDescription);
+}
+
+}
+
 void SidebarController::OpenThenToggleDeck (
     const OUString& rsDeckId)
 {
@@ -540,6 +557,7 @@ void SidebarController::OpenThenToggleDeck (
     SwitchToDeck(rsDeckId);
     mpTabBar->Invalidate();
     mpTabBar->HighlightDeck(rsDeckId);
+    collectUIInformation(rsDeckId);
 }
 
 void SidebarController::OpenThenSwitchToDeck (
diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx
index f3ac0899627d..e973fb438175 100644
--- a/starmath/source/ElementsDockingWindow.cxx
+++ b/starmath/source/ElementsDockingWindow.cxx
@@ -36,6 +36,8 @@
 #include <sfx2/sfxmodelfactory.hxx>
 #include <vcl/help.hxx>
 #include <vcl/settings.hxx>
+#include <vcl/uitest/logger.hxx>
+#include <vcl/uitest/eventdescription.hxx>
 
 SmElement::SmElement(std::unique_ptr<SmNode>&& pNode, const OUString& aText, const OUString& aHelpText) :
     mpNode(std::move(pNode)),
@@ -482,19 +484,37 @@ void SmElementsControl::MouseMove( const MouseEvent& rMouseEvent )
     Control::MouseMove(rMouseEvent);
 }
 
+namespace {
+
+void collectUIInformation(const OUString& aID)
+{
+    EventDescription aDescription;
+    aDescription.aID = aID;
+    aDescription.aParent = "element_selector";
+    aDescription.aAction = "SELECT";
+    aDescription.aKeyWord = "ElementUIObject";
+    UITestLogger::getInstance().logEvent(aDescription);
+}
+
+}
+
 void SmElementsControl::MouseButtonDown(const MouseEvent& rMouseEvent)
 {
     GrabFocus();
 
     if (rMouseEvent.IsLeft() && tools::Rectangle(Point(0, 0), GetOutputSizePixel()).IsInside(rMouseEvent.GetPosPixel()) && maSelectHdlLink.IsSet())
     {
-        for (std::unique_ptr<SmElement> & i : maElementList)
+        sal_uInt16 nElementCount = maElementList.size();
+
+        for (sal_uInt16 n = 0; n < nElementCount; n++)
         {
+            std::unique_ptr<SmElement> & i = maElementList[n];
             SmElement* element = i.get();
             tools::Rectangle rect(element->mBoxLocation, element->mBoxSize);
             if (rect.IsInside(rMouseEvent.GetPosPixel()))
             {
                 maSelectHdlLink.Call(*element);
+                collectUIInformation(OUString::number(n));
                 return;
             }
         }
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 56d415047b54..2198ee4df002 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -48,6 +48,8 @@
 #include <svx/sdrhittesthelper.hxx>
 #include <svx/svdocapt.hxx>
 #include <svx/svdograf.hxx>
+#include <vcl/uitest/logger.hxx>
+#include <vcl/uitest/eventdescription.hxx>
 
 #include <editeng/editdata.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
@@ -1634,6 +1636,25 @@ void SdrMarkView::MarkObj(const tools::Rectangle& rRect, bool bUnmark)
     }
 }
 
+namespace {
+
+void collectUIInformation(SdrObject* pObj)
+{
+    EventDescription aDescription;
+    aDescription.aAction = "SELECT";
+    aDescription.aParent = "MainWindow";
+    aDescription.aKeyWord = "CurrentApp";
+
+    if (!pObj->GetName().isEmpty())
+        aDescription.aParameters = {{"OBJECT", pObj->GetName()}};
+    else
+        aDescription.aParameters = {{"OBJECT", "Unnamed_Obj_" + OUString::number(pObj->GetOrdNum())}};
+
+    UITestLogger::getInstance().logEvent(aDescription);
+}
+
+}
+
 void SdrMarkView::MarkObj(SdrObject* pObj, SdrPageView* pPV, bool bUnmark, bool bImpNoSetMarkHdl)
 {
     if (pObj!=nullptr && pPV!=nullptr && IsObjMarkable(pObj, pPV)) {
@@ -1641,6 +1662,7 @@ void SdrMarkView::MarkObj(SdrObject* pObj, SdrPageView* pPV, bool bUnmark, bool
         if (!bUnmark)
         {
             GetMarkedObjectListWriteAccess().InsertEntry(SdrMark(pObj,pPV));
+            collectUIInformation(pObj);
         }
         else
         {
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index ccb5ffc84ccf..9ad23eb7a3ca 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -68,6 +68,8 @@
 #include <editeng/editview.hxx>
 #include <PostItMgr.hxx>
 #include <DocumentSettingManager.hxx>
+#include <vcl/uitest/logger.hxx>
+#include <vcl/uitest/eventdescription.hxx>
 
 using namespace com::sun::star;
 using namespace util;
@@ -1067,6 +1069,21 @@ bool SwCursorShell::SetInFrontOfLabel( bool bNew )
     return false;
 }
 
+namespace {
+
+void collectUIInformation(const OUString& aPage)
+{
+    EventDescription aDescription;
+    aDescription.aAction = "GOTO";
+    aDescription.aParameters = {{"PAGE", aPage}};
+    aDescription.aID = "writer_edit";
+    aDescription.aKeyWord = "SwEditWinUIObject";
+    aDescription.aParent = "MainWindow";
+    UITestLogger::getInstance().logEvent(aDescription);
+}
+
+}
+
 bool SwCursorShell::GotoPage( sal_uInt16 nPage )
 {
     SET_CURR_SHELL( this );
@@ -1077,6 +1094,8 @@ bool SwCursorShell::GotoPage( sal_uInt16 nPage )
                                          SwCursorSelOverFlags::ChangePos );
     if( bRet )
         UpdateCursor(SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE|SwCursorShell::READONLY);
+
+    collectUIInformation(OUString::number(nPage));
     return bRet;
 }
 
diff --git a/sw/source/uibase/uiview/viewmdi.cxx b/sw/source/uibase/uiview/viewmdi.cxx
index b3ac8c5b152b..11ee243edcd5 100644
--- a/sw/source/uibase/uiview/viewmdi.cxx
+++ b/sw/source/uibase/uiview/viewmdi.cxx
@@ -53,11 +53,29 @@
 
 #include <svx/srchdlg.hxx>
 
+#include <vcl/uitest/logger.hxx>
+#include <vcl/uitest/eventdescription.hxx>
+
 sal_uInt16  SwView::m_nMoveType = NID_PGE;
 sal_Int32 SwView::m_nActMark = 0;
 
 using namespace ::com::sun::star::uno;
 
+namespace {
+
+void collectUIInformation(const OUString& aFactor)
+{
+    EventDescription aDescription;
+    aDescription.aID = "writer_edit";
+    aDescription.aParameters = {{"ZOOM", aFactor}};
+    aDescription.aAction = "SET";
+    aDescription.aKeyWord = "SwEditWinUIObject";
+    aDescription.aParent = "MainWindow";
+    UITestLogger::getInstance().logEvent(aDescription);
+}
+
+}
+
 void SwView::SetZoom( SvxZoomType eZoomType, short nFactor, bool bViewOnly )
 {
     bool const bCursorIsVisible(m_pWrtShell->IsCursorVisible());
@@ -65,6 +83,8 @@ void SwView::SetZoom( SvxZoomType eZoomType, short nFactor, bool bViewOnly )
     // fdo#40465 force the cursor to stay in view whilst zooming
     if (bCursorIsVisible)
         m_pWrtShell->ShowCursor();
+
+    collectUIInformation(OUString::number(nFactor));
 }
 
 void SwView::SetZoom_( const Size &rEditSize, SvxZoomType eZoomType,
diff --git a/sw/source/uibase/wrtsh/select.cxx b/sw/source/uibase/wrtsh/select.cxx
index f12005e5cbab..3f4c2540f006 100644
--- a/sw/source/uibase/wrtsh/select.cxx
+++ b/sw/source/uibase/wrtsh/select.cxx
@@ -40,6 +40,8 @@
 #include <doc.hxx>
 #include <wordcountdialog.hxx>
 #include <memory>
+#include <vcl/uitest/logger.hxx>
+#include <vcl/uitest/eventdescription.hxx>
 
 namespace com { namespace sun { namespace star { namespace util {
     struct SearchOptions2;
@@ -388,6 +390,25 @@ void SwWrtShell::SttSelect()
     SwTransferable::CreateSelection( *this );
 }
 
+namespace {
+
+void collectUIInformation(SwShellCursor* pCursor)
+{
+    EventDescription aDescription;
+    OUString aSelStart = OUString::number(pCursor->Start()->nContent.GetIndex());
+    OUString aSelEnd = OUString::number(pCursor->End()->nContent.GetIndex());
+
+    aDescription.aParameters = {{"START_POS", aSelStart}, {"END_POS", aSelEnd}};
+    aDescription.aAction = "SELECT";
+    aDescription.aID = "writer_edit";
+    aDescription.aKeyWord = "SwEditWinUIObject";
+    aDescription.aParent = "MainWindow";
+
+    UITestLogger::getInstance().logEvent(aDescription);
+}
+
+}
+
 // End of a selection process.
 
 void SwWrtShell::EndSelect()
@@ -409,6 +430,8 @@ void SwWrtShell::EndSelect()
     SwWordCountWrapper *pWrdCnt = static_cast<SwWordCountWrapper*>(GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId()));
     if (pWrdCnt)
         pWrdCnt->UpdateCounts();
+
+    collectUIInformation(GetCursor_());
 }
 
 void SwWrtShell::ExtSelWrd(const Point *pPt, bool )
diff --git a/vcl/source/uitest/logger.cxx b/vcl/source/uitest/logger.cxx
index 54ac483ed627..be2648ead428 100644
--- a/vcl/source/uitest/logger.cxx
+++ b/vcl/source/uitest/logger.cxx
@@ -14,6 +14,7 @@
 #include <rtl/bootstrap.hxx>
 #include <osl/file.hxx>
 #include <vcl/uitest/uiobject.hxx>
+#include <vcl/uitest/eventdescription.hxx>
 #include <svdata.hxx>
 
 #include <memory>
@@ -35,12 +36,53 @@ UITestLogger::UITestLogger():
     }
 }
 
-void UITestLogger::logCommand(const OUString& rAction)
+void UITestLogger::logCommand(const OUString& rAction, const css::uno::Sequence< css::beans::PropertyValue >& rArgs)
 {
     if (!mbValid)
         return;
 
-    maStream.WriteLine(OUStringToOString(rAction, RTL_TEXTENCODING_UTF8));
+    OUStringBuffer aBuffer(rAction);
+    sal_Int32 nCount = rArgs.getLength();
+
+    if (nCount > 0)
+    {
+        aBuffer.append(" {");
+        for (sal_Int32 n = 0; n < nCount; n++)
+        {
+            const css::beans::PropertyValue& rProp = rArgs[n];
+
+            OUString aTypeName = rProp.Value.getValueTypeName();
+
+            if (aTypeName == "long" || aTypeName == "short")
+            {
+                sal_Int32 nValue = 0;
+                rProp.Value >>= nValue;
+                aBuffer.append("\"" + rProp.Name + "\": ");
+                aBuffer.append(OUString::number(nValue) + ", ");
+            }
+            else if (aTypeName == "unsigned long")
+            {
+                sal_uInt32 nValue = 0;
+                rProp.Value >>= nValue;
+                aBuffer.append("\"" + rProp.Name + "\": ");
+                aBuffer.append(OUString::number(nValue) + ", ");
+            }
+            else if (aTypeName == "boolean")
+            {
+                bool bValue = false;
+                rProp.Value >>= bValue;
+                aBuffer.append("\"" + rProp.Name + "\": ");
+                if (bValue)
+                    aBuffer.append("True, ");
+                else
+                    aBuffer.append("False, ");
+            }
+        }
+        aBuffer.append("}");
+    }
+
+    OUString aCommand(aBuffer.makeStringAndClear());
+    maStream.WriteLine(OUStringToOString(aCommand, RTL_TEXTENCODING_UTF8));
 }
 
 namespace {
@@ -175,6 +217,41 @@ void UITestLogger::logKeyInput(VclPtr<vcl::Window> const & xUIElement, const Key
     maStream.WriteLine(OUStringToOString(aContent, RTL_TEXTENCODING_UTF8));
 }
 
+namespace {
+
+OUString StringMapToOUString(const std::map<OUString, OUString>& rParameters)
+{
+    if (rParameters.empty())
+        return OUString("");
+
+    OUStringBuffer aParameterString = " {";
+
+    for (std::map<OUString, OUString>::const_iterator itr = rParameters.begin();
+        itr != rParameters.end(); ++itr)
+    {
+        if (itr != rParameters.begin())
+            aParameterString.append(", ");
+        aParameterString.append("\"" + itr->first + "\": \"" + itr->second + "\"");
+    }
+
+    aParameterString.append("}");
+
+    return aParameterString.makeStringAndClear();
+}
+
+}
+
+void UITestLogger::logEvent(const EventDescription& rDescription)
+{
+    OUString aParameterString = StringMapToOUString(rDescription.aParameters);
+
+    OUString aLogLine = rDescription.aKeyWord + " Action:" +
+        rDescription.aAction + " Id:" + rDescription.aID +
+        " Parent:" + rDescription.aParent + aParameterString;
+
+    log(aLogLine);
+}
+
 UITestLogger& UITestLogger::getInstance()
 {
     ImplSVData *const pSVData = ImplGetSVData();


More information about the Libreoffice-commits mailing list