2020-05-21 09:24:31 +02:00
|
|
|
/* -*- 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/.
|
|
|
|
*/
|
|
|
|
|
2020-06-20 16:01:07 +01:00
|
|
|
#include <jsdialog/jsdialogbuilder.hxx>
|
2020-02-18 15:41:56 +01:00
|
|
|
#include <sal/log.hxx>
|
|
|
|
#include <comphelper/lok.hxx>
|
Missing include
Building on Windows with PCH disabled:
[CXX] vcl/jsdialog/jsdialogbuilder.cxx
C:\lo\src\core\include\rtl/ref.hxx(113): error C2027: use of undefined type 'TabPage'
C:\lo\src\core\include\vcl/tabctrl.hxx(33): note: see declaration of 'TabPage'
C:\lo\src\core\include\rtl/ref.hxx(111): note: while compiling class template member function 'rtl::Reference<reference_type>::~Reference(void)'
with
[
reference_type=TabPage
]
C:/lo/src/core/vcl/jsdialog/jsdialogbuilder.cxx(207): note: see reference to function template instantiation 'rtl::Reference<reference_type>::~Reference(void)'
being compiled
with
[
reference_type=TabPage
]
C:\lo\src\core\include\vcl/vclptr.hxx(64): note: see reference to class template instantiation 'rtl::Reference<reference_type>' being compiled
with
[
reference_type=TabPage
]
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1425~1.286\Include\utility(289): note: see reference to class template instantiation 'VclPtr<TabPage>' being co
mpiled
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1425~1.286\Include\utility(290): note: see reference to class template instantiation 'std::pair<VclPtr<TabPage>
,VclPtr<VclGrid>>' being compiled
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1425~1.286\Include\xtree(330): note: see reference to class template instantiation 'std::pair<const rtl::OStrin
g,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>' being compiled
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1425~1.286\Include\xtree(752): note: see reference to class template instantiation 'std::_Tree_node<std::pair<c
onst rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>,std::_Default_allocator_traits<_Alloc>::void_pointer>' being compiled
with
[
_Alloc=std::allocator<std::pair<const rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>>
]
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1425~1.286\Include\xtree(1189): note: see reference to function template instantiation 'void std::_Tree_val<std
::_Tree_simple_types<std::pair<const rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>>>::_Erase_head<std::allocator<std::_Tree_node<std::pair<const rtl:
:OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>,std::_Default_allocator_traits<_Alloc>::void_pointer>>>(_Alnode &) noexcept' being compiled
with
[
_Alloc=std::allocator<std::pair<const rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>>,
_Alnode=std::allocator<std::_Tree_node<std::pair<const rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>,std::_Default_allocator_traits<std::allocator<st
d::pair<const rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>>>::void_pointer>>
]
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1425~1.286\Include\xtree(1189): note: see reference to function template instantiation 'void std::_Tree_val<std
::_Tree_simple_types<std::pair<const rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>>>::_Erase_head<std::allocator<std::_Tree_node<std::pair<const rtl:
:OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>,std::_Default_allocator_traits<_Alloc>::void_pointer>>>(_Alnode &) noexcept' being compiled
with
[
_Alloc=std::allocator<std::pair<const rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>>,
_Alnode=std::allocator<std::_Tree_node<std::pair<const rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>,std::_Default_allocator_traits<std::allocator<st
d::pair<const rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>>>::void_pointer>>
]
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1425~1.286\Include\xtree(1187): note: while compiling class template member function 'std::_Tree<std::_Tmap_tra
its<_Kty,_Ty,_Pr,_Alloc,false>>::~_Tree(void) noexcept'
with
[
_Kty=rtl::OString,
_Ty=std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>,
_Pr=std::less<rtl::OString>,
_Alloc=std::allocator<std::pair<const rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>>
]
C:\lo\src\core\vcl\inc\jsdialog/jsdialogbuilder.hxx(131): note: see reference to function template instantiation 'std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_All
oc,false>>::~_Tree(void) noexcept' being compiled
with
[
_Kty=rtl::OString,
_Ty=std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>,
_Pr=std::less<rtl::OString>,
_Alloc=std::allocator<std::pair<const rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>>
]
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1425~1.286\Include\map(75): note: see reference to class template instantiation 'std::_Tree<std::_Tmap_traits<_
Kty,_Ty,_Pr,_Alloc,false>>' being compiled
with
[
_Kty=rtl::OString,
_Ty=std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>,
_Pr=std::less<rtl::OString>,
_Alloc=std::allocator<std::pair<const rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>>
]
C:\lo\src\core\vcl\inc\salvtables.hxx(1032): note: see reference to class template instantiation 'std::map<rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid
>>,std::less<rtl::OString>,std::allocator<std::pair<const rtl::OString,std::pair<VclPtr<TabPage>,VclPtr<VclGrid>>>>>' being compiled
make[1]: *** [C:/lo/src/core/solenv/gbuild/LinkTarget.mk:303: C:/lo/src/build/workdir/CxxObject/vcl/jsdialog/jsdialogbuilder.o] Error 2
Change-Id: Id67ce45b1652a2915508963adb65e1e1f5c51dcd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94464
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-05-20 23:41:38 +02:00
|
|
|
#include <vcl/tabpage.hxx>
|
2020-07-12 17:22:54 +01:00
|
|
|
#include <vcl/toolkit/button.hxx>
|
2020-02-18 15:41:56 +01:00
|
|
|
#include <vcl/toolkit/dialog.hxx>
|
|
|
|
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
|
2020-03-05 12:24:27 +01:00
|
|
|
#include <vcl/toolkit/combobox.hxx>
|
2020-03-17 14:50:39 +01:00
|
|
|
#include <messagedialog.hxx>
|
2020-06-22 16:45:03 +02:00
|
|
|
#include <tools/json_writer.hxx>
|
|
|
|
#include <o3tl/deleter.hxx>
|
|
|
|
#include <memory>
|
2020-06-16 14:07:32 +02:00
|
|
|
#include <vcl/toolbox.hxx>
|
2020-08-18 15:55:27 +01:00
|
|
|
#include <vcl/toolkit/vclmedit.hxx>
|
2020-07-01 21:24:37 +02:00
|
|
|
#include <boost/property_tree/json_parser.hpp>
|
2020-10-30 10:51:08 +01:00
|
|
|
#include <vcl/toolkit/treelistentry.hxx>
|
|
|
|
#include <vcl/jsdialog/executor.hxx>
|
2020-02-18 15:41:56 +01:00
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow,
|
|
|
|
VclPtr<vcl::Window> aContentWindow, std::string sTypeOfJSON)
|
2020-03-31 15:42:28 +02:00
|
|
|
: Idle("JSDialog notify")
|
2020-10-21 15:45:19 +02:00
|
|
|
, m_aNotifierWindow(aNotifierWindow)
|
|
|
|
, m_aContentWindow(aContentWindow)
|
|
|
|
, m_sTypeOfJSON(sTypeOfJSON)
|
2020-03-31 15:42:28 +02:00
|
|
|
, m_LastNotificationMessage()
|
2020-07-07 13:15:31 +02:00
|
|
|
, m_bForce(false)
|
2020-02-24 18:35:18 +01:00
|
|
|
{
|
2020-03-31 15:42:28 +02:00
|
|
|
SetPriority(TaskPriority::POST_PAINT);
|
|
|
|
}
|
|
|
|
|
2020-07-07 13:15:31 +02:00
|
|
|
void JSDialogNotifyIdle::ForceUpdate() { m_bForce = true; }
|
|
|
|
|
2020-03-31 15:42:28 +02:00
|
|
|
void JSDialogNotifyIdle::Invoke()
|
|
|
|
{
|
2020-10-30 10:51:08 +01:00
|
|
|
if (!m_aNotifierWindow)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const vcl::ILibreOfficeKitNotifier* pNotifier = m_aNotifierWindow->GetLOKNotifier();
|
|
|
|
if (pNotifier)
|
2020-03-31 15:42:28 +02:00
|
|
|
{
|
2020-10-30 10:51:08 +01:00
|
|
|
tools::JsonWriter aJsonWriter;
|
|
|
|
m_aContentWindow->DumpAsPropertyTree(aJsonWriter);
|
|
|
|
aJsonWriter.put("id", m_aNotifierWindow->GetLOKWindowId());
|
|
|
|
aJsonWriter.put("jsontype", m_sTypeOfJSON);
|
2020-02-24 18:35:18 +01:00
|
|
|
|
2020-10-30 10:51:08 +01:00
|
|
|
if (m_sTypeOfJSON == "autofilter")
|
2020-03-31 15:42:28 +02:00
|
|
|
{
|
2020-10-30 10:51:08 +01:00
|
|
|
vcl::Window* pWindow = m_aContentWindow.get();
|
|
|
|
DockingWindow* pDockingWIndow = dynamic_cast<DockingWindow*>(pWindow);
|
|
|
|
while (pWindow && !pDockingWIndow)
|
|
|
|
{
|
|
|
|
pWindow = pWindow->GetParent();
|
|
|
|
pDockingWIndow = dynamic_cast<DockingWindow*>(pWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pDockingWIndow)
|
2020-03-31 15:42:28 +02:00
|
|
|
{
|
2020-10-30 10:51:08 +01:00
|
|
|
Point aPos = pDockingWIndow->GetFloatingPos();
|
|
|
|
aJsonWriter.put("posx", aPos.getX());
|
|
|
|
aJsonWriter.put("posy", aPos.getY());
|
2020-03-31 15:42:28 +02:00
|
|
|
}
|
|
|
|
}
|
2020-10-30 10:51:08 +01:00
|
|
|
|
|
|
|
if (m_bForce || !aJsonWriter.isDataEquals(m_LastNotificationMessage))
|
|
|
|
{
|
|
|
|
m_bForce = false;
|
|
|
|
m_LastNotificationMessage = aJsonWriter.extractAsStdString();
|
|
|
|
pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG,
|
|
|
|
m_LastNotificationMessage.c_str());
|
|
|
|
}
|
2020-02-24 18:35:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-07 13:15:31 +02:00
|
|
|
void JSDialogSender::notifyDialogState(bool bForce)
|
|
|
|
{
|
|
|
|
if (bForce)
|
|
|
|
mpIdleNotify->ForceUpdate();
|
|
|
|
mpIdleNotify->Start();
|
|
|
|
}
|
2020-03-31 15:42:28 +02:00
|
|
|
|
2020-06-27 16:14:11 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
vcl::Window* extract_sal_widget(weld::Widget* pParent)
|
|
|
|
{
|
|
|
|
SalInstanceWidget* pInstanceWidget = dynamic_cast<SalInstanceWidget*>(pParent);
|
|
|
|
return pInstanceWidget ? pInstanceWidget->getWidget() : nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 15:41:56 +01:00
|
|
|
JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot,
|
|
|
|
const OUString& rUIFile)
|
2020-06-27 16:14:11 +01:00
|
|
|
: SalInstanceBuilder(extract_sal_widget(pParent), rUIRoot, rUIFile)
|
2020-03-05 12:18:38 +01:00
|
|
|
, m_nWindowId(0)
|
2020-03-09 14:11:06 +01:00
|
|
|
, m_aParentDialog(nullptr)
|
2020-10-21 15:45:19 +02:00
|
|
|
, m_aContentWindow(nullptr)
|
|
|
|
, m_sTypeOfJSON("dialog")
|
2020-03-09 14:11:06 +01:00
|
|
|
, m_bHasTopLevelDialog(false)
|
2020-06-25 11:24:15 +02:00
|
|
|
, m_bIsNotebookbar(false)
|
2020-02-18 15:41:56 +01:00
|
|
|
{
|
2020-03-09 14:11:06 +01:00
|
|
|
vcl::Window* pRoot = m_xBuilder->get_widget_root();
|
|
|
|
if (pRoot && pRoot->GetParent())
|
|
|
|
{
|
|
|
|
m_aParentDialog = pRoot->GetParent()->GetParentWithLOKNotifier();
|
2020-06-15 19:03:09 +02:00
|
|
|
if (m_aParentDialog)
|
|
|
|
m_nWindowId = m_aParentDialog->GetLOKWindowId();
|
|
|
|
InsertWindowToMap(m_nWindowId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
// used for notebookbar
|
2020-06-15 19:03:09 +02:00
|
|
|
JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot,
|
|
|
|
const OUString& rUIFile,
|
2020-06-23 12:49:17 +02:00
|
|
|
const css::uno::Reference<css::frame::XFrame>& rFrame,
|
|
|
|
sal_uInt64 nWindowId)
|
2020-06-15 19:03:09 +02:00
|
|
|
: SalInstanceBuilder(pParent, rUIRoot, rUIFile, rFrame)
|
|
|
|
, m_nWindowId(0)
|
|
|
|
, m_aParentDialog(nullptr)
|
2020-10-21 15:45:19 +02:00
|
|
|
, m_aContentWindow(nullptr)
|
|
|
|
, m_sTypeOfJSON("notebookbar")
|
2020-06-15 19:03:09 +02:00
|
|
|
, m_bHasTopLevelDialog(false)
|
2020-06-25 11:24:15 +02:00
|
|
|
, m_bIsNotebookbar(false)
|
2020-06-15 19:03:09 +02:00
|
|
|
{
|
|
|
|
vcl::Window* pRoot = m_xBuilder->get_widget_root();
|
|
|
|
if (pRoot && pRoot->GetParent())
|
|
|
|
{
|
|
|
|
m_aParentDialog = pRoot->GetParent()->GetParentWithLOKNotifier();
|
|
|
|
if (m_aParentDialog)
|
|
|
|
m_nWindowId = m_aParentDialog->GetLOKWindowId();
|
2020-06-23 12:49:17 +02:00
|
|
|
if (!m_nWindowId && nWindowId)
|
2020-06-25 11:24:15 +02:00
|
|
|
{
|
2020-06-23 12:49:17 +02:00
|
|
|
m_nWindowId = nWindowId;
|
2020-06-25 11:24:15 +02:00
|
|
|
m_bIsNotebookbar = true;
|
|
|
|
}
|
2020-03-09 14:11:06 +01:00
|
|
|
InsertWindowToMap(m_nWindowId);
|
|
|
|
}
|
2020-02-18 15:41:56 +01:00
|
|
|
}
|
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
// used for autofilter dropdown
|
|
|
|
JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot,
|
|
|
|
const OUString& rUIFile)
|
|
|
|
: SalInstanceBuilder(pParent, rUIRoot, rUIFile)
|
|
|
|
, m_nWindowId(0)
|
|
|
|
, m_aParentDialog(nullptr)
|
|
|
|
, m_aContentWindow(nullptr)
|
|
|
|
, m_sTypeOfJSON("autofilter")
|
|
|
|
, m_bHasTopLevelDialog(false)
|
|
|
|
, m_bIsNotebookbar(false)
|
|
|
|
{
|
|
|
|
vcl::Window* pRoot = m_xBuilder->get_widget_root();
|
|
|
|
m_aContentWindow = pParent;
|
|
|
|
if (pRoot && pRoot->GetParent())
|
|
|
|
{
|
|
|
|
m_aParentDialog = pRoot->GetParent()->GetParentWithLOKNotifier();
|
|
|
|
if (m_aParentDialog)
|
|
|
|
m_nWindowId = m_aParentDialog->GetLOKWindowId();
|
|
|
|
InsertWindowToMap(m_nWindowId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
JSInstanceBuilder* JSInstanceBuilder::CreateDialogBuilder(weld::Widget* pParent,
|
|
|
|
const OUString& rUIRoot,
|
|
|
|
const OUString& rUIFile)
|
|
|
|
{
|
|
|
|
return new JSInstanceBuilder(pParent, rUIRoot, rUIFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
JSInstanceBuilder* JSInstanceBuilder::CreateNotebookbarBuilder(
|
|
|
|
vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
|
|
|
|
const css::uno::Reference<css::frame::XFrame>& rFrame, sal_uInt64 nWindowId)
|
|
|
|
{
|
|
|
|
return new JSInstanceBuilder(pParent, rUIRoot, rUIFile, rFrame, nWindowId);
|
|
|
|
}
|
|
|
|
|
|
|
|
JSInstanceBuilder* JSInstanceBuilder::CreateAutofilterWindowBuilder(vcl::Window* pParent,
|
|
|
|
const OUString& rUIRoot,
|
|
|
|
const OUString& rUIFile)
|
|
|
|
{
|
|
|
|
return new JSInstanceBuilder(pParent, rUIRoot, rUIFile);
|
|
|
|
}
|
|
|
|
|
2020-06-25 11:24:15 +02:00
|
|
|
JSInstanceBuilder::~JSInstanceBuilder()
|
|
|
|
{
|
|
|
|
if (m_nWindowId && (m_bHasTopLevelDialog || m_bIsNotebookbar))
|
|
|
|
GetLOKWeldWidgetsMap().erase(m_nWindowId);
|
|
|
|
}
|
2020-03-05 12:18:38 +01:00
|
|
|
|
2020-06-23 12:49:17 +02:00
|
|
|
std::map<sal_uInt64, WidgetMap>& JSInstanceBuilder::GetLOKWeldWidgetsMap()
|
2020-03-05 12:18:38 +01:00
|
|
|
{
|
2020-03-06 11:11:57 +01:00
|
|
|
// Map to remember the LOKWindowId <-> weld widgets binding.
|
2020-06-23 12:49:17 +02:00
|
|
|
static std::map<sal_uInt64, WidgetMap> s_aLOKWeldBuildersMap;
|
2020-03-05 12:18:38 +01:00
|
|
|
|
|
|
|
return s_aLOKWeldBuildersMap;
|
|
|
|
}
|
|
|
|
|
2020-07-02 11:01:54 +02:00
|
|
|
weld::Widget* JSInstanceBuilder::FindWeldWidgetsMap(sal_uInt64 nWindowId, const OString& rWidget)
|
2020-03-05 12:18:38 +01:00
|
|
|
{
|
2020-07-02 11:01:54 +02:00
|
|
|
const auto it = GetLOKWeldWidgetsMap().find(nWindowId);
|
2020-03-09 14:11:06 +01:00
|
|
|
|
2020-07-02 11:01:54 +02:00
|
|
|
if (it != GetLOKWeldWidgetsMap().end())
|
2020-03-06 11:11:57 +01:00
|
|
|
{
|
|
|
|
auto widgetIt = it->second.find(rWidget);
|
|
|
|
if (widgetIt != it->second.end())
|
|
|
|
return widgetIt->second;
|
|
|
|
}
|
2020-03-05 12:18:38 +01:00
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-06-23 12:49:17 +02:00
|
|
|
void JSInstanceBuilder::InsertWindowToMap(sal_uInt64 nWindowId)
|
2020-03-09 14:11:06 +01:00
|
|
|
{
|
|
|
|
WidgetMap map;
|
|
|
|
auto it = GetLOKWeldWidgetsMap().find(nWindowId);
|
|
|
|
if (it == GetLOKWeldWidgetsMap().end())
|
2020-06-23 12:49:17 +02:00
|
|
|
GetLOKWeldWidgetsMap().insert(std::map<sal_uInt64, WidgetMap>::value_type(nWindowId, map));
|
2020-03-09 14:11:06 +01:00
|
|
|
}
|
|
|
|
|
2020-03-06 11:11:57 +01:00
|
|
|
void JSInstanceBuilder::RememberWidget(const OString& id, weld::Widget* pWidget)
|
|
|
|
{
|
|
|
|
auto it = GetLOKWeldWidgetsMap().find(m_nWindowId);
|
|
|
|
if (it != GetLOKWeldWidgetsMap().end())
|
|
|
|
{
|
2020-06-25 11:24:15 +02:00
|
|
|
it->second.erase(id);
|
2020-03-06 11:11:57 +01:00
|
|
|
it->second.insert(WidgetMap::value_type(id, pWidget));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
VclPtr<vcl::Window>& JSInstanceBuilder::GetContentWindow()
|
|
|
|
{
|
|
|
|
if (m_aContentWindow)
|
|
|
|
return m_aContentWindow;
|
|
|
|
else
|
|
|
|
return m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
VclPtr<vcl::Window>& JSInstanceBuilder::GetNotifierWindow()
|
|
|
|
{
|
|
|
|
return m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog;
|
|
|
|
}
|
|
|
|
|
2020-10-06 09:45:54 +01:00
|
|
|
std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id)
|
2020-02-18 15:41:56 +01:00
|
|
|
{
|
|
|
|
::Dialog* pDialog = m_xBuilder->get<::Dialog>(id);
|
2020-03-05 12:18:38 +01:00
|
|
|
m_nWindowId = pDialog->GetLOKWindowId();
|
|
|
|
|
2020-03-09 14:11:06 +01:00
|
|
|
InsertWindowToMap(m_nWindowId);
|
2020-03-05 12:18:38 +01:00
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
std::unique_ptr<weld::Dialog> pRet(pDialog ? new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel,
|
|
|
|
pDialog, this, false, m_sTypeOfJSON)
|
|
|
|
: nullptr);
|
2020-10-06 09:45:54 +01:00
|
|
|
if (pDialog)
|
2020-02-18 15:41:56 +01:00
|
|
|
{
|
|
|
|
assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
|
|
|
|
m_aOwnedToplevel.set(pDialog);
|
|
|
|
m_xBuilder->drop_ownership(pDialog);
|
2020-03-09 14:11:06 +01:00
|
|
|
m_bHasTopLevelDialog = true;
|
2020-02-18 15:41:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier();
|
|
|
|
if (pNotifier)
|
|
|
|
{
|
2020-06-22 16:45:03 +02:00
|
|
|
tools::JsonWriter aJsonWriter;
|
|
|
|
m_aOwnedToplevel->DumpAsPropertyTree(aJsonWriter);
|
|
|
|
aJsonWriter.put("id", m_aOwnedToplevel->GetLOKWindowId());
|
|
|
|
pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, aJsonWriter.extractData());
|
2020-02-18 15:41:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2020-10-06 09:45:54 +01:00
|
|
|
std::unique_ptr<weld::Label> JSInstanceBuilder::weld_label(const OString& id)
|
2020-02-18 15:41:56 +01:00
|
|
|
{
|
|
|
|
::FixedText* pLabel = m_xBuilder->get<FixedText>(id);
|
2020-10-21 15:45:19 +02:00
|
|
|
auto pWeldWidget = std::make_unique<JSLabel>(GetNotifierWindow(), GetContentWindow(), pLabel,
|
|
|
|
this, false, m_sTypeOfJSON);
|
2020-03-09 14:11:06 +01:00
|
|
|
|
|
|
|
if (pWeldWidget)
|
|
|
|
RememberWidget(id, pWeldWidget.get());
|
2020-03-06 11:11:57 +01:00
|
|
|
|
|
|
|
return pWeldWidget;
|
2020-02-18 15:41:56 +01:00
|
|
|
}
|
|
|
|
|
2020-10-06 09:45:54 +01:00
|
|
|
std::unique_ptr<weld::Button> JSInstanceBuilder::weld_button(const OString& id)
|
2020-02-28 15:10:24 +01:00
|
|
|
{
|
|
|
|
::Button* pButton = m_xBuilder->get<::Button>(id);
|
2020-10-21 15:45:19 +02:00
|
|
|
auto pWeldWidget = pButton ? std::make_unique<JSButton>(GetNotifierWindow(), GetContentWindow(),
|
|
|
|
pButton, this, false, m_sTypeOfJSON)
|
2020-03-09 14:11:06 +01:00
|
|
|
: nullptr;
|
|
|
|
|
|
|
|
if (pWeldWidget)
|
|
|
|
RememberWidget(id, pWeldWidget.get());
|
2020-03-06 11:11:57 +01:00
|
|
|
|
|
|
|
return pWeldWidget;
|
2020-02-28 15:10:24 +01:00
|
|
|
}
|
|
|
|
|
2020-10-06 09:45:54 +01:00
|
|
|
std::unique_ptr<weld::Entry> JSInstanceBuilder::weld_entry(const OString& id)
|
2020-02-24 18:35:18 +01:00
|
|
|
{
|
|
|
|
Edit* pEntry = m_xBuilder->get<Edit>(id);
|
2020-10-21 15:45:19 +02:00
|
|
|
auto pWeldWidget = pEntry ? std::make_unique<JSEntry>(GetNotifierWindow(), GetContentWindow(),
|
|
|
|
pEntry, this, false, m_sTypeOfJSON)
|
2020-03-09 14:11:06 +01:00
|
|
|
: nullptr;
|
|
|
|
|
|
|
|
if (pWeldWidget)
|
|
|
|
RememberWidget(id, pWeldWidget.get());
|
2020-03-06 11:11:57 +01:00
|
|
|
|
|
|
|
return pWeldWidget;
|
2020-02-24 18:35:18 +01:00
|
|
|
}
|
|
|
|
|
2020-10-06 09:45:54 +01:00
|
|
|
std::unique_ptr<weld::ComboBox> JSInstanceBuilder::weld_combo_box(const OString& id)
|
2020-02-25 13:03:34 +01:00
|
|
|
{
|
|
|
|
vcl::Window* pWidget = m_xBuilder->get<vcl::Window>(id);
|
|
|
|
::ComboBox* pComboBox = dynamic_cast<::ComboBox*>(pWidget);
|
2020-03-06 11:11:57 +01:00
|
|
|
std::unique_ptr<weld::ComboBox> pWeldWidget;
|
|
|
|
|
2020-02-25 13:03:34 +01:00
|
|
|
if (pComboBox)
|
2020-03-06 11:11:57 +01:00
|
|
|
{
|
2020-10-21 15:45:19 +02:00
|
|
|
pWeldWidget = std::make_unique<JSComboBox>(GetNotifierWindow(), GetContentWindow(),
|
|
|
|
pComboBox, this, false, m_sTypeOfJSON);
|
2020-03-06 11:11:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ListBox* pListBox = dynamic_cast<ListBox*>(pWidget);
|
2020-10-21 15:45:19 +02:00
|
|
|
pWeldWidget = pListBox
|
|
|
|
? std::make_unique<JSListBox>(GetNotifierWindow(), GetContentWindow(),
|
|
|
|
pListBox, this, false, m_sTypeOfJSON)
|
|
|
|
: nullptr;
|
2020-03-06 11:11:57 +01:00
|
|
|
}
|
|
|
|
|
2020-03-09 14:11:06 +01:00
|
|
|
if (pWeldWidget)
|
|
|
|
RememberWidget(id, pWeldWidget.get());
|
|
|
|
|
2020-03-06 11:11:57 +01:00
|
|
|
return pWeldWidget;
|
2020-02-25 13:03:34 +01:00
|
|
|
}
|
|
|
|
|
2020-10-06 09:45:54 +01:00
|
|
|
std::unique_ptr<weld::Notebook> JSInstanceBuilder::weld_notebook(const OString& id)
|
2020-03-04 16:05:10 +01:00
|
|
|
{
|
|
|
|
TabControl* pNotebook = m_xBuilder->get<TabControl>(id);
|
2020-10-21 15:45:19 +02:00
|
|
|
auto pWeldWidget = pNotebook
|
|
|
|
? std::make_unique<JSNotebook>(GetNotifierWindow(), GetContentWindow(),
|
|
|
|
pNotebook, this, false, m_sTypeOfJSON)
|
|
|
|
: nullptr;
|
2020-03-06 11:11:57 +01:00
|
|
|
|
2020-03-09 14:11:06 +01:00
|
|
|
if (pWeldWidget)
|
|
|
|
RememberWidget(id, pWeldWidget.get());
|
|
|
|
|
2020-03-06 11:11:57 +01:00
|
|
|
return pWeldWidget;
|
2020-03-04 16:05:10 +01:00
|
|
|
}
|
|
|
|
|
2020-10-06 09:45:54 +01:00
|
|
|
std::unique_ptr<weld::SpinButton> JSInstanceBuilder::weld_spin_button(const OString& id)
|
2020-03-10 17:10:38 +01:00
|
|
|
{
|
|
|
|
FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id);
|
2020-10-21 15:45:19 +02:00
|
|
|
auto pWeldWidget = pSpinButton
|
|
|
|
? std::make_unique<JSSpinButton>(GetNotifierWindow(), GetContentWindow(),
|
|
|
|
pSpinButton, this, false, m_sTypeOfJSON)
|
|
|
|
: nullptr;
|
2020-03-10 17:10:38 +01:00
|
|
|
|
|
|
|
if (pWeldWidget)
|
|
|
|
RememberWidget(id, pWeldWidget.get());
|
|
|
|
|
|
|
|
return pWeldWidget;
|
|
|
|
}
|
|
|
|
|
2020-10-06 09:45:54 +01:00
|
|
|
std::unique_ptr<weld::CheckButton> JSInstanceBuilder::weld_check_button(const OString& id)
|
2020-03-10 17:10:38 +01:00
|
|
|
{
|
|
|
|
CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id);
|
2020-10-21 15:45:19 +02:00
|
|
|
auto pWeldWidget
|
|
|
|
= pCheckButton ? std::make_unique<JSCheckButton>(GetNotifierWindow(), GetContentWindow(),
|
|
|
|
pCheckButton, this, false, m_sTypeOfJSON)
|
|
|
|
: nullptr;
|
2020-03-10 17:10:38 +01:00
|
|
|
|
|
|
|
if (pWeldWidget)
|
|
|
|
RememberWidget(id, pWeldWidget.get());
|
|
|
|
|
|
|
|
return pWeldWidget;
|
|
|
|
}
|
|
|
|
|
2020-06-15 19:03:09 +02:00
|
|
|
std::unique_ptr<weld::DrawingArea>
|
|
|
|
JSInstanceBuilder::weld_drawing_area(const OString& id, const a11yref& rA11yImpl,
|
2020-10-06 09:45:54 +01:00
|
|
|
FactoryFunction pUITestFactoryFunction, void* pUserData)
|
2020-06-15 19:03:09 +02:00
|
|
|
{
|
|
|
|
VclDrawingArea* pArea = m_xBuilder->get<VclDrawingArea>(id);
|
2020-10-06 09:45:54 +01:00
|
|
|
auto pWeldWidget = pArea ? std::make_unique<JSDrawingArea>(
|
2020-10-21 15:45:19 +02:00
|
|
|
GetNotifierWindow(), GetContentWindow(), pArea, this, rA11yImpl,
|
|
|
|
pUITestFactoryFunction, pUserData, m_sTypeOfJSON)
|
2020-10-06 09:45:54 +01:00
|
|
|
: nullptr;
|
2020-06-15 19:03:09 +02:00
|
|
|
|
|
|
|
if (pWeldWidget)
|
|
|
|
RememberWidget(id, pWeldWidget.get());
|
|
|
|
|
|
|
|
return pWeldWidget;
|
|
|
|
}
|
|
|
|
|
2020-10-06 09:45:54 +01:00
|
|
|
std::unique_ptr<weld::Toolbar> JSInstanceBuilder::weld_toolbar(const OString& id)
|
2020-06-16 14:07:32 +02:00
|
|
|
{
|
|
|
|
ToolBox* pToolBox = m_xBuilder->get<ToolBox>(id);
|
2020-10-21 15:45:19 +02:00
|
|
|
auto pWeldWidget = pToolBox
|
|
|
|
? std::make_unique<JSToolbar>(GetNotifierWindow(), GetContentWindow(),
|
|
|
|
pToolBox, this, false, m_sTypeOfJSON)
|
|
|
|
: nullptr;
|
2020-06-16 14:07:32 +02:00
|
|
|
|
|
|
|
if (pWeldWidget)
|
|
|
|
RememberWidget(id, pWeldWidget.get());
|
|
|
|
|
|
|
|
return pWeldWidget;
|
|
|
|
}
|
|
|
|
|
2020-10-06 09:45:54 +01:00
|
|
|
std::unique_ptr<weld::TextView> JSInstanceBuilder::weld_text_view(const OString& id)
|
2020-07-02 14:44:24 +02:00
|
|
|
{
|
|
|
|
VclMultiLineEdit* pTextView = m_xBuilder->get<VclMultiLineEdit>(id);
|
2020-10-21 15:45:19 +02:00
|
|
|
auto pWeldWidget = pTextView
|
|
|
|
? std::make_unique<JSTextView>(GetNotifierWindow(), GetContentWindow(),
|
|
|
|
pTextView, this, false, m_sTypeOfJSON)
|
|
|
|
: nullptr;
|
2020-07-02 14:44:24 +02:00
|
|
|
|
|
|
|
if (pWeldWidget)
|
|
|
|
RememberWidget(id, pWeldWidget.get());
|
|
|
|
|
|
|
|
return pWeldWidget;
|
|
|
|
}
|
|
|
|
|
2020-10-30 10:51:08 +01:00
|
|
|
std::unique_ptr<weld::TreeView> JSInstanceBuilder::weld_tree_view(const OString& id)
|
|
|
|
{
|
|
|
|
SvTabListBox* pTreeView = m_xBuilder->get<SvTabListBox>(id);
|
|
|
|
auto pWeldWidget = pTreeView
|
|
|
|
? std::make_unique<JSTreeView>(GetNotifierWindow(), GetContentWindow(),
|
|
|
|
pTreeView, this, false, m_sTypeOfJSON)
|
|
|
|
: nullptr;
|
|
|
|
|
|
|
|
if (pWeldWidget)
|
|
|
|
RememberWidget(id, pWeldWidget.get());
|
|
|
|
|
|
|
|
return pWeldWidget;
|
|
|
|
}
|
|
|
|
|
2020-03-17 14:50:39 +01:00
|
|
|
weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent,
|
|
|
|
VclMessageType eMessageType,
|
|
|
|
VclButtonsType eButtonType,
|
|
|
|
const OUString& rPrimaryMessage)
|
|
|
|
{
|
|
|
|
SalInstanceWidget* pParentInstance = dynamic_cast<SalInstanceWidget*>(pParent);
|
|
|
|
SystemWindow* pParentWidget = pParentInstance ? pParentInstance->getSystemWindow() : nullptr;
|
|
|
|
VclPtrInstance<::MessageDialog> xMessageDialog(pParentWidget, rPrimaryMessage, eMessageType,
|
|
|
|
eButtonType);
|
|
|
|
|
|
|
|
const vcl::ILibreOfficeKitNotifier* pNotifier = xMessageDialog->GetLOKNotifier();
|
|
|
|
if (pNotifier)
|
|
|
|
{
|
2020-06-22 16:45:03 +02:00
|
|
|
tools::JsonWriter aJsonWriter;
|
|
|
|
xMessageDialog->DumpAsPropertyTree(aJsonWriter);
|
|
|
|
aJsonWriter.put("id", xMessageDialog->GetLOKWindowId());
|
2020-10-21 15:45:19 +02:00
|
|
|
aJsonWriter.put("jsontype", "dialog");
|
2020-06-22 16:45:03 +02:00
|
|
|
std::unique_ptr<char[], o3tl::free_delete> message(aJsonWriter.extractData());
|
|
|
|
pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.get());
|
2020-03-17 14:50:39 +01:00
|
|
|
}
|
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
return new JSMessageDialog(xMessageDialog, xMessageDialog, nullptr, true);
|
2020-03-17 14:50:39 +01:00
|
|
|
}
|
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSDialog::JSDialog(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
|
|
|
|
::Dialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
|
|
|
|
std::string sTypeOfJSON)
|
|
|
|
: JSWidget<SalInstanceDialog, ::Dialog>(aNotifierWindow, aContentWindow, pDialog, pBuilder,
|
|
|
|
bTakeOwnership, sTypeOfJSON)
|
2020-03-18 09:46:03 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSDialog::collapse(weld::Widget* pEdit, weld::Widget* pButton)
|
|
|
|
{
|
|
|
|
SalInstanceDialog::collapse(pEdit, pButton);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSDialog::undo_collapse()
|
|
|
|
{
|
|
|
|
SalInstanceDialog::undo_collapse();
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSLabel::JSLabel(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
|
|
|
|
FixedText* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
|
|
|
|
std::string sTypeOfJSON)
|
|
|
|
: JSWidget<SalInstanceLabel, FixedText>(aNotifierWindow, aContentWindow, pLabel, pBuilder,
|
|
|
|
bTakeOwnership, sTypeOfJSON)
|
2020-02-18 15:41:56 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSLabel::set_label(const OUString& rText)
|
|
|
|
{
|
|
|
|
SalInstanceLabel::set_label(rText);
|
2020-02-24 18:35:18 +01:00
|
|
|
notifyDialogState();
|
2020-02-18 15:41:56 +01:00
|
|
|
};
|
2020-02-24 18:35:18 +01:00
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSButton::JSButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
|
|
|
|
::Button* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
|
|
|
|
std::string sTypeOfJSON)
|
|
|
|
: JSWidget<SalInstanceButton, ::Button>(aNotifierWindow, aContentWindow, pButton, pBuilder,
|
|
|
|
bTakeOwnership, sTypeOfJSON)
|
2020-02-28 15:10:24 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSEntry::JSEntry(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
|
|
|
|
::Edit* pEntry, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
|
|
|
|
std::string sTypeOfJSON)
|
|
|
|
: JSWidget<SalInstanceEntry, ::Edit>(aNotifierWindow, aContentWindow, pEntry, pBuilder,
|
|
|
|
bTakeOwnership, sTypeOfJSON)
|
2020-02-24 18:35:18 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSEntry::set_text(const OUString& rText)
|
|
|
|
{
|
|
|
|
SalInstanceEntry::set_text(rText);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
2020-02-25 13:03:34 +01:00
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSListBox::JSListBox(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
|
|
|
|
::ListBox* pListBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
|
|
|
|
std::string sTypeOfJSON)
|
|
|
|
: JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox>(aNotifierWindow, aContentWindow, pListBox,
|
|
|
|
pBuilder, bTakeOwnership, sTypeOfJSON)
|
2020-02-25 13:03:34 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSListBox::insert(int pos, const OUString& rStr, const OUString* pId,
|
|
|
|
const OUString* pIconName, VirtualDevice* pImageSurface)
|
|
|
|
{
|
|
|
|
SalInstanceComboBoxWithoutEdit::insert(pos, rStr, pId, pIconName, pImageSurface);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSListBox::remove(int pos)
|
|
|
|
{
|
|
|
|
SalInstanceComboBoxWithoutEdit::remove(pos);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
2020-03-09 14:11:06 +01:00
|
|
|
void JSListBox::set_active(int pos)
|
|
|
|
{
|
|
|
|
SalInstanceComboBoxWithoutEdit::set_active(pos);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSComboBox::JSComboBox(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
|
|
|
|
::ComboBox* pComboBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
|
|
|
|
std::string sTypeOfJSON)
|
|
|
|
: JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox>(aNotifierWindow, aContentWindow, pComboBox,
|
|
|
|
pBuilder, bTakeOwnership, sTypeOfJSON)
|
2020-02-25 13:03:34 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSComboBox::insert(int pos, const OUString& rStr, const OUString* pId,
|
|
|
|
const OUString* pIconName, VirtualDevice* pImageSurface)
|
|
|
|
{
|
|
|
|
SalInstanceComboBoxWithEdit::insert(pos, rStr, pId, pIconName, pImageSurface);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSComboBox::remove(int pos)
|
|
|
|
{
|
|
|
|
SalInstanceComboBoxWithEdit::remove(pos);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSComboBox::set_entry_text(const OUString& rText)
|
|
|
|
{
|
|
|
|
SalInstanceComboBoxWithEdit::set_entry_text(rText);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
2020-03-04 16:05:10 +01:00
|
|
|
|
2020-03-05 14:42:44 +01:00
|
|
|
void JSComboBox::set_active(int pos)
|
|
|
|
{
|
|
|
|
SalInstanceComboBoxWithEdit::set_active(pos);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSNotebook::JSNotebook(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
|
|
|
|
::TabControl* pControl, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
|
|
|
|
std::string sTypeOfJSON)
|
|
|
|
: JSWidget<SalInstanceNotebook, ::TabControl>(aNotifierWindow, aContentWindow, pControl,
|
|
|
|
pBuilder, bTakeOwnership, sTypeOfJSON)
|
2020-03-04 16:05:10 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSNotebook::set_current_page(int nPage)
|
|
|
|
{
|
2020-07-07 13:15:31 +02:00
|
|
|
bool bForce = false;
|
|
|
|
int nCurrent = get_current_page();
|
|
|
|
if (nCurrent == nPage)
|
|
|
|
bForce = true;
|
|
|
|
|
2020-03-04 16:05:10 +01:00
|
|
|
SalInstanceNotebook::set_current_page(nPage);
|
2020-07-07 13:15:31 +02:00
|
|
|
notifyDialogState(bForce);
|
2020-03-04 16:05:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void JSNotebook::set_current_page(const OString& rIdent)
|
|
|
|
{
|
2020-07-07 13:15:31 +02:00
|
|
|
bool bForce = false;
|
|
|
|
OString sCurrent = get_current_page_ident();
|
|
|
|
if (sCurrent == rIdent)
|
|
|
|
bForce = true;
|
|
|
|
|
2020-03-04 16:05:10 +01:00
|
|
|
SalInstanceNotebook::set_current_page(rIdent);
|
2020-07-07 13:15:31 +02:00
|
|
|
notifyDialogState(bForce);
|
2020-03-04 16:05:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void JSNotebook::remove_page(const OString& rIdent)
|
|
|
|
{
|
|
|
|
SalInstanceNotebook::remove_page(rIdent);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSNotebook::insert_page(const OString& rIdent, const OUString& rLabel, int nPos)
|
|
|
|
{
|
|
|
|
SalInstanceNotebook::insert_page(rIdent, rLabel, nPos);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
2020-03-17 14:50:39 +01:00
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSSpinButton::JSSpinButton(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
|
|
|
|
::FormattedField* pSpin, SalInstanceBuilder* pBuilder,
|
|
|
|
bool bTakeOwnership, std::string sTypeOfJSON)
|
|
|
|
: JSWidget<SalInstanceSpinButton, ::FormattedField>(aNotifierWindow, aContentWindow, pSpin,
|
|
|
|
pBuilder, bTakeOwnership, sTypeOfJSON)
|
2020-03-10 17:10:38 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSSpinButton::set_value(int value)
|
|
|
|
{
|
|
|
|
SalInstanceSpinButton::set_value(value);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, VclPtr<vcl::Window> aContentWindow,
|
|
|
|
SalInstanceBuilder* pBuilder, bool bTakeOwnership)
|
2020-03-17 14:50:39 +01:00
|
|
|
: SalInstanceMessageDialog(pDialog, pBuilder, bTakeOwnership)
|
2020-10-21 15:45:19 +02:00
|
|
|
, JSDialogSender(m_xMessageDialog, aContentWindow, "dialog")
|
2020-03-17 14:50:39 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSMessageDialog::set_primary_text(const OUString& rText)
|
|
|
|
{
|
|
|
|
SalInstanceMessageDialog::set_primary_text(rText);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSMessageDialog::set_secondary_text(const OUString& rText)
|
|
|
|
{
|
|
|
|
SalInstanceMessageDialog::set_secondary_text(rText);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
2020-03-10 17:10:38 +01:00
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSCheckButton::JSCheckButton(VclPtr<vcl::Window> aNotifierWindow,
|
|
|
|
VclPtr<vcl::Window> aContentWindow, ::CheckBox* pCheckBox,
|
|
|
|
SalInstanceBuilder* pBuilder, bool bTakeOwnership,
|
|
|
|
std::string sTypeOfJSON)
|
|
|
|
: JSWidget<SalInstanceCheckButton, ::CheckBox>(aNotifierWindow, aContentWindow, pCheckBox,
|
|
|
|
pBuilder, bTakeOwnership, sTypeOfJSON)
|
2020-03-10 17:10:38 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSCheckButton::set_active(bool active)
|
|
|
|
{
|
|
|
|
SalInstanceCheckButton::set_active(active);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
2020-05-21 09:24:31 +02:00
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSDrawingArea::JSDrawingArea(VclPtr<vcl::Window> aNotifierWindow,
|
|
|
|
VclPtr<vcl::Window> aContentWindow, VclDrawingArea* pDrawingArea,
|
2020-06-15 19:03:09 +02:00
|
|
|
SalInstanceBuilder* pBuilder, const a11yref& rAlly,
|
2020-10-21 15:45:19 +02:00
|
|
|
FactoryFunction pUITestFactoryFunction, void* pUserData,
|
|
|
|
std::string sTypeOfJSON)
|
2020-06-15 19:03:09 +02:00
|
|
|
: SalInstanceDrawingArea(pDrawingArea, pBuilder, rAlly, pUITestFactoryFunction, pUserData,
|
2020-10-06 09:45:54 +01:00
|
|
|
false)
|
2020-10-21 15:45:19 +02:00
|
|
|
, JSDialogSender(aNotifierWindow, aContentWindow, sTypeOfJSON)
|
2020-06-15 19:03:09 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSDrawingArea::queue_draw()
|
|
|
|
{
|
|
|
|
SalInstanceDrawingArea::queue_draw();
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSDrawingArea::queue_draw_area(int x, int y, int width, int height)
|
|
|
|
{
|
|
|
|
SalInstanceDrawingArea::queue_draw_area(x, y, width, height);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSToolbar::JSToolbar(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
|
|
|
|
::ToolBox* pToolbox, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
|
|
|
|
std::string sTypeOfJSON)
|
|
|
|
: JSWidget<SalInstanceToolbar, ::ToolBox>(aNotifierWindow, aContentWindow, pToolbox, pBuilder,
|
|
|
|
bTakeOwnership, sTypeOfJSON)
|
2020-06-16 14:07:32 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSToolbar::signal_clicked(const OString& rIdent)
|
|
|
|
{
|
|
|
|
SalInstanceToolbar::signal_clicked(rIdent);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:45:19 +02:00
|
|
|
JSTextView::JSTextView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
|
|
|
|
::VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder,
|
|
|
|
bool bTakeOwnership, std::string sTypeOfJSON)
|
|
|
|
: JSWidget<SalInstanceTextView, ::VclMultiLineEdit>(aNotifierWindow, aContentWindow, pTextView,
|
|
|
|
pBuilder, bTakeOwnership, sTypeOfJSON)
|
2020-07-02 14:44:24 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSTextView::set_text(const OUString& rText)
|
|
|
|
{
|
|
|
|
SalInstanceTextView::set_text(rText);
|
|
|
|
notifyDialogState();
|
|
|
|
}
|
|
|
|
|
2020-10-30 10:51:08 +01:00
|
|
|
JSTreeView::JSTreeView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
|
|
|
|
::SvTabListBox* pTreeView, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
|
|
|
|
std::string sTypeOfJSON)
|
|
|
|
: JSWidget<SalInstanceTreeView, ::SvTabListBox>(aNotifierWindow, aContentWindow, pTreeView,
|
|
|
|
pBuilder, bTakeOwnership, sTypeOfJSON)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSTreeView::set_toggle(int pos, TriState eState, int col)
|
|
|
|
{
|
|
|
|
SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, 0);
|
|
|
|
|
|
|
|
while (pEntry && pos--)
|
|
|
|
pEntry = m_xTreeView->Next(pEntry);
|
|
|
|
|
|
|
|
if (pEntry)
|
|
|
|
SalInstanceTreeView::set_toggle(pEntry, eState, col);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSTreeView::select(int pos)
|
|
|
|
{
|
|
|
|
assert(m_xTreeView->IsUpdateMode() && "don't select when frozen");
|
|
|
|
disable_notify_events();
|
|
|
|
if (pos == -1 || (pos == 0 && n_children() == 0))
|
|
|
|
m_xTreeView->SelectAll(false);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, 0);
|
|
|
|
|
|
|
|
while (pEntry && pos--)
|
|
|
|
pEntry = m_xTreeView->Next(pEntry);
|
|
|
|
|
|
|
|
if (pEntry)
|
|
|
|
{
|
|
|
|
m_xTreeView->Select(pEntry, true);
|
|
|
|
m_xTreeView->MakeVisible(pEntry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
enable_notify_events();
|
|
|
|
}
|
|
|
|
|
2020-05-21 09:24:31 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|