summaryrefslogtreecommitdiff
path: root/xmlscript
diff options
context:
space:
mode:
authorShubham Goyal <22shubh22@gmail.com>2019-02-26 23:02:40 +0530
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-03-08 15:51:23 +0100
commit732d630c3d2a168c725c18e4dd8df7a0a4f85566 (patch)
treeaf02abe6e0b2346c46a464b8063faa81ee11ed7d /xmlscript
parentcfdba2b94fd7c0a2ec0250ddc9212d367db50c8c (diff)
tdf#53524 Create UNO grid control- dialog editor
The commit is based on the patch in https://bz.apache.org/ooo/show_bug.cgi?id=120066. Change-Id: Ia4ad536331954679940104adf5d6178228c90854 Reviewed-on: https://gerrit.libreoffice.org/68814 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'xmlscript')
-rw-r--r--xmlscript/dtd/dialog.dtd20
-rw-r--r--xmlscript/source/xmldlg_imexp/exp_share.hxx1
-rw-r--r--xmlscript/source/xmldlg_imexp/imp_share.hxx18
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx41
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx59
5 files changed, 138 insertions, 1 deletions
diff --git a/xmlscript/dtd/dialog.dtd b/xmlscript/dtd/dialog.dtd
index 4d9b93355c86..364517311405 100644
--- a/xmlscript/dtd/dialog.dtd
+++ b/xmlscript/dtd/dialog.dtd
@@ -59,7 +59,8 @@
dlg:formattedfield|
dlg:fixedline|
dlg:progressmeter|
- dlg:scrollbar
+ dlg:scrollbar|
+ dlg:table
)">
<!ELEMENT dlg:window (dlg:styles*, (%event;)*, dlg:bulletinboard*)>
@@ -395,3 +396,20 @@
dlg:value-min %numeric; #IMPLIED
dlg:value-max %numeric; #IMPLIED
>
+
+<!ELEMENT dlg:table ((%event;)*)>
+<!ATTLIST dlg:table %default-attributes;
+ dlg:showcolumnheader %boolean; #IMPLIED
+ dlg:showrowheader %boolean; #IMPLIED
+ dlg:gridline-color %numeric; #IMPLIED
+ dlg:usegridlines %boolean; #IMPLIED
+ dlg:headerbackground-color %numeric; #IMPLIED
+ dlg:headertext-color %numeric; #IMPLIED
+ dlg:activeselectionbackground-color %numeric; #IMPLIED
+ dlg:activeselectiontext-color %numeric; #IMPLIED
+ dlg:inactiveselectionbackground-color %numeric; #IMPLIED
+ dlg:inactiveselectiontext-color %numeric; #IMPLIED
+ dlg:selectiontype CDATA #IMPLIED
+ dlg:valign (top|center|bottom) #IMPLIED
+ dlg:tabstop %boolean; #IMPLIED
+ >
diff --git a/xmlscript/source/xmldlg_imexp/exp_share.hxx b/xmlscript/source/xmldlg_imexp/exp_share.hxx
index 39dc1fc3b9ef..f167f5320d43 100644
--- a/xmlscript/source/xmldlg_imexp/exp_share.hxx
+++ b/xmlscript/source/xmldlg_imexp/exp_share.hxx
@@ -201,6 +201,7 @@ public:
void readScrollBarModel( StyleBag * all_styles );
void readSpinButtonModel( StyleBag * all_styles );
void readFixedHyperLinkModel( StyleBag * all_styles );
+ void readGridControlModel( StyleBag * all_styles );
};
template<typename T>
diff --git a/xmlscript/source/xmldlg_imexp/imp_share.hxx b/xmlscript/source/xmldlg_imexp/imp_share.hxx
index 2108c340cfbe..a798dfb301f6 100644
--- a/xmlscript/source/xmldlg_imexp/imp_share.hxx
+++ b/xmlscript/source/xmldlg_imexp/imp_share.hxx
@@ -1028,6 +1028,24 @@ public:
{}
};
+//==============================================================================
+class GridControlElement
+ : public ControlElement
+{
+public:
+ virtual css::uno::Reference< css::xml::input::XElement >
+ SAL_CALL startChildElement(
+ sal_Int32 nUid,::rtl::OUString const & rLocalName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes ) override;
+ virtual void SAL_CALL endElement() override;
+
+ GridControlElement(OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
}
#endif // INCLUDED_XMLSCRIPT_SOURCE_XMLDLG_IMEXP_IMP_SHARE_HXX
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
index 0fde594f8921..e86038147a7f 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
@@ -1009,6 +1009,42 @@ void ElementDescriptor::readScrollBarModel( StyleBag * all_styles )
readEvents();
}
+void ElementDescriptor::readGridControlModel( StyleBag * all_styles )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp("BackgroundColor") >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readProp("TextColor") >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp("TextLineColor") >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( XMLNS_DIALOGS_PREFIX ":style-id",all_styles->getStyleId( aStyle ) );
+ }
+ // collect elements
+ readDefaults();
+ readBoolAttr("Tabstop", XMLNS_DIALOGS_PREFIX ":tabstop");
+ readVerticalAlignAttr( "VerticalAlign", XMLNS_DIALOGS_PREFIX ":valign");
+ readSelectionTypeAttr( "SelectionModel", XMLNS_DIALOGS_PREFIX ":selectiontype");
+ readBoolAttr( "ShowColumnHeader", XMLNS_DIALOGS_PREFIX ":showcolumnheader");
+ readBoolAttr( "ShowRowHeader", XMLNS_DIALOGS_PREFIX ":showrowheader");
+ readHexLongAttr( "GridLineColor", XMLNS_DIALOGS_PREFIX ":gridline-color");
+ readBoolAttr( "UseGridLines", XMLNS_DIALOGS_PREFIX ":usegridlines" );
+ readHexLongAttr( "HeaderBackgroundColor", XMLNS_DIALOGS_PREFIX ":headerbackground-color");
+ readHexLongAttr( "HeaderTextColor", XMLNS_DIALOGS_PREFIX ":headertext-color");
+ readHexLongAttr( "ActiveSelectionBackgroundColor", XMLNS_DIALOGS_PREFIX ":activeselectionbackground-color");
+ readHexLongAttr( "ActiveSelectionTextColor", XMLNS_DIALOGS_PREFIX ":activeselectiontext-color");
+ readHexLongAttr( "InactiveSelectionBackgroundColor", XMLNS_DIALOGS_PREFIX ":inactiveselectionbackground-color");
+ readHexLongAttr( "InactiveSelectionTextColor", XMLNS_DIALOGS_PREFIX ":inactiveselectiontext-color");
+ readEvents();
+}
+
void ElementDescriptor::readDialogModel( StyleBag * all_styles )
{
// collect elements
@@ -1216,6 +1252,11 @@ void ElementDescriptor::readBullitinBoard( StyleBag * all_styles )
pElem = new ElementDescriptor( xProps, xPropState, XMLNS_DIALOGS_PREFIX ":progressmeter", _xDocument );
pElem->readProgressBarModel( all_styles );
}
+ else if (xServiceInfo->supportsService( "com.sun.star.awt.grid.UnoControlGridModel" ) )
+ {
+ pElem = new ElementDescriptor( xProps, xPropState, XMLNS_DIALOGS_PREFIX ":table", _xDocument );
+ pElem->readGridControlModel( all_styles );
+ }
if (pElem)
{
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
index d73182609010..0a2a2f45b992 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
@@ -1701,6 +1701,11 @@ Reference< xml::input::XElement > BulletinBoardElement::startChildElement(
{
return new ProgressBarElement( rLocalName, xAttributes, this, m_xImport.get() );
}
+ // table
+ else if (rLocalName == "table")
+ {
+ return new GridControlElement( rLocalName, xAttributes, this, m_xImport.get() );
+ }
else if ( rLocalName == "multipage" )
{
return new MultiPage( rLocalName, xAttributes, this, m_xImport.get() );
@@ -1841,6 +1846,60 @@ void WindowElement::endElement()
_events.clear();
}
+// table
+Reference< xml::input::XElement > GridControlElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ // event
+ if (m_xImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() );
+ }
+ else
+ {
+ throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() );
+ }
+}
+
+void GridControlElement::endElement()
+{
+ ControlImportContext ctx( m_xImport.get(), getControlId( _xAttributes ), "com.sun.star.awt.grid.UnoControlGridModel");
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
+ ctx.importVerticalAlignProperty( "VerticalAlign", "valign", _xAttributes );
+ ctx.importSelectionTypeProperty( "SelectionModel", "selectiontype", _xAttributes );
+ ctx.importBooleanProperty( "ShowColumnHeader", "showcolumnheader", _xAttributes );
+ ctx.importBooleanProperty( "ShowRowHeader", "showrowheader", _xAttributes );
+ ctx.importHexLongProperty( "GridLineColor", "gridline-color", _xAttributes );
+ ctx.importBooleanProperty( "UseGridLines", "usegridlines", _xAttributes );
+ ctx.importHexLongProperty( "HeaderBackgroundColor", "headerbackground-color", _xAttributes );
+ ctx.importHexLongProperty( "HeaderTextColor", "headertext-color", _xAttributes );
+ ctx.importHexLongProperty( "ActiveSelectionBackgroundColor", "activeselectionbackground-color", _xAttributes );
+ ctx.importHexLongProperty( "ActiveSelectionTextColor", "activeselectiontext-color", _xAttributes );
+ ctx.importHexLongProperty( "InactiveSelectionBackgroundColor", "inactiveselectionbackground-color", _xAttributes );
+ ctx.importHexLongProperty( "InactiveSelectionTextColor", "inactiveselectiontext-color", _xAttributes );
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+
+ ctx.finish();
+}
+
+//##################################################################################################
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */