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>
|
2013-04-30 14:55:14 +01:00
|
|
|
#include <osl/module.hxx>
|
2013-10-22 15:58:57 +03:00
|
|
|
#include <tools/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>
|
|
|
|
#include <vcl/window.hxx>
|
2015-02-27 16:29:46 +00:00
|
|
|
#include <vcl/vclptr.hxx>
|
2012-03-27 14:20:17 +01:00
|
|
|
#include <map>
|
2012-10-10 23:57:22 +01:00
|
|
|
#include <set>
|
2012-06-07 15:11:02 +01:00
|
|
|
#include <stack>
|
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
|
2013-04-30 14:55:14 +01:00
|
|
|
#include <boost/ptr_container/ptr_map.hpp>
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2013-05-30 18:25:09 +02:00
|
|
|
#include <com/sun/star/frame/XFrame.hpp>
|
2014-09-22 11:45:37 +02:00
|
|
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
2013-05-30 18:25:09 +02:00
|
|
|
|
2012-06-06 08:56:46 +01:00
|
|
|
class ListBox;
|
2012-08-17 13:49:40 +01:00
|
|
|
class NumericFormatter;
|
2012-12-11 09:33:45 +00:00
|
|
|
class PopupMenu;
|
2012-10-06 17:14:10 +01:00
|
|
|
class ScrollBar;
|
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; }
|
2012-06-06 08:56:46 +01:00
|
|
|
|
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:
|
2012-10-02 22:41:14 +01:00
|
|
|
typedef std::map<OString, OString> stringmap;
|
2014-09-23 11:20:40 +02:00
|
|
|
typedef vcl::Window* (*customMakeWidget)(vcl::Window *pParent, stringmap &rVec);
|
2014-09-28 22:33:50 +10:00
|
|
|
|
|
|
|
public:
|
|
|
|
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>());
|
|
|
|
~VclBuilder();
|
|
|
|
|
2015-02-27 16:29:46 +00:00
|
|
|
///releases references and disposes all children.
|
|
|
|
void disposeBuilder();
|
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
//sID must exist and be of type T
|
|
|
|
template <typename T> T* get(T*& ret, const OString& sID);
|
|
|
|
|
|
|
|
//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();
|
|
|
|
|
|
|
|
PopupMenu* get_menu(PopupMenu*& ret, const OString& sID);
|
|
|
|
|
|
|
|
//sID may not exist
|
|
|
|
PopupMenu* get_menu(const OString& sID);
|
|
|
|
|
|
|
|
//given an sID return the response value for that widget
|
|
|
|
short get_response(const vcl::Window *pWindow) const;
|
|
|
|
|
|
|
|
OString get_by_window(const vcl::Window *pWindow) const;
|
|
|
|
void delete_by_window(const vcl::Window *pWindow);
|
|
|
|
|
|
|
|
//release ownership of pWindow, i.e. don't delete it
|
|
|
|
void drop_ownership(const vcl::Window *pWindow);
|
|
|
|
|
|
|
|
//apply the properties of rProps to pWindow
|
|
|
|
static void set_properties(vcl::Window *pWindow, const stringmap &rProps);
|
|
|
|
|
|
|
|
//Convert _ gtk markup to ~ vcl markup
|
|
|
|
static OString convertMnemonicMarkup(const OString &rIn);
|
|
|
|
|
|
|
|
static OString extractCustomProperty(stringmap &rMap);
|
|
|
|
static FieldUnit detectUnit(OString const&);
|
|
|
|
|
|
|
|
static bool extractDropdown(stringmap &rMap);
|
|
|
|
|
|
|
|
//add a default value of 25 width-chars to a map if width-chars not set
|
|
|
|
static void ensureDefaultWidthChars(VclBuilder::stringmap &rMap);
|
|
|
|
|
|
|
|
//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();
|
|
|
|
|
|
|
|
//Helpers to retrofit all the existing code to the builder
|
|
|
|
static void reorderWithinParent(std::vector< vcl::Window*>& rChilds, bool bIsButtonBox);
|
|
|
|
static void reorderWithinParent(vcl::Window &rWindow, sal_uInt16 nNewPosition);
|
|
|
|
|
|
|
|
/// Get label of the command (like of .uno:Save) from the description service
|
|
|
|
static OUString getCommandLabel(const OUString& rCommand, const css::uno::Reference<css::uno::XComponentContext>& rContext, const OUString& rModuleId);
|
|
|
|
|
|
|
|
/// Get image of the command (like of .uno:Save) from the description service
|
|
|
|
static Image getCommandImage(
|
|
|
|
const OUString& rCommand,
|
|
|
|
bool bLarge,
|
|
|
|
const css::uno::Reference<css::uno::XComponentContext>& rContext,
|
|
|
|
const css::uno::Reference<css::frame::XFrame>& rFrame,
|
|
|
|
const OUString& rModuleId );
|
|
|
|
|
|
|
|
css::uno::Reference<css::frame::XFrame> getFrame() { return m_xFrame; }
|
|
|
|
|
2012-03-26 12:15:22 +01:00
|
|
|
private:
|
2015-02-15 20:41:33 +00:00
|
|
|
VclBuilder(const VclBuilder&) SAL_DELETED_FUNCTION;
|
|
|
|
VclBuilder& operator=(const VclBuilder&) SAL_DELETED_FUNCTION;
|
|
|
|
|
2013-05-06 14:17:42 +02:00
|
|
|
typedef boost::ptr_map<OUString, osl::Module> ModuleMap;
|
2014-09-28 22:33:50 +10:00
|
|
|
|
2013-04-30 14:55:14 +01:00
|
|
|
//We store these until the builder is deleted, that way we can use the
|
|
|
|
//ui-previewer on custom widgets and guarantee the modules they are from
|
|
|
|
//exist for the duration of the dialog
|
2014-09-28 22:33:50 +10:00
|
|
|
ModuleMap m_aModuleMap;
|
2012-11-08 12:57:25 +00:00
|
|
|
|
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
|
2014-09-28 22:33:50 +10: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;
|
|
|
|
PackingData(bool bVerticalOrient = false, sal_Int32 nPosition = -1)
|
|
|
|
: m_bVerticalOrient(bVerticalOrient)
|
|
|
|
, m_nPosition(nPosition)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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;
|
2013-04-30 20:44:06 +01:00
|
|
|
short m_nResponseId;
|
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)
|
2013-04-30 20:44:06 +01:00
|
|
|
, m_nResponseId(RET_CANCEL)
|
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
|
|
|
|
{
|
|
|
|
OString m_sID;
|
|
|
|
PopupMenu *m_pMenu;
|
|
|
|
MenuAndId(const OString &rId, PopupMenu *pMenu)
|
|
|
|
: m_sID(rId)
|
|
|
|
, m_pMenu(pMenu)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
std::vector<MenuAndId> m_aMenus;
|
|
|
|
|
2012-06-06 08:56:46 +01:00
|
|
|
struct StringPair
|
2012-04-30 10:19:19 +01:00
|
|
|
{
|
2012-10-02 22:41:14 +01:00
|
|
|
OString m_sID;
|
|
|
|
OString m_sValue;
|
|
|
|
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
|
|
|
|
|
|
|
typedef StringPair RadioButtonGroupMap;
|
2013-01-19 17:14:21 +00:00
|
|
|
|
|
|
|
struct ButtonImageWidgetMap
|
|
|
|
{
|
|
|
|
OString m_sID;
|
|
|
|
OString m_sValue;
|
|
|
|
bool m_bRadio;
|
|
|
|
ButtonImageWidgetMap(const OString &rId, const OString &rValue, bool bRadio)
|
|
|
|
: m_sID(rId)
|
|
|
|
, m_sValue(rValue)
|
|
|
|
, m_bRadio(bRadio)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-11-22 12:27:36 +00:00
|
|
|
typedef StringPair TextBufferMap;
|
|
|
|
typedef StringPair WidgetAdjustmentMap;
|
2012-12-11 09:33:45 +00:00
|
|
|
typedef StringPair ButtonMenuMap;
|
2013-01-22 13:26:27 +00:00
|
|
|
typedef StringPair MnemonicWidgetMap;
|
2012-08-23 15:38:30 +01:00
|
|
|
|
2012-12-11 14:03:18 +00:00
|
|
|
struct ComboBoxModelMap
|
|
|
|
{
|
|
|
|
OString m_sID;
|
|
|
|
OString m_sValue;
|
|
|
|
sal_Int32 m_nActiveId;
|
|
|
|
ComboBoxModelMap(const OString &rId, const OString &rValue, sal_Int32 nActiveId)
|
|
|
|
: 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
|
|
|
{
|
2012-11-22 12:27:36 +00:00
|
|
|
typedef std::vector<OString> row;
|
|
|
|
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;
|
2014-09-28 22:33:50 +10:00
|
|
|
static void mungeModel(ListBox &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;
|
2014-09-28 22:33:50 +10:00
|
|
|
const TextBuffer*
|
|
|
|
get_buffer_by_name(const OString& sID) const;
|
|
|
|
|
|
|
|
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);
|
|
|
|
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-10-02 22:41:14 +01:00
|
|
|
typedef std::map<OString, OString> WidgetTranslations;
|
|
|
|
typedef std::map<OString, WidgetTranslations> Translations;
|
2012-08-23 15:38:30 +01:00
|
|
|
|
2012-12-20 09:18:29 +00:00
|
|
|
struct stockinfo
|
|
|
|
{
|
|
|
|
OString m_sStock;
|
|
|
|
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
|
|
|
|
{
|
|
|
|
OString m_sID;
|
|
|
|
std::vector<OString> m_aWidgets;
|
|
|
|
stringmap m_aProperties;
|
|
|
|
SizeGroup(const OString &rId)
|
|
|
|
: m_sID(rId)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
typedef std::map< vcl::Window*, stringmap> AtkMap;
|
2013-01-21 11:39:02 +00:00
|
|
|
|
2012-08-23 15:38:30 +01:00
|
|
|
struct ParserState
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
|
2012-08-23 15:38:30 +01:00
|
|
|
Translations m_aTranslations;
|
2012-11-22 12:27:36 +00:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
std::map< vcl::Window*, 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
|
|
|
|
|
|
|
std::vector<VclExpander*> m_aExpanderWidgets;
|
2014-02-06 16:45:50 +00:00
|
|
|
|
|
|
|
sal_uInt16 m_nLastToolbarId;
|
|
|
|
|
|
|
|
ParserState()
|
|
|
|
: m_nLastToolbarId(0)
|
|
|
|
{}
|
2012-08-23 15:38:30 +01:00
|
|
|
};
|
2012-08-07 15:27:51 +01:00
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
void loadTranslations(const LanguageTag &rLanguageTag, const OUString &rUri);
|
|
|
|
OString getTranslation(const OString &rId, const OString &rProperty) const;
|
2012-08-07 15:27:51 +01:00
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
OString m_sID;
|
|
|
|
OString m_sHelpRoot;
|
2013-04-04 14:23:18 +01:00
|
|
|
ResHookProc m_pStringReplace;
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window *m_pParent;
|
2014-09-28 22:33:50 +10:00
|
|
|
bool m_bToplevelHasDeferredInit;
|
|
|
|
bool m_bToplevelHasDeferredProperties;
|
|
|
|
bool m_bToplevelParentFound;
|
2012-08-23 15:38:30 +01:00
|
|
|
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
|
2014-09-23 11:20:40 +02:00
|
|
|
: public std::binary_function<const vcl::Window*, const vcl::Window*, bool>
|
2012-10-05 14:08:28 +01:00
|
|
|
{
|
|
|
|
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:
|
|
|
|
VclBuilder *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
|
|
|
|
2012-03-26 12:15:22 +01:00
|
|
|
private:
|
2014-09-23 11:20:40 +02:00
|
|
|
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
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
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
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
void connectNumericFormatterAdjustment(const OString &id, const OString &rAdjustment);
|
|
|
|
void connectTimeFormatterAdjustment(const OString &id, const OString &rAdjustment);
|
|
|
|
void connectDateFormatterAdjustment(const OString &id, const OString &rAdjustment);
|
2013-02-18 21:59:21 +00:00
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
bool extractGroup(const OString &id, stringmap &rVec);
|
|
|
|
bool extractModel(const OString &id, stringmap &rVec);
|
|
|
|
bool 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);
|
2014-09-28 22:33:50 +10:00
|
|
|
bool extractButtonImage(const OString &id, stringmap &rMap, bool bRadio);
|
|
|
|
bool extractStock(const OString &id, stringmap &rMap);
|
|
|
|
void extractMnemonicWidget(const OString &id, stringmap &rMap);
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
void handleTranslations(xmlreader::XmlReader &reader);
|
2012-08-07 15:27:51 +01:00
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
void handleChild(vcl::Window *pParent, xmlreader::XmlReader &reader);
|
2014-09-23 11:20:40 +02:00
|
|
|
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);
|
|
|
|
void applyPackingProperty(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader);
|
|
|
|
void collectProperty(xmlreader::XmlReader &reader, const OString &rID, stringmap &rVec);
|
2015-04-01 08:33:09 +02:00
|
|
|
static void collectPangoAttribute(xmlreader::XmlReader &reader, stringmap &rMap);
|
|
|
|
static void collectAtkAttribute(xmlreader::XmlReader &reader, stringmap &rMap);
|
|
|
|
static void collectAccelerator(xmlreader::XmlReader &reader, stringmap &rMap);
|
2014-09-28 22:33:50 +10:00
|
|
|
|
|
|
|
void insertMenuObject(
|
|
|
|
PopupMenu *pParent,
|
|
|
|
const OString &rClass,
|
|
|
|
const OString &rID,
|
|
|
|
stringmap &rProps,
|
|
|
|
stringmap &rAccels);
|
|
|
|
|
|
|
|
void handleMenuChild(PopupMenu *pParent, xmlreader::XmlReader &reader);
|
|
|
|
void handleMenuObject(PopupMenu *pParent, xmlreader::XmlReader &reader);
|
|
|
|
|
|
|
|
void handleListStore(xmlreader::XmlReader &reader, const OString &rID);
|
|
|
|
void handleRow(xmlreader::XmlReader &reader, const OString &rID, sal_Int32 nRowIndex);
|
|
|
|
void handleAdjustment(const OString &rID, stringmap &rProperties);
|
|
|
|
void handleTextBuffer(const OString &rID, stringmap &rProperties);
|
|
|
|
void handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &reader);
|
|
|
|
void handleMenu(xmlreader::XmlReader &reader, const OString &rID);
|
2012-12-14 14:25:29 +00:00
|
|
|
std::vector<OString> handleItems(xmlreader::XmlReader &reader, const OString &rID);
|
2012-06-06 08:56:46 +01:00
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
void handleSizeGroup(xmlreader::XmlReader &reader, const OString &rID);
|
2013-01-11 10:08:20 +00:00
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
void handleAtkObject(xmlreader::XmlReader &reader, const OString &rID, 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);
|
2012-03-26 12:15:22 +01:00
|
|
|
};
|
|
|
|
|
2014-09-28 22:33:50 +10:00
|
|
|
template <typename T>
|
|
|
|
inline T* VclBuilder::get(T*& ret, const OString& sID)
|
|
|
|
{
|
|
|
|
vcl::Window *w = get_by_name(sID);
|
|
|
|
SAL_WARN_IF(!w, "vcl.layout", "widget \"" << sID.getStr() << "\" not found in .ui");
|
|
|
|
SAL_WARN_IF(!dynamic_cast<T*>(w),
|
|
|
|
"vcl.layout", ".ui widget \"" << sID.getStr() << "\" 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);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
//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),
|
|
|
|
"vcl.layout", ".ui widget \"" << sID.getStr() << "\" needs to correspond to vcl type " << typeid(T).name());
|
|
|
|
assert(!w || dynamic_cast<T*>(w));
|
|
|
|
return static_cast<T*>(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline PopupMenu* VclBuilder::get_menu(PopupMenu*& ret, const OString& sID)
|
|
|
|
{
|
|
|
|
ret = get_menu(sID);
|
|
|
|
SAL_WARN_IF(!ret, "vcl.layout", "menu \"" << sID.getStr() << "\" not found in .ui");
|
|
|
|
assert(ret);
|
|
|
|
return ret;
|
|
|
|
}
|
2012-06-13 14:24:01 +01: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();
|
2014-09-28 22:33:50 +10:00
|
|
|
bool hasBuilder() const { return m_pUIBuilder != NULL; }
|
|
|
|
|
2014-01-16 20:33:54 +00:00
|
|
|
css::uno::Reference<css::frame::XFrame> getFrame() { return m_pUIBuilder->getFrame(); }
|
2014-09-28 22:33:50 +10:00
|
|
|
|
2014-03-13 08:38:29 +02:00
|
|
|
template <typename T> T* get(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);
|
|
|
|
}
|
2014-03-13 08:38:29 +02:00
|
|
|
PopupMenu* get_menu(PopupMenu*& ret, const OString & sID)
|
2013-01-19 13:23:57 +00:00
|
|
|
{
|
|
|
|
return m_pUIBuilder->get_menu(ret, sID);
|
|
|
|
}
|
2014-03-13 08:38:29 +02:00
|
|
|
PopupMenu* get_menu(const OString & sID)
|
2013-01-19 13:23:57 +00:00
|
|
|
{
|
|
|
|
return m_pUIBuilder->get_menu(sID);
|
|
|
|
}
|
2013-04-30 20:44:06 +01:00
|
|
|
void setDeferredProperties()
|
|
|
|
{
|
|
|
|
if (!m_pUIBuilder)
|
|
|
|
return;
|
|
|
|
m_pUIBuilder->setDeferredProperties();
|
|
|
|
}
|
2014-09-28 22:33:50 +10:00
|
|
|
|
|
|
|
protected:
|
|
|
|
VclBuilder *m_pUIBuilder;
|
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.
|
|
|
|
*/
|
2012-10-02 22:41:14 +01:00
|
|
|
bool VCL_DLLPUBLIC toBool(const OString &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: */
|