User:Hanya/Hyperlink Control on Dialog Editor

From Apache OpenOffice Wiki
Jump to: navigation, search

This is small memo to add new function to make new type of control on the dialog editor of the Basic IDE for further control addition.

The following differences are shorten, see attached patch in the issue: issue 119731.

Hyperlink control can be used on the dialog in this several years. But it can not be prepared by the dialog editor of the Basic IDE. And also, dialog xdl file containing hyperlink control, dlg:liklabel element can not be loaded by the library of Basic. It can be instantiated by css.awt.DialogProvider service with system path to the file but can not with vnd.sun.star.script protocol.


XDL file filter

The element dlg:linklabel is implemented already, so load/store function is not required to be added.

The hyperlink control model has these properties:

Label
Shown like a label of FixedText.
URL
URL to open when the control is clicked.

In the xdl filter, "Description" property is loaded and stored but the implementation of the model does not support it. And it is the problem to fail to load the xdl file by library of the basic. Simply, these lines are removed.

Index: xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
===================================================================
--- xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx	(revision 1344995)
+++ xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx	(working copy)
@@ -1124,9 +1124,10 @@
-    ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Description") ),
-							  OUString( RTL_CONSTASCII_USTRINGPARAM("description") ),
-							  _xAttributes );
+    // no Description defined in IDL and not implemented by imple
+    //ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Description") ),
+	//						  OUString( RTL_CONSTASCII_USTRINGPARAM("description") ),
+	//						  _xAttributes );
Index: xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
===================================================================
--- xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx	(revision 1344995)
+++ xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx	(working copy)
@@ -502,8 +502,8 @@
-	readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Description") ),
-                    OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":description") ) );
+	//readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Description") ),
+    //                OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":description") ) );

DTD for xdl file, dialog.dtd should be updated also.

Index: xmlscript/dtd/dialog.dtd
===================================================================
--- xmlscript/dtd/dialog.dtd	(revision 1344995)
+++ xmlscript/dtd/dialog.dtd	(working copy)
@@ -64,7 +64,8 @@
-                     dlg:scrollbar
+                     dlg:scrollbar|
+                     dlg:linklabel
                     )">
 
 <!ELEMENT dlg:window (dlg:styles*, (%event;)*, dlg:bulletinboard*)>
@@ -227,6 +228,16 @@
+<!ELEMENT dlg:linklabel ((%event;)*)>
+<!ATTLIST dlg:linklabel %default-attributes;
+                   dlg:value CDATA #IMPLIED
+                   dlg:url CDATA #IMPLIED
+                   dlg:align (left|center|right) #IMPLIED
+                   dlg:valign (top|center|bottom) #IMPLIED
+                   dlg:multiline %boolean; #IMPLIED
+                   dlg:tabstop %boolean; #IMPLIED
+                   >

Command

New command to insert hyperlink control is required. Commands placed on controls Toolbox toolbar are bound to SID_CHOOSE_CONTROLS.

Defined new SID for insert hyperlink control in main/svx/sdi/svx.sdi .

Index: svx/sdi/svx.sdi
===================================================================
--- svx/sdi/svx.sdi	(revision 1344995)
+++ svx/sdi/svx.sdi	(working copy)
@@ -3590,6 +3590,33 @@
+SfxBoolItem InsertHyperlinkControl SID_INSERT_HYPERLINKCONTROL
+
+[
+	/* flags: */
+	AutoUpdate = TRUE,
+	Cachable = Cachable,
+	FastCall = FALSE,
+	HasCoreId = FALSE,
+	HasDialog = FALSE,
+	ReadOnlyDoc = FALSE,
+	Toggle = FALSE,
+	Container = FALSE,
+	RecordAbsolute = FALSE,
+	RecordPerSet;
+	Synchron;
+
+	Readonly = FALSE,
+
+	/* config: */
+	AccelConfig = TRUE,
+	MenuConfig = TRUE,
+	StatusBarConfig = FALSE,
+	ToolBoxConfig = TRUE,
+	GroupId = GID_CONTROLS;
+]

Defined new slot in main/svx/inc/svx/svxids.hrc .

Index: svx/inc/svx/svxids.hrc
===================================================================
--- svx/inc/svx/svxids.hrc	(revision 1344995)
+++ svx/inc/svx/svxids.hrc	(working copy)
@@ -1257,6 +1257,7 @@
 #define SID_TRANSLITERATE_TOGGLE_CASE                   (SID_SVX_START+1104)
+#define SID_INSERT_HYPERLINKCONTROL						(SID_SVX_START+1105)

Defined new textual command in main/svx/inc/svx/svxcommands.h .

Index: svx/inc/svx/svxcommands.h
===================================================================
--- svx/inc/svx/svxcommands.h	(revision 1344995)
+++ svx/inc/svx/svxcommands.h	(working copy)
@@ -154,6 +154,7 @@
+#define CMD_SID_INSERT_HYPERLINKCONTROL             ".uno:InsertHyperlinkControl"

