solenv/bin/native-code.py     |  204 ++++++++++++++++++++++++++++++++++++++++++
 vcl/source/window/builder.cxx |   12 +-
 2 files changed, 212 insertions(+), 4 deletions(-)

New commits:
commit 2bc5ab312b1cdb8c299253a54fecdd3c64319fd2
Author:     Tor Lillqvist <t...@collabora.com>
AuthorDate: Tue Nov 6 10:17:10 2018 +0200
Commit:     Tor Lillqvist <t...@collabora.com>
CommitDate: Tue Nov 6 12:00:55 2018 +0100

    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/62946
    Reviewed-by: Tor Lillqvist <t...@collabora.com>
    Tested-by: Tor Lillqvist <t...@collabora.com>

diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index 430a429e9b6d..82c030ff79b5 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -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)
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index d8b80b5a10a5..b3e88485c743 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -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)
             {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to