Kaydet (Commit) 2bc5ab31 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 looking up the
function dynamically, which won't work in a Release build as the
linker will filter out functions that aren't explicitly referenced.

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
Reviewed-on: https://gerrit.libreoffice.org/62946Reviewed-by: 's avatarTor Lillqvist <tml@collabora.com>
Tested-by: 's avatarTor Lillqvist <tml@collabora.com>
üst 2a6e3fa7
......@@ -365,6 +365,192 @@ constructor_map = {
'writer' : writer_constructor_list,
}
custom_widgets = [
'ArgEdit',
'AutoCompleteMultiListBox',
'AutoCorrEdit',
'AutoFormatPreview',
'BackgroundPreview',
'BmpWindow',
'BookmarksBox',
'CaptionComboBox',
'CategoryListBox',
'ClassificationEditView',
'ColorConfigCtrl',
'ColorFieldControl',
'ColorPreviewControl',
'ColorSliderControl',
'ColumnEdit',
'ColumnValueSet',
'CommandCategoryListBox',
'ConditionEdit',
'ContentListBox',
'ContextVBox',
'CuiCustomMultilineEdit',
'CustomPropertiesControl',
'DataTreeListBox',
'DialControl',
'DriverListControl',
'DropdownBox',
'EditBox',
'EmbossControl',
'EmojiView',
'ExtBoxWithBtns',
'ExtensionBox',
'FEdit',
'FontNameBox',
'FontSizeBox',
'FontStyleBox',
'FontStyleBox',
'FormattedField',
'FormulaListBox',
'FrameDirectionListBox',
'GalleryPreview',
'GraphCtrl',
'GraphicPreviewWindow',
'HexColorControl',
'HyphenEdit',
'IndexBox',
'IndexBox',
'IntellectualPropertyPartEdit',
'LightButton',
'LineEndLB',
'LineLB',
'LineListBox',
'LookUpComboBox',
'MacroEventListBox',
'ManagedMenuButton',
'MultiLineEditSyntaxHighlight',
'NumFormatListBox',
'NumberingPreview',
'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',
'ScExtIButton',
'ScPivotLayoutTreeList',
'ScPivotLayoutTreeListData',
'ScPivotLayoutTreeListLabel',
'ScRefButtonEx',
'ScTabBgColorValueSet',
'SdPageObjsTLB',
'SearchBox',
'SearchResultsBox',
'SelectionListBox',
'SentenceEditWindow',
'SeriesListBox',
'SfxAccCfgTabListBox',
'SfxConfigFunctionListBox',
'SfxConfigGroupListBox',
'SfxPreviewWin',
'ShowNupOrderWindow',
'ShowNupOrderWindow',
'SidebarDialControl',
'SidebarToolBox',
'SlideTransitionBox',
'SmallButton',
'SmallButton',
'SpacingListBox',
'StatusBar',
'StructListBox',
'SuggestionDisplay',
'SuggestionEdit',
'SvSimpleTableContainer',
'SvTabListBox',
'SvTreeListBox',
'SvtFileView',
'SvtIconChoiceCtrl',
'SvtURLBox',
'Svx3DPreviewControl',
'SvxBmpNumValueSet',
'SvxCharView',
'SvxCheckListBox',
'SvxColorListBox',
'SvxColorValueSet',
'SvxCropExample',
'SvxDictEdit',
'SvxFillAttrBox',
'SvxFillTypeBox',
'SvxFontListBox',
'SvxFontPrevWindow',
'SvxFrameSelector',
'SvxHlmarkTreeLBox',
'SvxHyperURLBox',
'SvxLanguageBox',
'SvxLanguageComboBox',
'SvxLanguageComboBox',
'SvxLightCtl3D',
'SvxNoSpaceEdit',
'SvxNumValueSet',
'SvxNumberPreview',
'SvxNumberingPreview',
'SvxPageWindow',
'SvxParaPrevWindow',
'SvxPathControl',
'SvxPixelCtl',
'SvxPresetListBox',
'SvxRectCtl',
'SvxRelativeField',
'SvxSearchCharSet',
'SvxShowCharSet',
'SvxShowText',
'SvxSwFrameExample',
'SvxTextEncodingBox',
'SvxTextEncodingBox',
'SvxXConnectionPreview',
'SvxXLinePreview',
'SvxXMeasurePreview',
'SvxXRectPreview',
'SvxXShadowPreview',
'SwAddressPreview',
'SwCaptionPreview',
'SwColExample',
'SwColumnOnlyExample',
'SwDropCapsPict',
'SwEnvPreview',
'SwFieldRefTreeListBox',
'SwGlTreeListBox',
'SwGlossaryGroupTLB',
'SwIdxTreeListBox',
'SwLabPreview',
'SwMarkPreview',
'SwNavHelpToolBox',
'SwNumberingTypeListBox',
'SwPageGridExample',
'SwTokenWindow',
'TabWin_Impl',
'TableDesignBox',
'TableValueSet',
'TemplateDefaultView',
'TemplateLocalView',
'TemplateSearchView',
'TextDirectionListBox',
'ThesaurusAlternativesCtrl',
'ValueSet',
]
def get_constructor_guard(constructor):
if type(full_constructor_map[constructor]) is bool:
return None
......@@ -469,6 +655,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)
......
......@@ -1181,6 +1181,10 @@ void VclBuilder::preload()
#endif // DISABLE_DYNLOADING
}
#if defined DISABLE_DYNLOADING && !HAVE_FEATURE_DESKTOP
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,
stringmap &rMap)
{
......@@ -1698,12 +1702,12 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
}
else
pFunction = reinterpret_cast<customMakeWidget>(aI->second->getFunctionSymbol(sFunction));
#elif !HAVE_FEATURE_DESKTOP
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));
#if !HAVE_FEATURE_DESKTOP
SAL_WARN_IF(!pFunction, "vcl.layout", "Lookup of " << sFunction << " failed");
assert(pFunction);
#endif
#endif
if (pFunction)
{
......
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