Added new enum entry in SvxChooseControlEnum, main/basctl/source/basicide/idetemp.hxx .

Index: basctl/source/basicide/idetemp.hxx
===================================================================
--- basctl/source/basicide/idetemp.hxx	(revision 1344995)
+++ basctl/source/basicide/idetemp.hxx	(working copy)
@@ -52,7 +52,8 @@
-	SVX_SNAP_TREECONTROL
+	SVX_SNAP_TREECONTROL,
+	SVX_SNAP_HYPERLINKCONTROL
 };
 
 #define SvxChooseControlItem SfxAllEnumItem

And also the same enum is there: SvxChooseControlEnum, main/svx/sdi/svxitems.sdi .

Index: svx/sdi/svxitems.sdi
===================================================================
--- svx/sdi/svxitems.sdi	(revision 1344995)
+++ svx/sdi/svxitems.sdi	(working copy)
@@ -80,7 +80,8 @@
-	SVX_SNAP_TREECONTROL
+	SVX_SNAP_TREECONTROL,
+	SVX_SNAP_HYPERLINKCONTROL
 }
 item SvxChooseControlEnum SvxChooseControlItem;

Defined new label for the command in main/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu .

Index: officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
===================================================================
--- officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu	(revision 1344995)
+++ officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu	(working copy)
@@ -2556,6 +2556,14 @@
+            <node oor:name=".uno:InsertHyperlinkControl" oor:op="replace">
+                <prop oor:name="Label" oor:type="xs:string">
+                    <value xml:lang="en-US">Hyperlink Control</value>
+                </prop>
+                <prop oor:name="Properties" oor:type="xs:int">
+                    <value>1</value>
+                </prop>
+            </node>

Added new entry to the toolbar for new command in main/basctl/uiconfig/basicide/toolbar/insertcontrolsbar.xml .

Index: basctl/uiconfig/basicide/toolbar/insertcontrolsbar.xml
===================================================================
--- basctl/uiconfig/basicide/toolbar/insertcontrolsbar.xml	(revision 1344995)
+++ basctl/uiconfig/basicide/toolbar/insertcontrolsbar.xml	(working copy)
@@ -62,4 +62,5 @@
+ <toolbar:toolbaritem xlink:href=".uno:InsertHyperlinkControl" toolbar:style="radio" />
 </toolbar:toolbar>

If the entry is not defined in svx/sdi/svxitems.sdi, new SID is not included in inc/basslot.hxx file and its button is always disabled.

String resource

Defined RID in main/basctl/source/inc/dlgresid.hrc .

Index: basctl/source/inc/dlgresid.hrc
===================================================================
--- basctl/source/inc/dlgresid.hrc	(revision 1344995)
+++ basctl/source/inc/dlgresid.hrc	(working copy)
@@ -54,6 +54,7 @@
+#define RID_STR_CLASS_HYPERLINKCONTROL		( RID_DLG_START +  24 )

Added string resource in basctl/source/dlged/dlgresid.src .

Index: basctl/source/dlged/propbrw.cxx
===================================================================
--- basctl/source/dlged/propbrw.cxx	(revision 1344995)
+++ basctl/source/dlged/propbrw.cxx	(working copy)
@@ -488,6 +488,10 @@
+		else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedHyperlinkModel" ) ) ) )
+		{
+			nResId = RID_STR_CLASS_HYPERLINKCONTROL;
+		}

This resource is used for title name of the property browser in basctl/source/dlged/propbrw.cxx and to get default name of the control in basctl/source/dlged/dlgedobj.cxx.

Index: basctl/source/dlged/dlgedobj.cxx
===================================================================
--- basctl/source/dlged/dlgedobj.cxx	(revision 1344995)
+++ basctl/source/dlged/dlgedobj.cxx	(working copy)
@@ -795,6 +795,10 @@
+	else if ( supportsService( "com.sun.star.awt.UnoControlFixedHyperlinkModel" ) )
+	{
+		nResId = RID_STR_CLASS_HYPERLINKCONTROL;
+	}
@@ -925,6 +929,10 @@
+	else if ( supportsService( "com.sun.star.awt.UnoControlFixedHyperlinkModel" ))
+	{
+		return OBJ_DLG_HYPERLINKCONTROL;
+	}

Icons should be stored in main/defalut_images/res/commandlist with name "inserthyperlinkcontrol" and prefixes.

Implementation

Impelementation for inserting hyperlink control is done according to the existing way for other controls.

Defined OBJ id in basctl/source/inc/dlgeddef.hxx .

Index: basctl/source/inc/dlgeddef.hxx
===================================================================
--- basctl/source/inc/dlgeddef.hxx	(revision 1344995)
+++ basctl/source/inc/dlgeddef.hxx	(working copy)
@@ -57,7 +57,9 @@
+#define OBJ_DLG_HYPERLINKCONTROL  ((sal_uInt16)25)

