split out VclBuilder static methods

Change-Id: Ic94b39351c9a6131fb61883a98ae9e3ee60ad119
This commit is contained in:
Caolán McNamara 2017-08-02 10:12:55 +01:00
parent 0ac1e2ad19
commit 3b35bcf25f
24 changed files with 180 additions and 178 deletions

View File

@ -660,7 +660,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeSfxAccCfgTabListBox(VclPtr<vcl
{
WinBits nWinBits = WB_TABSTOP;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinBits |= WB_BORDER;

View File

@ -2450,7 +2450,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeAutoCompleteMultiListBox(VclPt
{
WinBits nWinBits = WB_TABSTOP;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinBits |= WB_BORDER;

View File

@ -321,7 +321,7 @@ BibGeneralPage::BibGeneralPage(vcl::Window* pParent, BibDataManager* pMan):
AddControlWithError(lcl_GetColumnName(pMapping, CUSTOM5_POS), *pCustom5FT,
sTableErrorString, HID_BIB_CUSTOM5_POS, 30, aChildren);
VclBuilder::reorderWithinParent(aChildren, false);
BuilderUtils::reorderWithinParent(aChildren, false);
xPosListener = new BibPosListener(this);
uno::Reference< sdbc::XRowSet > xRowSet(pDatMan->getForm(), UNO_QUERY);

View File

@ -82,30 +82,12 @@ public:
//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 OUString convertMnemonicMarkup(const OUString &rIn);
static OUString extractCustomProperty(stringmap &rMap);
static FieldUnit detectUnit(OUString 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);
/// return UI-File name (without '.ui')
const OString& getUIFile() const
{
@ -399,6 +381,27 @@ private:
void delete_by_window(vcl::Window *pWindow);
};
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);
}
template <typename T>
inline T* VclBuilder::get(VclPtr<T>& ret, const OString& sID)
{

View File

@ -30,7 +30,7 @@
#define VCL_BUILDER_FACTORY_CONSTRUCTOR(typeName,arg2) \
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL make##typeName(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap) \
{ \
OUString sBorder = VclBuilder::extractCustomProperty(rMap); \
OUString sBorder = BuilderUtils::extractCustomProperty(rMap); \
WinBits wb = arg2; \
if (!sBorder.isEmpty()) \
wb |= WB_BORDER; \

View File

@ -40,10 +40,10 @@ namespace i18n {
class XExtendedInputSequenceChecker;
}}}}
class VclBuilder;
struct DDInfo;
struct Impl_IMEInfos;
#define EDIT_NOLIMIT SAL_MAX_INT32
#define EDIT_UPDATEDATA_TIMEOUT 350

View File

@ -433,7 +433,6 @@ namespace vcl { class Cursor; }
class Dialog;
class WindowImpl;
class PaintHelper;
class VclBuilder;
class VclSizeGroup;
class OutputDevice;
class Application;
@ -448,7 +447,6 @@ class PushButton;
class RadioButton;
class SystemChildWindow;
class ImplBorderWindow;
class VclBuilder;
class ImplDockingWindowWrapper;
class ImplPopupFloatWin;
class MenuFloatingWindow;
@ -495,7 +493,6 @@ class VCL_DLLPUBLIC Window : public ::OutputDevice
friend class ::RadioButton;
friend class ::SystemChildWindow;
friend class ::ImplBorderWindow;
friend class ::VclBuilder;
friend class ::PaintHelper;
friend class ::LifecycleTest;

View File

@ -48,7 +48,7 @@ ScDoubleField::ScDoubleField( vcl::Window* pParent, WinBits nStyle ) :
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeScDoubleField(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
VclBuilder::ensureDefaultWidthChars(rMap);
BuilderUtils::ensureDefaultWidthChars(rMap);
rRet = VclPtr<ScDoubleField>::Create(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
}

View File

@ -150,7 +150,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeScTabBgColorValueSet(VclPtr<vc
{
WinBits nWinBits = WB_TABSTOP;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinBits |= WB_BORDER;

View File

@ -286,7 +286,7 @@ ContentListBox_Impl::ContentListBox_Impl(vcl::Window* pParent, WinBits nStyle)
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeContentListBox(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
WinBits nWinStyle = WB_TABSTOP;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
rRet = VclPtr<ContentListBox_Impl>::Create(pParent, nWinStyle);
@ -473,7 +473,7 @@ IndexBox_Impl::IndexBox_Impl(vcl::Window* pParent, WinBits nStyle)
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeIndexBox(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
WinBits nWinBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinBits |= WB_BORDER;
VclPtrInstance<IndexBox_Impl> pListBox(pParent, nWinBits);
@ -879,7 +879,7 @@ void SearchBox_Impl::Select()
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeSearchResultsBox(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
WinBits nWinBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinBits |= WB_BORDER;
VclPtrInstance<SearchResultsBox_Impl> pListBox(pParent, nWinBits);
@ -1140,7 +1140,7 @@ BookmarksBox_Impl::BookmarksBox_Impl(vcl::Window* pParent, WinBits nStyle)
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeBookmarksBox(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
WinBits nWinBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinBits |= WB_BORDER;
VclPtrInstance<BookmarksBox_Impl> pListBox(pParent, nWinBits);

View File

@ -989,7 +989,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeSvtFileView(VclPtr<vcl::Window
{
WinBits nBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK;
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
if (bDropdown)
nBits |= WB_DROPDOWN;

View File

@ -505,7 +505,7 @@ LineListBox::LineListBox( vcl::Window* pParent, WinBits nWinStyle ) :
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeLineListBox(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP;
if (bDropdown)
nWinBits |= WB_DROPDOWN;
@ -705,7 +705,7 @@ FontNameBox::FontNameBox( vcl::Window* pParent, WinBits nWinStyle ) :
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeFontNameBox(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP;
if (bDropdown)
nWinBits |= WB_DROPDOWN;
@ -1095,7 +1095,7 @@ Size FontStyleBox::GetOptimalSize() const
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeFontStyleBox(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP;
if (bDropdown)
nWinBits |= WB_DROPDOWN;
@ -1291,7 +1291,7 @@ FontSizeBox::FontSizeBox( vcl::Window* pParent, WinBits nWinSize ) :
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeFontSizeBox(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP;
if (bDropdown)
nWinBits |= WB_DROPDOWN;

View File

@ -1034,7 +1034,7 @@ HatchingLB::HatchingLB( vcl::Window* pParent, WinBits nWinStyle)
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeHatchingLB(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
WinBits nWinStyle = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
VclPtrInstance<HatchingLB> pListBox(pParent, nWinStyle);
@ -1074,7 +1074,7 @@ GradientLB::GradientLB( vcl::Window* pParent, WinBits aWB)
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeGradientLB(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
WinBits nWinStyle = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
VclPtrInstance<GradientLB> pListBox(pParent, nWinStyle);
@ -1114,7 +1114,7 @@ BitmapLB::BitmapLB( vcl::Window* pParent, WinBits aWB)
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeBitmapLB(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
WinBits nWinStyle = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
VclPtrInstance<BitmapLB> pListBox(pParent, nWinStyle);
@ -1247,11 +1247,11 @@ LineLB::LineLB(vcl::Window* pParent, WinBits aWB)
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeLineLB(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE|WB_TABSTOP;
if (bDropdown)
nWinBits |= WB_DROPDOWN;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinBits |= WB_BORDER;
VclPtrInstance<LineLB> pListBox(pParent, nWinBits);
@ -1345,11 +1345,11 @@ LineEndLB::LineEndLB( vcl::Window* pParent, WinBits aWB )
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeLineEndLB(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE|WB_TABSTOP;
if (bDropdown)
nWinBits |= WB_DROPDOWN;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinBits |= WB_BORDER;
VclPtrInstance<LineEndLB> pListBox(pParent, nWinBits);

View File

@ -113,7 +113,7 @@ static bool lcl_SeqHasLang( const Sequence< sal_Int16 > & rLangSeq, sal_Int16 nL
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeSvxLanguageBox(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
WinBits nBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP;
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
if (bDropdown)
nBits |= WB_DROPDOWN;
else
@ -126,7 +126,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeSvxLanguageBox(VclPtr<vcl::Win
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeSvxLanguageComboBox(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
WinBits nBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP;
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
if (bDropdown)
nBits |= WB_DROPDOWN;
else

View File

@ -38,8 +38,8 @@ SvxRelativeField::SvxRelativeField(
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeSvxRelativeField(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
OUString const custom(VclBuilder::extractCustomProperty(rMap));
FieldUnit const eUnit(VclBuilder::detectUnit(custom));
OUString const custom(BuilderUtils::extractCustomProperty(rMap));
FieldUnit const eUnit(BuilderUtils::detectUnit(custom));
rRet = VclPtr<SvxRelativeField>::Create(pParent,
WB_BORDER | WB_SPIN | WB_REPEAT |
WB_LEFT | WB_GROUP,

View File

@ -43,10 +43,10 @@ SvxTextEncodingBox::SvxTextEncodingBox( vcl::Window* pParent, WinBits nBits )
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeSvxTextEncodingBox(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE;
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
if (bDropdown)
nWinBits |= WB_DROPDOWN;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinBits |= WB_BORDER;
VclPtrInstance<SvxTextEncodingBox> pListBox(pParent, nWinBits);

View File

@ -1003,7 +1003,7 @@ void CaptionComboBox::KeyInput(const KeyEvent& rEvt)
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeCaptionComboBox(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
WinBits nBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK;
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
if (bDropdown)
nBits |= WB_DROPDOWN;
VclPtrInstance<CaptionComboBox> pComboBox(pParent, nBits);

View File

@ -1260,12 +1260,12 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeSelectionListBox(VclPtr<vcl::W
{
WinBits nBits = WB_LEFT|WB_VCENTER|WB_3DLOOK;
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
if (bDropdown)
nBits |= WB_DROPDOWN;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nBits |= WB_BORDER;

View File

@ -58,7 +58,7 @@ void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeReturnActionEdit(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
VclBuilder::ensureDefaultWidthChars(rMap);
BuilderUtils::ensureDefaultWidthChars(rMap);
rRet = VclPtr<ReturnActionEdit>::Create(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
}

View File

@ -36,7 +36,7 @@ ConditionEdit::ConditionEdit(vcl::Window* pParent, WinBits nStyle)
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeConditionEdit(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
VclBuilder::ensureDefaultWidthChars(rMap);
BuilderUtils::ensureDefaultWidthChars(rMap);
rRet = VclPtr<ConditionEdit>::Create(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
}

View File

@ -67,7 +67,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeNumFormatListBox(VclPtr<vcl::W
{
WinBits nBits = WB_LEFT|WB_VCENTER|WB_3DLOOK;
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
if (bDropdown)
nBits |= WB_DROPDOWN;

View File

@ -477,18 +477,6 @@ void VclBuilder::disposeBuilder()
m_pParent.clear();
}
OUString VclBuilder::extractCustomProperty(VclBuilder::stringmap &rMap)
{
OUString sCustomProperty;
VclBuilder::stringmap::iterator aFind = rMap.find(OString("customproperty"));
if (aFind != rMap.end())
{
sCustomProperty = aFind->second;
rMap.erase(aFind);
}
return sCustomProperty;
}
namespace
{
bool extractDrawValue(VclBuilder::stringmap& rMap)
@ -934,7 +922,7 @@ namespace
nBits |= WB_SIZEABLE;
if (extractCloseable(rMap))
nBits |= WB_CLOSEABLE;
OUString sBorder = VclBuilder::extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nBits |= WB_BORDER;
if (!extractDecorated(rMap))
@ -952,20 +940,6 @@ namespace
}
}
FieldUnit VclBuilder::detectUnit(OUString const& rString)
{
OUString const unit(extractUnit(rString));
return detectMetricUnit(unit);
}
void VclBuilder::ensureDefaultWidthChars(VclBuilder::stringmap &rMap)
{
OString sWidthChars("width-chars");
VclBuilder::stringmap::iterator aFind = rMap.find(sWidthChars);
if (aFind == rMap.end())
rMap[sWidthChars] = "25";
}
bool VclBuilder::extractGroup(const OString &id, stringmap &rMap)
{
VclBuilder::stringmap::iterator aFind = rMap.find(OString("group"));
@ -1065,18 +1039,6 @@ bool VclBuilder::extractModel(const OString &id, stringmap &rMap)
return false;
}
bool VclBuilder::extractDropdown(VclBuilder::stringmap &rMap)
{
bool bDropdown = true;
VclBuilder::stringmap::iterator aFind = rMap.find(OString("dropdown"));
if (aFind != rMap.end())
{
bDropdown = toBool(aFind->second);
rMap.erase(aFind);
}
return bDropdown;
}
bool VclBuilder::extractBuffer(const OString &id, stringmap &rMap)
{
VclBuilder::stringmap::iterator aFind = rMap.find(OString("buffer"));
@ -1272,7 +1234,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
else if (name == "GtkButton")
{
VclPtr<Button> xButton;
OUString sMenu = extractCustomProperty(rMap);
OUString sMenu = BuilderUtils::extractCustomProperty(rMap);
if (sMenu.isEmpty())
xButton = extractStockAndBuildPushButton(pParent, rMap);
else
@ -1287,7 +1249,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
else if (name == "GtkToggleButton")
{
VclPtr<Button> xButton;
OUString sMenu = extractCustomProperty(rMap);
OUString sMenu = BuilderUtils::extractCustomProperty(rMap);
assert(sMenu.getLength() && "not implemented yet");
xButton = extractStockAndBuildMenuToggleButton(pParent, rMap);
m_pParserState->m_aButtonMenuMaps.push_back(ButtonMenuMap(id, sMenu));
@ -1299,7 +1261,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
{
extractGroup(id, rMap);
WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_3DLOOK;
OUString sWrap = extractCustomProperty(rMap);
OUString sWrap = BuilderUtils::extractCustomProperty(rMap);
if (!sWrap.isEmpty())
nBits |= WB_WORDBREAK;
VclPtr<RadioButton> xButton = VclPtr<RadioButton>::Create(pParent, nBits);
@ -1309,7 +1271,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
else if (name == "GtkCheckButton")
{
WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_3DLOOK;
OUString sWrap = extractCustomProperty(rMap);
OUString sWrap = BuilderUtils::extractCustomProperty(rMap);
if (!sWrap.isEmpty())
nBits |= WB_WORDBREAK;
//maybe always import as TriStateBox and enable/disable tristate
@ -1327,7 +1289,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
else if (name == "GtkSpinButton")
{
OUString sAdjustment = extractAdjustment(rMap);
OUString sPattern = extractCustomProperty(rMap);
OUString sPattern = BuilderUtils::extractCustomProperty(rMap);
OUString sUnit = extractUnit(sPattern);
WinBits nBits = WB_CLIPCHILDREN|WB_LEFT|WB_BORDER|WB_3DLOOK;
@ -1371,12 +1333,12 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
xWindow = VclPtr<FixedHyperlink>::Create(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK|WB_NOLABEL);
else if ((name == "GtkComboBox") || (name == "GtkComboBoxText") || (name == "VclComboBoxText"))
{
OUString sPattern = extractCustomProperty(rMap);
OUString sPattern = BuilderUtils::extractCustomProperty(rMap);
extractModel(id, rMap);
WinBits nBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK;
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
if (bDropdown)
nBits |= WB_DROPDOWN;
@ -1414,13 +1376,13 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
}
else if (name == "VclComboBoxNumeric")
{
OUString sPattern = extractCustomProperty(rMap);
OUString sPattern = BuilderUtils::extractCustomProperty(rMap);
OUString sAdjustment = extractAdjustment(rMap);
extractModel(id, rMap);
WinBits nBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK;
bool bDropdown = VclBuilder::extractDropdown(rMap);
bool bDropdown = BuilderUtils::extractDropdown(rMap);
if (bDropdown)
nBits |= WB_DROPDOWN;
@ -1459,7 +1421,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
//d) remove the users of makeSvTreeViewBox
extractModel(id, rMap);
WinBits nWinStyle = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE;
OUString sBorder = extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
//ListBox manages its own scrolling,
@ -1471,7 +1433,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
else if (name == "GtkLabel")
{
WinBits nWinStyle = WB_CENTER|WB_VCENTER|WB_3DLOOK;
OUString sBorder = extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
extractMnemonicWidget(id, rMap);
@ -1524,7 +1486,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
else if (name == "GtkEntry")
{
xWindow = VclPtr<Edit>::Create(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
ensureDefaultWidthChars(rMap);
BuilderUtils::ensureDefaultWidthChars(rMap);
}
else if (name == "GtkNotebook")
{
@ -1532,7 +1494,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
}
else if (name == "GtkDrawingArea")
{
OUString sBorder = extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
xWindow = VclPtr<vcl::Window>::Create(pParent, sBorder.isEmpty() ? 0 : WB_BORDER);
}
else if (name == "GtkTextView")
@ -1540,7 +1502,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
extractBuffer(id, rMap);
WinBits nWinStyle = WB_CLIPCHILDREN|WB_LEFT;
OUString sBorder = extractCustomProperty(rMap);
OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
//VclMultiLineEdit manages its own scrolling,
@ -1684,7 +1646,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
setupFromActionName(static_cast<Button*>(xWindow.get()), rMap, m_xFrame);
else if (xWindow->GetType() == WindowType::MENUBUTTON)
{
OUString sMenu = extractCustomProperty(rMap);
OUString sMenu = BuilderUtils::extractCustomProperty(rMap);
if (!sMenu.isEmpty())
m_pParserState->m_aButtonMenuMaps.push_back(ButtonMenuMap(id, sMenu));
setupFromActionName(static_cast<Button*>(xWindow.get()), rMap, m_xFrame);
@ -1698,9 +1660,9 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
xWindow->SetHelpId(m_sHelpRoot + id);
SAL_INFO("vcl.layout", "for " << name <<
", created " << xWindow.get() << " child of " <<
pParent << "(" << xWindow->mpWindowImpl->mpParent.get() << "/" <<
xWindow->mpWindowImpl->mpRealParent.get() << "/" <<
xWindow->mpWindowImpl->mpBorderWindow.get() << ") with helpid " <<
pParent << "(" << xWindow->ImplGetWindowImpl()->mpParent.get() << "/" <<
xWindow->ImplGetWindowImpl()->mpRealParent.get() << "/" <<
xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " <<
xWindow->GetHelpId());
m_aChildren.push_back(WinAndId(id, xWindow, bVertical));
}
@ -1726,16 +1688,106 @@ void VclBuilder::setDeferredProperties()
stringmap aDeferredProperties;
aDeferredProperties.swap(m_aDeferredProperties);
m_bToplevelHasDeferredProperties = false;
set_properties(m_pParent, aDeferredProperties);
BuilderUtils::set_properties(m_pParent, aDeferredProperties);
}
void VclBuilder::set_properties(vcl::Window *pWindow, const stringmap &rProps)
namespace BuilderUtils
{
for (stringmap::const_iterator aI = rProps.begin(), aEnd = rProps.end(); aI != aEnd; ++aI)
void set_properties(vcl::Window *pWindow, const VclBuilder::stringmap &rProps)
{
const OString &rKey = aI->first;
const OUString &rValue = aI->second;
pWindow->set_property(rKey, rValue);
for (VclBuilder::stringmap::const_iterator aI = rProps.begin(), aEnd = rProps.end(); aI != aEnd; ++aI)
{
const OString &rKey = aI->first;
const OUString &rValue = aI->second;
pWindow->set_property(rKey, rValue);
}
}
OUString convertMnemonicMarkup(const OUString &rIn)
{
OUStringBuffer aRet(rIn);
for (sal_Int32 nI = 0; nI < aRet.getLength(); ++nI)
{
if (aRet[nI] == '_' && nI+1 < aRet.getLength())
{
if (aRet[nI+1] != '_')
aRet[nI] = MNEMONIC_CHAR;
else
aRet.remove(nI, 1);
++nI;
}
}
return aRet.makeStringAndClear();
}
OUString extractCustomProperty(VclBuilder::stringmap &rMap)
{
OUString sCustomProperty;
VclBuilder::stringmap::iterator aFind = rMap.find(OString("customproperty"));
if (aFind != rMap.end())
{
sCustomProperty = aFind->second;
rMap.erase(aFind);
}
return sCustomProperty;
}
FieldUnit detectUnit(OUString const& rString)
{
OUString const unit(extractUnit(rString));
return detectMetricUnit(unit);
}
void ensureDefaultWidthChars(VclBuilder::stringmap &rMap)
{
OString sWidthChars("width-chars");
VclBuilder::stringmap::iterator aFind = rMap.find(sWidthChars);
if (aFind == rMap.end())
rMap[sWidthChars] = "25";
}
bool extractDropdown(VclBuilder::stringmap &rMap)
{
bool bDropdown = true;
VclBuilder::stringmap::iterator aFind = rMap.find(OString("dropdown"));
if (aFind != rMap.end())
{
bDropdown = toBool(aFind->second);
rMap.erase(aFind);
}
return bDropdown;
}
void reorderWithinParent(vcl::Window &rWindow, sal_uInt16 nNewPosition)
{
WindowImpl *pWindowImpl = rWindow.ImplGetWindowImpl();
if (pWindowImpl->mpParent != pWindowImpl->mpRealParent)
{
assert(pWindowImpl->mpBorderWindow == pWindowImpl->mpParent);
assert(pWindowImpl->mpBorderWindow->ImplGetWindowImpl()->mpParent == pWindowImpl->mpRealParent);
reorderWithinParent(*pWindowImpl->mpBorderWindow, nNewPosition);
return;
}
rWindow.reorderWithinParent(nNewPosition);
}
void reorderWithinParent(std::vector<vcl::Window*>& rChilds, bool bIsButtonBox)
{
for (size_t i = 0; i < rChilds.size(); ++i)
{
reorderWithinParent(*rChilds[i], i);
if (!bIsButtonBox)
continue;
//The first member of the group for legacy code needs WB_GROUP set and the
//others not
WinBits nBits = rChilds[i]->GetStyle();
nBits &= ~WB_GROUP;
if (i == 0)
nBits |= WB_GROUP;
rChilds[i]->SetStyle(nBits);
}
}
}
@ -1788,7 +1840,7 @@ VclPtr<vcl::Window> VclBuilder::insertObject(vcl::Window *pParent, const OString
if (pCurrentChild == m_pParent.get() && m_bToplevelHasDeferredProperties)
m_aDeferredProperties = rProps;
else
set_properties(pCurrentChild, rProps);
BuilderUtils::set_properties(pCurrentChild, rProps);
for (stringmap::iterator aI = rPango.begin(), aEnd = rPango.end(); aI != aEnd; ++aI)
{
@ -1809,20 +1861,6 @@ VclPtr<vcl::Window> VclBuilder::insertObject(vcl::Window *pParent, const OString
return pCurrentChild;
}
void VclBuilder::reorderWithinParent(vcl::Window &rWindow, sal_uInt16 nNewPosition)
{
if (rWindow.mpWindowImpl->mpParent != rWindow.mpWindowImpl->mpRealParent)
{
assert(rWindow.mpWindowImpl->mpBorderWindow ==
rWindow.mpWindowImpl->mpParent);
assert(rWindow.mpWindowImpl->mpBorderWindow->mpWindowImpl->mpParent ==
rWindow.mpWindowImpl->mpRealParent);
reorderWithinParent(*rWindow.mpWindowImpl->mpBorderWindow, nNewPosition);
return;
}
rWindow.reorderWithinParent(nNewPosition);
}
void VclBuilder::handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &reader)
{
OString sID;
@ -2062,7 +2100,7 @@ void VclBuilder::handleChild(vcl::Window *pParent, xmlreader::XmlReader &reader)
//sort child order within parent so that tabbing
//between controls goes in a visually sensible sequence
std::stable_sort(aChilds.begin(), aChilds.end(), sortIntoBestTabTraversalOrder(this));
reorderWithinParent(aChilds, bIsButtonBox);
BuilderUtils::reorderWithinParent(aChilds, bIsButtonBox);
}
}
}
@ -2098,25 +2136,6 @@ void VclBuilder::handleChild(vcl::Window *pParent, xmlreader::XmlReader &reader)
}
}
void VclBuilder::reorderWithinParent(std::vector<vcl::Window*>& rChilds, bool bIsButtonBox)
{
for (size_t i = 0; i < rChilds.size(); ++i)
{
reorderWithinParent(*rChilds[i], i);
if (!bIsButtonBox)
continue;
//The first member of the group for legacy code needs WB_GROUP set and the
//others not
WinBits nBits = rChilds[i]->GetStyle();
nBits &= ~WB_GROUP;
if (i == 0)
nBits |= WB_GROUP;
rChilds[i]->SetStyle(nBits);
}
}
void VclBuilder::collectPangoAttribute(xmlreader::XmlReader &reader, stringmap &rMap)
{
xmlreader::Span span;
@ -2613,23 +2632,6 @@ void VclBuilder::handleSizeGroup(xmlreader::XmlReader &reader)
}
}
OUString VclBuilder::convertMnemonicMarkup(const OUString &rIn)
{
OUStringBuffer aRet(rIn);
for (sal_Int32 nI = 0; nI < aRet.getLength(); ++nI)
{
if (aRet[nI] == '_' && nI+1 < aRet.getLength())
{
if (aRet[nI+1] != '_')
aRet[nI] = MNEMONIC_CHAR;
else
aRet.remove(nI, 1);
++nI;
}
}
return aRet.makeStringAndClear();
}
namespace
{
vcl::KeyCode makeKeyCode(const std::pair<OString,OString> &rKey)
@ -2666,7 +2668,7 @@ void VclBuilder::insertMenuObject(PopupMenu *pParent, PopupMenu *pSubMenu, const
if (rClass == "GtkMenuItem")
{
OUString sLabel(convertMnemonicMarkup(extractLabel(rProps)));
OUString sLabel(BuilderUtils::convertMnemonicMarkup(extractLabel(rProps)));
OUString aCommand(extractActionName(rProps));
pParent->InsertItem(nNewId, sLabel, MenuItemBits::TEXT, rID);
pParent->SetItemCommand(nNewId, aCommand);
@ -2675,14 +2677,14 @@ void VclBuilder::insertMenuObject(PopupMenu *pParent, PopupMenu *pSubMenu, const
}
else if (rClass == "GtkCheckMenuItem")
{
OUString sLabel(convertMnemonicMarkup(extractLabel(rProps)));
OUString sLabel(BuilderUtils::convertMnemonicMarkup(extractLabel(rProps)));
OUString aCommand(extractActionName(rProps));
pParent->InsertItem(nNewId, sLabel, MenuItemBits::CHECKABLE, rID);
pParent->SetItemCommand(nNewId, aCommand);
}
else if (rClass == "GtkRadioMenuItem")
{
OUString sLabel(convertMnemonicMarkup(extractLabel(rProps)));
OUString sLabel(BuilderUtils::convertMnemonicMarkup(extractLabel(rProps)));
OUString aCommand(extractActionName(rProps));
pParent->InsertItem(nNewId, sLabel, MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK, rID);
pParent->SetItemCommand(nNewId, aCommand);
@ -3324,8 +3326,8 @@ VclBuilder::PackingData VclBuilder::get_window_packing_data(const vcl::Window *p
//border windows placed around them which are what you get
//from GetChild, so scoot up a level if necessary to get the
//window whose position value we have
const vcl::Window *pPropHolder = pWindow->mpWindowImpl->mpClientWindow ?
pWindow->mpWindowImpl->mpClientWindow : pWindow;
const vcl::Window *pPropHolder = pWindow->ImplGetWindowImpl()->mpClientWindow ?
pWindow->ImplGetWindowImpl()->mpClientWindow : pWindow;
for (std::vector<WinAndId>::const_iterator aI = m_aChildren.begin(),
aEnd = m_aChildren.end(); aI != aEnd; ++aI)

View File

@ -923,7 +923,7 @@ void VclButtonBox::sort_native_button_order()
//sort child order within parent so that we match the platform
//button order
std::stable_sort(aChilds.begin(), aChilds.end(), sortButtons(m_bVerticalContainer));
VclBuilder::reorderWithinParent(aChilds, true);
BuilderUtils::reorderWithinParent(aChilds, true);
}
struct GridEntry

View File

@ -1473,7 +1473,7 @@ bool Window::set_property(const OString &rKey, const OUString &rValue)
{
if ((rKey == "label") || (rKey == "title") || (rKey == "text") )
{
SetText(VclBuilder::convertMnemonicMarkup(rValue));
SetText(BuilderUtils::convertMnemonicMarkup(rValue));
}
else if (rKey == "visible")
Show(toBool(rValue));