2012-03-26 12:15:22 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
2012-09-27 09:38:41 +01:00
|
|
|
* This file is part of the LibreOffice project.
|
2012-03-26 12:15:22 +01:00
|
|
|
*
|
2012-09-27 09:38:41 +01:00
|
|
|
* 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/.
|
2012-03-26 12:15:22 +01:00
|
|
|
*/
|
2012-09-27 09:38:41 +01:00
|
|
|
|
2013-10-23 19:10:20 +02:00
|
|
|
#ifndef INCLUDED_VCL_BUILDER_HXX
|
|
|
|
#define INCLUDED_VCL_BUILDER_HXX
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2012-11-27 15:42:12 +00:00
|
|
|
#include <typeinfo>
|
2015-04-22 09:42:28 +02:00
|
|
|
#include <sal/log.hxx>
|
2017-07-31 17:16:27 +01:00
|
|
|
#include <unotools/resmgr.hxx>
|
2014-05-20 16:20:42 +02:00
|
|
|
#include <tools/fldunit.hxx>
|
2012-03-26 12:15:22 +01:00
|
|
|
#include <vcl/dllapi.h>
|
2019-07-15 22:19:00 +05:30
|
|
|
#include <vcl/NotebookBarAddonsMerger.hxx>
|
2012-03-26 12:15:22 +01:00
|
|
|
#include <vcl/window.hxx>
|
2015-02-27 16:29:46 +00:00
|
|
|
#include <vcl/vclptr.hxx>
|
2016-06-17 23:54:00 +02:00
|
|
|
#include <tools/wintypes.hxx>
|
|
|
|
#include <vcl/EnumContext.hxx>
|
2015-07-10 19:25:24 +02:00
|
|
|
|
|
|
|
#include <memory>
|
2012-03-27 14:20:17 +01:00
|
|
|
#include <map>
|
2012-03-26 12:15:22 +01:00
|
|
|
#include <vector>
|
2014-01-24 15:39:26 +00:00
|
|
|
#ifdef check
|
|
|
|
# //some problem with MacOSX and a check define
|
|
|
|
# undef check
|
|
|
|
#endif
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2018-02-17 21:21:32 +00:00
|
|
|
class Button;
|
2018-09-15 15:00:26 +01:00
|
|
|
class ComboBox;
|
2018-11-14 13:52:06 +00:00
|
|
|
class FormattedField;
|
2012-06-06 08:56:46 +01:00
|
|
|
class ListBox;
|
2018-02-23 09:35:08 +00:00
|
|
|
class MessageDialog;
|
2012-08-17 13:49:40 +01:00
|
|
|
class NumericFormatter;
|
2012-12-11 09:33:45 +00:00
|
|
|
class PopupMenu;
|
2018-02-17 21:21:32 +00:00
|
|
|
class SalInstanceBuilder;
|
2018-02-27 14:11:51 +00:00
|
|
|
class ScreenshotTest;
|
2012-10-06 17:14:10 +01:00
|
|
|
class ScrollBar;
|
2018-11-23 09:14:32 +00:00
|
|
|
class SvTabListBox;
|
2015-03-22 18:32:29 +09:00
|
|
|
class Slider;
|
2013-02-21 11:55:01 +00:00
|
|
|
class DateField;
|
2013-02-18 21:59:21 +00:00
|
|
|
class TimeField;
|
2013-07-30 12:12:36 +01:00
|
|
|
class VclExpander;
|
2012-11-22 12:27:36 +00:00
|
|
|
class VclMultiLineEdit;
|
2014-10-22 13:14:43 +02:00
|
|
|
namespace xmlreader { class XmlReader; }
|
2018-11-12 20:55:41 +01:00
|
|
|
namespace com { namespace sun { namespace star { namespace frame { class XFrame; } } } }
|
2012-06-06 08:56:46 +01:00
|
|
|
|
2018-06-08 11:08:27 +01:00
|
|
|
struct ComboBoxTextItem
|
|
|
|
{
|
|
|
|
OUString m_sItem;
|
|
|
|
OString m_sId;
|
|
|
|
ComboBoxTextItem(const OUString& rItem, const OString& rId)
|
|
|
|
: m_sItem(rItem)
|
|
|
|
, m_sId(rId)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-02-15 20:41:33 +00:00
|
|
|
class VCL_DLLPUBLIC VclBuilder
|
2012-03-26 12:15:22 +01:00
|
|
|
{
|
2012-06-15 12:30:19 +01:00
|
|
|
public:
|
2017-04-28 15:21:11 +01:00
|
|
|
typedef std::map<OString, OUString> stringmap;
|
2017-01-30 13:42:11 +00:00
|
|
|
typedef std::map<OString, std::pair<OString, OString>> accelmap;
|
2016-01-08 13:53:13 +11:00
|
|
|
/// These functions create a new widget with parent pParent and return it in rRet
|
2015-05-11 14:02:42 +01:00
|
|
|
typedef void (*customMakeWidget)(VclPtr<vcl::Window> &rRet, VclPtr<vcl::Window> &pParent, stringmap &rVec);
|
2014-09-28 22:33:50 +10:00
|
|
|
|
|
|
|
public:
|
2019-07-15 22:19:00 +05:30
|
|
|
VclBuilder(vcl::Window* pParent, const OUString& sUIRootDir, const OUString& sUIFile,
|
|
|
|
const OString& sID = OString(),
|
|
|
|
const css::uno::Reference<css::frame::XFrame>& rFrame
|
|
|
|
= css::uno::Reference<css::frame::XFrame>(),
|
|
|
|
bool bLegacy = true,
|
|
|
|
const NotebookBarAddonsItem& aNotebookBarAddonsItem = NotebookBarAddonsItem());
|
2017-04-28 15:21:11 +01:00
|
|
|
~VclBuilder();
|
2015-02-27 16:29:46 +00:00
|
|
|
///releases references and disposes all children.
|
|
|
|
void disposeBuilder();
|
2019-07-15 22:19:00 +05:30
|
|
|
NotebookBarAddonsItem m_pNotebookBarAddonsItem;
|
2014-09-28 22:33:50 +10:00
|
|
|
//sID must exist and be of type T
|
2015-03-09 14:29:30 +02:00
|
|
|
template <typename T> T* get(VclPtr<T>& ret, const OString& sID);
|
2014-09-28 22:33:50 +10:00
|
|
|
|
|
|
|
//sID may not exist, but must be of type T if it does
|
|
|
|
template <typename T /*= vcl::Window if we had c++11*/> T* get(const OString& sID);
|
|
|
|
|
|
|
|
vcl::Window* get_widget_root();
|
|
|
|
|
|
|
|
//sID may not exist
|
|
|
|
PopupMenu* get_menu(const OString& sID);
|
|
|
|
|
|
|
|
//release ownership of pWindow, i.e. don't delete it
|
|
|
|
void drop_ownership(const vcl::Window *pWindow);
|
|
|
|
|
|
|
|
//see m_aDeferredProperties, you need this for toplevel dialogs
|
|
|
|
//which build themselves from their ctor. The properties on
|
|
|
|
//the top level are stored in m_aDeferredProperties and need
|
|
|
|
//to be applied post ctor
|
|
|
|
void setDeferredProperties();
|
|
|
|
|
2016-06-15 17:57:39 +02:00
|
|
|
/// return UI-File name (without '.ui')
|
|
|
|
const OString& getUIFile() const
|
|
|
|
{
|
|
|
|
return m_sHelpRoot;
|
|
|
|
}
|
|
|
|
|
2018-02-11 00:01:44 +01:00
|
|
|
/// Pre-loads all modules containing UI information
|
|
|
|
static void preload();
|
|
|
|
|
2012-03-26 12:15:22 +01:00
|
|
|
private:
|
2015-10-12 15:25:41 +02:00
|
|
|
VclBuilder(const VclBuilder&) = delete;
|
|
|
|
VclBuilder& operator=(const VclBuilder&) = delete;
|
2015-02-15 20:41:33 +00:00
|
|
|
|
2018-11-14 13:50:57 +00:00
|
|
|
// owner for ListBox/ComboBox UserData
|
|
|
|
std::vector<std::unique_ptr<OUString>> m_aUserData;
|
|
|
|
|
2013-04-30 20:44:06 +01:00
|
|
|
//If the toplevel window has any properties which need to be set on it,
|
|
|
|
//but the toplevel is the owner of the builder, then its ctor
|
|
|
|
//has not been completed during the building, so properties for it
|
|
|
|
//are collected here and need to be set afterwards, e.g. during
|
|
|
|
//Show or Execute
|
2017-04-28 15:21:11 +01:00
|
|
|
stringmap m_aDeferredProperties;
|
2013-04-30 20:44:06 +01:00
|
|
|
|
2012-11-08 12:57:25 +00:00
|
|
|
struct PackingData
|
|
|
|
{
|
|
|
|
bool m_bVerticalOrient;
|
|
|
|
sal_Int32 m_nPosition;
|
2016-04-01 13:31:59 +02:00
|
|
|
PackingData(bool bVerticalOrient = false)
|
2012-11-08 12:57:25 +00:00
|
|
|
: m_bVerticalOrient(bVerticalOrient)
|
2016-04-01 13:31:59 +02:00
|
|
|
, m_nPosition(-1)
|
2012-11-08 12:57:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-04-25 11:12:55 +01:00
|
|
|
struct WinAndId
|
|
|
|
{
|
2012-10-02 22:41:14 +01:00
|
|
|
OString m_sID;
|
2015-02-27 16:29:46 +00:00
|
|
|
VclPtr<vcl::Window> m_pWindow;
|
2012-11-08 12:57:25 +00:00
|
|
|
PackingData m_aPackingData;
|
2014-09-23 11:20:40 +02:00
|
|
|
WinAndId(const OString &rId, vcl::Window *pWindow, bool bVertical)
|
2012-04-25 11:12:55 +01:00
|
|
|
: m_sID(rId)
|
|
|
|
, m_pWindow(pWindow)
|
2012-11-08 12:57:25 +00:00
|
|
|
, m_aPackingData(bVertical)
|
2012-04-25 11:12:55 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
std::vector<WinAndId> m_aChildren;
|
2012-04-30 10:19:19 +01:00
|
|
|
|
2012-12-11 09:33:45 +00:00
|
|
|
struct MenuAndId
|
|
|
|
{
|
2018-09-13 13:08:33 +02:00
|
|
|
OString const m_sID;
|
2016-06-20 15:56:35 +02:00
|
|
|
VclPtr<PopupMenu> m_pMenu;
|
|
|
|
MenuAndId(const OString &rId, PopupMenu *pMenu);
|
|
|
|
~MenuAndId();
|
2012-12-11 09:33:45 +00:00
|
|
|
};
|
|
|
|
std::vector<MenuAndId> m_aMenus;
|
|
|
|
|
2012-06-06 08:56:46 +01:00
|
|
|
struct StringPair
|
2012-04-30 10:19:19 +01:00
|
|
|
{
|
2018-09-13 13:08:33 +02:00
|
|
|
OString const m_sID;
|
|
|
|
OString const m_sValue;
|
2012-10-02 22:41:14 +01:00
|
|
|
StringPair(const OString &rId, const OString &rValue)
|
2012-04-30 10:19:19 +01:00
|
|
|
: m_sID(rId)
|
2012-06-06 08:56:46 +01:00
|
|
|
, m_sValue(rValue)
|
2012-04-30 10:19:19 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
2012-06-06 08:56:46 +01:00
|
|
|
|
2017-04-28 15:21:11 +01:00
|
|
|
struct UStringPair
|
|
|
|
{
|
|
|
|
OString m_sID;
|
|
|
|
OUString m_sValue;
|
|
|
|
UStringPair(const OString &rId, const OUString &rValue)
|
|
|
|
: m_sID(rId)
|
|
|
|
, m_sValue(rValue)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-06-06 08:56:46 +01:00
|
|
|
typedef StringPair RadioButtonGroupMap;
|
2013-01-19 17:14:21 +00:00
|
|
|
|
|
|
|
struct ButtonImageWidgetMap
|
|
|
|
{
|
2018-09-13 13:08:33 +02:00
|
|
|
OString const m_sID;
|
|
|
|
OUString const m_sValue;
|
|
|
|
bool const m_bRadio;
|
2017-04-28 15:21:11 +01:00
|
|
|
ButtonImageWidgetMap(const OString &rId, const OUString &rValue, bool bRadio)
|
2013-01-19 17:14:21 +00:00
|
|
|
: m_sID(rId)
|
|
|
|
, m_sValue(rValue)
|
|
|
|
, m_bRadio(bRadio)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-04-28 15:21:11 +01:00
|
|
|
typedef UStringPair TextBufferMap;
|
|
|
|
typedef UStringPair WidgetAdjustmentMap;
|
|
|
|
typedef UStringPair ButtonMenuMap;
|
|
|
|
typedef UStringPair MnemonicWidgetMap;
|
2012-08-23 15:38:30 +01:00
|
|
|
|
2012-12-11 14:03:18 +00:00
|
|
|
struct ComboBoxModelMap
|
|
|
|
{
|
2018-09-13 13:08:33 +02:00
|
|
|
OString const m_sID;
|
|
|
|
OUString const m_sValue;
|
|
|
|
sal_Int32 const m_nActiveId;
|
2017-04-28 15:21:11 +01:00
|
|
|
ComboBoxModelMap(const OString &rId, const OUString &rValue, sal_Int32 nActiveId)
|
2012-12-11 14:03:18 +00:00
|
|
|
: m_sID(rId)
|
|
|
|
, m_sValue(rValue)
|
|
|
|
, m_nActiveId(nActiveId)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-11-22 12:27:36 +00:00
|
|
|
struct ListStore
|
2012-06-15 12:30:19 +01:00
|
|
|
{
|
2017-04-28 15:21:11 +01:00
|
|
|
typedef std::vector<OUString> row;
|
2012-11-22 12:27:36 +00:00
|
|
|
std::vector<row> m_aEntries;
|
2012-06-15 12:30:19 +01:00
|
|
|
};
|
2014-09-28 22:33:50 +10:00
|
|
|
|
2014-03-13 08:38:29 +02:00
|
|
|
const ListStore* get_model_by_name(const OString& sID) const;
|
2018-06-13 16:31:39 +01:00
|
|
|
void mungeModel(ListBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId);
|
2018-09-15 15:00:26 +01:00
|
|
|
void mungeModel(ComboBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId);
|
2018-11-23 09:14:32 +00:00
|
|
|
void mungeModel(SvTabListBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId);
|
2012-06-15 12:30:19 +01:00
|
|
|
|
2012-11-22 12:27:36 +00:00
|
|
|
typedef stringmap TextBuffer;
|
2017-04-28 15:21:11 +01:00
|
|
|
const TextBuffer* get_buffer_by_name(const OString& sID) const;
|
2014-09-28 22:33:50 +10:00
|
|
|
|
|
|
|
static void mungeTextBuffer(VclMultiLineEdit &rTarget, const TextBuffer &rTextBuffer);
|
2012-08-23 15:38:30 +01:00
|
|
|
|
2012-11-22 12:27:36 +00:00
|
|
|
typedef stringmap Adjustment;
|
2014-09-28 22:33:50 +10:00
|
|
|
const Adjustment* get_adjustment_by_name(const OString& sID) const;
|
|
|
|
|
|
|
|
static void mungeAdjustment(NumericFormatter &rTarget, const Adjustment &rAdjustment);
|
2018-11-14 13:52:06 +00:00
|
|
|
static void mungeAdjustment(FormattedField &rTarget, const Adjustment &rAdjustment);
|
2014-09-28 22:33:50 +10:00
|
|
|
static void mungeAdjustment(DateField &rTarget, const Adjustment &rAdjustment);
|
|
|
|
static void mungeAdjustment(TimeField &rTarget, const Adjustment &rAdjustment);
|
|
|
|
static void mungeAdjustment(ScrollBar &rTarget, const Adjustment &rAdjustment);
|
2015-03-22 18:32:29 +09:00
|
|
|
static void mungeAdjustment(Slider &rTarget, const Adjustment &rAdjustment);
|
2012-06-15 12:30:19 +01:00
|
|
|
|
2012-12-20 09:18:29 +00:00
|
|
|
struct stockinfo
|
|
|
|
{
|
2017-04-28 15:21:11 +01:00
|
|
|
OUString m_sStock;
|
2012-12-20 09:18:29 +00:00
|
|
|
int m_nSize;
|
|
|
|
stockinfo() : m_nSize(4) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::map<OString, stockinfo> StockMap;
|
2012-11-22 12:27:36 +00:00
|
|
|
|
2013-01-11 10:08:20 +00:00
|
|
|
struct SizeGroup
|
|
|
|
{
|
|
|
|
std::vector<OString> m_aWidgets;
|
|
|
|
stringmap m_aProperties;
|
2015-11-25 08:42:22 +02:00
|
|
|
SizeGroup() {}
|
2013-01-11 10:08:20 +00:00
|
|
|
};
|
|
|
|
|
2017-04-28 15:21:11 +01:00
|
|
|
typedef std::map<VclPtr<vcl::Window>, stringmap> AtkMap;
|
2013-01-21 11:39:02 +00:00
|
|
|
|
2012-08-23 15:38:30 +01:00
|
|
|
struct ParserState
|
|
|
|
{
|
2017-06-11 20:56:30 +01:00
|
|
|
std::locale m_aResLocale;
|
|
|
|
|
2012-08-23 15:38:30 +01:00
|
|
|
std::vector<RadioButtonGroupMap> m_aGroupMaps;
|
2012-11-22 12:27:36 +00:00
|
|
|
|
2012-08-23 15:38:30 +01:00
|
|
|
std::vector<ComboBoxModelMap> m_aModelMaps;
|
2012-11-22 12:27:36 +00:00
|
|
|
std::map<OString, ListStore> m_aModels;
|
|
|
|
|
|
|
|
std::vector<TextBufferMap> m_aTextBufferMaps;
|
|
|
|
std::map<OString, TextBuffer> m_aTextBuffers;
|
|
|
|
|
2013-02-18 21:59:21 +00:00
|
|
|
std::vector<WidgetAdjustmentMap> m_aNumericFormatterAdjustmentMaps;
|
2018-11-14 13:52:06 +00:00
|
|
|
std::vector<WidgetAdjustmentMap> m_aFormattedFormatterAdjustmentMaps;
|
2013-02-18 21:59:21 +00:00
|
|
|
std::vector<WidgetAdjustmentMap> m_aTimeFormatterAdjustmentMaps;
|
2013-02-21 11:55:01 +00:00
|
|
|
std::vector<WidgetAdjustmentMap> m_aDateFormatterAdjustmentMaps;
|
2012-10-06 17:14:10 +01:00
|
|
|
std::vector<WidgetAdjustmentMap> m_aScrollAdjustmentMaps;
|
2015-03-22 18:32:29 +09:00
|
|
|
std::vector<WidgetAdjustmentMap> m_aSliderAdjustmentMaps;
|
|
|
|
|
2012-11-22 12:27:36 +00:00
|
|
|
std::map<OString, Adjustment> m_aAdjustments;
|
|
|
|
|
2012-10-02 22:41:14 +01:00
|
|
|
std::vector<ButtonImageWidgetMap> m_aButtonImageWidgetMaps;
|
|
|
|
StockMap m_aStockMap;
|
2012-11-22 12:27:36 +00:00
|
|
|
|
2012-12-11 09:33:45 +00:00
|
|
|
std::vector<ButtonMenuMap> m_aButtonMenuMaps;
|
|
|
|
|
2017-04-28 15:21:11 +01:00
|
|
|
std::map<VclPtr<vcl::Window>, VclPtr<vcl::Window>> m_aRedundantParentWidgets;
|
2013-01-11 10:08:20 +00:00
|
|
|
|
|
|
|
std::vector<SizeGroup> m_aSizeGroups;
|
2013-01-21 11:39:02 +00:00
|
|
|
|
|
|
|
AtkMap m_aAtkInfo;
|
2013-01-22 13:26:27 +00:00
|
|
|
|
|
|
|
std::vector<MnemonicWidgetMap> m_aMnemonicWidgetMaps;
|
2013-07-30 12:12:36 +01:00
|
|
|
|
2015-03-09 14:29:30 +02:00
|
|
|
std::vector< VclPtr<VclExpander> > m_aExpanderWidgets;
|
2014-02-06 16:45:50 +00:00
|
|
|
|
2018-02-23 09:35:08 +00:00
|
|
|
std::vector< VclPtr<MessageDialog> > m_aMessageDialogs;
|
|
|
|
|
2014-02-06 16:45:50 +00:00
|
|
|
sal_uInt16 m_nLastToolbarId;
|
|
|
|
|
2017-02-21 15:04:15 +00:00
|
|
|
sal_uInt16 m_nLastMenuItemId;
|
|
|
|
|
2015-03-09 14:29:30 +02:00
|
|
|
ParserState();
|
2012-08-23 15:38:30 +01:00
|
|
|
};
|
2012-08-07 15:27:51 +01:00
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
OString m_sID;
|
|
|
|
OString m_sHelpRoot;
|
2018-09-13 13:08:33 +02:00
|
|
|
ResHookProc const m_pStringReplace;
|
2015-03-09 14:29:30 +02:00
|
|
|
VclPtr<vcl::Window> m_pParent;
|
2014-09-28 22:33:50 +10:00
|
|
|
bool m_bToplevelHasDeferredInit;
|
|
|
|
bool m_bToplevelHasDeferredProperties;
|
|
|
|
bool m_bToplevelParentFound;
|
2018-09-13 13:08:33 +02:00
|
|
|
bool const m_bLegacy;
|
2016-03-13 11:48:47 +01:00
|
|
|
std::unique_ptr<ParserState> m_pParserState;
|
2012-08-22 21:18:52 +01:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window *get_by_name(const OString& sID);
|
2014-09-28 22:33:50 +10:00
|
|
|
void delete_by_name(const OString& sID);
|
2012-10-05 14:08:28 +01:00
|
|
|
|
|
|
|
class sortIntoBestTabTraversalOrder
|
|
|
|
{
|
|
|
|
public:
|
2014-09-28 22:33:50 +10:00
|
|
|
sortIntoBestTabTraversalOrder(VclBuilder *pBuilder)
|
|
|
|
: m_pBuilder(pBuilder) {}
|
|
|
|
|
|
|
|
bool operator()(const vcl::Window *pA, const vcl::Window *pB) const;
|
|
|
|
|
|
|
|
private:
|
2018-09-13 13:08:33 +02:00
|
|
|
VclBuilder * const m_pBuilder;
|
2012-10-05 14:08:28 +01:00
|
|
|
};
|
2013-05-30 18:25:09 +02:00
|
|
|
|
|
|
|
/// XFrame to be able to extract labels and other properties of the UNO commands (like of .uno:Bold).
|
2014-01-16 20:33:54 +00:00
|
|
|
css::uno::Reference<css::frame::XFrame> m_xFrame;
|
2013-05-30 18:25:09 +02:00
|
|
|
|
2018-02-17 21:21:32 +00:00
|
|
|
DECL_LINK(ResponseHdl, ::Button*, void);
|
2012-03-26 12:15:22 +01:00
|
|
|
private:
|
2015-04-14 10:07:27 +01:00
|
|
|
VclPtr<vcl::Window> insertObject(vcl::Window *pParent,
|
2014-09-28 22:33:50 +10:00
|
|
|
const OString &rClass, const OString &rID,
|
|
|
|
stringmap &rProps, stringmap &rPangoAttributes,
|
2014-12-19 10:53:31 +01:00
|
|
|
stringmap &rAtkProps);
|
2012-12-14 14:25:29 +00:00
|
|
|
|
2015-04-14 10:07:27 +01:00
|
|
|
VclPtr<vcl::Window> makeObject(vcl::Window *pParent,
|
2014-09-28 22:33:50 +10:00
|
|
|
const OString &rClass, const OString &rID,
|
2014-12-19 10:53:31 +01:00
|
|
|
stringmap &rVec);
|
2012-10-25 14:46:59 +01:00
|
|
|
|
2017-04-28 15:21:11 +01:00
|
|
|
void connectNumericFormatterAdjustment(const OString &id, const OUString &rAdjustment);
|
2018-11-14 13:52:06 +00:00
|
|
|
void connectFormattedFormatterAdjustment(const OString &id, const OUString &rAdjustment);
|
2017-04-28 15:21:11 +01:00
|
|
|
void connectTimeFormatterAdjustment(const OString &id, const OUString &rAdjustment);
|
|
|
|
void connectDateFormatterAdjustment(const OString &id, const OUString &rAdjustment);
|
2013-02-18 21:59:21 +00:00
|
|
|
|
2018-01-22 15:52:16 +02:00
|
|
|
void extractGroup(const OString &id, stringmap &rVec);
|
|
|
|
void extractModel(const OString &id, stringmap &rVec);
|
|
|
|
void extractBuffer(const OString &id, stringmap &rVec);
|
2015-04-01 16:23:59 +02:00
|
|
|
static bool extractAdjustmentToMap(const OString &id, stringmap &rVec, std::vector<WidgetAdjustmentMap>& rAdjustmentMap);
|
2018-01-22 15:52:16 +02:00
|
|
|
void extractButtonImage(const OString &id, stringmap &rMap, bool bRadio);
|
|
|
|
void extractStock(const OString &id, stringmap &rMap);
|
2014-09-28 22:33:50 +10:00
|
|
|
void extractMnemonicWidget(const OString &id, stringmap &rMap);
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
void handleChild(vcl::Window *pParent, xmlreader::XmlReader &reader);
|
2015-04-14 10:07:27 +01:00
|
|
|
VclPtr<vcl::Window> handleObject(vcl::Window *pParent, xmlreader::XmlReader &reader);
|
2014-09-28 22:33:50 +10:00
|
|
|
void handlePacking(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader);
|
2016-07-01 15:53:46 +02:00
|
|
|
static std::vector<vcl::EnumContext::Context> handleStyle(xmlreader::XmlReader &reader, int &nPriority);
|
|
|
|
static OString getStyleClass(xmlreader::XmlReader &reader);
|
2014-09-28 22:33:50 +10:00
|
|
|
void applyPackingProperty(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader);
|
2017-10-27 09:03:20 +02:00
|
|
|
void collectProperty(xmlreader::XmlReader &reader, stringmap &rVec) const;
|
2015-04-01 08:33:09 +02:00
|
|
|
static void collectPangoAttribute(xmlreader::XmlReader &reader, stringmap &rMap);
|
2018-03-21 15:30:00 +01:00
|
|
|
static void collectAtkRelationAttribute(xmlreader::XmlReader &reader, stringmap &rMap);
|
|
|
|
static void collectAtkRoleAttribute(xmlreader::XmlReader &reader, stringmap &rMap);
|
2017-01-30 13:42:11 +00:00
|
|
|
static void collectAccelerator(xmlreader::XmlReader &reader, accelmap &rMap);
|
2014-09-28 22:33:50 +10:00
|
|
|
|
|
|
|
void insertMenuObject(
|
|
|
|
PopupMenu *pParent,
|
2017-02-21 14:21:31 +00:00
|
|
|
PopupMenu *pSubMenu,
|
2014-09-28 22:33:50 +10:00
|
|
|
const OString &rClass,
|
|
|
|
const OString &rID,
|
|
|
|
stringmap &rProps,
|
2017-01-30 13:42:11 +00:00
|
|
|
accelmap &rAccels);
|
2014-09-28 22:33:50 +10:00
|
|
|
|
|
|
|
void handleMenuChild(PopupMenu *pParent, xmlreader::XmlReader &reader);
|
|
|
|
void handleMenuObject(PopupMenu *pParent, xmlreader::XmlReader &reader);
|
|
|
|
|
2018-11-05 21:01:23 +00:00
|
|
|
void handleListStore(xmlreader::XmlReader &reader, const OString &rID, const OString &rClass);
|
2017-07-27 12:52:01 +02:00
|
|
|
void handleRow(xmlreader::XmlReader &reader, const OString &rID);
|
2014-09-28 22:33:50 +10:00
|
|
|
void handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &reader);
|
|
|
|
void handleMenu(xmlreader::XmlReader &reader, const OString &rID);
|
2018-06-08 11:08:27 +01:00
|
|
|
std::vector<ComboBoxTextItem> handleItems(xmlreader::XmlReader &reader) const;
|
2012-06-06 08:56:46 +01:00
|
|
|
|
2017-07-27 12:52:01 +02:00
|
|
|
void handleSizeGroup(xmlreader::XmlReader &reader);
|
2013-01-11 10:08:20 +00:00
|
|
|
|
2017-07-27 12:52:01 +02:00
|
|
|
void handleAtkObject(xmlreader::XmlReader &reader, vcl::Window *pWindow);
|
2013-01-21 11:12:49 +00:00
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
void handleActionWidget(xmlreader::XmlReader &reader);
|
2013-04-30 20:44:06 +01:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
PackingData get_window_packing_data(const vcl::Window *pWindow) const;
|
2014-09-28 22:33:50 +10:00
|
|
|
void set_window_packing_position(const vcl::Window *pWindow, sal_Int32 nPosition);
|
2012-08-15 11:19:06 +01:00
|
|
|
|
2015-04-01 08:33:09 +02:00
|
|
|
static vcl::Window* prepareWidgetOwnScrolling(vcl::Window *pParent, WinBits &rWinStyle);
|
2014-09-28 22:33:50 +10:00
|
|
|
void cleanupWidgetOwnScrolling(vcl::Window *pScrollParent, vcl::Window *pWindow, stringmap &rMap);
|
2013-01-10 10:12:13 +00:00
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
void set_response(const OString& sID, short nResponse);
|
2017-08-01 17:31:28 +01:00
|
|
|
|
|
|
|
OString get_by_window(const vcl::Window *pWindow) const;
|
|
|
|
void delete_by_window(vcl::Window *pWindow);
|
2012-03-26 12:15:22 +01:00
|
|
|
};
|
|
|
|
|
2017-08-02 10:12:55 +01:00
|
|
|
namespace BuilderUtils
|
|
|
|
{
|
|
|
|
//apply the properties of rProps to pWindow
|
|
|
|
VCL_DLLPUBLIC void set_properties(vcl::Window *pWindow, const VclBuilder::stringmap &rProps);
|
|
|
|
|
|
|
|
//Convert _ gtk markup to ~ vcl markup
|
|
|
|
VCL_DLLPUBLIC OUString convertMnemonicMarkup(const OUString &rIn);
|
|
|
|
|
|
|
|
VCL_DLLPUBLIC OUString extractCustomProperty(VclBuilder::stringmap &rMap);
|
|
|
|
VCL_DLLPUBLIC FieldUnit detectUnit(OUString const&);
|
|
|
|
|
|
|
|
VCL_DLLPUBLIC bool extractDropdown(VclBuilder::stringmap &rMap);
|
|
|
|
|
|
|
|
//add a default value of 25 width-chars to a map if width-chars not set
|
|
|
|
VCL_DLLPUBLIC void ensureDefaultWidthChars(VclBuilder::stringmap &rMap);
|
|
|
|
|
|
|
|
//Helpers to retrofit all the existing code to the builder
|
|
|
|
VCL_DLLPUBLIC void reorderWithinParent(std::vector< vcl::Window*>& rChilds, bool bIsButtonBox);
|
|
|
|
VCL_DLLPUBLIC void reorderWithinParent(vcl::Window &rWindow, sal_uInt16 nNewPosition);
|
2018-03-21 15:30:00 +01:00
|
|
|
|
|
|
|
//Convert an accessibility role name to accessibility role number
|
|
|
|
VCL_DLLPUBLIC sal_Int16 getRoleFromName(const OString& roleName);
|
2017-08-02 10:12:55 +01:00
|
|
|
}
|
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
template <typename T>
|
2015-03-09 14:29:30 +02:00
|
|
|
inline T* VclBuilder::get(VclPtr<T>& ret, const OString& sID)
|
2014-09-28 22:33:50 +10:00
|
|
|
{
|
|
|
|
vcl::Window *w = get_by_name(sID);
|
2017-05-26 10:58:42 +02:00
|
|
|
SAL_WARN_IF(!w, "vcl.layout", "widget \"" << sID << "\" not found in .ui");
|
2014-09-28 22:33:50 +10:00
|
|
|
SAL_WARN_IF(!dynamic_cast<T*>(w),
|
2017-05-26 10:58:42 +02:00
|
|
|
"vcl.layout", ".ui widget \"" << sID << "\" needs to correspond to vcl type " << typeid(T).name());
|
2014-11-06 21:07:21 +11:00
|
|
|
assert(w);
|
|
|
|
assert(dynamic_cast<T*>(w));
|
2014-09-28 22:33:50 +10:00
|
|
|
ret = static_cast<T*>(w);
|
2015-03-09 14:29:30 +02:00
|
|
|
return ret.get();
|
2014-09-28 22:33:50 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
//sID may not exist, but must be of type T if it does
|
|
|
|
template <typename T /*= vcl::Window if we had c++11*/>
|
|
|
|
inline T* VclBuilder::get(const OString& sID)
|
|
|
|
{
|
|
|
|
vcl::Window *w = get_by_name(sID);
|
|
|
|
SAL_WARN_IF(w && !dynamic_cast<T*>(w),
|
2017-05-26 10:58:42 +02:00
|
|
|
"vcl.layout", ".ui widget \"" << sID << "\" needs to correspond to vcl type " << typeid(T).name());
|
2014-09-28 22:33:50 +10:00
|
|
|
assert(!w || dynamic_cast<T*>(w));
|
|
|
|
return static_cast<T*>(w);
|
|
|
|
}
|
|
|
|
|
2015-07-13 09:55:03 +02:00
|
|
|
|
2012-12-04 17:11:52 +00:00
|
|
|
//helper baseclass to ease retro fitting dialogs/tabpages that load a resource
|
2012-06-13 14:24:01 +01:00
|
|
|
//to load a .ui file instead
|
2012-08-15 13:19:58 +01:00
|
|
|
//
|
|
|
|
//vcl requires the Window Children of a Parent Window to be destroyed before
|
|
|
|
//the Parent Window. VclBuilderContainer owns the VclBuilder which owns the
|
|
|
|
//Children Window. So the VclBuilderContainer dtor must be called before
|
|
|
|
//the Parent Window dtor.
|
|
|
|
//
|
|
|
|
//i.e. class Dialog : public SystemWindow, public VclBuilderContainer
|
|
|
|
//not class Dialog : public VclBuilderContainer, public SystemWindow
|
2015-02-27 16:29:46 +00:00
|
|
|
//
|
|
|
|
//With the new 'dispose' framework, it is necessary to force the builder
|
|
|
|
//dispose before the Window dispose; so a Dialog::dispose() method would
|
|
|
|
//finish: disposeBuilder(); SystemWindow::dispose() to capture this ordering.
|
2012-06-13 14:24:01 +01:00
|
|
|
|
|
|
|
class VCL_DLLPUBLIC VclBuilderContainer
|
|
|
|
{
|
|
|
|
public:
|
2014-09-28 22:33:50 +10:00
|
|
|
VclBuilderContainer();
|
|
|
|
virtual ~VclBuilderContainer();
|
2015-02-27 16:29:46 +00:00
|
|
|
void disposeBuilder();
|
2014-09-28 22:33:50 +10:00
|
|
|
|
2012-10-02 22:41:14 +01:00
|
|
|
static OUString getUIRootDir();
|
2015-11-10 10:28:29 +01:00
|
|
|
bool hasBuilder() const { return m_pUIBuilder != nullptr; }
|
2014-09-28 22:33:50 +10:00
|
|
|
|
2015-03-09 14:29:30 +02:00
|
|
|
template <typename T> T* get(VclPtr<T>& ret, const OString& sID)
|
2012-08-30 00:56:52 +01:00
|
|
|
{
|
|
|
|
return m_pUIBuilder->get<T>(ret, sID);
|
|
|
|
}
|
2014-09-23 11:20:40 +02:00
|
|
|
template <typename T /*= vcl::Window if we had c++11*/> T* get(const OString & sID)
|
2012-08-30 00:56:52 +01:00
|
|
|
{
|
|
|
|
return m_pUIBuilder->get<T>(sID);
|
|
|
|
}
|
2013-04-30 20:44:06 +01:00
|
|
|
void setDeferredProperties()
|
|
|
|
{
|
|
|
|
if (!m_pUIBuilder)
|
|
|
|
return;
|
|
|
|
m_pUIBuilder->setDeferredProperties();
|
|
|
|
}
|
2016-06-15 17:57:39 +02:00
|
|
|
OString getUIFile() const
|
|
|
|
{
|
|
|
|
if (m_pUIBuilder)
|
|
|
|
{
|
|
|
|
return m_pUIBuilder->getUIFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
return OString();
|
|
|
|
}
|
2014-09-28 22:33:50 +10:00
|
|
|
|
|
|
|
protected:
|
2017-01-11 09:48:18 +02:00
|
|
|
std::unique_ptr<VclBuilder> m_pUIBuilder;
|
2018-02-17 21:21:32 +00:00
|
|
|
|
|
|
|
friend class ::SalInstanceBuilder;
|
2018-02-27 14:11:51 +00:00
|
|
|
friend class ::ScreenshotTest;
|
2012-06-13 14:24:01 +01:00
|
|
|
};
|
|
|
|
|
2012-09-19 22:01:49 +01:00
|
|
|
/*
|
|
|
|
* @return true if rValue is "True", "true", "1", etc.
|
|
|
|
*/
|
2017-04-28 15:21:11 +01:00
|
|
|
bool VCL_DLLPUBLIC toBool(const OUString &rValue);
|
2012-06-13 14:24:01 +01:00
|
|
|
|
2012-03-26 12:15:22 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|