New instance of the control model is created in basctl/source/dlged/dlgedfac.cxx .

Index: basctl/source/dlged/dlgedfac.cxx
===================================================================
--- basctl/source/dlged/dlgedfac.cxx	(revision 1344995)
+++ basctl/source/dlged/dlgedfac.cxx	(working copy)
@@ -70,7 +70,7 @@
 	if( (pObjFactory->nInventor == DlgInventor) &&
 		(pObjFactory->nIdentifier >= OBJ_DLG_PUSHBUTTON) &&
-		(pObjFactory->nIdentifier <= OBJ_DLG_TREECONTROL)    )
+		(pObjFactory->nIdentifier <= OBJ_DLG_HYPERLINKCONTROL)    )
@@ -184,76 +184,11 @@
+			case OBJ_DLG_HYPERLINKCONTROL:
+				 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFixedHyperlinkModel"), xDialogSFact );
+				 break;

Default label for new instance is set in basctl/source/dlged/dlgedobj.cxx .

@@ -1085,7 +1093,8 @@
-			    supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ) )
+			    supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ) || 
+			    supportsService( "com.sun.star.awt.UnoControlFixedHyperlinkModel" ))

The state of the command like after clicking of the toolbar button, processed in

Index: basctl/source/basicide/tbxctl.cxx
===================================================================
--- basctl/source/basicide/tbxctl.cxx	(revision 1344995)
+++ basctl/source/basicide/tbxctl.cxx	(working copy)
@@ -171,7 +171,8 @@
+				case SVX_SNAP_HYPERLINKCONTROL: nTemp = SID_INSERT_HYPERLINKCONTROL; break;
Index: basctl/source/basicide/baside3.cxx
===================================================================
--- basctl/source/basicide/baside3.cxx	(revision 1344995)
+++ basctl/source/basicide/baside3.cxx	(working copy)
@@ -391,8 +391,9 @@
+							case OBJ_DLG_HYPERLINKCONTROL:  nObj = SVX_SNAP_HYPERLINKCONTROL; break;

When the command is executed and it is for insert hyperlink control:

@@ -598,6 +599,12 @@
+				case SVX_SNAP_HYPERLINKCONTROL:
+				{
+					GetEditor()->SetMode( DLGED_INSERT );
+					GetEditor()->SetInsertObj( OBJ_DLG_HYPERLINKCONTROL );
+				}
+				break;

Property browser

When created contro is selected on the dialog editor, and then Properties button is clicked, property browser is shown and it shows list of properties of the selected controls. Its implementation is there under main/extensions/source/propctrlr .

Added new HID in extensions/inc/propctrlr.hrc and extensions/util/hidother.src .

+#define HID_PROP_URL                                    "EXTENSIONS_HID_PROP_URL"

Added HID.

+hidspecial HID_PROP_URL                         { HelpId = HID_PROP_URL; }

Defined property id for URL in extensions/source/propctrlr/formmetadata.hxx .

+    #define PROPERTY_ID_URL                         203

Added URL property to show in extensions/source/propctrlr/formmetadata.cxx .

@@ -354,7 +354,8 @@
+		DEF_INFO_2( URL,               URL,                URL,            

Added to choose control type in extensions/source/propctrlr/formcomponenthandler.cxx .

@@ -1088,6 +1088,7 @@
+        case PROPERTY_ID_URL:

Added resource id for URL property in extensions/source/propctrlr/formresid.hrc .

+#define RID_STR_URL                         ( RID_FORMBROWSER_START + 256 )

Defined label for the URL property in extensions/source/propctrlr/formres.src .

@@ -1517,3 +1517,8 @@
+String RID_STR_URL
+{
+    Text [ en-US ] = "URL";
+};

Define textual property name in extensions/source/propctrlr/formstrings.hxx .

+	PCR_CONSTASCII_STRING( PROPERTY_URL,                    "URL" );

Multiservice factory of the dialog model

The multiservice factory interface of css.awt.UnoControlDialogModel can instantiate css.awt.UnoControlFixedHyperlinkModel service but it is not listed in available service names.

Index: toolkit/source/controls/controlmodelcontainerbase.cxx
===================================================================
--- toolkit/source/controls/controlmodelcontainerbase.cxx	(revision 1344995)
+++ toolkit/source/controls/controlmodelcontainerbase.cxx	(working copy)
@@ -429,7 +429,7 @@
-		pNamesSeq = new Sequence< ::rtl::OUString >( 24 );
+		pNamesSeq = new Sequence< ::rtl::OUString >( 25 );
@@ -455,6 +455,7 @@
+		pNames[24] = ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedHyperlinkModel );

Problems

Created xdl file including hyperlink control can not be loaded because of the filter problem mentioned above.

Personal tools