Kaydet (Commit) d6cd273c authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Add function to map custom widget name to its function to native-code.py

Use that function in the dialog builder instead of having explicit
code in there to check the names.

For now this simply uses a manually curated list of custom widgets. I
used some command line tools to extract the names of custom widgets
used in our .ui files, and then filtered out some I guess (hope) will
not be needed in a mobile app.

For this to work the custom widgets need to have unique names.
Currently that is not the case. Unless I did some mistake, there is
just one case of duplicate name, NotebookbarTabControl, which exists
both in the sfx and vcl libraries. (I simply filtered out that one,
too, for now.)

Change-Id: I29bbf6dfef2b3bde03acfc322495d051a7f275a8
üst de016544
......@@ -396,6 +396,138 @@ constructor_map = {
'writer' : writer_constructor_list,
}
custom_widgets = [
'ArgEdit',
'AutoCompleteMultiListBox',
'AutoCorrEdit',
'BookmarksBox',
'CaptionComboBox',
'CategoryListBox',
'ClassificationEditView',
'ColorConfigCtrl',
'ColumnEdit',
'CommandCategoryListBox',
'ConditionEdit',
'ContentListBox',
'ContextVBox',
'CuiCustomMultilineEdit',
'CustomAnimationList',
'CustomPropertiesControl',
'DataTreeListBox',
'DriverListControl',
'DropdownBox',
'EditBox',
'EmojiView',
'ExtBoxWithBtns',
'ExtensionBox',
'FEdit',
'FontNameBox',
'FontSizeBox',
'FontStyleBox',
'FormattedField',
'FormulaListBox',
'GalleryPreview',
'IndexBox',
'IndexBox',
'IntellectualPropertyPartEdit',
'LightButton',
'LookUpComboBox',
'MacroEventListBox',
'ManagedMenuButton',
'MultiLineEditSyntaxHighlight',
'NumFormatListBox',
'OFileURLControl',
'OptionalBox',
'PageNumberListBox',
'PaperSizeListBox',
'PriorityHBox',
'PriorityMergedHBox',
'PropertyControl',
'RecentDocsView',
'RefButton',
'RefEdit',
'ReplaceEdit',
'ReturnActionEdit',
'RowEdit',
'RubyEdit',
'RubyPreview',
'RubyRadioButton',
'SFTreeListBox',
'SameContentListBox',
'ScAutoFmtPreview',
'ScCondFormatList',
'ScCsvTableBox',
'ScCursorRefEdit',
'ScDPFunctionListBox',
'ScDataTableView',
'ScDoubleField',
'ScEditWindow',
'ScPivotLayoutTreeList',
'ScPivotLayoutTreeListData',
'ScPivotLayoutTreeListLabel',
'ScRefButtonEx',
'SdPageObjsTLB',
'SearchBox',
'SearchResultsBox',
'SelectionListBox',
'SentenceEditWindow',
'SeriesListBox',
'SfxAccCfgTabListBox',
'SfxConfigFunctionListBox',
'SfxConfigGroupListBox',
'ShowNupOrderWindow',
'ShowNupOrderWindow',
'SidebarDialControl',
'SidebarToolBox',
'SmallButton',
'SpacingListBox',
'StatusBar',
'StructListBox',
'SuggestionDisplay',
'SuggestionEdit',
'SvSimpleTableContainer',
'SvTabListBox',
'SvTreeListBox',
'SvtFileView',
'SvtIconChoiceCtrl',
'SvtURLBox',
'Svx3DPreviewControl',
'SvxCharViewControl',
'SvxCheckListBox',
'SvxColorListBox',
'SvxColorValueSet',
'SvxDictEdit',
'SvxFillAttrBox',
'SvxFillTypeBox',
'SvxFontPrevWindow',
'SvxHlmarkTreeLBox',
'SvxHyperURLBox',
'SvxLanguageBox',
'SvxLanguageComboBox',
'SvxLightCtl3D',
'SvxNoSpaceEdit',
'SvxPathControl',
'SvxRelativeField',
'SvxSwFrameExample',
'SvxTextEncodingBox',
'SvxTextEncodingBox',
'SwAddressPreview',
'SwCaptionPreview',
'SwFieldRefTreeListBox',
'SwGlTreeListBox',
'SwGlossaryGroupTLB',
'SwIdxTreeListBox',
'SwMarkPreview',
'SwNavHelpToolBox',
'SwTokenWindow',
'TableValueSet',
'TemplateDefaultView',
'TemplateLocalView',
'TemplateSearchView',
'ThesaurusAlternativesCtrl',
'ValueSet',
]
def get_constructor_guard(constructor):
if type(full_constructor_map[constructor]) is bool:
return None
......@@ -501,6 +633,24 @@ for constructor in sorted(full_constructor_map.keys()):
if constructor_guard:
print ('#endif')
print ('')
for entry in sorted(custom_widgets):
print ('void make' + entry + '();')
print ('static struct { const char *name; void(*func)(); } custom_widgets[] = {')
for entry in sorted(custom_widgets):
print (' { "make' + entry + '", make' + entry + ' },')
print ('};')
print ('')
print ("""
void (*lo_get_custom_widget_func(const char* name))()
{
for (int i = 0; i < sizeof(custom_widgets) / sizeof(custom_widgets[0]); i++)
if (strcmp(name, custom_widgets[i].name) == 0)
return custom_widgets[i].func;
return nullptr;
}
""")
print ("""
const lib_to_factory_mapping *
lo_get_factory_map(void)
......
......@@ -1490,12 +1490,7 @@ void VclBuilder::preload()
}
#if defined DISABLE_DYNLOADING && !HAVE_FEATURE_DESKTOP
VCL_BUILDER_FACTORY_EXTERN(CustomPropertiesControl);
VCL_BUILDER_FACTORY_EXTERN(RefButton);
VCL_BUILDER_FACTORY_EXTERN(RefEdit);
VCL_BUILDER_FACTORY_EXTERN(ScRefButtonEx);
extern "C" VclBuilder::customMakeWidget lo_get_custom_widget_func(const char* name);
#endif
VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &name, const OString &id,
......@@ -2051,18 +2046,8 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
else
pFunction = reinterpret_cast<customMakeWidget>(aI->second->getFunctionSymbol(sFunction));
#elif !HAVE_FEATURE_DESKTOP
if (false)
; // Just so that all the other condition line pairs look the same
else if (sFunction == "makeCustomPropertiesControl")
pFunction = makeCustomPropertiesControl;
else if (sFunction == "makeRefButton")
pFunction = makeRefButton;
else if (sFunction == "makeRefEdit")
pFunction = makeRefEdit;
else if (sFunction == "makeScRefButtonEx")
pFunction = makeScRefButtonEx;
SAL_WARN_IF(!pFunction, "vcl.layout", "Missing case for " << sFunction);
pFunction = lo_get_custom_widget_func(sFunction.toUtf8().getStr());
SAL_WARN_IF(!pFunction, "vcl.layout", "Could not find " << sFunction);
assert(pFunction);
#else
pFunction = reinterpret_cast<customMakeWidget>(osl_getFunctionSymbol((oslModule) RTLD_DEFAULT, sFunction.pData));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment