summaryrefslogtreecommitdiff
path: root/xmlscript
diff options
context:
space:
mode:
Diffstat (limited to 'xmlscript')
-rw-r--r--xmlscript/dtd/dialog.dtd405
-rw-r--r--xmlscript/dtd/libraries.dtd45
-rw-r--r--xmlscript/dtd/library.dtd44
-rw-r--r--xmlscript/dtd/module.dtd35
-rw-r--r--xmlscript/inc/makefile.mk47
-rw-r--r--xmlscript/inc/pch/precompiled_xmlscript.cxx31
-rw-r--r--xmlscript/inc/pch/precompiled_xmlscript.hxx34
-rw-r--r--xmlscript/inc/xmlscript/xml_helper.hxx149
-rw-r--r--xmlscript/inc/xmlscript/xml_import.hxx69
-rw-r--r--xmlscript/inc/xmlscript/xmldlg_imexp.hxx94
-rw-r--r--xmlscript/inc/xmlscript/xmllib_imexp.hxx97
-rw-r--r--xmlscript/inc/xmlscript/xmlmod_imexp.hxx68
-rw-r--r--xmlscript/inc/xmlscript/xmlns.h48
-rw-r--r--xmlscript/prj/build.lst10
-rw-r--r--xmlscript/prj/d.lst13
-rw-r--r--xmlscript/source/inc/misc.hxx66
-rw-r--r--xmlscript/source/misc/makefile.mk48
-rw-r--r--xmlscript/source/misc/unoservices.cxx134
-rw-r--r--xmlscript/source/xml_helper/makefile.mk50
-rw-r--r--xmlscript/source/xml_helper/xml_byteseq.cxx176
-rw-r--r--xmlscript/source/xml_helper/xml_element.cxx135
-rw-r--r--xmlscript/source/xml_helper/xml_impctx.cxx907
-rw-r--r--xmlscript/source/xmldlg_imexp/common.hxx45
-rw-r--r--xmlscript/source/xmldlg_imexp/exp_share.hxx252
-rw-r--r--xmlscript/source/xmldlg_imexp/imp_share.hxx1073
-rw-r--r--xmlscript/source/xmldlg_imexp/makefile.mk52
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx144
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx1345
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_export.cxx1630
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx2680
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_import.cxx1931
-rw-r--r--xmlscript/source/xmlflat_imexp/makefile.mk50
-rw-r--r--xmlscript/source/xmlflat_imexp/xmlbas_export.cxx554
-rw-r--r--xmlscript/source/xmlflat_imexp/xmlbas_export.hxx135
-rw-r--r--xmlscript/source/xmlflat_imexp/xmlbas_import.cxx934
-rw-r--r--xmlscript/source/xmlflat_imexp/xmlbas_import.hxx348
-rw-r--r--xmlscript/source/xmllib_imexp/imp_share.hxx266
-rw-r--r--xmlscript/source/xmllib_imexp/makefile.mk50
-rw-r--r--xmlscript/source/xmllib_imexp/xmllib_export.cxx178
-rw-r--r--xmlscript/source/xmllib_imexp/xmllib_import.cxx375
-rw-r--r--xmlscript/source/xmlmod_imexp/imp_share.hxx146
-rw-r--r--xmlscript/source/xmlmod_imexp/makefile.mk49
-rw-r--r--xmlscript/source/xmlmod_imexp/xmlmod_export.cxx82
-rw-r--r--xmlscript/source/xmlmod_imexp/xmlmod_import.cxx232
-rw-r--r--xmlscript/test/imexp.cxx244
-rw-r--r--xmlscript/test/makefile.mk85
-rw-r--r--xmlscript/test/test.xml106
-rw-r--r--xmlscript/test/w3c.jpgbin0 -> 2028 bytes
-rw-r--r--xmlscript/util/makefile.mk77
-rw-r--r--xmlscript/util/target.pmk35
-rw-r--r--xmlscript/util/xcr.flt13
51 files changed, 15816 insertions, 0 deletions
diff --git a/xmlscript/dtd/dialog.dtd b/xmlscript/dtd/dialog.dtd
new file mode 100644
index 000000000000..020ceedd5a5e
--- /dev/null
+++ b/xmlscript/dtd/dialog.dtd
@@ -0,0 +1,405 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ Copyright 2000, 2010 Oracle and/or its affiliates.
+
+ OpenOffice.org - a multi-platform office productivity suite
+
+ This file is part of OpenOffice.org.
+
+ OpenOffice.org is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License version 3
+ only, as published by the Free Software Foundation.
+
+ OpenOffice.org is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License version 3 for more details
+ (a copy is included in the LICENSE file that accompanied this code).
+
+ You should have received a copy of the GNU Lesser General Public License
+ version 3 along with OpenOffice.org. If not, see
+ <http://www.openoffice.org/license.html>
+ for a copy of the LGPLv3 License.
+
+-->
+
+<!ENTITY % boolean "(true|false)">
+<!ENTITY % numeric "CDATA">
+
+<!ENTITY % default-attributes "dlg:id CDATA #REQUIRED
+ dlg:left %numeric; #REQUIRED
+ dlg:top %numeric; #REQUIRED
+ dlg:width %numeric; #REQUIRED
+ dlg:height %numeric; #REQUIRED
+ dlg:style-id CDATA #IMPLIED
+ dlg:tab-index %numeric; #IMPLIED
+ dlg:disabled %boolean; #IMPLIED
+ dlg:printable %boolean; #IMPLIED
+ dlg:page %numeric; #IMPLIED
+ dlg:tag CDATA #IMPLIED
+ dlg:help-text CDATA #IMPLIED
+ dlg:help-url CDATA #IMPLIED
+ ">
+
+<!ENTITY % event "(script:event|
+ script:listener-event|
+ dlg:event
+ )">
+
+<!ENTITY % control "(dlg:bulletinboard|
+ dlg:button|
+ dlg:checkbox|
+ dlg:combobox|
+ dlg:menulist|
+ dlg:radiogroup|
+ dlg:titledbox|
+ dlg:textfield|
+ dlg:text|
+ dlg:filecontrol|
+ dlg:img|
+ dlg:timefield|
+ dlg:datefield|
+ dlg:numericfield|
+ dlg:currencyfield|
+ dlg:patternfield|
+ dlg:formattedfield|
+ dlg:fixedline|
+ dlg:progressmeter|
+ dlg:scrollbar
+ )">
+
+<!ELEMENT dlg:window (dlg:styles*, (%event;)*, dlg:bulletinboard*)>
+<!ATTLIST dlg:window %default-attributes;
+ dlg:closeable %boolean; #IMPLIED
+ dlg:moveable %boolean; #IMPLIED
+ dlg:resizeable %boolean; #IMPLIED
+ dlg:title CDATA #IMPLIED
+ dlg:withtitlebar CDATA #IMPLIED
+ dlg:image-src CDATA #IMPLIED
+ xmlns:dlg CDATA #FIXED "http://openoffice.org/2000/dialog"
+ xmlns:script CDATA #FIXED "http://openoffice.org/2000/script"
+ >
+
+<!ELEMENT dlg:styles (dlg:style+)>
+
+<!ELEMENT dlg:style EMPTY>
+<!ATTLIST dlg:style dlg:style-id CDATA #REQUIRED
+ dlg:background-color %numeric; #IMPLIED
+ dlg:text-color %numeric; #IMPLIED
+ dlg:textline-color %numeric; #IMPLIED
+ dlg:fill-color %numeric; #IMPLIED
+ dlg:border CDATA #IMPLIED
+ dlg:font-name CDATA #IMPLIED
+ dlg:font-height %numeric; #IMPLIED
+ dlg:font-width %numeric; #IMPLIED
+ dlg:font-stylename CDATA #IMPLIED
+ dlg:font-family (decorative|modern|roman|script|swiss|system) #IMPLIED
+ dlg:font-charset (ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol) #IMPLIED
+ dlg:font-pitch (fixed|variable) #IMPLIED
+ dlg:font-charwidth %numeric; #IMPLIED
+ dlg:font-weight %numeric; #IMPLIED
+ dlg:font-slant (oblique|italic|reverse_oblique|reverse_italic) #IMPLIED
+ dlg:font-underline (single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave) #IMPLIED
+ dlg:font-strikeout (single|double|bold|slash|x) #IMPLIED
+ dlg:font-orientation CDATA #IMPLIED
+ dlg:font-kerning %boolean; #IMPLIED
+ dlg:font-wordlinemode %boolean; #IMPLIED
+ dlg:font-type (raster|device|scalable) #IMPLIED
+ dlg:font-relief (none|embossed|engraved) #IMPLIED
+ dlg:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED
+ dlg:look (none|3d|simple) #IMPLIED
+ >
+
+<!ELEMENT script:event EMPTY>
+<!ATTLIST script:event script:location CDATA #IMPLIED
+ script:language CDATA #REQUIRED
+ script:macro-name CDATA #REQUIRED
+ script:event-name CDATA #REQUIRED
+ >
+<!ELEMENT script:listener-event EMPTY>
+<!ATTLIST script:listener-event script:location CDATA #IMPLIED
+ script:language CDATA #REQUIRED
+ script:macro-name CDATA #REQUIRED
+ script:listener-type CDATA #REQUIRED
+ script:listener-method CDATA #REQUIRED
+ script:listener-param CDATA #IMPLIED
+ >
+<!-- deprecated -->
+<!ELEMENT dlg:event EMPTY>
+<!ATTLIST dlg:event dlg:listener-type CDATA #REQUIRED
+ dlg:event-method CDATA #REQUIRED
+ dlg:script-type CDATA #IMPLIED
+ dlg:script-code CDATA #IMPLIED
+ dlg:param CDATA #IMPLIED
+ >
+<!-- /deprecated -->
+
+<!ELEMENT dlg:bulletinboard ((%control;)*)>
+<!ATTLIST dlg:bulletinboard dlg:left %numeric; #IMPLIED
+ dlg:top %numeric; #IMPLIED
+ >
+
+<!ELEMENT dlg:button ((%event;)*)>
+<!ATTLIST dlg:button %default-attributes;
+ dlg:value CDATA #IMPLIED
+ dlg:align (left|center|right) #IMPLIED
+ dlg:valign (top|center|bottom) #IMPLIED
+ dlg:checked %boolean; #IMPLIED
+ dlg:image-src CDATA #IMPLIED
+ dlg:image-position (left-top|left-center|left-bottom|right-top|right-center|right-bottom|top-left|top-center|top-right|bottom-left|bottom-center|bottom-right|center) #IMPLIED
+ dlg:image-align (top|left|right|bottom) #IMPLIED
+ dlg:default %boolean; #IMPLIED
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:button-type (standard|ok|cancel|help) #IMPLIED
+ dlg:repeat %numeric; #IMPLIED
+ dlg:toggled (0|1) #IMPLIED
+ dlg:grab-focus (true|false) #IMPLIED
+ dlg:multiline %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:checkbox ((%event;)*)>
+<!ATTLIST dlg:checkbox %default-attributes;
+ dlg:value CDATA #IMPLIED
+ dlg:align (left|center|right) #IMPLIED
+ dlg:valign (top|center|bottom) #IMPLIED
+ dlg:checked %boolean; #IMPLIED
+ dlg:tristate %boolean; #IMPLIED
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:image-src CDATA #IMPLIED
+ dlg:image-position (left-top|left-center|left-bottom|right-top|right-center|right-bottom|top-left|top-center|top-right|bottom-left|bottom-center|bottom-right|center) #IMPLIED
+ dlg:multiline %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:combobox (dlg:menupopup?, (%event;)*)>
+<!ATTLIST dlg:combobox %default-attributes;
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:readonly %boolean; #IMPLIED
+ dlg:autocomplete %boolean; #IMPLIED
+ dlg:spin %boolean; #IMPLIED
+ dlg:maxlength %numeric; #IMPLIED
+ dlg:linecount %numeric; #IMPLIED
+ dlg:value CDATA #IMPLIED
+ dlg:hide-inactive-selection %boolean; #IMPLIED
+ dlg:align (left|center|right) #IMPLIED
+ >
+
+<!ELEMENT dlg:menulist (dlg:menupopup?, (%event;)*)>
+<!ATTLIST dlg:menulist %default-attributes;
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:spin %boolean; #IMPLIED
+ dlg:multiselection %boolean; #IMPLIED
+ dlg:readonly %boolean; #IMPLIED
+ dlg:linecount %numeric; #IMPLIED
+ dlg:align (left|center|right) #IMPLIED
+ >
+
+<!ELEMENT dlg:menupopup (dlg:menuitem+)>
+<!ELEMENT dlg:menuitem EMPTY>
+<!ATTLIST dlg:menuitem dlg:value CDATA #REQUIRED
+ dlg:selected %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:radiogroup (dlg:radio+)>
+<!ELEMENT dlg:radio ((%event;)*)>
+<!ATTLIST dlg:radio %default-attributes;
+ dlg:value CDATA #IMPLIED
+ dlg:align (left|center|right) #IMPLIED
+ dlg:valign (top|center|bottom) #IMPLIED
+ dlg:checked %boolean; #IMPLIED
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:image-src CDATA #IMPLIED
+ dlg:image-position (left-top|left-center|left-bottom|right-top|right-center|right-bottom|top-left|top-center|top-right|bottom-left|bottom-center|bottom-right|center) #IMPLIED
+ dlg:multiline %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:titledbox (dlg:title?, dlg:radio*, (%control;)*, (%event;)*)>
+<!ATTLIST dlg:titledbox %default-attributes;
+ >
+<!ELEMENT dlg:title EMPTY>
+<!ATTLIST dlg:title dlg:value CDATA #IMPLIED
+ >
+
+<!ELEMENT dlg:text ((%event;)*)>
+<!ATTLIST dlg:text %default-attributes;
+ dlg:value CDATA #IMPLIED
+ dlg:align (left|center|right) #IMPLIED
+ dlg:valign (top|center|bottom) #IMPLIED
+ dlg:multiline %boolean; #IMPLIED
+ dlg:tabstop %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:textfield ((%event;)*)>
+<!ATTLIST dlg:textfield %default-attributes;
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:align (left|center|right) #IMPLIED
+ dlg:readonly %boolean; #IMPLIED
+ dlg:echochar CDATA #IMPLIED
+ dlg:hard-linebreaks %boolean; #IMPLIED
+ dlg:hscroll %boolean; #IMPLIED
+ dlg:vscroll %boolean; #IMPLIED
+ dlg:maxlength %numeric; #IMPLIED
+ dlg:multiline %boolean; #IMPLIED
+ dlg:value CDATA #IMPLIED
+ dlg:hide-inactive-selection %boolean; #IMPLIED
+ dlg:lineend-format (carriage-return|line-feed|carriage-return-line-feed) #IMPLIED
+ >
+
+<!ELEMENT dlg:img ((%event;)*)>
+<!ATTLIST dlg:img %default-attributes;
+ dlg:src CDATA #IMPLIED
+ dlg:scale-image %boolean; #IMPLIED
+ dlg:tabstop %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:filecontrol ((%event;)*)>
+<!ATTLIST dlg:filecontrol %default-attributes;
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:value CDATA #IMPLIED
+ dlg:hide-inactive-selection %boolean; #IMPLIED
+ dlg:readonly %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:treecontrol ((%event;)*)>
+<!ATTLIST dlg:treecontrol %default-attributes;
+ dlg:selectiontype CDATA #IMPLIED
+ dlg:rootdisplayed %boolean; #IMPLIED
+ dlg:showshandles %boolean; #IMPLIED
+ dlg:showsroothandles %boolean; #IMPLIED
+ dlg:rowheight %boolean; #IMPLIED
+ dlg:editable %numeric; #IMPLIED
+ dlg:invokesstopnodeediting %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:currencyfield ((%event;)*)>
+<!ATTLIST dlg:currencyfield %default-attributes;
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:readonly %boolean; #IMPLIED
+ dlg:currency-symbol CDATA #IMPLIED
+ dlg:strict-format %boolean; #IMPLIED
+ dlg:decimal-accuracy %numeric; #IMPLIED
+ dlg:thousands-separator %boolean; #IMPLIED
+ dlg:value %numeric; #IMPLIED
+ dlg:value-min %numeric; #IMPLIED
+ dlg:value-max %numeric; #IMPLIED
+ dlg:value-step %numeric; #IMPLIED
+ dlg:spin %boolean; #IMPLIED
+ dlg:repeat %numeric; #IMPLIED
+ dlg:hide-inactive-selection %boolean; #IMPLIED
+ dlg:prepend-symbol %boolean; #IMPLIED
+ dlg:enforce-format %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:datefield ((%event;)*)>
+<!ATTLIST dlg:datefield %default-attributes;
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:readonly %boolean; #IMPLIED
+ dlg:strict-format %boolean; #IMPLIED
+ dlg:date-format (system_short|system_short_YY|system_short_YYYY|system_long|short_DDMMYY|short_MMDDYY|short_YYMMDD|short_DDMMYYYY|short_MMDDYYYY|short_YYYYMMDD|short_YYMMDD_DIN5008|short_YYYYMMDD_DIN5008) #IMPLIED
+ dlg:show-century %boolean; #IMPLIED
+ dlg:value CDATA #IMPLIED
+ dlg:value-min CDATA #IMPLIED
+ dlg:value-max CDATA #IMPLIED
+ dlg:spin %boolean; #IMPLIED
+ dlg:repeat %numeric; #IMPLIED
+ dlg:hide-inactive-selection %boolean; #IMPLIED
+ dlg:dropdown %boolean; #IMPLIED
+ dlg:text CDATA #IMPLIED
+ dlg:enforce-format %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:numericfield ((%event;)*)>
+<!ATTLIST dlg:numericfield %default-attributes;
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:readonly %boolean; #IMPLIED
+ dlg:strict-format %boolean; #IMPLIED
+ dlg:decimal-accuracy %numeric; #IMPLIED
+ dlg:thousands-separator %boolean; #IMPLIED
+ dlg:value %numeric; #IMPLIED
+ dlg:value-min %numeric; #IMPLIED
+ dlg:value-max %numeric; #IMPLIED
+ dlg:value-step %numeric; #IMPLIED
+ dlg:spin %boolean; #IMPLIED
+ dlg:repeat %numeric; #IMPLIED
+ dlg:hide-inactive-selection %boolean; #IMPLIED
+ dlg:enforce-format %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:timefield ((%event;)*)>
+<!ATTLIST dlg:timefield %default-attributes;
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:readonly %boolean; #IMPLIED
+ dlg:strict-format %boolean; #IMPLIED
+ dlg:time-format (24h_short|24h_long|12h_short|12h_long|Duration_short|Duration_long) #IMPLIED
+ dlg:value CDATA #IMPLIED
+ dlg:value-min CDATA #IMPLIED
+ dlg:value-max CDATA #IMPLIED
+ dlg:spin %boolean; #IMPLIED
+ dlg:repeat %numeric; #IMPLIED
+ dlg:hide-inactive-selection %boolean; #IMPLIED
+ dlg:text CDATA #IMPLIED
+ dlg:enforce-format %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:patternfield ((%event;)*)>
+<!ATTLIST dlg:patternfield %default-attributes;
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:readonly %boolean; #IMPLIED
+ dlg:strict-format %boolean; #IMPLIED
+ dlg:edit-mask CDATA #IMPLIED
+ dlg:literal-mask CDATA #IMPLIED
+ dlg:value CDATA #IMPLIED
+ dlg:maxlength %numeric; #IMPLIED
+ dlg:hide-inactive-selection %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:formattedfield ((%event;)*)>
+<!ATTLIST dlg:formattedfield %default-attributes;
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:readonly %boolean; #IMPLIED
+ dlg:strict-format %boolean; #IMPLIED
+ dlg:maxlength %numeric; #IMPLIED
+ dlg:spin %boolean; #IMPLIED
+ dlg:align (left|center|right) #IMPLIED
+ dlg:text CDATA #IMPLIED
+ dlg:value-default CDATA #IMPLIED
+ dlg:value-max %numeric; #IMPLIED
+ dlg:value-min %numeric; #IMPLIED
+ dlg:value %numeric; #IMPLIED
+ dlg:format-code CDATA #IMPLIED
+ dlg:format-locale CDATA #IMPLIED
+ dlg:repeat %numeric; #IMPLIED
+ dlg:hide-inactive-selection %boolean; #IMPLIED
+ dlg:treat-as-number %boolean; #IMPLIED
+ dlg:enforce-format %boolean; #IMPLIED
+ >
+
+<!ELEMENT dlg:fixedline ((%event;)*)>
+<!ATTLIST dlg:fixedline %default-attributes;
+ dlg:align (horizontal|vertical) #IMPLIED
+ dlg:value CDATA #IMPLIED
+ >
+
+<!ELEMENT dlg:scrollbar ((%event;)*)>
+<!ATTLIST dlg:scrollbar %default-attributes;
+ dlg:align (horizontal|vertical) #IMPLIED
+ dlg:curpos %numeric; #IMPLIED
+ dlg:maxpos %numeric; #IMPLIED
+ dlg:minpos %numeric; #IMPLIED
+ dlg:increment %numeric; #IMPLIED
+ dlg:pageincrement %numeric; #IMPLIED
+ dlg:visible-size %numeric; #IMPLIED
+ dlg:repeat %numeric; #IMPLIED
+ dlg:tabstop %boolean; #IMPLIED
+ dlg:live-scroll %boolean; #IMPLIED
+ dlg:symbol-color %numeric; #IMPLIED
+ >
+
+<!ELEMENT dlg:progressmeter ((%event;)*)>
+<!ATTLIST dlg:progressmeter %default-attributes;
+ dlg:value %numeric; #IMPLIED
+ dlg:value-min %numeric; #IMPLIED
+ dlg:value-max %numeric; #IMPLIED
+ >
diff --git a/xmlscript/dtd/libraries.dtd b/xmlscript/dtd/libraries.dtd
new file mode 100644
index 000000000000..383f37e21315
--- /dev/null
+++ b/xmlscript/dtd/libraries.dtd
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ Copyright 2000, 2010 Oracle and/or its affiliates.
+
+ OpenOffice.org - a multi-platform office productivity suite
+
+ This file is part of OpenOffice.org.
+
+ OpenOffice.org is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License version 3
+ only, as published by the Free Software Foundation.
+
+ OpenOffice.org is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License version 3 for more details
+ (a copy is included in the LICENSE file that accompanied this code).
+
+ You should have received a copy of the GNU Lesser General Public License
+ version 3 along with OpenOffice.org. If not, see
+ <http://www.openoffice.org/license.html>
+ for a copy of the LGPLv3 License.
+
+-->
+
+<!ENTITY % boolean "(true|false)">
+
+<!ELEMENT library:libraries (library:library)*>
+<!ATTLIST library:libraries
+ xmlns:library CDATA #FIXED "http://openoffice.org/2000/library"
+ xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink"
+>
+
+<!ELEMENT library:library EMPTY>
+<!ATTLIST library:library
+ library:name CDATA #REQUIRED
+ xlink:href CDATA #IMPLIED
+ xlink:type CDATA #IMPLIED
+ library:link %boolean; #REQUIRED
+ library:readonly %boolean; #IMPLIED
+>
+
diff --git a/xmlscript/dtd/library.dtd b/xmlscript/dtd/library.dtd
new file mode 100644
index 000000000000..80f687b9bfc2
--- /dev/null
+++ b/xmlscript/dtd/library.dtd
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ Copyright 2000, 2010 Oracle and/or its affiliates.
+
+ OpenOffice.org - a multi-platform office productivity suite
+
+ This file is part of OpenOffice.org.
+
+ OpenOffice.org is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License version 3
+ only, as published by the Free Software Foundation.
+
+ OpenOffice.org is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License version 3 for more details
+ (a copy is included in the LICENSE file that accompanied this code).
+
+ You should have received a copy of the GNU Lesser General Public License
+ version 3 along with OpenOffice.org. If not, see
+ <http://www.openoffice.org/license.html>
+ for a copy of the LGPLv3 License.
+
+-->
+
+<!ENTITY % boolean "(true|false)">
+
+<!ELEMENT library:library (library:element)*>
+<!ATTLIST library:library
+ xmlns:library CDATA #FIXED "http://openoffice.org/2000/library"
+ library:name CDATA #REQUIRED
+ library:readonly %boolean; #REQUIRED
+ library:passwordprotected %boolean; #REQUIRED
+ library:preload %boolean; #IMPLIED
+>
+
+<!ELEMENT library:element EMPTY>
+<!ATTLIST library:element
+ library:name CDATA #REQUIRED
+>
+
diff --git a/xmlscript/dtd/module.dtd b/xmlscript/dtd/module.dtd
new file mode 100644
index 000000000000..e0e7c843d46d
--- /dev/null
+++ b/xmlscript/dtd/module.dtd
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ Copyright 2000, 2010 Oracle and/or its affiliates.
+
+ OpenOffice.org - a multi-platform office productivity suite
+
+ This file is part of OpenOffice.org.
+
+ OpenOffice.org is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License version 3
+ only, as published by the Free Software Foundation.
+
+ OpenOffice.org is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License version 3 for more details
+ (a copy is included in the LICENSE file that accompanied this code).
+
+ You should have received a copy of the GNU Lesser General Public License
+ version 3 along with OpenOffice.org. If not, see
+ <http://www.openoffice.org/license.html>
+ for a copy of the LGPLv3 License.
+
+-->
+
+<!ELEMENT script:module (#PCDATA)>
+<!ATTLIST script:module
+ xmlns:script CDATA #FIXED "http://openoffice.org/2000/script"
+ script:name CDATA #REQUIRED
+ script:language CDATA #REQUIRED
+>
+
diff --git a/xmlscript/inc/makefile.mk b/xmlscript/inc/makefile.mk
new file mode 100644
index 000000000000..4141e88a2844
--- /dev/null
+++ b/xmlscript/inc/makefile.mk
@@ -0,0 +1,47 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=xmlscript
+TARGET=inc
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+.IF "$(ENABLE_PCH)"!=""
+ALLTAR : \
+ $(SLO)$/precompiled.pch \
+ $(SLO)$/precompiled_ex.pch
+
+.ENDIF # "$(ENABLE_PCH)"!=""
+
diff --git a/xmlscript/inc/pch/precompiled_xmlscript.cxx b/xmlscript/inc/pch/precompiled_xmlscript.cxx
new file mode 100644
index 000000000000..812b8d428514
--- /dev/null
+++ b/xmlscript/inc/pch/precompiled_xmlscript.cxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_xmlscript.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/inc/pch/precompiled_xmlscript.hxx b/xmlscript/inc/pch/precompiled_xmlscript.hxx
new file mode 100644
index 000000000000..ad1762464bde
--- /dev/null
+++ b/xmlscript/inc/pch/precompiled_xmlscript.hxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): Generated on 2006-09-01 17:50:21.357613
+
+#ifdef PRECOMPILED_HEADERS
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/inc/xmlscript/xml_helper.hxx b/xmlscript/inc/xmlscript/xml_helper.hxx
new file mode 100644
index 000000000000..f3b272db7afd
--- /dev/null
+++ b/xmlscript/inc/xmlscript/xml_helper.hxx
@@ -0,0 +1,149 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XMLSCRIPT_XML_HELPER_HXX_
+#define _XMLSCRIPT_XML_HELPER_HXX_
+
+#include <vector>
+#include <rtl/byteseq.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+
+
+namespace xmlscript
+{
+
+/*##################################################################################################
+
+ EXPORTING
+
+##################################################################################################*/
+
+//==================================================================================================
+class XMLElement
+ : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XAttributeList >
+{
+public:
+ inline XMLElement( ::rtl::OUString const & name )
+ SAL_THROW( () )
+ : _name( name )
+ {}
+
+ /** Adds a sub element of element.
+
+ @param xElem element reference
+ */
+ void SAL_CALL addSubElement(
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > const & xElem )
+ SAL_THROW( () );
+
+ /** Gets sub element of given index. The index follows order in which sub elements were added.
+
+ @param nIndex index of sub element
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > SAL_CALL getSubElement( sal_Int32 nIndex )
+ SAL_THROW( () );
+
+ /** Adds an attribute to elements.
+
+ @param rAttrName qname of attribute
+ @param rValue value string of element
+ */
+ void SAL_CALL addAttribute( ::rtl::OUString const & rAttrName, ::rtl::OUString const & rValue )
+ SAL_THROW( () );
+
+ /** Gets the tag name (qname) of element.
+
+ @return
+ qname of element
+ */
+ inline ::rtl::OUString SAL_CALL getName() SAL_THROW( () )
+ { return _name; }
+
+ /** Dumps out element (and all sub elements).
+
+ @param xOut document handler to be written to
+ */
+ void SAL_CALL dump(
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > const & xOut );
+ /** Dumps out sub elements (and all further sub elements).
+
+ @param xOut document handler to be written to
+ */
+ void SAL_CALL dumpSubElements(
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > const & xOut );
+
+ // XAttributeList
+ virtual sal_Int16 SAL_CALL getLength()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNameByIndex( sal_Int16 nPos )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTypeByIndex( sal_Int16 nPos )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTypeByName( ::rtl::OUString const & rName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getValueByIndex( sal_Int16 nPos )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getValueByName( ::rtl::OUString const & rName )
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ ::rtl::OUString _name;
+
+ ::std::vector< ::rtl::OUString > _attrNames;
+ ::std::vector< ::rtl::OUString > _attrValues;
+
+ ::std::vector< ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > > _subElems;
+};
+
+
+/*##################################################################################################
+
+ STREAMING
+
+##################################################################################################*/
+
+//==================================================================================================
+::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
+SAL_CALL createInputStream(
+ ::rtl::ByteSequence const & rInData )
+ SAL_THROW( () );
+
+//==================================================================================================
+::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
+SAL_CALL createOutputStream(
+ ::rtl::ByteSequence * pOutData )
+ SAL_THROW( () );
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/inc/xmlscript/xml_import.hxx b/xmlscript/inc/xmlscript/xml_import.hxx
new file mode 100644
index 000000000000..ca8cc3a0f0e9
--- /dev/null
+++ b/xmlscript/inc/xmlscript/xml_import.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#if ! defined _XMLSCRIPT_XML_IMPORT_HXX_
+#define _XMLSCRIPT_XML_IMPORT_HXX_
+
+#include "com/sun/star/xml/input/XRoot.hpp"
+#include "com/sun/star/xml/sax/XExtendedDocumentHandler.hpp"
+
+
+namespace xmlscript
+{
+
+/*##############################################################################
+
+ IMPORTING
+
+##############################################################################*/
+
+/** Creates a document handler to be used for SAX1 parser that can handle
+ namespaces. Namespace URI are mapped to integer ids for performance.
+ Implementing the XImporter interface, you will get a startRootElement()
+ for the root element of your XML document and subsequent
+ startChildElement() callbacks for each sub element.
+ Namespaces of tags are identified by their integer value.
+
+ @param xRoot
+ initial object being called for root context
+ @param bSingleThreadedUse
+ flag whether context management is synchronized.
+ @return
+ document handler for parser
+*/
+::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >
+SAL_CALL createDocumentHandler(
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::input::XRoot > const & xRoot,
+ bool bSingleThreadedUse = true )
+ SAL_THROW( () );
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/inc/xmlscript/xmldlg_imexp.hxx b/xmlscript/inc/xmlscript/xmldlg_imexp.hxx
new file mode 100644
index 000000000000..30d92bfc1bd3
--- /dev/null
+++ b/xmlscript/inc/xmlscript/xmldlg_imexp.hxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XMLSCRIPT_XMLDLG_IMEXP_HXX_
+#define _XMLSCRIPT_XMLDLG_IMEXP_HXX_
+
+#include <com/sun/star/frame/XModel.hpp>
+
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/io/XInputStreamProvider.hpp>
+#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include "xmlscript/xmlns.h"
+
+
+namespace xmlscript
+{
+
+//==============================================================================
+void SAL_CALL exportDialogModel(
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XExtendedDocumentHandler > const & xOut,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::container::XNameContainer > const & xDialogModel,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > const & xDocument )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+//==============================================================================
+::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >
+SAL_CALL importDialogModel(
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::container::XNameContainer > const & xDialogModel,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext > const & xContext,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > const & xDocument )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+// additional functions for convenience
+
+//==============================================================================
+::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStreamProvider >
+SAL_CALL exportDialogModel(
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::container::XNameContainer > const & xDialogModel,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext > const & xContext,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > const & xDocument )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+//==============================================================================
+void SAL_CALL importDialogModel(
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::io::XInputStream > xInput,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::container::XNameContainer > const & xDialogModel,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext > const & xContext,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > const & xDocument )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/inc/xmlscript/xmllib_imexp.hxx b/xmlscript/inc/xmlscript/xmllib_imexp.hxx
new file mode 100644
index 000000000000..95750c26655f
--- /dev/null
+++ b/xmlscript/inc/xmlscript/xmllib_imexp.hxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XMLSCRIPT_XMLLIB_IMEXP_HXX_
+#define _XMLSCRIPT_XMLLIB_IMEXP_HXX_
+
+#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include "xmlscript/xmlns.h"
+
+
+namespace xmlscript
+{
+
+//==============================================================================
+// Library container export
+// HACK C++ struct to transport info. Later the container
+// itself should do the export/import and use exportet XML
+// functionality from xmlscript
+struct LibDescriptor
+{
+ ::rtl::OUString aName;
+ ::rtl::OUString aStorageURL;
+ sal_Bool bLink;
+ sal_Bool bReadOnly;
+ sal_Bool bPasswordProtected;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aElementNames;
+ sal_Bool bPreload;
+};
+
+struct LibDescriptorArray
+{
+ LibDescriptor* mpLibs;
+ sal_Int32 mnLibCount;
+
+ LibDescriptorArray( void ) { mpLibs = NULL; mnLibCount = 0; }
+ LibDescriptorArray( sal_Int32 nLibCount );
+
+ ~LibDescriptorArray();
+
+};
+
+void
+SAL_CALL exportLibraryContainer(
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XExtendedDocumentHandler > const & xOut,
+ const LibDescriptorArray* pLibArray )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XDocumentHandler >
+SAL_CALL importLibraryContainer( LibDescriptorArray* pLibArray )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+
+void
+SAL_CALL exportLibrary(
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XExtendedDocumentHandler > const & xOut,
+ const LibDescriptor& rLib )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XDocumentHandler >
+SAL_CALL importLibrary( LibDescriptor& rLib )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/inc/xmlscript/xmlmod_imexp.hxx b/xmlscript/inc/xmlscript/xmlmod_imexp.hxx
new file mode 100644
index 000000000000..f2e3b169454f
--- /dev/null
+++ b/xmlscript/inc/xmlscript/xmlmod_imexp.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XMLSCRIPT_XMLMOD_IMEXP_HXX_
+#define _XMLSCRIPT_XMLMOD_IMEXP_HXX_
+
+#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <xmlscript/xmlns.h>
+
+
+namespace xmlscript
+{
+
+//==============================================================================
+// Script module import/export
+// HACK C++ struct to transport info. Later the container
+// itself should do the export/import and use exportet XML
+// functionality from xmlscript
+struct ModuleDescriptor
+{
+ ::rtl::OUString aName;
+ ::rtl::OUString aLanguage;
+ ::rtl::OUString aCode;
+ ::rtl::OUString aModuleType; // VBA
+};
+
+void
+SAL_CALL exportScriptModule(
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XExtendedDocumentHandler > const & xOut,
+ const ModuleDescriptor& rMod )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XDocumentHandler >
+SAL_CALL importScriptModule( ModuleDescriptor& rMod )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/inc/xmlscript/xmlns.h b/xmlscript/inc/xmlscript/xmlns.h
new file mode 100644
index 000000000000..13751ea8489e
--- /dev/null
+++ b/xmlscript/inc/xmlscript/xmlns.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XMLSCRIPT_XMLNS_H_
+#define _XMLSCRIPT_XMLNS_H_
+
+#define XMLNS_DIALOGS_URI "http://openoffice.org/2000/dialog"
+#define XMLNS_DIALOGS_PREFIX "dlg"
+
+#define XMLNS_SCRIPT_URI "http://openoffice.org/2000/script"
+#define XMLNS_SCRIPT_PREFIX "script"
+
+#define XMLNS_OOO_URI "http://openoffice.org/2004/office"
+#define XMLNS_OOO_PREFIX "ooo"
+
+#define XMLNS_LIBRARY_URI "http://openoffice.org/2000/library"
+#define XMLNS_LIBRARY_PREFIX "library"
+
+#define XMLNS_XLINK_URI "http://www.w3.org/1999/xlink"
+#define XMLNS_XLINK_PREFIX "xlink"
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/prj/build.lst b/xmlscript/prj/build.lst
new file mode 100644
index 000000000000..f3410c668633
--- /dev/null
+++ b/xmlscript/prj/build.lst
@@ -0,0 +1,10 @@
+xt xmlscript : comphelper tools offapi NULL
+xt xmlscript usr1 - all xt_mkout NULL
+xt xmlscript\inc nmake - all xt_inc NULL
+xt xmlscript\source\xml_helper nmake - all xt_xml_helper xt_inc NULL
+xt xmlscript\source\xmldlg_imexp nmake - all xt_xmldlg_imexp xt_inc NULL
+xt xmlscript\source\xmllib_imexp nmake - all xt_xmllib_imexp xt_inc NULL
+xt xmlscript\source\xmlmod_imexp nmake - all xt_xmlmod_imexp xt_inc NULL
+xt xmlscript\source\xmlflat_imexp nmake - all xt_xmlflat_imexp xt_inc NULL
+xt xmlscript\source\misc nmake - all xt_misc xt_inc NULL
+xt xmlscript\util nmake - all xt_util xt_xml_helper xt_xmldlg_imexp xt_xmllib_imexp xt_xmlmod_imexp xt_xmlflat_imexp xt_misc NULL
diff --git a/xmlscript/prj/d.lst b/xmlscript/prj/d.lst
new file mode 100644
index 000000000000..51b2891e4926
--- /dev/null
+++ b/xmlscript/prj/d.lst
@@ -0,0 +1,13 @@
+mkdir: %_DEST%\inc%_EXT%\xmlscript
+..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll
+..\%__SRC%\lib\*.lib %_DEST%\lib%_EXT%\*.lib
+..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT%\lib*.so
+..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
+
+..\inc\xmlscript\xml_helper.hxx %_DEST%\inc%_EXT%\xmlscript\xml_helper.hxx
+..\inc\xmlscript\xmldlg_imexp.hxx %_DEST%\inc%_EXT%\xmlscript\xmldlg_imexp.hxx
+..\inc\xmlscript\xmllib_imexp.hxx %_DEST%\inc%_EXT%\xmlscript\xmllib_imexp.hxx
+..\inc\xmlscript\xmlmod_imexp.hxx %_DEST%\inc%_EXT%\xmlscript\xmlmod_imexp.hxx
+..\inc\xmlscript\xmlns.h %_DEST%\inc%_EXT%\xmlscript\xmlns.h
+
+..\dtd\*.dtd %_DEST%\bin%_EXT%\*.dtd
diff --git a/xmlscript/source/inc/misc.hxx b/xmlscript/source/inc/misc.hxx
new file mode 100644
index 000000000000..bd7f737292af
--- /dev/null
+++ b/xmlscript/source/inc/misc.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_XMLSCRIPT_MISC_HXX
+#define INCLUDED_XMLSCRIPT_MISC_HXX
+
+#include "com/sun/star/uno/Any.hxx"
+
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+
+
+namespace xmlscript
+{
+
+//==============================================================================
+template< typename T >
+inline void extract_throw( T * p, ::com::sun::star::uno::Any const & a )
+{
+ if (! (a >>= *p))
+ {
+ throw ::com::sun::star::uno::RuntimeException(
+ OUSTR("expected ") + ::getCppuType( p ).getTypeName(),
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XInterface>() );
+ }
+}
+
+//==============================================================================
+template< typename T >
+inline T extract_throw( ::com::sun::star::uno::Any const & a )
+{
+ T v = T();
+ extract_throw<T>( &v, a );
+ return v;
+}
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/misc/makefile.mk b/xmlscript/source/misc/makefile.mk
new file mode 100644
index 000000000000..dfac81bfa6aa
--- /dev/null
+++ b/xmlscript/source/misc/makefile.mk
@@ -0,0 +1,48 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=xmlscript
+TARGET=misc
+NO_BSYMBOLIC=TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
+#-----------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/unoservices.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/target.pmk
+.ENDIF # L10N_framework
+.INCLUDE : target.mk
diff --git a/xmlscript/source/misc/unoservices.cxx b/xmlscript/source/misc/unoservices.cxx
new file mode 100644
index 000000000000..8c0ccc3589f9
--- /dev/null
+++ b/xmlscript/source/misc/unoservices.cxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+
+#include <cppuhelper/implementationentry.hxx>
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+
+
+// =============================================================================
+
+namespace xmlscript
+{
+ Sequence< OUString > SAL_CALL getSupportedServiceNames_DocumentHandlerImpl();
+ OUString SAL_CALL getImplementationName_DocumentHandlerImpl();
+ Reference< XInterface > SAL_CALL create_DocumentHandlerImpl(
+ Reference< XComponentContext > const & xContext )
+ SAL_THROW( (Exception) );
+
+ Sequence< OUString > SAL_CALL getSupportedServiceNames_XMLBasicExporter();
+ OUString SAL_CALL getImplementationName_XMLBasicExporter();
+ Reference< XInterface > SAL_CALL create_XMLBasicExporter(
+ Reference< XComponentContext > const & xContext )
+ SAL_THROW( (Exception) );
+
+ Sequence< OUString > SAL_CALL getSupportedServiceNames_XMLOasisBasicExporter();
+ OUString SAL_CALL getImplementationName_XMLOasisBasicExporter();
+ Reference< XInterface > SAL_CALL create_XMLOasisBasicExporter(
+ Reference< XComponentContext > const & xContext )
+ SAL_THROW( (Exception) );
+
+ Sequence< OUString > SAL_CALL getSupportedServiceNames_XMLBasicImporter();
+ OUString SAL_CALL getImplementationName_XMLBasicImporter();
+ Reference< XInterface > SAL_CALL create_XMLBasicImporter(
+ Reference< XComponentContext > const & xContext )
+ SAL_THROW( (Exception) );
+
+ Sequence< OUString > SAL_CALL getSupportedServiceNames_XMLOasisBasicImporter();
+ OUString SAL_CALL getImplementationName_XMLOasisBasicImporter();
+ Reference< XInterface > SAL_CALL create_XMLOasisBasicImporter(
+ Reference< XComponentContext > const & xContext )
+ SAL_THROW( (Exception) );
+
+ // -----------------------------------------------------------------------------
+
+ static struct ::cppu::ImplementationEntry s_entries [] =
+ {
+ {
+ create_DocumentHandlerImpl, getImplementationName_DocumentHandlerImpl,
+ getSupportedServiceNames_DocumentHandlerImpl, ::cppu::createSingleComponentFactory,
+ 0, 0
+ },
+ {
+ create_XMLBasicExporter, getImplementationName_XMLBasicExporter,
+ getSupportedServiceNames_XMLBasicExporter, ::cppu::createSingleComponentFactory,
+ 0, 0
+ },
+ {
+ create_XMLOasisBasicExporter, getImplementationName_XMLOasisBasicExporter,
+ getSupportedServiceNames_XMLOasisBasicExporter, ::cppu::createSingleComponentFactory,
+ 0, 0
+ },
+ {
+ create_XMLBasicImporter, getImplementationName_XMLBasicImporter,
+ getSupportedServiceNames_XMLBasicImporter, ::cppu::createSingleComponentFactory,
+ 0, 0
+ },
+ {
+ create_XMLOasisBasicImporter, getImplementationName_XMLOasisBasicImporter,
+ getSupportedServiceNames_XMLOasisBasicImporter, ::cppu::createSingleComponentFactory,
+ 0, 0
+ },
+ { 0, 0, 0, 0, 0, 0 }
+ };
+}
+
+// =============================================================================
+
+extern "C"
+{
+ void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** )
+ {
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+ {
+ return ::cppu::component_writeInfoHelper(
+ pServiceManager, pRegistryKey, ::xmlscript::s_entries );
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+ {
+ return ::cppu::component_getFactoryHelper(
+ pImplName, pServiceManager, pRegistryKey, ::xmlscript::s_entries );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xml_helper/makefile.mk b/xmlscript/source/xml_helper/makefile.mk
new file mode 100644
index 000000000000..7b48695bae64
--- /dev/null
+++ b/xmlscript/source/xml_helper/makefile.mk
@@ -0,0 +1,50 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=xmlscript
+TARGET=xml_helper
+NO_BSYMBOLIC=TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
+#-----------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/xml_impctx.obj \
+ $(SLO)$/xml_element.obj \
+ $(SLO)$/xml_byteseq.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/target.pmk
+.ENDIF # L10N_framework
+
+.INCLUDE : target.mk
diff --git a/xmlscript/source/xml_helper/xml_byteseq.cxx b/xmlscript/source/xml_helper/xml_byteseq.cxx
new file mode 100644
index 000000000000..d23e12d671c3
--- /dev/null
+++ b/xmlscript/source/xml_helper/xml_byteseq.cxx
@@ -0,0 +1,176 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+#include <rtl/memory.h>
+
+#include <cppuhelper/implbase1.hxx>
+#include <xmlscript/xml_helper.hxx>
+
+
+using namespace rtl;
+using namespace osl;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+
+namespace xmlscript
+{
+
+//==================================================================================================
+class BSeqInputStream
+ : public ::cppu::WeakImplHelper1< io::XInputStream >
+{
+ ByteSequence _seq;
+ sal_Int32 _nPos;
+
+public:
+ inline BSeqInputStream( ByteSequence const & rSeq )
+ SAL_THROW( () )
+ : _seq( rSeq )
+ , _nPos( 0 )
+ {}
+
+ // XInputStream
+ virtual sal_Int32 SAL_CALL readBytes(
+ Sequence< sal_Int8 > & rData, sal_Int32 nBytesToRead )
+ throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException);
+ virtual sal_Int32 SAL_CALL readSomeBytes(
+ Sequence< sal_Int8 > & rData, sal_Int32 nMaxBytesToRead )
+ throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException);
+ virtual void SAL_CALL skipBytes(
+ sal_Int32 nBytesToSkip )
+ throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException);
+ virtual sal_Int32 SAL_CALL available()
+ throw (io::NotConnectedException, io::IOException, RuntimeException);
+ virtual void SAL_CALL closeInput()
+ throw (io::NotConnectedException, io::IOException, RuntimeException);
+};
+//__________________________________________________________________________________________________
+sal_Int32 BSeqInputStream::readBytes(
+ Sequence< sal_Int8 > & rData, sal_Int32 nBytesToRead )
+ throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException)
+{
+ nBytesToRead = ((nBytesToRead > _seq.getLength() - _nPos)
+ ? _seq.getLength() - _nPos
+ : nBytesToRead);
+
+ ByteSequence aBytes( _seq.getConstArray() + _nPos, nBytesToRead );
+ rData = toUnoSequence( aBytes );
+ _nPos += nBytesToRead;
+ return nBytesToRead;
+}
+//__________________________________________________________________________________________________
+sal_Int32 BSeqInputStream::readSomeBytes(
+ Sequence< sal_Int8 > & rData, sal_Int32 nMaxBytesToRead )
+ throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException)
+{
+ return readBytes( rData, nMaxBytesToRead );
+}
+//__________________________________________________________________________________________________
+void BSeqInputStream::skipBytes(
+ sal_Int32 /*nBytesToSkip*/ )
+ throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException)
+{
+}
+//__________________________________________________________________________________________________
+sal_Int32 BSeqInputStream::available()
+ throw (io::NotConnectedException, io::IOException, RuntimeException)
+{
+ return (_seq.getLength() - _nPos);
+}
+//__________________________________________________________________________________________________
+void BSeqInputStream::closeInput()
+ throw (io::NotConnectedException, io::IOException, RuntimeException)
+{
+}
+
+//##################################################################################################
+
+//==================================================================================================
+class BSeqOutputStream
+ : public ::cppu::WeakImplHelper1< io::XOutputStream >
+{
+ ByteSequence * _seq;
+
+public:
+ inline BSeqOutputStream( ByteSequence * seq )
+ SAL_THROW( () )
+ : _seq( seq )
+ {}
+
+ // XOutputStream
+ virtual void SAL_CALL writeBytes(
+ Sequence< sal_Int8 > const & rData )
+ throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException);
+ virtual void SAL_CALL flush()
+ throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException);
+ virtual void SAL_CALL closeOutput()
+ throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException);
+};
+//__________________________________________________________________________________________________
+void BSeqOutputStream::writeBytes( Sequence< sal_Int8 > const & rData )
+ throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException)
+{
+ sal_Int32 nPos = _seq->getLength();
+ _seq->realloc( nPos + rData.getLength() );
+ ::rtl_copyMemory( (char *)_seq->getArray() + nPos,
+ (char const *)rData.getConstArray(),
+ rData.getLength() );
+}
+//__________________________________________________________________________________________________
+void BSeqOutputStream::flush()
+ throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException)
+{
+}
+//__________________________________________________________________________________________________
+void BSeqOutputStream::closeOutput()
+ throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException)
+{
+}
+
+//##################################################################################################
+
+//==================================================================================================
+Reference< io::XInputStream > SAL_CALL createInputStream( ByteSequence const & rInData )
+ SAL_THROW( () )
+{
+ return new BSeqInputStream( rInData );
+}
+
+//==================================================================================================
+Reference< io::XOutputStream > SAL_CALL createOutputStream( ByteSequence * pOutData )
+ SAL_THROW( () )
+{
+ return new BSeqOutputStream( pOutData );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xml_helper/xml_element.cxx b/xmlscript/source/xml_helper/xml_element.cxx
new file mode 100644
index 000000000000..1eae9b80d590
--- /dev/null
+++ b/xmlscript/source/xml_helper/xml_element.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+#include <xmlscript/xml_helper.hxx>
+
+
+using namespace rtl;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+
+namespace xmlscript
+{
+
+//__________________________________________________________________________________________________
+void XMLElement::addAttribute( OUString const & rAttrName, OUString const & rValue )
+ SAL_THROW( () )
+{
+ _attrNames.push_back( rAttrName );
+ _attrValues.push_back( rValue );
+}
+//__________________________________________________________________________________________________
+void XMLElement::addSubElement( Reference< xml::sax::XAttributeList > const & xElem )
+ SAL_THROW( () )
+{
+ _subElems.push_back( xElem );
+}
+//__________________________________________________________________________________________________
+Reference< xml::sax::XAttributeList > XMLElement::getSubElement( sal_Int32 nIndex )
+ SAL_THROW( () )
+{
+ return _subElems[ (size_t)nIndex ];
+}
+//__________________________________________________________________________________________________
+void XMLElement::dumpSubElements( Reference< xml::sax::XDocumentHandler > const & xOut )
+{
+ for ( size_t nPos = 0; nPos < _subElems.size(); ++nPos )
+ {
+ XMLElement * pElem = static_cast< XMLElement * >( _subElems[ nPos ].get() );
+ pElem->dump( xOut );
+ }
+}
+//__________________________________________________________________________________________________
+void XMLElement::dump( Reference< xml::sax::XDocumentHandler > const & xOut )
+{
+ xOut->ignorableWhitespace( OUString() );
+ xOut->startElement( _name, static_cast< xml::sax::XAttributeList * >( this ) );
+ // write sub elements
+ dumpSubElements( xOut );
+ //
+ xOut->ignorableWhitespace( OUString() );
+ xOut->endElement( _name );
+}
+
+// XAttributeList
+//__________________________________________________________________________________________________
+sal_Int16 XMLElement::getLength()
+ throw (RuntimeException)
+{
+ return static_cast<sal_Int16>(_attrNames.size());
+}
+//__________________________________________________________________________________________________
+OUString XMLElement::getNameByIndex( sal_Int16 nPos )
+ throw (RuntimeException)
+{
+ OSL_ASSERT( (size_t)nPos < _attrNames.size() );
+ return _attrNames[ nPos ];
+}
+//__________________________________________________________________________________________________
+OUString XMLElement::getTypeByIndex( sal_Int16 nPos )
+ throw (RuntimeException)
+{
+ OSL_ASSERT( (size_t)nPos < _attrNames.size() );
+ static_cast<void>(nPos);
+ // xxx todo
+ return OUString();
+}
+//__________________________________________________________________________________________________
+OUString XMLElement::getTypeByName( OUString const & /*rName*/ )
+ throw (RuntimeException)
+{
+ // xxx todo
+ return OUString();
+}
+//__________________________________________________________________________________________________
+OUString XMLElement::getValueByIndex( sal_Int16 nPos )
+ throw (RuntimeException)
+{
+ OSL_ASSERT( (size_t)nPos < _attrNames.size() );
+ return _attrValues[ nPos ];
+}
+//__________________________________________________________________________________________________
+OUString XMLElement::getValueByName( OUString const & rName )
+ throw (RuntimeException)
+{
+ for ( size_t nPos = 0; nPos < _attrNames.size(); ++nPos )
+ {
+ if (_attrNames[ nPos ] == rName)
+ {
+ return _attrValues[ nPos ];
+ }
+ }
+ return OUString();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx b/xmlscript/source/xml_helper/xml_impctx.cxx
new file mode 100644
index 000000000000..9edccbf9bff4
--- /dev/null
+++ b/xmlscript/source/xml_helper/xml_impctx.cxx
@@ -0,0 +1,907 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+
+#include "osl/diagnose.h"
+#include "osl/mutex.hxx"
+#include "rtl/ustrbuf.hxx"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "cppuhelper/implbase1.hxx"
+#include "cppuhelper/implbase3.hxx"
+#include "xmlscript/xml_import.hxx"
+
+#include "com/sun/star/xml/input/XAttributes.hpp"
+#include "com/sun/star/lang/XInitialization.hpp"
+#include "com/sun/star/uno/XComponentContext.hpp"
+
+#include <vector>
+#include <hash_map>
+
+#include <memory>
+
+
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace xmlscript
+{
+
+const sal_Int32 UID_UNKNOWN = -1;
+
+Sequence< OUString > getSupportedServiceNames_DocumentHandlerImpl()
+{
+ OUString name( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.xml.input.SaxDocumentHandler") );
+ return Sequence< OUString >( &name, 1 );
+}
+
+OUString getImplementationName_DocumentHandlerImpl()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.xml.input.SaxDocumentHandler") );
+}
+
+typedef ::std::hash_map< OUString, sal_Int32, OUStringHash > t_OUString2LongMap;
+typedef ::std::hash_map< sal_Int32, OUString > t_Long2OUStringMap;
+
+struct PrefixEntry
+{
+ ::std::vector< sal_Int32 > m_Uids;
+
+ inline PrefixEntry() SAL_THROW( () )
+ { m_Uids.reserve( 4 ); }
+};
+
+typedef ::std::hash_map<
+ OUString, PrefixEntry *, OUStringHash > t_OUString2PrefixMap;
+
+struct ElementEntry
+{
+ Reference< xml::input::XElement > m_xElement;
+ ::std::vector< OUString > m_prefixes;
+
+ inline ElementEntry()
+ { m_prefixes.reserve( 2 ); }
+};
+
+typedef ::std::vector< ElementEntry * > t_ElementVector;
+
+class ExtendedAttributes;
+
+//==============================================================================
+struct MGuard
+{
+ Mutex * m_pMutex;
+ explicit MGuard( Mutex * pMutex )
+ : m_pMutex( pMutex )
+ { if (m_pMutex) m_pMutex->acquire(); }
+ ~MGuard() throw ()
+ { if (m_pMutex) m_pMutex->release(); }
+};
+
+//==============================================================================
+class DocumentHandlerImpl :
+ public ::cppu::WeakImplHelper3< xml::sax::XDocumentHandler,
+ xml::input::XNamespaceMapping,
+ lang::XInitialization >
+{
+ friend class ExtendedAttributes;
+
+ Reference< xml::input::XRoot > m_xRoot;
+
+ t_OUString2LongMap m_URI2Uid;
+ sal_Int32 m_uid_count;
+
+ OUString m_sXMLNS_PREFIX_UNKNOWN;
+ OUString m_sXMLNS;
+
+ sal_Int32 m_nLastURI_lookup;
+ OUString m_aLastURI_lookup;
+
+ t_OUString2PrefixMap m_prefixes;
+ sal_Int32 m_nLastPrefix_lookup;
+ OUString m_aLastPrefix_lookup;
+
+ t_ElementVector m_elements;
+ sal_Int32 m_nSkipElements;
+
+ Mutex * m_pMutex;
+
+ inline Reference< xml::input::XElement > getCurrentElement() const;
+
+ inline sal_Int32 getUidByURI( OUString const & rURI );
+ inline sal_Int32 getUidByPrefix( OUString const & rPrefix );
+
+ inline void pushPrefix(
+ OUString const & rPrefix, OUString const & rURI );
+ inline void popPrefix( OUString const & rPrefix );
+
+ inline void getElementName(
+ OUString const & rQName, sal_Int32 * pUid, OUString * pLocalName );
+
+public:
+ DocumentHandlerImpl(
+ Reference< xml::input::XRoot > const & xRoot,
+ bool bSingleThreadedUse );
+ virtual ~DocumentHandlerImpl() throw ();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw (RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(
+ OUString const & servicename )
+ throw (RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw (RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize(
+ Sequence< Any > const & arguments )
+ throw (Exception);
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument()
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL endDocument()
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL startElement(
+ OUString const & rQElementName,
+ Reference< xml::sax::XAttributeList > const & xAttribs )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL endElement(
+ OUString const & rQElementName )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL characters(
+ OUString const & rChars )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL ignorableWhitespace(
+ OUString const & rWhitespaces )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL processingInstruction(
+ OUString const & rTarget, OUString const & rData )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL setDocumentLocator(
+ Reference< xml::sax::XLocator > const & xLocator )
+ throw (xml::sax::SAXException, RuntimeException);
+
+ // XNamespaceMapping
+ virtual sal_Int32 SAL_CALL getUidByUri( OUString const & Uri )
+ throw (RuntimeException);
+ virtual OUString SAL_CALL getUriByUid( sal_Int32 Uid )
+ throw (container::NoSuchElementException, RuntimeException);
+};
+
+//______________________________________________________________________________
+DocumentHandlerImpl::DocumentHandlerImpl(
+ Reference< xml::input::XRoot > const & xRoot,
+ bool bSingleThreadedUse )
+ : m_xRoot( xRoot ),
+ m_uid_count( 0 ),
+ m_sXMLNS_PREFIX_UNKNOWN(
+ RTL_CONSTASCII_USTRINGPARAM("<<< unknown prefix >>>") ),
+ m_sXMLNS( RTL_CONSTASCII_USTRINGPARAM("xmlns") ),
+ m_nLastURI_lookup( UID_UNKNOWN ),
+ m_aLastURI_lookup( RTL_CONSTASCII_USTRINGPARAM("<<< unknown URI >>>") ),
+ m_nLastPrefix_lookup( UID_UNKNOWN ),
+ m_aLastPrefix_lookup(
+ RTL_CONSTASCII_USTRINGPARAM("<<< unknown URI >>>") ),
+ m_nSkipElements( 0 ),
+ m_pMutex( 0 )
+{
+ m_elements.reserve( 10 );
+
+ if (! bSingleThreadedUse)
+ m_pMutex = new Mutex();
+}
+
+//______________________________________________________________________________
+DocumentHandlerImpl::~DocumentHandlerImpl() throw ()
+{
+ if (m_pMutex != 0)
+ {
+ delete m_pMutex;
+#if OSL_DEBUG_LEVEL == 0
+ m_pMutex = 0;
+#endif
+ }
+}
+
+//______________________________________________________________________________
+inline Reference< xml::input::XElement >
+DocumentHandlerImpl::getCurrentElement() const
+{
+ MGuard aGuard( m_pMutex );
+ if (m_elements.empty())
+ return Reference< xml::input::XElement >();
+ else
+ return m_elements.back()->m_xElement;
+}
+
+//______________________________________________________________________________
+inline sal_Int32 DocumentHandlerImpl::getUidByURI( OUString const & rURI )
+{
+ MGuard guard( m_pMutex );
+ if (m_nLastURI_lookup == UID_UNKNOWN || m_aLastURI_lookup != rURI)
+ {
+ t_OUString2LongMap::const_iterator iFind( m_URI2Uid.find( rURI ) );
+ if (iFind != m_URI2Uid.end()) // id found
+ {
+ m_nLastURI_lookup = iFind->second;
+ m_aLastURI_lookup = rURI;
+ }
+ else
+ {
+ m_nLastURI_lookup = m_uid_count;
+ ++m_uid_count;
+ m_URI2Uid[ rURI ] = m_nLastURI_lookup;
+ m_aLastURI_lookup = rURI;
+ }
+ }
+ return m_nLastURI_lookup;
+}
+
+//______________________________________________________________________________
+inline sal_Int32 DocumentHandlerImpl::getUidByPrefix(
+ OUString const & rPrefix )
+{
+ // commonly the last added prefix is used often for several tags...
+ // good guess
+ if (m_nLastPrefix_lookup == UID_UNKNOWN || m_aLastPrefix_lookup != rPrefix)
+ {
+ t_OUString2PrefixMap::const_iterator iFind(
+ m_prefixes.find( rPrefix ) );
+ if (iFind != m_prefixes.end())
+ {
+ const PrefixEntry & rPrefixEntry = *iFind->second;
+ OSL_ASSERT( ! rPrefixEntry.m_Uids.empty() );
+ m_nLastPrefix_lookup = rPrefixEntry.m_Uids.back();
+ m_aLastPrefix_lookup = rPrefix;
+ }
+ else
+ {
+ m_nLastPrefix_lookup = UID_UNKNOWN;
+ m_aLastPrefix_lookup = m_sXMLNS_PREFIX_UNKNOWN;
+ }
+ }
+ return m_nLastPrefix_lookup;
+}
+
+//______________________________________________________________________________
+inline void DocumentHandlerImpl::pushPrefix(
+ OUString const & rPrefix, OUString const & rURI )
+{
+ // lookup id for URI
+ sal_Int32 nUid = getUidByURI( rURI );
+
+ // mark prefix with id
+ t_OUString2PrefixMap::const_iterator iFind( m_prefixes.find( rPrefix ) );
+ if (iFind == m_prefixes.end()) // unused prefix
+ {
+ PrefixEntry * pEntry = new PrefixEntry();
+ pEntry->m_Uids.push_back( nUid ); // latest id for prefix
+ m_prefixes[ rPrefix ] = pEntry;
+ }
+ else
+ {
+ PrefixEntry * pEntry = iFind->second;
+ OSL_ASSERT( ! pEntry->m_Uids.empty() );
+ pEntry->m_Uids.push_back( nUid );
+ }
+
+ m_aLastPrefix_lookup = rPrefix;
+ m_nLastPrefix_lookup = nUid;
+}
+
+//______________________________________________________________________________
+inline void DocumentHandlerImpl::popPrefix(
+ OUString const & rPrefix )
+{
+ t_OUString2PrefixMap::iterator iFind( m_prefixes.find( rPrefix ) );
+ if (iFind != m_prefixes.end()) // unused prefix
+ {
+ PrefixEntry * pEntry = iFind->second;
+ pEntry->m_Uids.pop_back(); // pop last id for prefix
+ if (pEntry->m_Uids.empty()) // erase prefix key
+ {
+ m_prefixes.erase( iFind );
+ delete pEntry;
+ }
+ }
+
+ m_nLastPrefix_lookup = UID_UNKNOWN;
+ m_aLastPrefix_lookup = m_sXMLNS_PREFIX_UNKNOWN;
+}
+
+//______________________________________________________________________________
+inline void DocumentHandlerImpl::getElementName(
+ OUString const & rQName, sal_Int32 * pUid, OUString * pLocalName )
+{
+ sal_Int32 nColonPos = rQName.indexOf( (sal_Unicode)':' );
+ *pLocalName = (nColonPos >= 0 ? rQName.copy( nColonPos +1 ) : rQName);
+ *pUid = getUidByPrefix(
+ nColonPos >= 0 ? rQName.copy( 0, nColonPos ) : OUString() );
+}
+
+
+//==============================================================================
+class ExtendedAttributes :
+ public ::cppu::WeakImplHelper1< xml::input::XAttributes >
+{
+ sal_Int32 m_nAttributes;
+ sal_Int32 * m_pUids;
+ OUString * m_pPrefixes;
+ OUString * m_pLocalNames;
+ OUString * m_pQNames;
+ OUString * m_pValues;
+
+ DocumentHandlerImpl * m_pHandler;
+
+public:
+ inline ExtendedAttributes(
+ sal_Int32 nAttributes,
+ sal_Int32 * pUids, OUString * pPrefixes,
+ OUString * pLocalNames, OUString * pQNames,
+ Reference< xml::sax::XAttributeList > const & xAttributeList,
+ DocumentHandlerImpl * pHandler );
+ virtual ~ExtendedAttributes() throw ();
+
+ // XAttributes
+ virtual sal_Int32 SAL_CALL getLength()
+ throw (RuntimeException);
+ virtual sal_Int32 SAL_CALL getIndexByQName(
+ OUString const & rQName )
+ throw (RuntimeException);
+ virtual sal_Int32 SAL_CALL getIndexByUidName(
+ sal_Int32 nUid, OUString const & rLocalName )
+ throw (RuntimeException);
+ virtual OUString SAL_CALL getQNameByIndex(
+ sal_Int32 nIndex )
+ throw (RuntimeException);
+ virtual sal_Int32 SAL_CALL getUidByIndex(
+ sal_Int32 nIndex )
+ throw (RuntimeException);
+ virtual OUString SAL_CALL getLocalNameByIndex(
+ sal_Int32 nIndex )
+ throw (RuntimeException);
+ virtual OUString SAL_CALL getValueByIndex(
+ sal_Int32 nIndex )
+ throw (RuntimeException);
+ virtual OUString SAL_CALL getValueByUidName(
+ sal_Int32 nUid, OUString const & rLocalName )
+ throw (RuntimeException);
+ virtual OUString SAL_CALL getTypeByIndex(
+ sal_Int32 nIndex )
+ throw (RuntimeException);
+};
+
+//______________________________________________________________________________
+inline ExtendedAttributes::ExtendedAttributes(
+ sal_Int32 nAttributes,
+ sal_Int32 * pUids, OUString * pPrefixes,
+ OUString * pLocalNames, OUString * pQNames,
+ Reference< xml::sax::XAttributeList > const & xAttributeList,
+ DocumentHandlerImpl * pHandler )
+ : m_nAttributes( nAttributes )
+ , m_pUids( pUids )
+ , m_pPrefixes( pPrefixes )
+ , m_pLocalNames( pLocalNames )
+ , m_pQNames( pQNames )
+ , m_pValues( new OUString[ nAttributes ] )
+ , m_pHandler( pHandler )
+{
+ m_pHandler->acquire();
+
+ for ( sal_Int16 nPos = 0; nPos < nAttributes; ++nPos )
+ {
+ m_pValues[ nPos ] = xAttributeList->getValueByIndex( nPos );
+ }
+}
+
+//______________________________________________________________________________
+ExtendedAttributes::~ExtendedAttributes() throw ()
+{
+ m_pHandler->release();
+
+ delete [] m_pUids;
+ delete [] m_pPrefixes;
+ delete [] m_pLocalNames;
+ delete [] m_pQNames;
+ delete [] m_pValues;
+}
+
+
+//##############################################################################
+
+// XServiceInfo
+
+//______________________________________________________________________________
+OUString DocumentHandlerImpl::getImplementationName()
+ throw (RuntimeException)
+{
+ return getImplementationName_DocumentHandlerImpl();
+}
+
+//______________________________________________________________________________
+sal_Bool DocumentHandlerImpl::supportsService(
+ OUString const & servicename )
+ throw (RuntimeException)
+{
+ Sequence< OUString > names( getSupportedServiceNames_DocumentHandlerImpl() );
+ for ( sal_Int32 nPos = names.getLength(); nPos--; )
+ {
+ if (names[ nPos ].equals( servicename ))
+ return sal_True;
+ }
+ return sal_False;
+}
+
+//______________________________________________________________________________
+Sequence< OUString > DocumentHandlerImpl::getSupportedServiceNames()
+ throw (RuntimeException)
+{
+ return getSupportedServiceNames_DocumentHandlerImpl();
+}
+
+// XInitialization
+
+//______________________________________________________________________________
+void DocumentHandlerImpl::initialize(
+ Sequence< Any > const & arguments )
+ throw (Exception)
+{
+ MGuard guard( m_pMutex );
+ Reference< xml::input::XRoot > xRoot;
+ if (arguments.getLength() == 1 &&
+ (arguments[ 0 ] >>= xRoot) &&
+ xRoot.is())
+ {
+ m_xRoot = xRoot;
+ }
+ else
+ {
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "missing root instance!") ),
+ Reference< XInterface >() );
+ }
+}
+
+
+// XNamespaceMapping
+
+//______________________________________________________________________________
+sal_Int32 DocumentHandlerImpl::getUidByUri( OUString const & Uri )
+ throw (RuntimeException)
+{
+ sal_Int32 uid = getUidByURI( Uri );
+ OSL_ASSERT( uid != UID_UNKNOWN );
+ return uid;
+}
+
+//______________________________________________________________________________
+OUString DocumentHandlerImpl::getUriByUid( sal_Int32 Uid )
+ throw (container::NoSuchElementException, RuntimeException)
+{
+ MGuard guard( m_pMutex );
+ t_OUString2LongMap::const_iterator iPos( m_URI2Uid.begin() );
+ t_OUString2LongMap::const_iterator const iEnd( m_URI2Uid.end() );
+ for ( ; iPos != iEnd; ++iPos )
+ {
+ if (iPos->second == Uid)
+ return iPos->first;
+ }
+ throw container::NoSuchElementException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no such xmlns uid!") ),
+ static_cast< OWeakObject * >(this) );
+}
+
+
+// XDocumentHandler
+
+//______________________________________________________________________________
+void DocumentHandlerImpl::startDocument()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ m_xRoot->startDocument(
+ static_cast< xml::input::XNamespaceMapping * >( this ) );
+}
+
+//______________________________________________________________________________
+void DocumentHandlerImpl::endDocument()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ m_xRoot->endDocument();
+}
+
+//______________________________________________________________________________
+void DocumentHandlerImpl::startElement(
+ OUString const & rQElementName,
+ Reference< xml::sax::XAttributeList > const & xAttribs )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ Reference< xml::input::XElement > xCurrentElement;
+ Reference< xml::input::XAttributes > xAttributes;
+ sal_Int32 nUid;
+ OUString aLocalName;
+ ::std::auto_ptr< ElementEntry > elementEntry( new ElementEntry );
+
+ { // guard start:
+ MGuard aGuard( m_pMutex );
+ // currently skipping elements and waiting for end tags?
+ if (m_nSkipElements > 0)
+ {
+ ++m_nSkipElements; // wait for another end tag
+#if OSL_DEBUG_LEVEL > 1
+ OString aQName(
+ OUStringToOString( rQElementName, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "### no context given on createChildElement() "
+ "=> ignoring element \"%s\" ...", aQName.getStr() );
+#endif
+ return;
+ }
+
+ sal_Int16 nAttribs = xAttribs->getLength();
+
+ // save all namespace ids
+ sal_Int32 * pUids = new sal_Int32[ nAttribs ];
+ OUString * pPrefixes = new OUString[ nAttribs ];
+ OUString * pLocalNames = new OUString[ nAttribs ];
+ OUString * pQNames = new OUString[ nAttribs ];
+
+ // first recognize all xmlns attributes
+ sal_Int16 nPos;
+ for ( nPos = 0; nPos < nAttribs; ++nPos )
+ {
+ // mark attribute to be collected further
+ // on with attribute's uid and current prefix
+ pUids[ nPos ] = 0; // modified
+
+ pQNames[ nPos ] = xAttribs->getNameByIndex( nPos );
+ OUString const & rQAttributeName = pQNames[ nPos ];
+
+ if (rQAttributeName.compareTo( m_sXMLNS, 5 ) == 0)
+ {
+ if (rQAttributeName.getLength() == 5) // set default namespace
+ {
+ OUString aDefNamespacePrefix;
+ pushPrefix(
+ aDefNamespacePrefix,
+ xAttribs->getValueByIndex( nPos ) );
+ elementEntry->m_prefixes.push_back( aDefNamespacePrefix );
+ pUids[ nPos ] = UID_UNKNOWN;
+ pPrefixes[ nPos ] = m_sXMLNS;
+ pLocalNames[ nPos ] = aDefNamespacePrefix;
+ }
+ else if ((sal_Unicode)':' == rQAttributeName[ 5 ]) // set prefix
+ {
+ OUString aPrefix( rQAttributeName.copy( 6 ) );
+ pushPrefix( aPrefix, xAttribs->getValueByIndex( nPos ) );
+ elementEntry->m_prefixes.push_back( aPrefix );
+ pUids[ nPos ] = UID_UNKNOWN;
+ pPrefixes[ nPos ] = m_sXMLNS;
+ pLocalNames[ nPos ] = aPrefix;
+ }
+ // else just a name starting with xmlns, but no prefix
+ }
+ }
+
+ // now read out attribute prefixes (all namespace prefixes have been set)
+ for ( nPos = 0; nPos < nAttribs; ++nPos )
+ {
+ if (pUids[ nPos ] >= 0) // no xmlns: attribute
+ {
+ OUString const & rQAttributeName = pQNames[ nPos ];
+ OSL_ENSURE(
+ rQAttributeName.compareToAscii(
+ RTL_CONSTASCII_STRINGPARAM("xmlns:") ) != 0,
+ "### unexpected xmlns!" );
+
+ // collect attribute's uid and current prefix
+ sal_Int32 nColonPos = rQAttributeName.indexOf( (sal_Unicode) ':' );
+ if (nColonPos >= 0)
+ {
+ pPrefixes[ nPos ] = rQAttributeName.copy( 0, nColonPos );
+ pLocalNames[ nPos ] = rQAttributeName.copy( nColonPos +1 );
+ }
+ else
+ {
+ pPrefixes[ nPos ] = OUString();
+ pLocalNames[ nPos ] = rQAttributeName;
+ // leave local names unmodified
+ }
+ pUids[ nPos ] = getUidByPrefix( pPrefixes[ nPos ] );
+ }
+ }
+ // ownership of arrays belongs to attribute list
+ xAttributes = static_cast< xml::input::XAttributes * >(
+ new ExtendedAttributes(
+ nAttribs, pUids, pPrefixes, pLocalNames, pQNames,
+ xAttribs, this ) );
+
+ getElementName( rQElementName, &nUid, &aLocalName );
+
+ // create new child context and append to list
+ if (! m_elements.empty())
+ xCurrentElement = m_elements.back()->m_xElement;
+ } // :guard end
+
+ if (xCurrentElement.is())
+ {
+ elementEntry->m_xElement =
+ xCurrentElement->startChildElement( nUid, aLocalName, xAttributes );
+ }
+ else
+ {
+ elementEntry->m_xElement =
+ m_xRoot->startRootElement( nUid, aLocalName, xAttributes );
+ }
+
+ {
+ MGuard aGuard( m_pMutex );
+ if (elementEntry->m_xElement.is())
+ {
+ m_elements.push_back( elementEntry.release() );
+ }
+ else
+ {
+ ++m_nSkipElements;
+#if OSL_DEBUG_LEVEL > 1
+ OString aQName(
+ OUStringToOString( rQElementName, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE(
+ "### no context given on createChildElement() => "
+ "ignoring element \"%s\" ...", aQName.getStr() );
+#endif
+ }
+ }
+}
+
+//______________________________________________________________________________
+void DocumentHandlerImpl::endElement(
+ OUString const & rQElementName )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ Reference< xml::input::XElement > xCurrentElement;
+ {
+ MGuard aGuard( m_pMutex );
+ if (m_nSkipElements)
+ {
+ --m_nSkipElements;
+#if OSL_DEBUG_LEVEL > 1
+ OString aQName(
+ OUStringToOString( rQElementName, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "### received endElement() for \"%s\".", aQName.getStr() );
+#endif
+ static_cast<void>(rQElementName);
+ return;
+ }
+
+ // popping context
+ OSL_ASSERT( ! m_elements.empty() );
+ ElementEntry * pEntry = m_elements.back();
+ xCurrentElement = pEntry->m_xElement;
+
+#if OSL_DEBUG_LEVEL > 0
+ sal_Int32 nUid;
+ OUString aLocalName;
+ getElementName( rQElementName, &nUid, &aLocalName );
+ OSL_ASSERT( xCurrentElement->getLocalName() == aLocalName );
+ OSL_ASSERT( xCurrentElement->getUid() == nUid );
+#endif
+
+ // pop prefixes
+ for ( sal_Int32 nPos = pEntry->m_prefixes.size(); nPos--; )
+ {
+ popPrefix( pEntry->m_prefixes[ nPos ] );
+ }
+ m_elements.pop_back();
+ delete pEntry;
+ }
+ xCurrentElement->endElement();
+}
+
+//______________________________________________________________________________
+void DocumentHandlerImpl::characters( OUString const & rChars )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ Reference< xml::input::XElement > xCurrentElement( getCurrentElement() );
+ if (xCurrentElement.is())
+ xCurrentElement->characters( rChars );
+}
+
+//______________________________________________________________________________
+void DocumentHandlerImpl::ignorableWhitespace(
+ OUString const & rWhitespaces )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ Reference< xml::input::XElement > xCurrentElement( getCurrentElement() );
+ if (xCurrentElement.is())
+ xCurrentElement->ignorableWhitespace( rWhitespaces );
+}
+
+//______________________________________________________________________________
+void DocumentHandlerImpl::processingInstruction(
+ OUString const & rTarget, OUString const & rData )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ Reference< xml::input::XElement > xCurrentElement( getCurrentElement() );
+ if (xCurrentElement.is())
+ xCurrentElement->processingInstruction( rTarget, rData );
+ else
+ m_xRoot->processingInstruction( rTarget, rData );
+}
+
+//______________________________________________________________________________
+void DocumentHandlerImpl::setDocumentLocator(
+ Reference< xml::sax::XLocator > const & xLocator )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ m_xRoot->setDocumentLocator( xLocator );
+}
+
+//##############################################################################
+
+// XAttributes
+
+//______________________________________________________________________________
+sal_Int32 ExtendedAttributes::getIndexByQName( OUString const & rQName )
+ throw (RuntimeException)
+{
+ for ( sal_Int32 nPos = m_nAttributes; nPos--; )
+ {
+ if (m_pQNames[ nPos ].equals( rQName ))
+ {
+ return nPos;
+ }
+ }
+ return -1;
+}
+
+//______________________________________________________________________________
+sal_Int32 ExtendedAttributes::getLength()
+ throw (RuntimeException)
+{
+ return m_nAttributes;
+}
+
+//______________________________________________________________________________
+OUString ExtendedAttributes::getLocalNameByIndex( sal_Int32 nIndex )
+ throw (RuntimeException)
+{
+ if (nIndex < m_nAttributes)
+ return m_pLocalNames[ nIndex ];
+ else
+ return OUString();
+}
+
+//______________________________________________________________________________
+OUString ExtendedAttributes::getQNameByIndex( sal_Int32 nIndex )
+ throw (RuntimeException)
+{
+ if (nIndex < m_nAttributes)
+ return m_pQNames[ nIndex ];
+ else
+ return OUString();
+}
+
+//______________________________________________________________________________
+OUString ExtendedAttributes::getTypeByIndex( sal_Int32 nIndex )
+ throw (RuntimeException)
+{
+ static_cast<void>(nIndex);
+ OSL_ASSERT( nIndex < m_nAttributes );
+ return OUString(); // unsupported
+}
+
+//______________________________________________________________________________
+OUString ExtendedAttributes::getValueByIndex( sal_Int32 nIndex )
+ throw (RuntimeException)
+{
+ if (nIndex < m_nAttributes)
+ return m_pValues[ nIndex ];
+ else
+ return OUString();
+}
+
+//______________________________________________________________________________
+sal_Int32 ExtendedAttributes::getIndexByUidName(
+ sal_Int32 nUid, OUString const & rLocalName )
+ throw (RuntimeException)
+{
+ for ( sal_Int32 nPos = m_nAttributes; nPos--; )
+ {
+ if (m_pUids[ nPos ] == nUid && m_pLocalNames[ nPos ] == rLocalName)
+ {
+ return nPos;
+ }
+ }
+ return -1;
+}
+
+//______________________________________________________________________________
+sal_Int32 ExtendedAttributes::getUidByIndex( sal_Int32 nIndex )
+ throw (RuntimeException)
+{
+ if (nIndex < m_nAttributes)
+ return m_pUids[ nIndex ];
+ else
+ return -1;
+}
+
+//______________________________________________________________________________
+OUString ExtendedAttributes::getValueByUidName(
+ sal_Int32 nUid, OUString const & rLocalName )
+ throw (RuntimeException)
+{
+ for ( sal_Int32 nPos = m_nAttributes; nPos--; )
+ {
+ if (m_pUids[ nPos ] == nUid && m_pLocalNames[ nPos ] == rLocalName)
+ {
+ return m_pValues[ nPos ];
+ }
+ }
+ return OUString();
+}
+
+
+//##############################################################################
+
+
+//==============================================================================
+Reference< xml::sax::XDocumentHandler > SAL_CALL createDocumentHandler(
+ Reference< xml::input::XRoot > const & xRoot,
+ bool bSingleThreadedUse )
+ SAL_THROW( () )
+{
+ OSL_ASSERT( xRoot.is() );
+ if (xRoot.is())
+ {
+ return static_cast< xml::sax::XDocumentHandler * >(
+ new DocumentHandlerImpl( xRoot, bSingleThreadedUse ) );
+ }
+ return Reference< xml::sax::XDocumentHandler >();
+}
+
+//------------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL create_DocumentHandlerImpl(
+ Reference< XComponentContext > const & )
+ SAL_THROW( (Exception) )
+{
+ return static_cast< ::cppu::OWeakObject * >(
+ new DocumentHandlerImpl(
+ Reference< xml::input::XRoot >(), false /* mt use */ ) );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmldlg_imexp/common.hxx b/xmlscript/source/xmldlg_imexp/common.hxx
new file mode 100644
index 000000000000..e391fb619ed4
--- /dev/null
+++ b/xmlscript/source/xmldlg_imexp/common.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_COMMON_HXX
+#define INCLUDED_COMMON_HXX
+
+#include "sal/types.h"
+
+namespace xmlscript {
+
+const sal_Int16 BORDER_NONE = 0;
+const sal_Int16 BORDER_3D = 1;
+const sal_Int16 BORDER_SIMPLE = 2;
+const sal_Int16 BORDER_SIMPLE_COLOR = 3;
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmldlg_imexp/exp_share.hxx b/xmlscript/source/xmldlg_imexp/exp_share.hxx
new file mode 100644
index 000000000000..ffb97055dff4
--- /dev/null
+++ b/xmlscript/source/xmldlg_imexp/exp_share.hxx
@@ -0,0 +1,252 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "common.hxx"
+#include "misc.hxx"
+#include <xmlscript/xmldlg_imexp.hxx>
+#include <xmlscript/xml_helper.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/FontEmphasisMark.hpp>
+#include <com/sun/star/awt/FontRelief.hpp>
+#include <vector>
+
+
+namespace css = ::com::sun::star;
+
+namespace xmlscript
+{
+
+struct Style
+{
+ sal_uInt32 _backgroundColor;
+ sal_uInt32 _textColor;
+ sal_uInt32 _textLineColor;
+ sal_Int16 _border;
+ sal_Int32 _borderColor;
+ css::awt::FontDescriptor _descr;
+ sal_uInt16 _fontRelief;
+ sal_uInt16 _fontEmphasisMark;
+ sal_uInt32 _fillColor;
+ sal_Int16 _visualEffect;
+
+ // current highest mask: 0x40
+ short _all;
+ short _set;
+
+ ::rtl::OUString _id;
+
+ inline Style( short all_ ) SAL_THROW( () )
+ : _fontRelief( css::awt::FontRelief::NONE )
+ , _fontEmphasisMark( css::awt::FontEmphasisMark::NONE )
+ , _all( all_ )
+ , _set( 0 )
+ {}
+
+ css::uno::Reference< css::xml::sax::XAttributeList > createElement();
+};
+class StyleBag
+{
+ ::std::vector< Style * > _styles;
+
+public:
+ ~StyleBag() SAL_THROW( () );
+
+ ::rtl::OUString getStyleId( Style const & rStyle ) SAL_THROW( () );
+
+ void dump( css::uno::Reference< css::xml::sax::XExtendedDocumentHandler >
+ const & xOut );
+};
+
+class ElementDescriptor
+ : public ::xmlscript::XMLElement
+{
+ css::uno::Reference< css::beans::XPropertySet > _xProps;
+ css::uno::Reference< css::beans::XPropertyState > _xPropState;
+
+public:
+ inline ElementDescriptor(
+ css::uno::Reference< css::beans::XPropertySet > const & xProps,
+ css::uno::Reference< css::beans::XPropertyState > const & xPropState,
+ ::rtl::OUString const & name )
+ SAL_THROW( () )
+ : XMLElement( name )
+ , _xProps( xProps )
+ , _xPropState( xPropState )
+ {}
+ inline ElementDescriptor(
+ ::rtl::OUString const & name )
+ SAL_THROW( () )
+ : XMLElement( name )
+ {}
+
+ template<typename T>
+ inline void read(
+ ::rtl::OUString const & propName, ::rtl::OUString const & attrName,
+ bool forceAttribute = false );
+
+ //
+ template<typename T>
+ inline bool readProp( T * ret, ::rtl::OUString const & rPropName );
+ css::uno::Any readProp( ::rtl::OUString const & rPropName );
+ //
+ void readDefaults( bool supportPrintable = true, bool supportVisible = true );
+ //
+ void readStringAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
+ inline void readDoubleAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName )
+ { read<double>( rPropName, rAttrName ); }
+ inline void readLongAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ bool forceAttribute = false )
+ { read<sal_Int32>( rPropName, rAttrName, forceAttribute ); }
+ void readHexLongAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
+ inline void readShortAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName )
+ { read<sal_Int32>( rPropName, rAttrName ); }
+ inline void readBoolAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName )
+ { read<sal_Bool>( rPropName, rAttrName ); }
+
+ void readAlignAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
+ void readVerticalAlignAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
+ void readImageAlignAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
+ void readImagePositionAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
+ void readDateFormatAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
+ void readTimeFormatAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
+ void readOrientationAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
+ void readButtonTypeAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
+ void readLineEndFormatAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
+ void readSelectionTypeAttr(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName );
+ //
+ inline void addBoolAttr(
+ ::rtl::OUString const & rAttrName, sal_Bool bValue )
+ { addAttribute( rAttrName, ::rtl::OUString::valueOf(bValue) ); }
+ void addNumberFormatAttr(
+ css::uno::Reference< css::beans::XPropertySet >
+ const & xFormatProperties,
+ ::rtl::OUString const & rAttrName );
+
+ //
+ void readEvents() SAL_THROW( (css::uno::Exception) );
+ //
+ void readDialogModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readMultiPageModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readButtonModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readEditModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readCheckBoxModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readRadioButtonModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument )
+ SAL_THROW( (css::uno::Exception) );
+ void readComboBoxModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument )
+ SAL_THROW( (css::uno::Exception) );
+ void readCurrencyFieldModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readDateFieldModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readFileControlModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readTreeControlModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readFixedTextModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readGroupBoxModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readImageControlModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument )
+ SAL_THROW( (css::uno::Exception) );
+ void readListBoxModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument )
+ SAL_THROW( (css::uno::Exception) );
+ void readNumericFieldModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readPatternFieldModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readFormattedFieldModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readTimeFieldModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readFixedLineModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readProgressBarModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+ void readScrollBarModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument )
+ SAL_THROW( (css::uno::Exception) );
+ void readSpinButtonModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument )
+ SAL_THROW( (css::uno::Exception) );
+ void readFixedHyperLinkModel( StyleBag * all_styles )
+ SAL_THROW( (css::uno::Exception) );
+};
+
+template<typename T>
+inline void ElementDescriptor::read(
+ ::rtl::OUString const & propName, ::rtl::OUString const & attrName,
+ bool forceAttribute )
+{
+ if (forceAttribute ||
+ css::beans::PropertyState_DEFAULT_VALUE !=
+ _xPropState->getPropertyState( propName ))
+ {
+ css::uno::Any a( _xProps->getPropertyValue( propName ) );
+ T v = T();
+ if (a >>= v)
+ addAttribute( attrName, ::rtl::OUString::valueOf(v) );
+ else
+ OSL_ENSURE( 0, "### unexpected property type!" );
+ }
+}
+
+template<typename T>
+inline bool ElementDescriptor::readProp(
+ T * ret, ::rtl::OUString const & rPropName )
+{
+ _xProps->getPropertyValue( rPropName ) >>= *ret;
+ return css::beans::PropertyState_DEFAULT_VALUE !=
+ _xPropState->getPropertyState( rPropName );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmldlg_imexp/imp_share.hxx b/xmlscript/source/xmldlg_imexp/imp_share.hxx
new file mode 100644
index 000000000000..27929a349bfe
--- /dev/null
+++ b/xmlscript/source/xmldlg_imexp/imp_share.hxx
@@ -0,0 +1,1073 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "common.hxx"
+#include "misc.hxx"
+#include <xmlscript/xmldlg_imexp.hxx>
+#include <xmlscript/xmllib_imexp.hxx>
+#include <xmlscript/xmlmod_imexp.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/FontEmphasisMark.hpp>
+#include <com/sun/star/awt/FontRelief.hpp>
+#include <com/sun/star/xml/input/XRoot.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <vector>
+
+
+namespace css = ::com::sun::star;
+
+namespace xmlscript
+{
+
+//
+inline sal_Int32 toInt32( ::rtl::OUString const & rStr ) SAL_THROW( () )
+{
+ sal_Int32 nVal;
+ if (rStr.getLength() > 2 && rStr[ 0 ] == '0' && rStr[ 1 ] == 'x')
+ nVal = rStr.copy( 2 ).toInt32( 16 );
+ else
+ nVal = rStr.toInt32();
+ return nVal;
+}
+
+inline bool getBoolAttr(
+ sal_Bool * pRet, ::rtl::OUString const & rAttrName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ sal_Int32 nUid )
+{
+ ::rtl::OUString aValue( xAttributes->getValueByUidName( nUid, rAttrName ) );
+ if (aValue.getLength())
+ {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("true") ))
+ {
+ *pRet = sal_True;
+ return true;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("false") ))
+ {
+ *pRet = sal_False;
+ return true;
+ }
+ else
+ {
+ throw css::xml::sax::SAXException(
+ rAttrName + OUSTR(": no boolean value (true|false)!"),
+ css::uno::Reference<css::uno::XInterface>(), css::uno::Any() );
+ }
+ }
+ return false;
+}
+
+inline bool getStringAttr(
+ ::rtl::OUString * pRet, ::rtl::OUString const & rAttrName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ sal_Int32 nUid )
+{
+ *pRet = xAttributes->getValueByUidName( nUid, rAttrName );
+ return (pRet->getLength() > 0);
+}
+
+inline bool getLongAttr(
+ sal_Int32 * pRet, ::rtl::OUString const & rAttrName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ sal_Int32 nUid )
+{
+ ::rtl::OUString aValue( xAttributes->getValueByUidName( nUid, rAttrName ) );
+ if (aValue.getLength())
+ {
+ *pRet = toInt32( aValue );
+ return true;
+ }
+ return false;
+}
+
+class ImportContext;
+
+//==============================================================================
+struct DialogImport
+ : public ::cppu::WeakImplHelper1< css::xml::input::XRoot >
+{
+ friend class ImportContext;
+
+ css::uno::Reference< css::uno::XComponentContext > _xContext;
+ css::uno::Reference< css::util::XNumberFormatsSupplier > _xSupplier;
+
+ ::std::vector< ::rtl::OUString > _styleNames;
+ ::std::vector< css::uno::Reference< css::xml::input::XElement > > _styles;
+
+ css::uno::Reference< css::container::XNameContainer > _xDialogModel;
+ css::uno::Reference< css::lang::XMultiServiceFactory > _xDialogModelFactory;
+ css::uno::Reference< css::frame::XModel > _xDoc;
+ css::uno::Reference< css::script::XLibraryContainer > _xScriptLibraryContainer;
+
+ sal_Int32 XMLNS_DIALOGS_UID, XMLNS_SCRIPT_UID;
+
+public:
+ inline bool isEventElement(
+ sal_Int32 nUid, ::rtl::OUString const & rLocalName )
+ {
+ return ((XMLNS_SCRIPT_UID == nUid &&
+ (rLocalName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("event") ) ||
+ rLocalName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("listener-event") ))) ||
+ (XMLNS_DIALOGS_UID == nUid &&
+ rLocalName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("event") )));
+ }
+
+ void addStyle(
+ ::rtl::OUString const & rStyleId,
+ css::uno::Reference< css::xml::input::XElement > const & xStyle )
+ SAL_THROW( () );
+ css::uno::Reference< css::xml::input::XElement > getStyle(
+ ::rtl::OUString const & rStyleId ) const
+ SAL_THROW( () );
+
+ inline css::uno::Reference< css::uno::XComponentContext >
+ const & getComponentContext() SAL_THROW( () ) { return _xContext; }
+ css::uno::Reference< css::util::XNumberFormatsSupplier >
+ const & getNumberFormatsSupplier();
+
+ inline DialogImport(
+ css::uno::Reference<css::uno::XComponentContext> const & xContext,
+ css::uno::Reference<css::container::XNameContainer>
+ const & xDialogModel,
+ css::uno::Reference<css::frame::XModel> const & xDoc )
+ SAL_THROW( () )
+ : _xContext( xContext )
+ , _xDialogModel( xDialogModel )
+ , _xDialogModelFactory( xDialogModel, css::uno::UNO_QUERY_THROW ), _xDoc( xDoc )
+ { OSL_ASSERT( _xDialogModel.is() && _xDialogModelFactory.is() &&
+ _xContext.is() ); }
+ virtual ~DialogImport()
+ SAL_THROW( () );
+
+ inline css::uno::Reference< css::frame::XModel > getDocOwner() { return _xDoc; }
+
+ css::uno::Reference< css::script::XLibraryContainer > getScriptLibraryContainer();
+ // XRoot
+ virtual void SAL_CALL startDocument(
+ css::uno::Reference< css::xml::input::XNamespaceMapping >
+ const & xNamespaceMapping )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endDocument()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL processingInstruction(
+ ::rtl::OUString const & rTarget, ::rtl::OUString const & rData )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL setDocumentLocator(
+ css::uno::Reference< css::xml::sax::XLocator > const & xLocator )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual css::uno::Reference< css::xml::input::XElement >
+ SAL_CALL startRootElement(
+ sal_Int32 nUid, ::rtl::OUString const & rLocalName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+};
+
+//==============================================================================
+class ElementBase
+ : public ::cppu::WeakImplHelper1< css::xml::input::XElement >
+{
+protected:
+ DialogImport * _pImport;
+ ElementBase * _pParent;
+
+ sal_Int32 _nUid;
+ ::rtl::OUString _aLocalName;
+ css::uno::Reference< css::xml::input::XAttributes > _xAttributes;
+
+public:
+ ElementBase(
+ sal_Int32 nUid, ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () );
+ virtual ~ElementBase()
+ SAL_THROW( () );
+
+ // XElement
+ virtual css::uno::Reference<css::xml::input::XElement> SAL_CALL getParent()
+ throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getLocalName()
+ throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getUid()
+ throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::xml::input::XAttributes >
+ SAL_CALL getAttributes() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL ignorableWhitespace(
+ ::rtl::OUString const & rWhitespaces )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL characters( ::rtl::OUString const & rChars )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL processingInstruction(
+ ::rtl::OUString const & Target, ::rtl::OUString const & Data )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+};
+
+//==============================================================================
+class StylesElement
+ : public ElementBase
+{
+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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline StylesElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ElementBase( pImport->XMLNS_DIALOGS_UID,
+ rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class StyleElement
+ : public ElementBase
+{
+ sal_Int32 _backgroundColor;
+ sal_Int32 _textColor;
+ sal_Int32 _textLineColor;
+ sal_Int16 _border;
+ sal_Int32 _borderColor;
+ css::awt::FontDescriptor _descr;
+ sal_Int16 _fontRelief;
+ sal_Int16 _fontEmphasisMark;
+ sal_Int32 _fillColor;
+ sal_Int16 _visualEffect;
+
+ // current highest mask: 0x40
+ short _inited, _hasValue;
+
+ void setFontProperties(
+ css::uno::Reference< css::beans::XPropertySet > const & xProps );
+
+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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ bool importTextColorStyle(
+ css::uno::Reference< css::beans::XPropertySet > const & xProps );
+ bool importTextLineColorStyle(
+ css::uno::Reference< css::beans::XPropertySet > const & xProps );
+ bool importFillColorStyle(
+ css::uno::Reference< css::beans::XPropertySet > const & xProps );
+ bool importBackgroundColorStyle(
+ css::uno::Reference< css::beans::XPropertySet > const & xProps );
+ bool importFontStyle(
+ css::uno::Reference< css::beans::XPropertySet > const & xProps );
+ bool importBorderStyle(
+ css::uno::Reference< css::beans::XPropertySet > const & xProps );
+ bool importVisualEffectStyle(
+ css::uno::Reference< css::beans::XPropertySet > const & xProps );
+
+ inline StyleElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ElementBase( pImport->XMLNS_DIALOGS_UID,
+ rLocalName, xAttributes, pParent, pImport )
+ , _fontRelief( css::awt::FontRelief::NONE )
+ , _fontEmphasisMark( css::awt::FontEmphasisMark::NONE )
+ , _inited( 0 )
+ , _hasValue( 0 )
+ {}
+};
+
+//==============================================================================
+class MenuPopupElement
+ : public ElementBase
+{
+ ::std::vector< ::rtl::OUString > _itemValues;
+ ::std::vector< sal_Int16 > _itemSelected;
+public:
+ css::uno::Sequence< ::rtl::OUString > getItemValues();
+ css::uno::Sequence< sal_Int16 > getSelectedItems();
+
+ 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline MenuPopupElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ElementBase( pImport->XMLNS_DIALOGS_UID,
+ rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class ControlElement
+ : public ElementBase
+{
+ friend class EventElement;
+
+protected:
+ sal_Int32 _nBasePosX, _nBasePosY;
+
+ ::std::vector< css::uno::Reference< css::xml::input::XElement > > _events;
+
+ ::rtl::OUString getControlId(
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ css::uno::Reference< css::xml::input::XElement > getStyle(
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+public:
+ ::std::vector<css::uno::Reference< css::xml::input::XElement> > *getEvents()
+ SAL_THROW( () ) { return &_events; }
+
+ ControlElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () );
+};
+
+//==============================================================================
+class ImportContext
+{
+protected:
+ DialogImport * _pImport;
+ css::uno::Reference< css::beans::XPropertySet > _xControlModel;
+ ::rtl::OUString _aId;
+
+public:
+ inline ImportContext(
+ DialogImport * pImport,
+ css::uno::Reference< css::beans::XPropertySet > const & xControlModel_,
+ ::rtl::OUString const & id )
+ : _pImport( pImport ),
+ _xControlModel( xControlModel_ ),
+ _aId( id )
+ { OSL_ASSERT( _xControlModel.is() ); }
+
+ inline css::uno::Reference< css::beans::XPropertySet > getControlModel()
+ { return _xControlModel; }
+
+ void importDefaults(
+ sal_Int32 nBaseX, sal_Int32 nBaseY,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ bool supportPrintable = true );
+ void importEvents(
+ ::std::vector< css::uno::Reference< css::xml::input::XElement > >
+ const & rEvents );
+
+ bool importStringProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importDoubleProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importBooleanProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importShortProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importLongProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importLongProperty(
+ sal_Int32 nOffset,
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importHexLongProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importAlignProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importVerticalAlignProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importImageAlignProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importImagePositionProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importDateFormatProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importTimeFormatProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importOrientationProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importButtonTypeProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importLineEndFormatProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+ bool importSelectionTypeProperty(
+ ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
+ css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
+};
+
+//==============================================================================
+class ControlImportContext : public ImportContext
+{
+public:
+ inline ControlImportContext(
+ DialogImport * pImport,
+ ::rtl::OUString const & rId, ::rtl::OUString const & rControlName )
+ : ImportContext(
+ pImport,
+ css::uno::Reference< css::beans::XPropertySet >(
+ pImport->_xDialogModelFactory->createInstance( rControlName ),
+ css::uno::UNO_QUERY_THROW ), rId )
+ {}
+ inline ~ControlImportContext()
+ {
+ _pImport->_xDialogModel->insertByName(
+ _aId, css::uno::makeAny(
+ css::uno::Reference<css::awt::XControlModel>::query(
+ _xControlModel ) ) );
+ }
+};
+
+//==============================================================================
+class WindowElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline WindowElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class EventElement
+ : public ElementBase
+{
+public:
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline EventElement(
+ sal_Int32 nUid, ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ElementBase( nUid, rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class BulletinBoardElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ BulletinBoardElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () );
+};
+
+//==============================================================================
+class ButtonElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline ButtonElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class CheckBoxElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline CheckBoxElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class ComboBoxElement
+ : public ControlElement
+{
+ css::uno::Reference< css::xml::input::XElement > _popup;
+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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline ComboBoxElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class MenuListElement
+ : public ControlElement
+{
+ css::uno::Reference< css::xml::input::XElement > _popup;
+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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline MenuListElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class RadioElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline RadioElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class RadioGroupElement
+ : public ControlElement
+{
+ ::std::vector< css::uno::Reference< css::xml::input::XElement > > _radios;
+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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline RadioGroupElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class TitledBoxElement
+ : public BulletinBoardElement
+{
+ ::rtl::OUString _label;
+ ::std::vector< css::uno::Reference< css::xml::input::XElement > > _radios;
+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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline TitledBoxElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : BulletinBoardElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class TextElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline TextElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+//==============================================================================
+class FixedHyperLinkElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline FixedHyperLinkElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+//==============================================================================
+class TextFieldElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline TextFieldElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class ImageControlElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline ImageControlElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class FileControlElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline FileControlElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class TreeControlElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline TreeControlElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class CurrencyFieldElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline CurrencyFieldElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class DateFieldElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline DateFieldElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class NumericFieldElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline NumericFieldElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class TimeFieldElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline TimeFieldElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class PatternFieldElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline PatternFieldElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class FormattedFieldElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline FormattedFieldElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class FixedLineElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline FixedLineElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class ScrollBarElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline ScrollBarElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class SpinButtonElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline SpinButtonElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==============================================================================
+class MultiPage
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline MultiPage(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+class ProgressBarElement
+ : 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 )
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException);
+
+ inline ProgressBarElement(
+ ::rtl::OUString const & rLocalName,
+ css::uno::Reference< css::xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmldlg_imexp/makefile.mk b/xmlscript/source/xmldlg_imexp/makefile.mk
new file mode 100644
index 000000000000..e0583aa78d9b
--- /dev/null
+++ b/xmlscript/source/xmldlg_imexp/makefile.mk
@@ -0,0 +1,52 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=xmlscript
+TARGET=xmldlg_imexp
+NO_BSYMBOLIC=TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
+#-----------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/xmldlg_import.obj \
+ $(SLO)$/xmldlg_impmodels.obj \
+ $(SLO)$/xmldlg_export.obj \
+ $(SLO)$/xmldlg_expmodels.obj \
+ $(SLO)$/xmldlg_addfunc.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/target.pmk
+.ENDIF # L10N_framework
+
+.INCLUDE : target.mk
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx
new file mode 100644
index 000000000000..f0e8a3dfd4ea
--- /dev/null
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx
@@ -0,0 +1,144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/xml/sax/XParser.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <xmlscript/xml_helper.hxx>
+#include <xmlscript/xmldlg_imexp.hxx>
+
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+
+namespace xmlscript
+{
+
+//==================================================================================================
+class InputStreamProvider
+ : public ::cppu::WeakImplHelper1< io::XInputStreamProvider >
+{
+ ByteSequence _bytes;
+
+public:
+ inline InputStreamProvider( ByteSequence const & rBytes )
+ : _bytes( rBytes )
+ {}
+
+ // XInputStreamProvider
+ virtual Reference< io::XInputStream > SAL_CALL createInputStream()
+ throw (RuntimeException);
+};
+//__________________________________________________________________________________________________
+Reference< io::XInputStream > InputStreamProvider::createInputStream()
+ throw (RuntimeException)
+{
+ return ::xmlscript::createInputStream( _bytes );
+}
+
+//==================================================================================================
+Reference< io::XInputStreamProvider > SAL_CALL exportDialogModel(
+ Reference< container::XNameContainer > const & xDialogModel,
+ Reference< XComponentContext > const & xContext,
+ Reference< XModel > const & xDocument )
+ SAL_THROW( (Exception) )
+{
+ Reference< lang::XMultiComponentFactory > xSMgr( xContext->getServiceManager() );
+ if (! xSMgr.is())
+ {
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no service manager available!") ),
+ Reference< XInterface >() );
+ }
+
+ Reference< xml::sax::XExtendedDocumentHandler > xHandler( xSMgr->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer") ), xContext ), UNO_QUERY );
+ OSL_ASSERT( xHandler.is() );
+ if (! xHandler.is())
+ {
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("could not create sax-writer component!") ),
+ Reference< XInterface >() );
+ }
+
+ ByteSequence aBytes;
+
+ Reference< io::XActiveDataSource > xSource( xHandler, UNO_QUERY );
+ xSource->setOutputStream( createOutputStream( &aBytes ) );
+ exportDialogModel( xHandler, xDialogModel, xDocument );
+
+ return new InputStreamProvider( aBytes );
+}
+
+//==================================================================================================
+void SAL_CALL importDialogModel(
+ Reference< io::XInputStream > xInput,
+ Reference< container::XNameContainer > const & xDialogModel,
+ Reference< XComponentContext > const & xContext,
+ Reference< XModel > const & xDocument )
+ SAL_THROW( (Exception) )
+{
+ Reference< lang::XMultiComponentFactory > xSMgr( xContext->getServiceManager() );
+ if (! xSMgr.is())
+ {
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no service manager available!") ),
+ Reference< XInterface >() );
+ }
+
+ Reference< xml::sax::XParser > xParser( xSMgr->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser") ), xContext ), UNO_QUERY );
+ OSL_ASSERT( xParser.is() );
+ if (! xParser.is())
+ {
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("could not create sax-parser component!") ),
+ Reference< XInterface >() );
+ }
+
+ // error handler, entity resolver omitted for this helper function
+ xParser->setDocumentHandler( importDialogModel( xDialogModel, xContext, xDocument ) );
+
+ xml::sax::InputSource source;
+ source.aInputStream = xInput;
+ source.sSystemId = OUString( RTL_CONSTASCII_USTRINGPARAM("virtual file") );
+
+ xParser->parseStream( source );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
new file mode 100644
index 000000000000..a2abb08d5c0f
--- /dev/null
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
@@ -0,0 +1,1345 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+#include "exp_share.hxx"
+
+#include <com/sun/star/form/binding/XListEntrySink.hpp>
+#include <com/sun/star/form/binding/XBindableValue.hpp>
+#include <com/sun/star/form/binding/XValueBinding.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/document/XGraphicObjectResolver.hpp>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/processfactory.hxx>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+namespace xmlscript
+{
+
+void lclExportBindableAndListSourceBits( Reference< frame::XModel > const & xDocument, const Reference< beans::XPropertySet >& _xProps, ElementDescriptor& rModel )
+{
+ Reference< lang::XMultiServiceFactory > xFac;
+ if ( xDocument.is() )
+ xFac.set( xDocument, uno::UNO_QUERY );
+
+ Reference< form::binding::XBindableValue > xBinding( _xProps, UNO_QUERY );
+
+ if ( xFac.is() && xBinding.is() )
+ {
+ try
+ {
+ Reference< beans::XPropertySet > xConvertor( xFac->createInstance( OUSTR( "com.sun.star.table.CellAddressConversion" )), uno::UNO_QUERY );
+ Reference< beans::XPropertySet > xBindable( xBinding->getValueBinding(), UNO_QUERY );
+ if ( xBindable.is() )
+ {
+ table::CellAddress aAddress;
+ xBindable->getPropertyValue( OUSTR("BoundCell") ) >>= aAddress;
+ xConvertor->setPropertyValue( OUSTR("Address"), makeAny( aAddress ) );
+ rtl::OUString sAddress;
+ xConvertor->getPropertyValue( OUSTR("PersistentRepresentation") ) >>= sAddress;
+ if ( sAddress.getLength() > 0 )
+ rModel.addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":linked-cell"), sAddress );
+
+ OSL_TRACE( "*** Bindable value %s", rtl::OUStringToOString( sAddress, RTL_TEXTENCODING_UTF8 ).getStr() );
+
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+ Reference< form::binding::XListEntrySink > xEntrySink( _xProps, UNO_QUERY );
+ if ( xEntrySink.is() )
+ {
+ Reference< beans::XPropertySet > xListSource( xEntrySink->getListEntrySource(), UNO_QUERY );
+ if ( xListSource.is() )
+ {
+ try
+ {
+ Reference< beans::XPropertySet > xConvertor( xFac->createInstance( OUSTR( "com.sun.star.table.CellRangeAddressConversion" )), uno::UNO_QUERY );
+
+ table::CellRangeAddress aAddress;
+ xListSource->getPropertyValue( OUSTR( "CellRange" ) ) >>= aAddress;
+
+ rtl::OUString sAddress;
+ xConvertor->setPropertyValue( OUSTR("Address"), makeAny( aAddress ) );
+ xConvertor->getPropertyValue( OUSTR("PersistentRepresentation") ) >>= sAddress;
+ OSL_TRACE("**** cell range source list %s",
+ rtl::OUStringToOString( sAddress, RTL_TEXTENCODING_UTF8 ).getStr() );
+ if ( sAddress.getLength() > 0 )
+ rModel.addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":source-cell-range"), sAddress );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+ }
+
+}
+static inline bool readBorderProps(
+ ElementDescriptor * element, Style & style )
+{
+ if (element->readProp( &style._border, OUSTR("Border") )) {
+ if (style._border == BORDER_SIMPLE /* simple */)
+ {
+ if (element->readProp( &style._borderColor, OUSTR("BorderColor") ))
+ style._border = BORDER_SIMPLE_COLOR;
+ }
+ return true;
+ }
+ return false;
+}
+
+static inline bool readFontProps( ElementDescriptor * element, Style & style )
+{
+ bool ret = element->readProp(
+ &style._descr, OUSTR("FontDescriptor") );
+ ret |= element->readProp(
+ &style._fontEmphasisMark, OUSTR("FontEmphasisMark") );
+ ret |= element->readProp(
+ &style._fontRelief, OUSTR("FontRelief") );
+ return ret;
+}
+
+//__________________________________________________________________________________________________
+void ElementDescriptor::readMultiPageModel( StyleBag * all_styles )
+{
+ // collect styles
+ Style aStyle( 0x2 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-max") ) );
+
+ OUString aTitle;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ) ) >>= aTitle)
+ {
+ ElementDescriptor * title = new ElementDescriptor(
+ _xProps, _xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":title") ) );
+ title->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ),
+ aTitle );
+ addSubElement( title );
+ }
+
+ readEvents();
+}
+void ElementDescriptor::readButtonModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultButton") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":default") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) );
+ readVerticalAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":valign") ) );
+ readButtonTypeAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("PushButtonType") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":button-type") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-src") ) );
+ readImagePositionAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-position") ) );
+ readImageAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageAlign") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-align") ) );
+ if (extract_throw<bool>( _xProps->getPropertyValue( OUSTR("Repeat") ) ))
+ readLongAttr( OUSTR("RepeatDelay"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":repeat"), true /* force */ );
+ if (extract_throw<bool>( _xProps->getPropertyValue( OUSTR("Toggle") ) ))
+ addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":toggled"), OUSTR("1") );
+ readBoolAttr( OUSTR("FocusOnClick"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":grab-focus") );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multiline") ) );
+
+
+ // State
+ sal_Int16 nState = 0;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ) ) >>= nState)
+ {
+ switch (nState)
+ {
+ case 0:
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checked") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("false") ) );
+ break;
+ case 1:
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checked") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected radio state!" );
+ break;
+ }
+ }
+
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readCheckBoxModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x8 | 0x20 | 0x40 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (readProp( OUSTR("VisualEffect") ) >>= aStyle._visualEffect)
+ aStyle._set |= 0x40;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) );
+ readVerticalAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":valign") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-src") ) );
+ readImagePositionAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-position") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multiline") ) );
+
+ sal_Bool bTriState = sal_False;
+ if ((readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TriState") ) ) >>= bTriState) && bTriState)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tristate") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) );
+ }
+ sal_Int16 nState = 0;
+ if (_xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ) ) >>= nState)
+ {
+ switch (nState)
+ {
+ case 0:
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checked") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("false") ) );
+ break;
+ case 1:
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checked") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) );
+ break;
+ case 2: // tristate=true exported, checked omitted => dont know!
+ OSL_ENSURE( bTriState, "### detected tristate value, but TriState is not set!" );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected checkbox state!" );
+ break;
+ }
+ }
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readComboBoxModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Autocomplete") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":autocomplete") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":readonly") ) );
+ readBoolAttr( OUSTR("HideInactiveSelection"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":hide-inactive-selection") );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Dropdown") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":spin") ) );
+ readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MaxTextLen") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":maxlength") ) );
+ readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("LineCount") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linecount") ) );
+ // Cell Range, Ref Cell etc.
+ lclExportBindableAndListSourceBits( xDocument, _xProps, *this );
+ // string item list
+ Sequence< OUString > itemValues;
+ if ((readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ) ) >>= itemValues) &&
+ itemValues.getLength() > 0)
+ {
+ ElementDescriptor * popup = new ElementDescriptor(
+ _xProps, _xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menupopup") ) );
+
+ OUString const * pItemValues = itemValues.getConstArray();
+ for ( sal_Int32 nPos = 0; nPos < itemValues.getLength(); ++nPos )
+ {
+ ElementDescriptor * item = new ElementDescriptor(
+ _xProps, _xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menuitem") ) );
+ item->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ),
+ pItemValues[ nPos ] );
+ popup->addSubElement( item );
+ }
+
+ addSubElement( popup );
+ }
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readListBoxModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiSelection") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multiselection") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":readonly") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Dropdown") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":spin") ) );
+ readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("LineCount") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linecount") ) );
+ readAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) );
+ lclExportBindableAndListSourceBits( xDocument, _xProps, *this );
+ // string item list
+ Sequence< OUString > itemValues;
+ if ((readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ) ) >>= itemValues) &&
+ itemValues.getLength() > 0)
+ {
+ ElementDescriptor * popup = new ElementDescriptor(
+ _xProps, _xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menupopup") ) );
+
+ OUString const * pItemValues = itemValues.getConstArray();
+ sal_Int32 nPos;
+ for ( nPos = 0; nPos < itemValues.getLength(); ++nPos )
+ {
+ ElementDescriptor * item = new ElementDescriptor(
+ _xProps, _xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menuitem") ) );
+ item->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ),
+ pItemValues[ nPos ] );
+ popup->addSubElement( item );
+ }
+
+ Sequence< sal_Int16 > selected;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") ) ) >>= selected)
+ {
+ sal_Int16 const * pSelected = selected.getConstArray();
+ for ( nPos = selected.getLength(); nPos--; )
+ {
+ ElementDescriptor * item = static_cast< ElementDescriptor * >(
+ popup->getSubElement( pSelected[ nPos ] ).get() );
+ item->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":selected") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) );
+ }
+ }
+
+ addSubElement( popup );
+ }
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readRadioButtonModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x8 | 0x20 | 0x40 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (readProp( OUSTR("VisualEffect") ) >>= aStyle._visualEffect)
+ aStyle._set |= 0x40;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) );
+ readVerticalAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":valign") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-src") ) );
+ readImagePositionAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-position") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multiline") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("GroupName") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":group-name") ) );
+
+ sal_Int16 nState = 0;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ) ) >>= nState)
+ {
+ switch (nState)
+ {
+ case 0:
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checked") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("false") ) );
+ break;
+ case 1:
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checked") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected radio state!" );
+ break;
+ }
+ }
+ lclExportBindableAndListSourceBits( xDocument, _xProps, *this );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readGroupBoxModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x2 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+
+ OUString aTitle;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ) ) >>= aTitle)
+ {
+ ElementDescriptor * title = new ElementDescriptor(
+ _xProps, _xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":title") ) );
+ title->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ),
+ aTitle );
+ addSubElement( title );
+ }
+
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readFixedTextModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) );
+ readVerticalAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":valign") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multiline") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("NoLabel") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":nolabel") ) );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readFixedHyperLinkModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("URL") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":url") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Description") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":description") ) );
+ readAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) );
+ readVerticalAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":valign") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multiline") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("NoLabel") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":nolabel") ) );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readEditModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readBoolAttr( OUSTR("HideInactiveSelection"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":hide-inactive-selection") );
+ readAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HardLineBreaks") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":hard-linebreaks") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HScroll") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":hscroll") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("VScroll") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":vscroll") ) );
+ readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MaxTextLen") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":maxlength") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multiline") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":readonly") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readLineEndFormatAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("LineEndFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":lineend-format") ) );
+ sal_Int16 nEcho = 0;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("EchoChar") ) ) >>= nEcho)
+ {
+ sal_Unicode cEcho = (sal_Unicode)nEcho;
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":echochar") ),
+ OUString( &cEcho, 1 ) );
+ }
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readImageControlModel( StyleBag * all_styles, com::sun::star::uno::Reference< com::sun::star::frame::XModel > const & xDocument )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x4 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleImage") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":scale-image") ) );
+ rtl::OUString sURL;
+ _xProps->getPropertyValue( OUSTR("ImageURL") ) >>= sURL;
+
+ if ( sURL.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) ) ) == 0 )
+ {
+ Reference< document::XStorageBasedDocument > xDocStorage( xDocument, UNO_QUERY );
+
+ if ( xDocStorage.is() )
+ {
+ uno::Sequence< Any > aArgs( 1 );
+ aArgs[ 0 ] <<= xDocStorage->getDocumentStorage();
+
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ uno::Reference< document::XGraphicObjectResolver > xGraphicResolver;
+ aContext.createComponentWithArguments( OUSTR( "com.sun.star.comp.Svx.GraphicExportHelper" ), aArgs, xGraphicResolver );
+ if ( xGraphicResolver.is() )
+ {
+ sURL = xGraphicResolver->resolveGraphicObjectURL( sURL );
+ }
+ }
+ }
+ if ( sURL.getLength() > 0 )
+ {
+ addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":src"), sURL );
+ }
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readFileControlModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readBoolAttr( OUSTR("HideInactiveSelection"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":hide-inactive-selection") );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":readonly") ) );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readTreeControlModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readSelectionTypeAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SelectionType") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":selectiontype") ) );
+
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("RootDisplayed") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":rootdisplayed") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ShowsHandles") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":showshandles") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ShowsRootHandles") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":showsroothandles") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Editable") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":editable") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("InvokesStopNodeEditing") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":invokesstopnodeediting") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("RowHeight") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":rowheight") ) );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readCurrencyFieldModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":readonly") ) );
+ readBoolAttr( OUSTR("HideInactiveSelection"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":hide-inactive-selection") );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("StrictFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":strict-format") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("CurrencySymbol") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":currency-symbol") ) );
+ readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("DecimalAccuracy") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":decimal-accuracy") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ShowThousandsSeparator") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":thousands-separator") ) );
+ readDoubleAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Value") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readDoubleAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ValueMin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-min") ) );
+ readDoubleAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ValueMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-max") ) );
+ readDoubleAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ValueStep") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-step") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Spin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":spin") ) );
+ if (extract_throw<bool>( _xProps->getPropertyValue( OUSTR("Repeat") ) ))
+ readLongAttr( OUSTR("RepeatDelay"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":repeat"), true /* force */ );
+ readBoolAttr(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("PrependCurrencySymbol") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":prepend-symbol") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("EnforceFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":enforce-format") ) );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readDateFieldModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":readonly") ) );
+ readBoolAttr( OUSTR("HideInactiveSelection"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":hide-inactive-selection") );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("StrictFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":strict-format") ) );
+ readDateFormatAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("DateFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":date-format") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("DateShowCentury") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":show-century") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Date") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("DateMin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-min") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("DateMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-max") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Spin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":spin") ) );
+ if (extract_throw<bool>( _xProps->getPropertyValue( OUSTR("Repeat") ) ))
+ readLongAttr( OUSTR("RepeatDelay"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":repeat"), true /* force */ );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Dropdown") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":dropdown") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("EnforceFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":enforce-format") ) );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readNumericFieldModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":readonly") ) );
+ readBoolAttr( OUSTR("HideInactiveSelection"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":hide-inactive-selection") );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("StrictFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":strict-format") ) );
+ readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("DecimalAccuracy") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":decimal-accuracy") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ShowThousandsSeparator") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":thousands-separator") ) );
+ readDoubleAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Value") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readDoubleAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ValueMin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-min") ) );
+ readDoubleAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ValueMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-max") ) );
+ readDoubleAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ValueStep") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-step") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Spin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":spin") ) );
+ if (extract_throw<bool>( _xProps->getPropertyValue( OUSTR("Repeat") ) ))
+ readLongAttr( OUSTR("RepeatDelay"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":repeat"), true /* force */ );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("EnforceFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":enforce-format") ) );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readTimeFieldModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":readonly") ) );
+ readBoolAttr( OUSTR("HideInactiveSelection"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":hide-inactive-selection") );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("StrictFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":strict-format") ) );
+ readTimeFormatAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("TimeFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":time-format") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Time") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("TimeMin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-min") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("TimeMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-max") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Spin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":spin") ) );
+ if (extract_throw<bool>( _xProps->getPropertyValue( OUSTR("Repeat") ) ))
+ readLongAttr( OUSTR("RepeatDelay"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":repeat"), true /* force */ );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("EnforceFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":enforce-format") ) );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readPatternFieldModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":readonly") ) );
+ readBoolAttr( OUSTR("HideInactiveSelection"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":hide-inactive-selection") );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("StrictFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":strict-format") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MaxTextLen") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":maxlength") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("EditMask") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":edit-mask") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("LiteralMask") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":literal-mask") ) );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readFormattedFieldModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x4 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":readonly") ) );
+ readBoolAttr( OUSTR("HideInactiveSelection"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":hide-inactive-selection") );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("StrictFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":strict-format") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text") ) );
+ readAlignAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) );
+ readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MaxTextLen") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":maxlength") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Spin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":spin") ) );
+ if (extract_throw<bool>( _xProps->getPropertyValue( OUSTR("Repeat") ) ))
+ readLongAttr( OUSTR("RepeatDelay"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":repeat"), true /* force */ );
+
+ Any a( readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("EffectiveDefault") ) ) );
+ switch (a.getValueTypeClass())
+ {
+ case TypeClass_DOUBLE:
+ addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-default") ),
+ OUString::valueOf( *(double const *)a.getValue() ) );
+ break;
+ case TypeClass_STRING:
+ addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-default") ),
+ *(OUString const *)a.getValue() );
+ break;
+ default:
+ break;
+ }
+ readDoubleAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("EffectiveMin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-min") ) );
+ readDoubleAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("EffectiveMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-max") ) );
+ readDoubleAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("EffectiveValue") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+
+ // format spec
+ sal_Int32 nKey = 0;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("FormatKey") ) ) >>= nKey)
+ {
+ Reference< util::XNumberFormatsSupplier > xSupplier;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("FormatsSupplier") ) ) >>= xSupplier)
+ {
+ addNumberFormatAttr(
+ xSupplier->getNumberFormats()->getByKey( nKey ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-min") ) );
+ }
+ }
+ readBoolAttr(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("TreatAsNumber") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":treat-as-number") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("EnforceFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":enforce-format") ) );
+
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readFixedLineModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x2 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readOrientationAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Orientation") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readProgressBarModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x4 | 0x10 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("FillColor") ) ) >>= aStyle._descr)
+ aStyle._set |= 0x10;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-min") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-max") ) );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readScrollBarModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x4 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readOrientationAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Orientation") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("BlockIncrement") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":pageincrement") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("LineIncrement") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":increment") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ScrollValue") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":curpos") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ScrollValueMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":maxpos") ) );
+ readLongAttr( OUSTR("ScrollValueMin"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":minpos") );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("VisibleSize") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":visible-size") ) );
+ readLongAttr( OUSTR("RepeatDelay"), OUSTR(XMLNS_DIALOGS_PREFIX ":repeat") );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("LiveScroll") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":live-scroll") ) );
+ readHexLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SymbolColor") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":symbol-color") ) );
+ // Cell Range, Ref Cell etc.
+ lclExportBindableAndListSourceBits( xDocument, _xProps, *this );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readSpinButtonModel( StyleBag * all_styles, Reference< frame::XModel > const & xDocument )
+ SAL_THROW( (Exception) )
+{
+ // collect styles
+ Style aStyle( 0x1 | 0x4 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readBorderProps( this, aStyle ))
+ aStyle._set |= 0x4;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults();
+ readOrientationAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Orientation") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":align") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinIncrement") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":increment") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinValue") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":curval") ) );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinValueMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":maxval") ) );
+ readLongAttr( OUSTR("SpinValueMin"),
+ OUSTR(XMLNS_DIALOGS_PREFIX ":minval") );
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Repeat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":repeat") ) );
+ readLongAttr( OUSTR("RepeatDelay"), OUSTR(XMLNS_DIALOGS_PREFIX ":repeat-delay") );
+ readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tabstop") ) );
+ readHexLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("SymbolColor") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":symbol-color") ) );
+ // Cell Range, Ref Cell etc.
+ lclExportBindableAndListSourceBits( xDocument, _xProps, *this );
+ readEvents();
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readDialogModel( StyleBag * all_styles )
+ SAL_THROW( (Exception) )
+{
+ // collect elements
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_DIALOGS_PREFIX) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_URI) ) );
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_SCRIPT_PREFIX) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_URI) ) );
+
+ // collect styles
+ Style aStyle( 0x1 | 0x2 | 0x8 | 0x20 );
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) >>= aStyle._backgroundColor)
+ aStyle._set |= 0x1;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ) ) >>= aStyle._textColor)
+ aStyle._set |= 0x2;
+ if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ) ) >>= aStyle._textLineColor)
+ aStyle._set |= 0x20;
+ if (readFontProps( this, aStyle ))
+ aStyle._set |= 0x8;
+ if (aStyle._set)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ),
+ all_styles->getStyleId( aStyle ) );
+ }
+
+ // collect elements
+ readDefaults( false, false );
+ readBoolAttr(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Closeable") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":closeable") ) );
+ readBoolAttr(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Moveable") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":moveable") ) );
+ readBoolAttr(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Sizeable") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":resizeable") ) );
+ readStringAttr(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":title") ) );
+
+ Any aDecorationAny( _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Decoration") ) ) );
+ bool bDecoration = sal_False;
+ if ( (aDecorationAny >>= bDecoration) && !bDecoration )
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":withtitlebar") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("false") ) );
+
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-src") ) );
+
+ readEvents();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
new file mode 100644
index 000000000000..cec44ca50a04
--- /dev/null
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
@@ -0,0 +1,1630 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+#include "exp_share.hxx"
+
+#include <rtl/ustrbuf.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <com/sun/star/awt/CharSet.hpp>
+#include <com/sun/star/awt/FontFamily.hpp>
+#include <com/sun/star/awt/FontPitch.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontType.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontWidth.hpp>
+#include <com/sun/star/awt/ImagePosition.hpp>
+#include <com/sun/star/awt/LineEndFormat.hpp>
+#include <com/sun/star/awt/PushButtonType.hpp>
+#include <com/sun/star/awt/VisualEffect.hpp>
+
+#include <com/sun/star/script/XScriptEventsSupplier.hpp>
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+
+#include <com/sun/star/style/VerticalAlignment.hpp>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+
+#include <com/sun/star/view/SelectionType.hpp>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+namespace xmlscript
+{
+
+//__________________________________________________________________________________________________
+Reference< xml::sax::XAttributeList > Style::createElement()
+{
+ ElementDescriptor * pStyle = new ElementDescriptor(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style") ) );
+
+ // style-id
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), _id );
+
+ // background-color
+ if (_set & 0x1)
+ {
+ OUStringBuffer buf( 16 );
+ buf.append( (sal_Unicode)'0' );
+ buf.append( (sal_Unicode)'x' );
+ buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_backgroundColor, 16 ) );
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":background-color") ),
+ buf.makeStringAndClear() );
+ }
+
+ // text-color
+ if (_set & 0x2)
+ {
+ OUStringBuffer buf( 16 );
+ buf.append( (sal_Unicode)'0' );
+ buf.append( (sal_Unicode)'x' );
+ buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_textColor, 16 ) );
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text-color") ),
+ buf.makeStringAndClear() );
+ }
+
+ // textline-color
+ if (_set & 0x20)
+ {
+ OUStringBuffer buf( 16 );
+ buf.append( (sal_Unicode)'0' );
+ buf.append( (sal_Unicode)'x' );
+ buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_textLineColor, 16 ) );
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":textline-color") ),
+ buf.makeStringAndClear() );
+ }
+
+ // fill-color
+ if (_set & 0x10)
+ {
+ OUStringBuffer buf( 16 );
+ buf.append( (sal_Unicode)'0' );
+ buf.append( (sal_Unicode)'x' );
+ buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_fillColor, 16 ) );
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":fill-color") ),
+ buf.makeStringAndClear() );
+ }
+
+ // border
+ if (_set & 0x4)
+ {
+ switch (_border)
+ {
+ case BORDER_NONE:
+ pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"),
+ OUSTR("none") );
+ break;
+ case BORDER_3D:
+ pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"),
+ OUSTR("3d") );
+ break;
+ case BORDER_SIMPLE:
+ pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"),
+ OUSTR("simple") );
+ break;
+ case BORDER_SIMPLE_COLOR: {
+ OUStringBuffer buf;
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") );
+ buf.append( OUString::valueOf(
+ (sal_Int64)(sal_uInt64)_borderColor, 16 ) );
+ pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"),
+ buf.makeStringAndClear() );
+ break;
+ }
+ default:
+ OSL_ENSURE( 0, "### unexpected border value!" );
+ break;
+ }
+ }
+
+ // visual effect (look)
+ if (_set & 0x40)
+ {
+ switch (_visualEffect)
+ {
+ case awt::VisualEffect::NONE:
+ pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":look"),
+ OUSTR("none") );
+ break;
+ case awt::VisualEffect::LOOK3D:
+ pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":look"),
+ OUSTR("3d") );
+ break;
+ case awt::VisualEffect::FLAT:
+ pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":look"),
+ OUSTR("simple") );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected visual effect value!" );
+ break;
+ }
+ }
+
+ // font-
+ if (_set & 0x8)
+ {
+ awt::FontDescriptor def_descr;
+
+ // dialog:font-name CDATA #IMPLIED
+ if (def_descr.Name != _descr.Name)
+ {
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-name") ),
+ _descr.Name );
+ }
+ // dialog:font-height %numeric; #IMPLIED
+ if (def_descr.Height != _descr.Height)
+ {
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-height") ),
+ OUString::valueOf( (sal_Int32)_descr.Height ) );
+ }
+ // dialog:font-width %numeric; #IMPLIED
+ if (def_descr.Width != _descr.Width)
+ {
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-width") ),
+ OUString::valueOf( (sal_Int32)_descr.Width ) );
+ }
+ // dialog:font-stylename CDATA #IMPLIED
+ if (def_descr.StyleName != _descr.StyleName)
+ {
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-stylename") ),
+ _descr.StyleName );
+ }
+ // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED
+ if (def_descr.Family != _descr.Family)
+ {
+ switch (_descr.Family)
+ {
+ case awt::FontFamily::DECORATIVE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("decorative") ) );
+ break;
+ case awt::FontFamily::MODERN:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("modern") ) );
+ break;
+ case awt::FontFamily::ROMAN:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("roman") ) );
+ break;
+ case awt::FontFamily::SCRIPT:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("script") ) );
+ break;
+ case awt::FontFamily::SWISS:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("swiss") ) );
+ break;
+ case awt::FontFamily::SYSTEM:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("system") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected font-family!" );
+ break;
+ }
+ }
+ // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED
+ if (def_descr.CharSet != _descr.CharSet)
+ {
+ switch (_descr.CharSet)
+ {
+ case awt::CharSet::ANSI:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("ansi") ) );
+ break;
+ case awt::CharSet::MAC:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("mac") ) );
+ break;
+ case awt::CharSet::IBMPC_437:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_437") ) );
+ break;
+ case awt::CharSet::IBMPC_850:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_850") ) );
+ break;
+ case awt::CharSet::IBMPC_860:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_860") ) );
+ break;
+ case awt::CharSet::IBMPC_861:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_861") ) );
+ break;
+ case awt::CharSet::IBMPC_863:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_863") ) );
+ break;
+ case awt::CharSet::IBMPC_865:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_865") ) );
+ break;
+ case awt::CharSet::SYSTEM:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("system") ) );
+ break;
+ case awt::CharSet::SYMBOL:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("symbol") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected font-charset!" );
+ break;
+ }
+ }
+ // dialog:font-pitch "(fixed|variable)" #IMPLIED
+ if (def_descr.Pitch != _descr.Pitch)
+ {
+ switch (_descr.Pitch)
+ {
+ case awt::FontPitch::FIXED:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-pitch") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("fixed") ) );
+ break;
+ case awt::FontPitch::VARIABLE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-pitch") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("variable") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected font-pitch!" );
+ break;
+ }
+ }
+ // dialog:font-charwidth CDATA #IMPLIED
+ if (def_descr.CharacterWidth != _descr.CharacterWidth)
+ {
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charwidth") ),
+ OUString::valueOf( (float)_descr.CharacterWidth ) );
+ }
+ // dialog:font-weight CDATA #IMPLIED
+ if (def_descr.Weight != _descr.Weight)
+ {
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-weight") ),
+ OUString::valueOf( (float)_descr.Weight ) );
+ }
+ // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED
+ if (def_descr.Slant != _descr.Slant)
+ {
+ switch (_descr.Slant)
+ {
+ case awt::FontSlant_OBLIQUE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("oblique") ) );
+ break;
+ case awt::FontSlant_ITALIC:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("italic") ) );
+ break;
+ case awt::FontSlant_REVERSE_OBLIQUE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("reverse_oblique") ) );
+ break;
+ case awt::FontSlant_REVERSE_ITALIC:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("reverse_italic") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected font-slant!" );
+ break;
+ }
+ }
+ // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED
+ if (def_descr.Underline != _descr.Underline)
+ {
+ switch (_descr.Underline)
+ {
+ case awt::FontUnderline::SINGLE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) );
+ break;
+ case awt::FontUnderline::DOUBLE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("double") ) );
+ break;
+ case awt::FontUnderline::DOTTED:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("dotted") ) );
+ break;
+ case awt::FontUnderline::DASH:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("dash") ) );
+ break;
+ case awt::FontUnderline::LONGDASH:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("longdash") ) );
+ break;
+ case awt::FontUnderline::DASHDOT:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("dashdot") ) );
+ break;
+ case awt::FontUnderline::DASHDOTDOT:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("dashdotdot") ) );
+ break;
+ case awt::FontUnderline::SMALLWAVE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("smallwave") ) );
+ break;
+ case awt::FontUnderline::WAVE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("wave") ) );
+ break;
+ case awt::FontUnderline::DOUBLEWAVE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("doublewave") ) );
+ break;
+ case awt::FontUnderline::BOLD:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("bold") ) );
+ break;
+ case awt::FontUnderline::BOLDDOTTED:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("bolddotted") ) );
+ break;
+ case awt::FontUnderline::BOLDDASH:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("bolddash") ) );
+ break;
+ case awt::FontUnderline::BOLDLONGDASH:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("boldlongdash") ) );
+ break;
+ case awt::FontUnderline::BOLDDASHDOT:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("bolddashdot") ) );
+ break;
+ case awt::FontUnderline::BOLDDASHDOTDOT:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("bolddashdotdot") ) );
+ break;
+ case awt::FontUnderline::BOLDWAVE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("boldwave") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected font-underline!" );
+ break;
+ }
+ }
+ // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED
+ if (def_descr.Strikeout != _descr.Strikeout)
+ {
+ switch (_descr.Strikeout)
+ {
+ case awt::FontStrikeout::SINGLE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) );
+ break;
+ case awt::FontStrikeout::DOUBLE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("double") ) );
+ break;
+ case awt::FontStrikeout::BOLD:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("bold") ) );
+ break;
+ case awt::FontStrikeout::SLASH:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("slash") ) );
+ break;
+ case awt::FontStrikeout::X:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("x") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected font-strikeout!" );
+ break;
+ }
+ }
+ // dialog:font-orientation CDATA #IMPLIED
+ if (def_descr.Orientation != _descr.Orientation)
+ {
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-orientation") ),
+ OUString::valueOf( (float)_descr.Orientation ) );
+ }
+ // dialog:font-kerning %boolean; #IMPLIED
+ if ((def_descr.Kerning != sal_False) != (_descr.Kerning != sal_False))
+ {
+ pStyle->addBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-kerning") ),
+ _descr.Kerning );
+ }
+ // dialog:font-wordlinemode %boolean; #IMPLIED
+ if ((def_descr.WordLineMode != sal_False) != (_descr.WordLineMode != sal_False))
+ {
+ pStyle->addBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-wordlinemode") ),
+ _descr.WordLineMode );
+ }
+ // dialog:font-type "(raster|device|scalable)" #IMPLIED
+ if (def_descr.Type != _descr.Type)
+ {
+ switch (_descr.Type)
+ {
+ case awt::FontType::RASTER:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("raster") ) );
+ break;
+ case awt::FontType::DEVICE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("device") ) );
+ break;
+ case awt::FontType::SCALABLE:
+ pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("scalable") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected font-type!" );
+ break;
+ }
+ }
+
+ // additional attributes not in FontDescriptor struct
+ // dialog:font-relief (none|embossed|engraved) #IMPLIED
+ switch (_fontRelief)
+ {
+ case awt::FontRelief::NONE: // dont export default
+ break;
+ case awt::FontRelief::EMBOSSED:
+ pStyle->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-relief") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("embossed") ) );
+ break;
+ case awt::FontRelief::ENGRAVED:
+ pStyle->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-relief") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("engraved") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected font-relief!" );
+ break;
+ }
+ // dialog:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED
+ switch (_fontEmphasisMark)
+ {
+ case awt::FontEmphasisMark::NONE: // dont export default
+ break;
+ case awt::FontEmphasisMark::DOT:
+ pStyle->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("dot") ) );
+ break;
+ case awt::FontEmphasisMark::CIRCLE:
+ pStyle->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("circle") ) );
+ break;
+ case awt::FontEmphasisMark::DISC:
+ pStyle->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("disc") ) );
+ break;
+ case awt::FontEmphasisMark::ACCENT:
+ pStyle->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("accent") ) );
+ break;
+ case awt::FontEmphasisMark::ABOVE:
+ pStyle->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("above") ) );
+ break;
+ case awt::FontEmphasisMark::BELOW:
+ pStyle->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("below") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected font-emphasismark!" );
+ break;
+ }
+ }
+
+ return pStyle;
+}
+
+//##################################################################################################
+
+//__________________________________________________________________________________________________
+void ElementDescriptor::addNumberFormatAttr(
+ Reference< beans::XPropertySet > const & xFormatProperties,
+ OUString const & /*rAttrName*/ )
+{
+ Reference< beans::XPropertyState > xState( xFormatProperties, UNO_QUERY );
+ OUString sFormat;
+ lang::Locale locale;
+ OSL_VERIFY( xFormatProperties->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("FormatString") ) ) >>= sFormat );
+ OSL_VERIFY( xFormatProperties->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Locale") ) ) >>= locale );
+
+ addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":format-code") ),
+ sFormat );
+
+ // format-locale
+ OUStringBuffer buf( 48 );
+ buf.append( locale.Language );
+ if (locale.Country.getLength())
+ {
+ buf.append( (sal_Unicode)';' );
+ buf.append( locale.Country );
+ if (locale.Variant.getLength())
+ {
+ buf.append( (sal_Unicode)';' );
+ buf.append( locale.Variant );
+ }
+ }
+ addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":format-locale") ),
+ buf.makeStringAndClear() );
+}
+//__________________________________________________________________________________________________
+Any ElementDescriptor::readProp( OUString const & rPropName )
+{
+ if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+ {
+ return _xProps->getPropertyValue( rPropName );
+ }
+ return Any();
+}
+
+//______________________________________________________________________________
+void ElementDescriptor::readStringAttr(
+ OUString const & rPropName, OUString const & rAttrName )
+{
+ if (beans::PropertyState_DEFAULT_VALUE !=
+ _xPropState->getPropertyState( rPropName ))
+ {
+ Any a( _xProps->getPropertyValue( rPropName ) );
+ OUString v;
+ if (a >>= v)
+ addAttribute( rAttrName, v );
+ else
+ OSL_ENSURE( 0, "### unexpected property type!" );
+ }
+}
+
+//__________________________________________________________________________________________________
+void ElementDescriptor::readHexLongAttr( OUString const & rPropName, OUString const & rAttrName )
+{
+ if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+ {
+ Any a( _xProps->getPropertyValue( rPropName ) );
+ if (a.getValueTypeClass() == TypeClass_LONG)
+ {
+ OUStringBuffer buf( 16 );
+ buf.append( (sal_Unicode)'0' );
+ buf.append( (sal_Unicode)'x' );
+ buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)*(sal_uInt32 *)a.getValue(), 16 ) );
+ addAttribute( rAttrName, buf.makeStringAndClear() );
+ }
+ }
+}
+
+//__________________________________________________________________________________________________
+void ElementDescriptor::readDateFormatAttr( OUString const & rPropName, OUString const & rAttrName )
+{
+ if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+ {
+ Any a( _xProps->getPropertyValue( rPropName ) );
+ if (a.getValueTypeClass() == TypeClass_SHORT)
+ {
+ switch (*(sal_Int16 const *)a.getValue())
+ {
+ case 0:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_short") ) );
+ break;
+ case 1:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_short_YY") ) );
+ break;
+ case 2:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_short_YYYY") ) );
+ break;
+ case 3:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_long") ) );
+ break;
+ case 4:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_DDMMYY") ) );
+ break;
+ case 5:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_MMDDYY") ) );
+ break;
+ case 6:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYMMDD") ) );
+ break;
+ case 7:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_DDMMYYYY") ) );
+ break;
+ case 8:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_MMDDYYYY") ) );
+ break;
+ case 9:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYYYMMDD") ) );
+ break;
+ case 10:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYMMDD_DIN5008") ) );
+ break;
+ case 11:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYYYMMDD_DIN5008") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected date format!" );
+ break;
+ }
+ }
+ }
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readTimeFormatAttr( OUString const & rPropName, OUString const & rAttrName )
+{
+ if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+ {
+ Any a( _xProps->getPropertyValue( rPropName ) );
+ if (a.getValueTypeClass() == TypeClass_SHORT)
+ {
+ switch (*(sal_Int16 const *)a.getValue())
+ {
+ case 0:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("24h_short") ) );
+ break;
+ case 1:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("24h_long") ) );
+ break;
+ case 2:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("12h_short") ) );
+ break;
+ case 3:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("12h_long") ) );
+ break;
+ case 4:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("Duration_short") ) );
+ break;
+ case 5:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("Duration_long") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### unexpected time format!" );
+ break;
+ }
+ }
+ }
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readAlignAttr( OUString const & rPropName, OUString const & rAttrName )
+{
+ if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+ {
+ Any a( _xProps->getPropertyValue( rPropName ) );
+ if (a.getValueTypeClass() == TypeClass_SHORT)
+ {
+ switch (*(sal_Int16 const *)a.getValue())
+ {
+ case 0:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left") ) );
+ break;
+ case 1:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("center") ) );
+ break;
+ case 2:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### illegal alignment value!" );
+ break;
+ }
+ }
+ }
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readVerticalAlignAttr( OUString const & rPropName, OUString const & rAttrName )
+{
+ if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+ {
+ Any a( _xProps->getPropertyValue( rPropName ) );
+ if (a.getValueTypeClass() == TypeClass_ENUM && a.getValueType() == ::getCppuType( (style::VerticalAlignment*)0 ))
+ {
+ style::VerticalAlignment eAlign;
+ a >>= eAlign;
+ switch (eAlign)
+ {
+ case style::VerticalAlignment_TOP:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top") ) );
+ break;
+ case style::VerticalAlignment_MIDDLE:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("center") ) );
+ break;
+ case style::VerticalAlignment_BOTTOM:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### illegal vertical alignment value!" );
+ break;
+ }
+ }
+ }
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readImageAlignAttr( OUString const & rPropName, OUString const & rAttrName )
+{
+ if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+ {
+ Any a( _xProps->getPropertyValue( rPropName ) );
+ if (a.getValueTypeClass() == TypeClass_SHORT)
+ {
+ switch (*(sal_Int16 const *)a.getValue())
+ {
+ case 0:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left") ) );
+ break;
+ case 1:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top") ) );
+ break;
+ case 2:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right") ) );
+ break;
+ case 3:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### illegal image alignment value!" );
+ break;
+ }
+ }
+ }
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readImagePositionAttr( OUString const & rPropName, OUString const & rAttrName )
+{
+ if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+ {
+ Any a( _xProps->getPropertyValue( rPropName ) );
+ if (a.getValueTypeClass() == TypeClass_SHORT)
+ {
+ switch (*(sal_Int16 const *)a.getValue())
+ {
+ case awt::ImagePosition::LeftTop:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left-top") ) );
+ break;
+ case awt::ImagePosition::LeftCenter:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left-center") ) );
+ break;
+ case awt::ImagePosition::LeftBottom:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left-bottom") ) );
+ break;
+ case awt::ImagePosition::RightTop:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right-top") ) );
+ break;
+ case awt::ImagePosition::RightCenter:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right-center") ) );
+ break;
+ case awt::ImagePosition::RightBottom:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right-bottom") ) );
+ break;
+ case awt::ImagePosition::AboveLeft:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top-left") ) );
+ break;
+ case awt::ImagePosition::AboveCenter:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top-center") ) );
+ break;
+ case awt::ImagePosition::AboveRight:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top-right") ) );
+ break;
+ case awt::ImagePosition::BelowLeft:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom-left") ) );
+ break;
+ case awt::ImagePosition::BelowCenter:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom-center") ) );
+ break;
+ case awt::ImagePosition::BelowRight:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom-right") ) );
+ break;
+ case awt::ImagePosition::Centered:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("center") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### illegal image position value!" );
+ break;
+ }
+ }
+ }
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readButtonTypeAttr( OUString const & rPropName, OUString const & rAttrName )
+{
+ if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+ {
+ Any a( _xProps->getPropertyValue( rPropName ) );
+ if (a.getValueTypeClass() == TypeClass_SHORT)
+ {
+ switch (*(sal_Int16 const *)a.getValue())
+ {
+ case awt::PushButtonType_STANDARD:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("standard") ) );
+ break;
+ case awt::PushButtonType_OK:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("ok") ) );
+ break;
+ case awt::PushButtonType_CANCEL:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("cancel") ) );
+ break;
+ case awt::PushButtonType_HELP:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("help") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### illegal button-type value!" );
+ break;
+ }
+ }
+ }
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readOrientationAttr( OUString const & rPropName, OUString const & rAttrName )
+{
+ if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+ {
+ Any a( _xProps->getPropertyValue( rPropName ) );
+ if (a.getValueTypeClass() == TypeClass_LONG)
+ {
+ switch (*(sal_Int32 const *)a.getValue())
+ {
+ case 0:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("horizontal") ) );
+ break;
+ case 1:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("vertical") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### illegal orientation value!" );
+ break;
+ }
+ }
+ }
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readLineEndFormatAttr( OUString const & rPropName, OUString const & rAttrName )
+{
+ if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+ {
+ Any a( _xProps->getPropertyValue( rPropName ) );
+ if (a.getValueTypeClass() == TypeClass_SHORT)
+ {
+ switch (*(sal_Int16 const *)a.getValue())
+ {
+ case awt::LineEndFormat::CARRIAGE_RETURN:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("carriage-return") ) );
+ break;
+ case awt::LineEndFormat::LINE_FEED:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("line-feed") ) );
+ break;
+ case awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("carriage-return-line-feed") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### illegal line end format value!" );
+ break;
+ }
+ }
+ }
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readSelectionTypeAttr( OUString const & rPropName, OUString const & rAttrName )
+{
+ if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
+ {
+ Any aSelectionType ( _xProps->getPropertyValue( rPropName ) );
+
+ if (aSelectionType.getValueTypeClass() == TypeClass_ENUM && aSelectionType.getValueType() == ::getCppuType( (::view::SelectionType*)0 ))
+ {
+ ::view::SelectionType eSelectionType;
+ aSelectionType >>= eSelectionType;
+
+ switch (eSelectionType)
+ {
+ case ::view::SelectionType_NONE:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("none") ) );
+ break;
+ case ::view::SelectionType_SINGLE:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) );
+ break;
+ case ::view::SelectionType_MULTI:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("multi") ) );
+ break;
+ case ::view::SelectionType_RANGE:
+ addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("range") ) );
+ break;
+ default:
+ OSL_ENSURE( 0, "### illegal selection type value!" );
+ break;
+ }
+ }
+ }
+}
+//__________________________________________________________________________________________________
+void ElementDescriptor::readDefaults( bool supportPrintable, bool supportVisible )
+{
+ Any a( _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) ) );
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
+ * reinterpret_cast< const OUString * >( a.getValue() ) );
+ readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("TabIndex") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tab-index") ) );
+
+ sal_Bool bEnabled = sal_False;
+ if (_xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Enabled") ) ) >>= bEnabled)
+ {
+ if (! bEnabled)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":disabled") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) );
+ }
+ }
+ else
+ {
+ OSL_ENSURE( 0, "unexpected property type for \"Enabled\": not bool!" );
+ }
+
+ sal_Bool bVisible = sal_True;
+ if (supportVisible) try
+ {
+ if (_xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("EnableVisible") ) ) >>= bVisible)
+ {
+
+ // only write out the non default case
+ if (! bVisible)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":visible") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("false") ) );
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ // force writing of pos/size
+ a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ) );
+ if (a.getValueTypeClass() == TypeClass_LONG)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":left") ),
+ OUString::valueOf( *(sal_Int32 const *)a.getValue() ) );
+ }
+ a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ) );
+ if (a.getValueTypeClass() == TypeClass_LONG)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":top") ),
+ OUString::valueOf( *(sal_Int32 const *)a.getValue() ) );
+ }
+ a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ) );
+ if (a.getValueTypeClass() == TypeClass_LONG)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":width") ),
+ OUString::valueOf( *(sal_Int32 const *)a.getValue() ) );
+ }
+ a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ) );
+ if (a.getValueTypeClass() == TypeClass_LONG)
+ {
+ addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":height") ),
+ OUString::valueOf( *(sal_Int32 const *)a.getValue() ) );
+ }
+
+ if (supportPrintable)
+ {
+ readBoolAttr(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Printable") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":printable") ) );
+ }
+ readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Step") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":page") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tag") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpText") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":help-text") ) );
+ readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":help-url") ) );
+}
+
+struct StringTriple
+{
+ char const * first;
+ char const * second;
+ char const * third;
+};
+extern StringTriple const * const g_pEventTranslations;
+
+//__________________________________________________________________________________________________
+void ElementDescriptor::readEvents()
+ SAL_THROW( (Exception) )
+{
+ Reference< script::XScriptEventsSupplier > xSupplier( _xProps, UNO_QUERY );
+ if (xSupplier.is())
+ {
+ Reference< container::XNameContainer > xEvents( xSupplier->getEvents() );
+ if (xEvents.is())
+ {
+ Sequence< OUString > aNames( xEvents->getElementNames() );
+ OUString const * pNames = aNames.getConstArray();
+ for ( sal_Int32 nPos = 0; nPos < aNames.getLength(); ++nPos )
+ {
+ script::ScriptEventDescriptor descr;
+ if (xEvents->getByName( pNames[ nPos ] ) >>= descr)
+ {
+ OSL_ENSURE( descr.ListenerType.getLength() > 0 &&
+ descr.EventMethod.getLength() > 0 &&
+ descr.ScriptCode.getLength() > 0 &&
+ descr.ScriptType.getLength() > 0,
+ "### invalid event descr!" );
+
+ OUString aEventName;
+
+ if (! descr.AddListenerParam.getLength())
+ {
+ // detection of event-name
+ ::rtl::OString listenerType(
+ ::rtl::OUStringToOString(
+ descr.ListenerType,
+ RTL_TEXTENCODING_ASCII_US ) );
+ ::rtl::OString eventMethod(
+ ::rtl::OUStringToOString(
+ descr.EventMethod,
+ RTL_TEXTENCODING_ASCII_US ) );
+ StringTriple const * p = g_pEventTranslations;
+ while (p->first)
+ {
+ if (0 == ::rtl_str_compare( p->second, eventMethod.getStr() ) &&
+ 0 == ::rtl_str_compare( p->first, listenerType.getStr() ))
+ {
+ aEventName = OUString( p->third, ::rtl_str_getLength( p->third ), RTL_TEXTENCODING_ASCII_US );
+ break;
+ }
+ ++p;
+ }
+ }
+
+ ElementDescriptor * pElem;
+ Reference< xml::sax::XAttributeList > xElem;
+
+ if (aEventName.getLength()) // script:event
+ {
+ pElem = new ElementDescriptor(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":event") ) );
+ xElem = pElem;
+
+ pElem->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":event-name") ),
+ aEventName );
+ }
+ else // script:listener-event
+ {
+ pElem = new ElementDescriptor(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-event") ) );
+ xElem = pElem;
+
+ pElem->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-type") ),
+ descr.ListenerType );
+ pElem->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-method") ),
+ descr.EventMethod );
+
+ if (descr.AddListenerParam.getLength())
+ {
+ pElem->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-param") ),
+ descr.AddListenerParam );
+ }
+ }
+ if ( descr.ScriptType.equals( OUString( RTL_CONSTASCII_USTRINGPARAM( "StarBasic" ) ) ) )
+ {
+ // separate optional location
+ sal_Int32 nIndex = descr.ScriptCode.indexOf( (sal_Unicode)':' );
+ if (nIndex >= 0)
+ {
+ pElem->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":location") ),
+ descr.ScriptCode.copy( 0, nIndex ) );
+ pElem->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ),
+ descr.ScriptCode.copy( nIndex +1 ) );
+ }
+ else
+ {
+ pElem->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ),
+ descr.ScriptCode );
+ }
+ }
+ else
+ {
+ pElem->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ),
+ descr.ScriptCode );
+ }
+
+ // language
+ pElem->addAttribute(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":language") ),
+ descr.ScriptType );
+
+ addSubElement( xElem );
+ }
+ else
+ {
+ OSL_ENSURE( 0, "### unexpected event type in container!" );
+ }
+ }
+ }
+ }
+}
+
+//##################################################################################################
+
+inline bool equalFont( Style const & style1, Style const & style2 )
+{
+ awt::FontDescriptor const & f1 = style1._descr;
+ awt::FontDescriptor const & f2 = style2._descr;
+ return (
+ f1.Name == f2.Name &&
+ f1.Height == f2.Height &&
+ f1.Width == f2.Width &&
+ f1.StyleName == f2.StyleName &&
+ f1.Family == f2.Family &&
+ f1.CharSet == f2.CharSet &&
+ f1.Pitch == f2.CharSet &&
+ f1.CharacterWidth == f2.CharacterWidth &&
+ f1.Weight == f2.Weight &&
+ f1.Slant == f2.Slant &&
+ f1.Underline == f2.Underline &&
+ f1.Strikeout == f2.Strikeout &&
+ f1.Orientation == f2.Orientation &&
+ (f1.Kerning != sal_False) == (f2.Kerning != sal_False) &&
+ (f1.WordLineMode != sal_False) == (f2.WordLineMode != sal_False) &&
+ f1.Type == f2.Type &&
+ style1._fontRelief == style2._fontRelief &&
+ style1._fontEmphasisMark == style2._fontEmphasisMark
+ );
+}
+//__________________________________________________________________________________________________
+OUString StyleBag::getStyleId( Style const & rStyle )
+ SAL_THROW( () )
+{
+ if (! rStyle._set) // nothin set
+ {
+ return OUString(); // everything default: no need to export a specific style
+ }
+
+ // lookup existing style
+ for ( size_t nStylesPos = 0; nStylesPos < _styles.size(); ++nStylesPos )
+ {
+ Style * pStyle = _styles[ nStylesPos ];
+
+ short demanded_defaults = ~rStyle._set & rStyle._all;
+ // test, if defaults are not set
+ if ((~pStyle->_set & demanded_defaults) == demanded_defaults &&
+ (rStyle._set & (pStyle->_all & ~pStyle->_set)) == 0)
+ {
+ short bset = rStyle._set & pStyle->_set;
+ if ((bset & 0x1) &&
+ rStyle._backgroundColor != pStyle->_backgroundColor)
+ continue;
+ if ((bset & 0x2) &&
+ rStyle._textColor != pStyle->_textColor)
+ continue;
+ if ((bset & 0x20) &&
+ rStyle._textLineColor != pStyle->_textLineColor)
+ continue;
+ if ((bset & 0x10) &&
+ rStyle._fillColor != pStyle->_fillColor)
+ continue;
+ if ((bset & 0x4) &&
+ (rStyle._border != pStyle->_border ||
+ (rStyle._border == BORDER_SIMPLE_COLOR &&
+ rStyle._borderColor != pStyle->_borderColor)))
+ continue;
+ if ((bset & 0x8) &&
+ !equalFont( rStyle, *pStyle ))
+ continue;
+ if ((bset & 0x40) &&
+ rStyle._visualEffect != pStyle->_visualEffect)
+ continue;
+
+ // merge in
+ short bnset = rStyle._set & ~pStyle->_set;
+ if (bnset & 0x1)
+ pStyle->_backgroundColor = rStyle._backgroundColor;
+ if (bnset & 0x2)
+ pStyle->_textColor = rStyle._textColor;
+ if (bnset & 0x20)
+ pStyle->_textLineColor = rStyle._textLineColor;
+ if (bnset & 0x10)
+ pStyle->_fillColor = rStyle._fillColor;
+ if (bnset & 0x4) {
+ pStyle->_border = rStyle._border;
+ pStyle->_borderColor = rStyle._borderColor;
+ }
+ if (bnset & 0x8) {
+ pStyle->_descr = rStyle._descr;
+ pStyle->_fontRelief = rStyle._fontRelief;
+ pStyle->_fontEmphasisMark = rStyle._fontEmphasisMark;
+ }
+ if (bnset & 0x40)
+ pStyle->_visualEffect = rStyle._visualEffect;
+
+ pStyle->_all |= rStyle._all;
+ pStyle->_set |= rStyle._set;
+
+ return pStyle->_id;
+ }
+ }
+
+ // no appr style found, append new
+ Style * pStyle = new Style( rStyle );
+ pStyle->_id = OUString::valueOf( (sal_Int32)_styles.size() );
+ _styles.push_back( pStyle );
+ return pStyle->_id;
+}
+//__________________________________________________________________________________________________
+StyleBag::~StyleBag() SAL_THROW( () )
+{
+ for ( size_t nPos = 0; nPos < _styles.size(); ++nPos )
+ {
+ delete _styles[ nPos ];
+ }
+}
+//__________________________________________________________________________________________________
+void StyleBag::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut )
+{
+ if (! _styles.empty())
+ {
+ OUString aStylesName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":styles") );
+ xOut->ignorableWhitespace( OUString() );
+ xOut->startElement( aStylesName, Reference< xml::sax::XAttributeList >() );
+ // export styles
+ for ( size_t nPos = 0; nPos < _styles.size(); ++nPos )
+ {
+ Reference< xml::sax::XAttributeList > xAttr( _styles[ nPos ]->createElement() );
+ static_cast< ElementDescriptor * >( xAttr.get() )->dump( xOut.get() );
+ }
+ xOut->ignorableWhitespace( OUString() );
+ xOut->endElement( aStylesName );
+ }
+}
+
+//##################################################################################################
+
+//==================================================================================================
+void SAL_CALL exportDialogModel(
+ Reference< xml::sax::XExtendedDocumentHandler > const & xOut,
+ Reference< container::XNameContainer > const & xDialogModel,
+ Reference< frame::XModel > const & xDocument )
+ SAL_THROW( (Exception) )
+{
+ StyleBag all_styles;
+ ::std::vector< Reference< xml::sax::XAttributeList > > all_elements;
+
+ // read out all props
+
+ Sequence< OUString > aElements( xDialogModel->getElementNames() );
+ OUString const * pElements = aElements.getConstArray();
+
+ ElementDescriptor * pRadioGroup = 0;
+
+ sal_Int32 nPos;
+ for ( nPos = 0; nPos < aElements.getLength(); ++nPos )
+ {
+ Any aControlModel( xDialogModel->getByName( pElements[ nPos ] ) );
+ Reference< beans::XPropertySet > xProps;
+ OSL_VERIFY( aControlModel >>= xProps );
+ if (! xProps.is())
+ continue;
+ Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY );
+ OSL_ENSURE( xPropState.is(), "no XPropertyState!" );
+ if (! xPropState.is())
+ continue;
+ Reference< lang::XServiceInfo > xServiceInfo( xProps, UNO_QUERY );
+ OSL_ENSURE( xServiceInfo.is(), "no XServiceInfo!" );
+ if (! xServiceInfo.is())
+ continue;
+
+ ElementDescriptor * pElem = 0;
+ Reference< xml::sax::XAttributeList > xElem;
+
+ // group up radio buttons
+ if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) )
+ {
+ if (! pRadioGroup) // open radiogroup
+ {
+ pRadioGroup = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radiogroup") ) );
+ all_elements.push_back( pRadioGroup );
+ }
+
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radio") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readRadioButtonModel( &all_styles, xDocument );
+ pRadioGroup->addSubElement( xElem );
+ }
+ else // no radio
+ {
+ pRadioGroup = 0; // close radiogroup
+
+ if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":button") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readButtonModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checkbox") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readCheckBoxModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":combobox") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readComboBoxModel( &all_styles, xDocument );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menulist") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readListBoxModel( &all_styles, xDocument );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":titledbox") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readGroupBoxModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multipage") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readMultiPageModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readFixedTextModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":textfield") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readEditModel( &all_styles );
+ }
+ // FixedHyperLink
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedHyperlinkModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linklabel") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readFixedHyperLinkModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":img") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readImageControlModel( &all_styles, xDocument );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFileControlModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":filecontrol") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readFileControlModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.tree.TreeControlModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":treecontrol") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readTreeControlModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCurrencyFieldModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":currencyfield") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readCurrencyFieldModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlDateFieldModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":datefield") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readDateFieldModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlNumericFieldModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":numericfield") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readNumericFieldModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlTimeFieldModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":timefield") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readTimeFieldModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlPatternFieldModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":patternfield") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readPatternFieldModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFormattedFieldModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":formattedfield") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readFormattedFieldModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":fixedline") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readFixedLineModel( &all_styles );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":scrollbar") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readScrollBarModel( &all_styles, xDocument );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":spinbutton") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readSpinButtonModel( &all_styles, xDocument );
+ }
+ else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) )
+ {
+ pElem = new ElementDescriptor(
+ xProps, xPropState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":progressmeter") ) );
+ xElem = static_cast< xml::sax::XAttributeList * >( pElem );
+ pElem->readProgressBarModel( &all_styles );
+ }
+ //
+
+ OSL_ASSERT( xElem.is() );
+ if (xElem.is())
+ {
+ all_elements.push_back( xElem );
+ }
+ else
+ {
+ OSL_ENSURE( sal_False, "unknown control type!" );
+ continue;
+ }
+ }
+ }
+
+ xOut->startDocument();
+
+ OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM(
+ "<!DOCTYPE dlg:window PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
+ " \"dialog.dtd\">" ) );
+ xOut->unknown( aDocTypeStr );
+ xOut->ignorableWhitespace( OUString() );
+
+ // window
+ Reference< beans::XPropertySet > xProps( xDialogModel, UNO_QUERY );
+ OSL_ASSERT( xProps.is() );
+ Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY );
+ OSL_ASSERT( xPropState.is() );
+
+ OUString aWindowName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":window") );
+ ElementDescriptor * pWindow = new ElementDescriptor( xProps, xPropState, aWindowName );
+ Reference< xml::sax::XAttributeList > xWindow( pWindow );
+ pWindow->readDialogModel( &all_styles );
+ xOut->ignorableWhitespace( OUString() );
+ xOut->startElement( aWindowName, xWindow );
+ // dump out events
+ pWindow->dumpSubElements( xOut.get() );
+ // dump out stylebag
+ all_styles.dump( xOut );
+
+ if (! all_elements.empty())
+ {
+ // open up bulletinboard
+ OUString aBBoardName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":bulletinboard") );
+ xOut->ignorableWhitespace( OUString() );
+ xOut->startElement( aBBoardName, Reference< xml::sax::XAttributeList >() );
+
+ // export control elements
+ for ( std::size_t n = 0; n < all_elements.size(); ++n )
+ {
+ ElementDescriptor * pElem = static_cast< ElementDescriptor * >( all_elements[ n ].get() );
+ pElem->dump( xOut.get() );
+ }
+
+ // end bulletinboard
+ xOut->ignorableWhitespace( OUString() );
+ xOut->endElement( aBBoardName );
+ }
+
+ // end window
+ xOut->ignorableWhitespace( OUString() );
+ xOut->endElement( aWindowName );
+
+ xOut->endDocument();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
new file mode 100644
index 000000000000..901aeac8127a
--- /dev/null
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
@@ -0,0 +1,2680 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+#include "imp_share.hxx"
+#include <com/sun/star/form/binding/XBindableValue.hpp>
+#include <com/sun/star/form/binding/XValueBinding.hpp>
+#include <com/sun/star/form/binding/XListEntrySink.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/document/XGraphicObjectResolver.hpp>
+#include <com/sun/star/script/vba/XVBACompatibility.hpp>
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/processfactory.hxx>
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+namespace xmlscript
+{
+Reference< xml::input::XElement > MultiPage::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+rtl::OUString _label = rtl::OUString::createFromAscii("foo");
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement(
+ nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("title") ))
+ {
+ getStringAttr( &_label,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ xAttributes,
+ _pImport->XMLNS_DIALOGS_UID );
+
+ return new ElementBase(
+ _pImport->XMLNS_DIALOGS_UID,
+ rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+
+void MultiPage::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) );
+// OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( 0, 0, _xAttributes ); // inherited from BulletinBoardElement
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-max") ),
+ _xAttributes );
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+// #FIXME cut'n'pasted from xmloff/source/core/xmlimp.cxx:1251
+// of course we need to find a common home for this helper
+
+bool IsPackageURL( const ::rtl::OUString& rURL )
+{
+ // Some quick tests: Some may rely on the package structure!
+ sal_Int32 nLen = rURL.getLength();
+ if( (nLen > 0 && '/' == rURL[0]) )
+ // RFC2396 net_path or abs_path
+ return false;
+ else if( nLen > 1 && '.' == rURL[0] )
+ {
+ if( '.' == rURL[1] )
+ // ../: We are never going up one level, so we know
+ // it's not an external URI
+ return false;
+ else if( '/' == rURL[1] )
+ // we are remaining on a level, so it's an package URI
+ return true;
+ }
+
+ // Now check for a RFC2396 schema
+ sal_Int32 nPos = 1;
+ while( nPos < nLen )
+ {
+ switch( rURL[nPos] )
+ {
+ case '/':
+ // a relative path segement
+ return true;
+ case ':':
+ // a schema
+ return false;
+ default:
+ break;
+ // we don't care about any other characters
+ }
+ ++nPos;
+ }
+
+ return true;
+}
+
+void importBindableAndListRangeBits( DialogImport* _pImport, const rtl::OUString sLinkedCell, const rtl::OUString & sCellRange, ControlImportContext& ctx )
+{
+ Reference< lang::XMultiServiceFactory > xFac( _pImport->getDocOwner(), UNO_QUERY );
+ if ( xFac.is() && ( sLinkedCell.getLength() || sCellRange.getLength() ) )
+ {
+ // Set up Celllink
+ if ( sLinkedCell.getLength() )
+ {
+ Reference< form::binding::XBindableValue > xBindable( ctx.getControlModel(), uno::UNO_QUERY );
+ Reference< beans::XPropertySet > xConvertor( xFac->createInstance( OUSTR( "com.sun.star.table.CellAddressConversion" )), uno::UNO_QUERY );
+ if ( xBindable.is() && xConvertor.is() )
+ {
+ table::CellAddress aAddress;
+ xConvertor->setPropertyValue( OUSTR( "PersistentRepresentation" ), uno::makeAny( sLinkedCell ) );
+ xConvertor->getPropertyValue( OUSTR( "Address" ) ) >>= aAddress;
+ beans::NamedValue aArg1;
+ aArg1.Name = OUSTR("BoundCell");
+ aArg1.Value <<= aAddress;
+
+ uno::Sequence< uno::Any > aArgs(1);
+ aArgs[ 0 ] <<= aArg1;
+
+ uno::Reference< form::binding::XValueBinding > xBinding( xFac->createInstanceWithArguments( OUSTR("com.sun.star.table.CellValueBinding" ), aArgs ), uno::UNO_QUERY );
+ xBindable->setValueBinding( xBinding );
+
+ }
+ }
+ // Set up CelllRange
+ if ( sCellRange.getLength() )
+ {
+ Reference< form::binding::XListEntrySink > xListEntrySink( ctx.getControlModel(), uno::UNO_QUERY );
+ Reference< beans::XPropertySet > xConvertor( xFac->createInstance( OUSTR( "com.sun.star.table.CellRangeAddressConversion" )), uno::UNO_QUERY );
+ if ( xListEntrySink.is() && xConvertor.is() )
+ {
+ table::CellRangeAddress aAddress;
+ xConvertor->setPropertyValue( OUSTR( "PersistentRepresentation" ), uno::makeAny( sCellRange ) );
+ xConvertor->getPropertyValue( OUSTR( "Address" ) ) >>= aAddress;
+ beans::NamedValue aArg1;
+ aArg1.Name = OUSTR("CellRange");
+ aArg1.Value <<= aAddress;
+
+ uno::Sequence< uno::Any > aArgs(1);
+ aArgs[ 0 ] <<= aArg1;
+
+ uno::Reference< form::binding::XListEntrySource > xSource( xFac->createInstanceWithArguments( OUSTR("com.sun.star.table.CellRangeListSource" ), aArgs ), uno::UNO_QUERY );
+ xListEntrySink->setListEntrySource( xSource );
+
+ }
+ }
+ }
+}
+
+sal_Bool isVBACompatibilityMode( DialogImport* _pImport )
+{
+ sal_Bool bVBAMode = sal_False;
+ Reference< script::vba::XVBACompatibility > xVBACompat( _pImport->getScriptLibraryContainer(), UNO_QUERY );
+ if( xVBACompat.is() )
+ {
+ bVBAMode = xVBACompat->getVBACompatibilityMode();
+ }
+ return bVBAMode;
+}
+
+// progessmeter
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > ProgressBarElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement(
+ nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void ProgressBarElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importFillColorStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-min") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-max") ),
+ _xAttributes );
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// scrollbar
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > ScrollBarElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void ScrollBarElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ OUString sService( OUSTR("com.sun.star.awt.UnoControlScrollBarModel") );
+ // we should probably limit this to vba mode also ( leave for now )
+ if ( isVBACompatibilityMode( _pImport ) )
+ sService = OUSTR("com.sun.star.form.component.ScrollBar");
+
+ OUString sLinkedCell;
+ try
+ {
+ sLinkedCell = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "linked-cell" ) );
+ }
+ catch( Exception& /*e*/ )
+ {
+ }
+
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ sService );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importOrientationProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Orientation") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("BlockIncrement") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("pageincrement") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("LineIncrement") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("increment") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ScrollValue") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("curpos") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ScrollValueMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("maxpos") ),
+ _xAttributes );
+ ctx.importLongProperty( OUSTR("ScrollValueMin"), OUSTR("minpos"),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("VisibleSize") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("visible-size") ),
+ _xAttributes );
+ ctx.importLongProperty( OUSTR("RepeatDelay"), OUSTR("repeat"),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("LiveScroll") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("live-scroll") ),
+ _xAttributes );
+ ctx.importHexLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("SymbolColor") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("symbol-color") ),
+ _xAttributes );
+
+ // import cell-link
+ OUString sCellRange;
+ importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx );
+
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// spinbutton
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > SpinButtonElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void SpinButtonElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ OUString sLinkedCell;
+ try
+ {
+ sLinkedCell = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "linked-cell" ) );
+ }
+ catch( Exception& /*e*/ )
+ {
+ }
+
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.SpinButton") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importOrientationProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Orientation") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinIncrement") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("increment") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinValue") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("curval") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("SpinValueMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("maxval") ),
+ _xAttributes );
+ ctx.importLongProperty( OUSTR("SpinValueMin"), OUSTR("minval"),
+ _xAttributes );
+ ctx.importLongProperty( OUSTR("Repeat"), OUSTR("repeat"),
+ _xAttributes );
+ ctx.importLongProperty( OUSTR("RepeatDelay"), OUSTR("repeat-delay"),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importHexLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("SymbolColor") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("symbol-color") ),
+ _xAttributes );
+ // import cell-link
+ OUString sCellRange;
+ importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx );
+
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// fixedline
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > FixedLineElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void FixedLineElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importOrientationProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Orientation") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
+ _xAttributes );
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// patternfield
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > PatternFieldElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void PatternFieldElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlPatternFieldModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("StrictFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("strict-format") ),
+ _xAttributes );
+ ctx.importBooleanProperty(
+ OUSTR("HideInactiveSelection"), OUSTR("hide-inactive-selection"),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MaxTextLen") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("maxlength") ),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("EditMask") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("edit-mask") ),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("LiteralMask") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("literal-mask") ),
+ _xAttributes );
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// formattedfield
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > FormattedFieldElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void FormattedFieldElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFormattedFieldModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("StrictFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("strict-format") ),
+ _xAttributes );
+ ctx.importBooleanProperty(
+ OUSTR("HideInactiveSelection"), OUSTR("hide-inactive-selection"),
+ _xAttributes );
+ ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
+ _xAttributes );
+ ctx.importDoubleProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("EffectiveMin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-min") ),
+ _xAttributes );
+ ctx.importDoubleProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("EffectiveMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-max") ),
+ _xAttributes );
+ ctx.importDoubleProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("EffectiveValue") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("text") ),
+ _xAttributes );
+ ctx.importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MaxTextLen") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("maxlength") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Spin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("spin") ),
+ _xAttributes );
+ if (ctx.importLongProperty( OUSTR("RepeatDelay"), OUSTR("repeat"),
+ _xAttributes ))
+ ctx.getControlModel()->setPropertyValue(
+ OUSTR("Repeat"), makeAny(true) );
+
+ OUString sDefault(
+ _xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-default") ) ) );
+ if (sDefault.getLength())
+ {
+ double d = sDefault.toDouble();
+ if (d != 0.0 ||
+ sDefault.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("0") ) ||
+ sDefault.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("0.0") ))
+ {
+ ctx.getControlModel()->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("EffectiveDefault") ),
+ makeAny( d ) );
+ }
+ else // treat as string
+ {
+ ctx.getControlModel()->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("EffectiveDefault") ),
+ makeAny( sDefault ) );
+ }
+ }
+
+ // format spec
+ ctx.getControlModel()->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("FormatsSupplier") ),
+ makeAny( _pImport->getNumberFormatsSupplier() ) );
+
+ OUString sFormat(
+ _xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("format-code") ) ) );
+ if (sFormat.getLength())
+ {
+ lang::Locale locale;
+
+ OUString sLocale(
+ _xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("format-locale") ) ) );
+ if (sLocale.getLength())
+ {
+ // split locale
+ sal_Int32 semi0 = sLocale.indexOf( ';' );
+ if (semi0 < 0) // no semi at all, just try language
+ {
+ locale.Language = sLocale;
+ }
+ else
+ {
+ sal_Int32 semi1 = sLocale.indexOf( ';', semi0 +1 );
+ if (semi1 > semi0) // language;country;variant
+ {
+ locale.Language = sLocale.copy( 0, semi0 );
+ locale.Country = sLocale.copy( semi0 +1, semi1 - semi0 -1 );
+ locale.Variant = sLocale.copy( semi1 +1 );
+ }
+ else // try language;country
+ {
+ locale.Language = sLocale.copy( 0, semi0 );
+ locale.Country = sLocale.copy( semi0 +1 );
+ }
+ }
+ }
+
+ try
+ {
+ Reference< util::XNumberFormats > xFormats(
+ _pImport->getNumberFormatsSupplier()->getNumberFormats() );
+ sal_Int32 nKey = xFormats->queryKey( sFormat, locale, sal_True );
+ if (-1 == nKey)
+ {
+ nKey = xFormats->addNew( sFormat, locale );
+ }
+ ctx.getControlModel()->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("FormatKey") ), makeAny( nKey ) );
+ }
+ catch (util::MalformedNumberFormatException & exc)
+ {
+ OSL_ENSURE( 0, "### util::MalformedNumberFormatException occured!" );
+ // rethrow
+ throw xml::sax::SAXException( exc.Message, Reference< XInterface >(), Any() );
+ }
+ }
+ ctx.importBooleanProperty(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("TreatAsNumber") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("treat-as-number") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("EnforceFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("enforce-format") ),
+ _xAttributes );
+
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// timefield
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > TimeFieldElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void TimeFieldElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlTimeFieldModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("StrictFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("strict-format") ),
+ _xAttributes );
+ ctx.importBooleanProperty(
+ OUSTR("HideInactiveSelection"), OUSTR("hide-inactive-selection"),
+ _xAttributes );
+ ctx.importTimeFormatProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("TimeFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("time-format") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Time") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("TimeMin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-min") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("TimeMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-max") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Spin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("spin") ),
+ _xAttributes );
+ if (ctx.importLongProperty( OUSTR("RepeatDelay"), OUSTR("repeat"),
+ _xAttributes ))
+ ctx.getControlModel()->setPropertyValue(
+ OUSTR("Repeat"), makeAny(true) );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("text") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("EnforceFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("enforce-format") ),
+ _xAttributes );
+
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// numericfield
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > NumericFieldElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void NumericFieldElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlNumericFieldModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("StrictFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("strict-format") ),
+ _xAttributes );
+ ctx.importBooleanProperty(
+ OUSTR("HideInactiveSelection"), OUSTR("hide-inactive-selection"),
+ _xAttributes );
+ ctx.importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("DecimalAccuracy") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("decimal-accuracy") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ShowThousandsSeparator") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("thousands-separator") ),
+ _xAttributes );
+ ctx.importDoubleProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Value") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importDoubleProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ValueMin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-min") ),
+ _xAttributes );
+ ctx.importDoubleProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ValueMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-max") ),
+ _xAttributes );
+ ctx.importDoubleProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ValueStep") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-step") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Spin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("spin") ),
+ _xAttributes );
+ if (ctx.importLongProperty( OUSTR("RepeatDelay"), OUSTR("repeat"),
+ _xAttributes ))
+ ctx.getControlModel()->setPropertyValue(
+ OUSTR("Repeat"), makeAny(true) );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("EnforceFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("enforce-format") ),
+ _xAttributes );
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// datefield
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > DateFieldElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void DateFieldElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlDateFieldModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("StrictFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("strict-format") ),
+ _xAttributes );
+ ctx.importBooleanProperty(
+ OUSTR("HideInactiveSelection"), OUSTR("hide-inactive-selection"),
+ _xAttributes );
+ ctx.importDateFormatProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("DateFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("date-format") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("DateShowCentury") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("show-century") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Date") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("DateMin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-min") ),
+ _xAttributes );
+ ctx.importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("DateMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-max") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Spin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("spin") ),
+ _xAttributes );
+ if (ctx.importLongProperty( OUSTR("RepeatDelay"), OUSTR("repeat"),
+ _xAttributes ))
+ ctx.getControlModel()->setPropertyValue(
+ OUSTR("Repeat"), makeAny(true) );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Dropdown") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("dropdown") ),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("text") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("EnforceFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("enforce-format") ),
+ _xAttributes );
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// currencyfield
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > CurrencyFieldElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void CurrencyFieldElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCurrencyFieldModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("StrictFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("strict-format") ),
+ _xAttributes );
+ ctx.importBooleanProperty(
+ OUSTR("HideInactiveSelection"), OUSTR("hide-inactive-selection"),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("CurrencySymbol") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("currency-symbol") ),
+ _xAttributes );
+ ctx.importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("DecimalAccuracy") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("decimal-accuracy") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ShowThousandsSeparator") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("thousands-separator") ),
+ _xAttributes );
+ ctx.importDoubleProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Value") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importDoubleProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ValueMin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-min") ),
+ _xAttributes );
+ ctx.importDoubleProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ValueMax") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-max") ),
+ _xAttributes );
+ ctx.importDoubleProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ValueStep") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value-step") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Spin") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("spin") ),
+ _xAttributes );
+ if (ctx.importLongProperty( OUSTR("RepeatDelay"), OUSTR("repeat"),
+ _xAttributes ))
+ ctx.getControlModel()->setPropertyValue(
+ OUSTR("Repeat"), makeAny(true) );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("PrependCurrencySymbol") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("prepend-symbol") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("EnforceFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("enforce-format") ),
+ _xAttributes );
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// filecontrol
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > FileControlElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void FileControlElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFileControlModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importBooleanProperty(
+ OUSTR("HideInactiveSelection"), OUSTR("hide-inactive-selection"),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ),
+ _xAttributes );
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+//##################################################################################################
+
+// treecontrol
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > TreeControlElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void TreeControlElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.tree.TreeControlModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importSelectionTypeProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("SelectionType") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("selectiontype") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("RootDisplayed") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("rootdisplayed") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ShowsHandles") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("showshandles") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ShowsRootHandles") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("showsroothandles") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Editable") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("editable") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("RowHeight") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("InvokesStopNodeEditing") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invokesstopnodeediting") ),
+ _xAttributes );
+
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// imagecontrol
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > ImageControlElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void ImageControlElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleImage") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("scale-image") ),
+ _xAttributes );
+ rtl::OUString sURL = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "src" ) );
+ Reference< document::XStorageBasedDocument > xDocStorage( _pImport->getDocOwner(), UNO_QUERY );
+
+ if ( xDocStorage.is() && IsPackageURL( sURL ) )
+ {
+ uno::Sequence< Any > aArgs( 1 );
+ aArgs[ 0 ] <<= xDocStorage->getDocumentStorage();
+
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ uno::Reference< document::XGraphicObjectResolver > xGraphicResolver;
+ aContext.createComponentWithArguments( OUSTR( "com.sun.star.comp.Svx.GraphicImportHelper" ), aArgs, xGraphicResolver );
+
+ if ( xGraphicResolver.is() )
+ {
+ rtl::OUString aTmp( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
+ aTmp += sURL;
+ sURL = xGraphicResolver->resolveGraphicObjectURL( aTmp );
+ Reference< beans::XPropertySet > xProps( ctx.getControlModel(), UNO_QUERY );
+ // we must set the url while the graphic object ( held by the resolver is in scope )
+ if ( xProps.is() )
+ xProps->setPropertyValue( OUSTR("ImageURL"), makeAny( sURL ) );
+ }
+ }
+
+ else if ( sURL.getLength() > 0 )
+ {
+ Reference< beans::XPropertySet > xProps( ctx.getControlModel(), UNO_QUERY );
+ if ( xProps.is() )
+ xProps->setPropertyValue( OUSTR("ImageURL"), makeAny( sURL ) );
+ }
+
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// textfield
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > TextElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void TextElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
+ _xAttributes );
+ ctx.importVerticalAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("valign") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("multiline") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("NoLabel") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("nolabel") ),
+ _xAttributes );
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+// FixedHyperLink
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > FixedHyperLinkElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void FixedHyperLinkElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedHyperlinkModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("URL") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("url") ),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Description") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("description") ),
+ _xAttributes );
+
+ ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
+ _xAttributes );
+ ctx.importVerticalAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("valign") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("multiline") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("NoLabel") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("nolabel") ),
+ _xAttributes );
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// edit
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > TextFieldElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void TextFieldElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) );
+ 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->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HardLineBreaks") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("hard-linebreaks") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HScroll") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("hscroll") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("VScroll") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("vscroll") ),
+ _xAttributes );
+ ctx.importBooleanProperty(
+ OUSTR("HideInactiveSelection"), OUSTR("hide-inactive-selection"),
+ _xAttributes );
+ ctx.importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MaxTextLen") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("maxlength") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("multiline") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importLineEndFormatProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("LineEndFormat") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("lineend-format") ),
+ _xAttributes );
+ OUString aValue;
+ if (getStringAttr( &aValue,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("echochar") ),
+ _xAttributes,
+ _pImport->XMLNS_DIALOGS_UID ) &&
+ aValue.getLength() > 0)
+ {
+ OSL_ENSURE( aValue.getLength() == 1, "### more than one character given for echochar!" );
+ sal_Int16 nChar = (sal_Int16)aValue[ 0 ];
+ xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("EchoChar") ),
+ makeAny( nChar ) );
+ }
+
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// titledbox
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > TitledBoxElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else if (_pImport->XMLNS_DIALOGS_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // title
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("title") ))
+ {
+ getStringAttr( &_label,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ xAttributes,
+ _pImport->XMLNS_DIALOGS_UID );
+
+ return new ElementBase(
+ _pImport->XMLNS_DIALOGS_UID,
+ rLocalName, xAttributes, this, _pImport );
+ }
+ // radio
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("radio") ))
+ {
+ // dont create radios here, => titledbox must be inserted first due to radio grouping,
+ // possible predecessors!
+ Reference< xml::input::XElement > xRet(
+ new RadioElement( rLocalName, xAttributes, this, _pImport ) );
+ _radios.push_back( xRet );
+ return xRet;
+ }
+ // event
+ else if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ return BulletinBoardElement::startChildElement( nUid, rLocalName, xAttributes );
+ }
+}
+//__________________________________________________________________________________________________
+void TitledBoxElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ {
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( 0, 0, _xAttributes ); // inherited from BulletinBoardElement
+
+ if (_label.getLength())
+ {
+ xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ makeAny( _label ) );
+ }
+
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+ }
+
+ // create radios AFTER group box!
+ for ( size_t nPos = 0; nPos < _radios.size(); ++nPos )
+ {
+ Reference< xml::input::XElement > xRadio( _radios[ nPos ] );
+ Reference< xml::input::XAttributes > xAttributes(
+ xRadio->getAttributes() );
+ OUString sLinkedCell;
+ OUString sCellRange;
+ OUString sService( OUSTR("com.sun.star.awt.UnoControlRadioButtonModel") );
+ try
+ {
+ sLinkedCell = xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "linked-cell" ) );
+ // we should probably limit this to vba mode also ( leave for now )
+ if ( isVBACompatibilityMode( _pImport ) )
+ sService = OUSTR("com.sun.star.form.component.RadioButton");
+ }
+ catch( Exception& /*e*/ )
+ {
+ }
+
+
+ ControlImportContext ctx(
+ _pImport, getControlId( xAttributes ),
+ sService );
+ 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->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ pStyle->importVisualEffectStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ xAttributes );
+ ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
+ xAttributes );
+ ctx.importVerticalAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("valign") ),
+ xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("image-src") ),
+ xAttributes );
+ ctx.importImagePositionProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("image-position") ),
+ xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("multiline") ),
+ xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("GroupName") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("group-name") ),
+ xAttributes );
+
+ sal_Int16 nVal = 0;
+ sal_Bool bChecked = sal_False;
+ if (getBoolAttr( &bChecked,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("checked") ),
+ xAttributes,
+ _pImport->XMLNS_DIALOGS_UID ) &&
+ bChecked)
+ {
+ nVal = 1;
+ }
+ xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ),
+ makeAny( nVal ) );
+ importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx );
+ ::std::vector< Reference< xml::input::XElement > > * radioEvents =
+ static_cast< RadioElement * >( xRadio.get() )->getEvents();
+ ctx.importEvents( *radioEvents );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ radioEvents->clear();
+ }
+ // avoid ring-reference:
+ // vector< radio elements > holding radio elements holding this (via _pParent)
+ _radios.clear();
+}
+
+//##################################################################################################
+
+// radio
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > RadioElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+
+//##################################################################################################
+
+// radiogroup
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > RadioGroupElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ if (_pImport->XMLNS_DIALOGS_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // radio
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("radio") ))
+ {
+ // dont create radios here, => titledbox must be inserted first due to radio grouping,
+ // possible predecessors!
+ Reference< xml::input::XElement > xRet(
+ new RadioElement( rLocalName, xAttributes, this, _pImport ) );
+ _radios.push_back( xRet );
+ return xRet;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected radio element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void RadioGroupElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ for ( size_t nPos = 0; nPos < _radios.size(); ++nPos )
+ {
+ Reference< xml::input::XElement > xRadio( _radios[ nPos ] );
+ Reference< xml::input::XAttributes > xAttributes(
+ xRadio->getAttributes() );
+ OUString sLinkedCell;
+ OUString sCellRange;
+ OUString sService( OUSTR("com.sun.star.awt.UnoControlRadioButtonModel") );
+ try
+ {
+ sLinkedCell = xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "linked-cell" ) );
+ // we should probably limit this to vba mode also ( leave for now )
+ if ( isVBACompatibilityMode( _pImport ) )
+ sService = OUSTR("com.sun.star.form.component.RadioButton");
+ }
+ catch( Exception& /*e*/ )
+ {
+ }
+
+ ControlImportContext ctx(
+ _pImport, getControlId( xAttributes ),
+ sService );
+ 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->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ pStyle->importVisualEffectStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ xAttributes );
+ ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
+ xAttributes );
+ ctx.importVerticalAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("valign") ),
+ xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("image-src") ),
+ xAttributes );
+ ctx.importImagePositionProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("image-position") ),
+ xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("multiline") ),
+ xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("GroupName") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("group-name") ),
+ xAttributes );
+ sal_Int16 nVal = 0;
+ sal_Bool bChecked = sal_False;
+ if (getBoolAttr( &bChecked,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("checked") ),
+ xAttributes,
+ _pImport->XMLNS_DIALOGS_UID ) &&
+ bChecked)
+ {
+ nVal = 1;
+ }
+ xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ),
+ makeAny( nVal ) );
+
+ importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx );
+ ::std::vector< Reference< xml::input::XElement > > * radioEvents =
+ static_cast< RadioElement * >( xRadio.get() )->getEvents();
+ ctx.importEvents( *radioEvents );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ radioEvents->clear();
+ }
+ // avoid ring-reference:
+ // vector< radio elements > holding radio elements holding this (via _pParent)
+ _radios.clear();
+}
+
+//##################################################################################################
+
+// menupopup
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > MenuPopupElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ if (_pImport->XMLNS_DIALOGS_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // menuitem
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("menuitem") ))
+ {
+ OUString aValue(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ) ) );
+ OSL_ENSURE( aValue.getLength(), "### menuitem has no value?" );
+ if (aValue.getLength())
+ {
+ _itemValues.push_back( aValue );
+
+ OUString aSel(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("selected") ) ) );
+ if (aSel.getLength() && aSel.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("true") ))
+ {
+ _itemSelected.push_back(
+ static_cast<sal_Int16>(_itemValues.size()) -1 );
+ }
+ }
+ return new ElementBase(
+ _pImport->XMLNS_DIALOGS_UID,
+ rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected menuitem!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+Sequence< OUString > MenuPopupElement::getItemValues()
+{
+ Sequence< OUString > aRet( _itemValues.size() );
+ OUString * pRet = aRet.getArray();
+ for ( size_t nPos = _itemValues.size(); nPos--; )
+ {
+ pRet[ nPos ] = _itemValues[ nPos ];
+ }
+ return aRet;
+}
+//__________________________________________________________________________________________________
+Sequence< sal_Int16 > MenuPopupElement::getSelectedItems()
+{
+ Sequence< sal_Int16 > aRet( _itemSelected.size() );
+ sal_Int16 * pRet = aRet.getArray();
+ for ( size_t nPos = _itemSelected.size(); nPos--; )
+ {
+ pRet[ nPos ] = _itemSelected[ nPos ];
+ }
+ return aRet;
+}
+
+//##################################################################################################
+
+// menulist
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > MenuListElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else if (_pImport->XMLNS_DIALOGS_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // menupopup
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("menupopup") ))
+ {
+ _popup = new MenuPopupElement( rLocalName, xAttributes, this, _pImport );
+ return _popup;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event or menupopup element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void MenuListElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ OUString sLinkedCell;
+ OUString sCellRange;
+ OUString sListBoxService( OUSTR("com.sun.star.awt.UnoControlListBoxModel") );
+
+ // we should probably limit this to vba mode also ( leave for now )
+ if ( isVBACompatibilityMode( _pImport ) )
+ sListBoxService = OUSTR("com.sun.star.form.component.ListBox");
+
+ try
+ {
+ sLinkedCell = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "linked-cell" ) );
+ sCellRange = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "source-cell-range" ) );
+ }
+ catch( Exception& /*e*/ )
+ {
+ }
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ //OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) );
+ sListBoxService );
+ 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->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiSelection") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("multiselection") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Dropdown") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("spin") ),
+ _xAttributes );
+ ctx.importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("LineCount") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("linecount") ),
+ _xAttributes );
+ ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
+ _xAttributes );
+ // import cell-link and cell source range
+ importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx );
+ if (_popup.is())
+ {
+ MenuPopupElement * p = static_cast< MenuPopupElement * >( _popup.get() );
+ if ( !sCellRange.getLength() )
+ xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ),
+ makeAny( p->getItemValues() ) );
+ if ( !sLinkedCell.getLength() )
+ xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") ),
+ makeAny( p->getSelectedItems() ) );
+ }
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// combobox
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > ComboBoxElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else if (_pImport->XMLNS_DIALOGS_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // menupopup
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("menupopup") ))
+ {
+ _popup = new MenuPopupElement( rLocalName, xAttributes, this, _pImport );
+ return _popup;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event or menupopup element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void ComboBoxElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ OUString sService( OUSTR("com.sun.star.awt.UnoControlComboBoxModel") );
+
+ // we should probably limit this to vba mode also ( leave for now )
+ if ( isVBACompatibilityMode( _pImport ) )
+ sService = OUSTR("com.sun.star.form.component.ComboBox");
+
+ OUString sLinkedCell;
+ OUString sCellRange;
+ try
+ {
+ sLinkedCell = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "linked-cell" ) );
+ sCellRange = _xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, OUSTR( "source-cell-range" ) );
+ }
+ catch( Exception& /*e*/ )
+ {
+ }
+
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ sService );
+ 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->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importBorderStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Autocomplete") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("autocomplete") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Dropdown") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("spin") ),
+ _xAttributes );
+ ctx.importBooleanProperty(
+ OUSTR("HideInactiveSelection"), OUSTR("hide-inactive-selection"),
+ _xAttributes );
+ ctx.importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MaxTextLen") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("maxlength") ),
+ _xAttributes );
+ ctx.importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("LineCount") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("linecount") ),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
+ _xAttributes );
+ // import cell-link and cell source range
+ importBindableAndListRangeBits( _pImport, sLinkedCell, sCellRange, ctx );
+
+ if (_popup.is() && !sCellRange.getLength() )
+ {
+ MenuPopupElement * p = static_cast< MenuPopupElement * >( _popup.get() );
+ xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ),
+ makeAny( p->getItemValues() ) );
+ }
+
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// checkbox
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > CheckBoxElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void CheckBoxElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) );
+ 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->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ pStyle->importVisualEffectStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
+ _xAttributes );
+ ctx.importVerticalAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("valign") ),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("image-src") ),
+ _xAttributes );
+ ctx.importImagePositionProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("image-position") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("multiline") ),
+ _xAttributes );
+
+
+ sal_Bool bTriState = sal_False;
+ if (getBoolAttr( &bTriState,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tristate") ),
+ _xAttributes,
+ _pImport->XMLNS_DIALOGS_UID ))
+ {
+ xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("TriState") ),
+ makeAny( bTriState ) );
+ }
+ sal_Bool bChecked = sal_False;
+ if (getBoolAttr( &bChecked,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("checked") ),
+ _xAttributes,
+ _pImport->XMLNS_DIALOGS_UID ))
+ {
+ // has "checked" attribute
+ sal_Int16 nVal = (bChecked ? 1 : 0);
+ xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ),
+ makeAny( nVal ) );
+ }
+ else
+ {
+ sal_Int16 nVal = (bTriState ? 2 : 0); // if tristate set, but checked omitted => dont know!
+ xControlModel->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ),
+ makeAny( nVal ) );
+ }
+
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// button
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > ButtonElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void ButtonElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ ControlImportContext ctx(
+ _pImport, getControlId( _xAttributes ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ pStyle->importBackgroundColorStyle( xControlModel );
+ pStyle->importTextColorStyle( xControlModel );
+ pStyle->importTextLineColorStyle( xControlModel );
+ pStyle->importFontStyle( xControlModel );
+ }
+
+ ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tabstop") ),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Label") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("value") ),
+ _xAttributes );
+ ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
+ _xAttributes );
+ ctx.importVerticalAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("VerticalAlign") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("valign") ),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultButton") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("default") ),
+ _xAttributes );
+ ctx.importButtonTypeProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("PushButtonType") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("button-type") ),
+ _xAttributes );
+ ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("image-src") ),
+ _xAttributes );
+ ctx.importImagePositionProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImagePosition") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("image-position") ),
+ _xAttributes );
+ ctx.importImageAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageAlign") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("image-align") ),
+ _xAttributes );
+ if (ctx.importLongProperty( OUSTR("RepeatDelay"), OUSTR("repeat"),
+ _xAttributes ))
+ ctx.getControlModel()->setPropertyValue(
+ OUSTR("Repeat"), makeAny(true) );
+ sal_Int32 toggled = 0;
+ if (getLongAttr( &toggled, OUSTR("toggled"), _xAttributes,
+ _pImport->XMLNS_DIALOGS_UID ) && toggled == 1)
+ ctx.getControlModel()->setPropertyValue(OUSTR("Toggle"), makeAny(true));
+ ctx.importBooleanProperty( OUSTR("FocusOnClick"), OUSTR("grab-focus"),
+ _xAttributes );
+ ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("multiline") ),
+ _xAttributes );
+ // State
+ sal_Bool bChecked = sal_False;
+ if (getBoolAttr(
+ &bChecked,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("checked") ),
+ _xAttributes,
+ _pImport->XMLNS_DIALOGS_UID ) &&
+ bChecked)
+ {
+ sal_Int16 nVal = 1;
+ ctx.getControlModel()->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("State") ), makeAny( nVal ) );
+ }
+
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+//##################################################################################################
+
+// bulletinboard
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > BulletinBoardElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ if (_pImport->XMLNS_DIALOGS_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // button
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("button") ))
+ {
+ return new ButtonElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // checkbox
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("checkbox") ))
+ {
+ return new CheckBoxElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // combobox
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("combobox") ))
+ {
+ return new ComboBoxElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // listbox
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("menulist") ))
+ {
+ return new MenuListElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // radiogroup
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("radiogroup") ))
+ {
+ return new RadioGroupElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // titledbox
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("titledbox") ))
+ {
+ return new TitledBoxElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // text
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("text") ))
+ {
+ return new TextElement( rLocalName, xAttributes, this, _pImport );
+ }
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("linklabel") ))
+ {
+ return new FixedHyperLinkElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // textfield
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("textfield") ))
+ {
+ return new TextFieldElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // img
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("img") ))
+ {
+ return new ImageControlElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // filecontrol
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("filecontrol") ))
+ {
+ return new FileControlElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // treecontrol
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("treecontrol") ))
+ {
+ return new TreeControlElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // currencyfield
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("currencyfield") ))
+ {
+ return new CurrencyFieldElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // datefield
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("datefield") ))
+ {
+ return new DateFieldElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // datefield
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("numericfield") ))
+ {
+ return new NumericFieldElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // timefield
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("timefield") ))
+ {
+ return new TimeFieldElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // patternfield
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("patternfield") ))
+ {
+ return new PatternFieldElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // formattedfield
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("formattedfield") ))
+ {
+ return new FormattedFieldElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // fixedline
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("fixedline") ))
+ {
+ return new FixedLineElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // scrollbar
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("scrollbar") ))
+ {
+ return new ScrollBarElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // spinbutton
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("spinbutton") ) && isVBACompatibilityMode( _pImport ) )
+ {
+ return new SpinButtonElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // progressmeter
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("progressmeter") ))
+ {
+ return new ProgressBarElement( rLocalName, xAttributes, this, _pImport );
+ }
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("multipage") ))
+ {
+ return new MultiPage( rLocalName, xAttributes, this, _pImport );
+ }
+ // bulletinboard
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bulletinboard") ))
+ {
+ return new BulletinBoardElement( rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected styles, bulletinboard or bulletinboard element, not: ") ) + rLocalName,
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+BulletinBoardElement::BulletinBoardElement(
+ OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ControlElement( rLocalName, xAttributes, pParent, pImport )
+{
+ OUString aValue(
+ _xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("left") ) ) );
+ if (aValue.getLength())
+ {
+ _nBasePosX += toInt32( aValue );
+ }
+ aValue = _xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("top") ) );
+ if (aValue.getLength())
+ {
+ _nBasePosY += toInt32( aValue );
+ }
+}
+
+//##################################################################################################
+
+// style
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > StyleElement::startChildElement(
+ sal_Int32 /*nUid*/, OUString const & /*rLocalName*/,
+ Reference< xml::input::XAttributes > const & /*xAttributes*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("unexpected sub elements of style!") ),
+ Reference< XInterface >(), Any() );
+}
+//__________________________________________________________________________________________________
+void StyleElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ Reference< xml::input::XAttributes > xStyle;
+ OUString aStyleId(
+ _xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("style-id") ) ) );
+ if (aStyleId.getLength())
+ {
+ _pImport->addStyle( aStyleId, this );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("missing style-id attribute!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+
+//##################################################################################################
+
+// styles
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > StylesElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ if (_pImport->XMLNS_DIALOGS_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // style
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("style") ))
+ {
+ return new StyleElement( rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected style element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+
+//##################################################################################################
+
+// window
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > WindowElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // event
+ if (_pImport->isEventElement( nUid, rLocalName ))
+ {
+ return new EventElement( nUid, rLocalName, xAttributes, this, _pImport );
+ }
+ else if (_pImport->XMLNS_DIALOGS_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // styles
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("styles") ))
+ {
+ return new StylesElement( rLocalName, xAttributes, this, _pImport );
+ }
+ // bulletinboard
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bulletinboard") ))
+ {
+ return new BulletinBoardElement( rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected styles ot bulletinboard element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void WindowElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ Reference< beans::XPropertySet > xProps(
+ _pImport->_xDialogModel, UNO_QUERY_THROW );
+ ImportContext ctx( _pImport, xProps, getControlId( _xAttributes ) );
+
+ Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
+ if (xStyle.is())
+ {
+ StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
+ pStyle->importBackgroundColorStyle( xProps );
+ pStyle->importTextColorStyle( xProps );
+ pStyle->importTextLineColorStyle( xProps );
+ pStyle->importFontStyle( xProps );
+ }
+
+ ctx.importDefaults( 0, 0, _xAttributes, false );
+ ctx.importBooleanProperty(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Closeable") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("closeable") ),
+ _xAttributes );
+ ctx.importBooleanProperty(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Moveable") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("moveable") ),
+ _xAttributes );
+ ctx.importBooleanProperty(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Sizeable") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("resizeable") ),
+ _xAttributes );
+ ctx.importStringProperty(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("title") ),
+ _xAttributes );
+ ctx.importBooleanProperty(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Decoration") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("withtitlebar") ),
+ _xAttributes );
+ ctx.importStringProperty(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("image-src") ),
+ _xAttributes );
+ ctx.importEvents( _events );
+ // avoid ring-reference:
+ // vector< event elements > holding event elements holding this (via _pParent)
+ _events.clear();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx
new file mode 100644
index 000000000000..81ba97c6a955
--- /dev/null
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx
@@ -0,0 +1,1931 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+#include "imp_share.hxx"
+
+#include <osl/diagnose.h>
+#include <tools/diagnose_ex.h>
+#include <osl/mutex.hxx>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <xmlscript/xml_import.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/awt/CharSet.hpp>
+#include <com/sun/star/awt/FontFamily.hpp>
+#include <com/sun/star/awt/FontPitch.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontType.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontWidth.hpp>
+#include <com/sun/star/awt/ImagePosition.hpp>
+#include <com/sun/star/awt/LineEndFormat.hpp>
+#include <com/sun/star/awt/PushButtonType.hpp>
+#include <com/sun/star/awt/VisualEffect.hpp>
+#include <com/sun/star/style/VerticalAlignment.hpp>
+
+#include <com/sun/star/script/XScriptEventsSupplier.hpp>
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+
+#include <com/sun/star/view/SelectionType.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/script/DocumentScriptLibraryContainer.hpp>
+#include <com/sun/star/script/vba/XVBACompatibility.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+using ::rtl::OUString;
+
+namespace xmlscript
+{
+
+//__________________________________________________________________________________________________
+void EventElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ static_cast< ControlElement * >( _pParent )->_events.push_back( this );
+}
+//__________________________________________________________________________________________________
+ControlElement::ControlElement(
+ OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : ElementBase(
+ pImport->XMLNS_DIALOGS_UID, rLocalName, xAttributes, pParent, pImport )
+{
+ if (_pParent)
+ {
+ // inherit position
+ _nBasePosX = static_cast< ControlElement * >( _pParent )->_nBasePosX;
+ _nBasePosY = static_cast< ControlElement * >( _pParent )->_nBasePosY;
+ }
+ else
+ {
+ _nBasePosX = 0;
+ _nBasePosY = 0;
+ }
+}
+
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > ControlElement::getStyle(
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aStyleId(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("style-id") ) ) );
+ if (aStyleId.getLength())
+ {
+ return _pImport->getStyle( aStyleId );
+ }
+ return Reference< xml::input::XElement >();
+}
+//__________________________________________________________________________________________________
+OUString ControlElement::getControlId(
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aId(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("id") ) ) );
+ if (! aId.getLength())
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("missing id attribute!") ),
+ Reference< XInterface >(), Any() );
+ }
+ return aId;
+}
+
+//##################################################################################################
+
+//__________________________________________________________________________________________________
+bool StyleElement::importTextColorStyle(
+ Reference< beans::XPropertySet > const & xProps )
+{
+ if ((_inited & 0x2) != 0)
+ {
+ if ((_hasValue & 0x2) != 0)
+ {
+ xProps->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ),
+ makeAny( _textColor ) );
+ return true;
+ }
+ return false;
+ }
+ _inited |= 0x2;
+
+ if (getLongAttr( &_textColor,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("text-color") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ _hasValue |= 0x2;
+ xProps->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ),
+ makeAny( _textColor ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool StyleElement::importTextLineColorStyle(
+ Reference< beans::XPropertySet > const & xProps )
+{
+ if ((_inited & 0x20) != 0)
+ {
+ if ((_hasValue & 0x20) != 0)
+ {
+ xProps->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ),
+ makeAny( _textLineColor ) );
+ return true;
+ }
+ return false;
+ }
+ _inited |= 0x20;
+
+ if (getLongAttr( &_textLineColor,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("textline-color") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ _hasValue |= 0x20;
+ xProps->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ),
+ makeAny( _textLineColor ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool StyleElement::importFillColorStyle(
+ Reference< beans::XPropertySet > const & xProps )
+{
+ if ((_inited & 0x10) != 0)
+ {
+ if ((_hasValue & 0x10) != 0)
+ {
+ xProps->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("FillColor") ), makeAny( _fillColor ) );
+ return true;
+ }
+ return false;
+ }
+ _inited |= 0x10;
+
+ if (getLongAttr(
+ &_fillColor,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("fill-color") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ _hasValue |= 0x10;
+ xProps->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("FillColor") ),
+ makeAny( _fillColor ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool StyleElement::importBackgroundColorStyle(
+ Reference< beans::XPropertySet > const & xProps )
+{
+ if ((_inited & 0x1) != 0)
+ {
+ if ((_hasValue & 0x1) != 0)
+ {
+ xProps->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ), makeAny( _backgroundColor ) );
+ return true;
+ }
+ return false;
+ }
+ _inited |= 0x1;
+
+ if (getLongAttr(
+ &_backgroundColor,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("background-color") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ _hasValue |= 0x1;
+ xProps->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ), makeAny( _backgroundColor ) );
+ return true;
+ }
+ return false;
+}
+
+//__________________________________________________________________________________________________
+bool StyleElement::importBorderStyle(
+ Reference< beans::XPropertySet > const & xProps )
+{
+ if ((_inited & 0x4) != 0)
+ {
+ if ((_hasValue & 0x4) != 0)
+ {
+ xProps->setPropertyValue(
+ OUSTR("Border"), makeAny( _border == BORDER_SIMPLE_COLOR
+ ? BORDER_SIMPLE : _border ) );
+ if (_border == BORDER_SIMPLE_COLOR)
+ xProps->setPropertyValue( OUSTR("BorderColor"),
+ makeAny(_borderColor) );
+ return true;
+ }
+ return false;
+ }
+ _inited |= 0x4;
+
+ OUString aValue;
+ if (getStringAttr(
+ &aValue, OUSTR("border"),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID )) {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") ))
+ _border = BORDER_NONE;
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("3d") ))
+ _border = BORDER_3D;
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("simple") ))
+ _border = BORDER_SIMPLE;
+ else {
+ _border = BORDER_SIMPLE_COLOR;
+ _borderColor = toInt32(aValue);
+ }
+
+ _hasValue |= 0x4;
+ importBorderStyle(xProps); // write values
+ }
+ return false;
+}
+
+//______________________________________________________________________________
+bool StyleElement::importVisualEffectStyle(
+ Reference<beans::XPropertySet> const & xProps )
+{
+ if ((_inited & 0x40) != 0)
+ {
+ if ((_hasValue & 0x40) != 0)
+ {
+ xProps->setPropertyValue( OUSTR("VisualEffect"),
+ makeAny(_visualEffect) );
+ return true;
+ }
+ return false;
+ }
+ _inited |= 0x40;
+
+ OUString aValue;
+ if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("look") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") ))
+ {
+ _visualEffect = awt::VisualEffect::NONE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("3d") ))
+ {
+ _visualEffect = awt::VisualEffect::LOOK3D;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("simple") ))
+ {
+ _visualEffect = awt::VisualEffect::FLAT;
+ }
+ else
+ OSL_ASSERT( 0 );
+
+ _hasValue |= 0x40;
+ xProps->setPropertyValue( OUSTR("VisualEffect"),
+ makeAny(_visualEffect) );
+ }
+ return false;
+}
+
+//__________________________________________________________________________________________________
+void StyleElement::setFontProperties(
+ Reference< beans::XPropertySet > const & xProps )
+{
+ xProps->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("FontDescriptor") ), makeAny( _descr ) );
+ xProps->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("FontEmphasisMark") ), makeAny( _fontEmphasisMark ) );
+ xProps->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("FontRelief") ), makeAny( _fontRelief ) );
+}
+//__________________________________________________________________________________________________
+bool StyleElement::importFontStyle(
+ Reference< beans::XPropertySet > const & xProps )
+{
+ if ((_inited & 0x8) != 0)
+ {
+ if ((_hasValue & 0x8) != 0)
+ {
+ setFontProperties( xProps );
+ return true;
+ }
+ return false;
+ }
+ _inited |= 0x8;
+
+ OUString aValue;
+ bool bFontImport;
+
+ // dialog:font-name CDATA #IMPLIED
+ bFontImport = getStringAttr(
+ &_descr.Name, OUString( RTL_CONSTASCII_USTRINGPARAM("font-name") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID );
+
+ // dialog:font-height %numeric; #IMPLIED
+ if (getStringAttr(
+ &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-height") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ _descr.Height = (sal_Int16)toInt32( aValue );
+ bFontImport = true;
+ }
+ // dialog:font-width %numeric; #IMPLIED
+ if (getStringAttr(
+ &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-width") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ _descr.Width = (sal_Int16)toInt32( aValue );
+ bFontImport = true;
+ }
+ // dialog:font-stylename CDATA #IMPLIED
+ bFontImport |= getStringAttr(
+ &_descr.StyleName,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("font-stylename") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID );
+
+ // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED
+ if (getStringAttr(
+ &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-family") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("decorative") ))
+ {
+ _descr.Family = awt::FontFamily::DECORATIVE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("modern") ))
+ {
+ _descr.Family = awt::FontFamily::MODERN;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("roman") ))
+ {
+ _descr.Family = awt::FontFamily::ROMAN;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("script") ))
+ {
+ _descr.Family = awt::FontFamily::SCRIPT;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("swiss") ))
+ {
+ _descr.Family = awt::FontFamily::SWISS;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system") ))
+ {
+ _descr.Family = awt::FontFamily::SYSTEM;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-family style!") ),
+ Reference< XInterface >(), Any() );
+ }
+ bFontImport = true;
+ }
+
+ // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED
+ if (getStringAttr(
+ &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-charset") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ansi") ))
+ {
+ _descr.CharSet = awt::CharSet::ANSI;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("mac") ))
+ {
+ _descr.CharSet = awt::CharSet::MAC;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_437") ))
+ {
+ _descr.CharSet = awt::CharSet::IBMPC_437;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_850") ))
+ {
+ _descr.CharSet = awt::CharSet::IBMPC_850;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_860") ))
+ {
+ _descr.CharSet = awt::CharSet::IBMPC_860;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_861") ))
+ {
+ _descr.CharSet = awt::CharSet::IBMPC_861;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_863") ))
+ {
+ _descr.CharSet = awt::CharSet::IBMPC_863;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_865") ))
+ {
+ _descr.CharSet = awt::CharSet::IBMPC_865;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system") ))
+ {
+ _descr.CharSet = awt::CharSet::SYSTEM;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("symbol") ))
+ {
+ _descr.CharSet = awt::CharSet::SYMBOL;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-charset style!") ),
+ Reference< XInterface >(), Any() );
+ }
+ bFontImport = true;
+ }
+
+ // dialog:font-pitch "(fixed|variable)" #IMPLIED
+ if (getStringAttr(
+ &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-pitch") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("fixed") ))
+ {
+ _descr.Pitch = awt::FontPitch::FIXED;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("variable") ))
+ {
+ _descr.Pitch = awt::FontPitch::VARIABLE;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-pitch style!") ),
+ Reference< XInterface >(), Any() );
+ }
+ bFontImport = true;
+ }
+
+ // dialog:font-charwidth CDATA #IMPLIED
+ if (getStringAttr(
+ &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-charwidth") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ _descr.CharacterWidth = aValue.toFloat();
+ bFontImport = true;
+ }
+ // dialog:font-weight CDATA #IMPLIED
+ if (getStringAttr(
+ &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-weight") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ _descr.Weight = aValue.toFloat();
+ bFontImport = true;
+ }
+
+ // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED
+ if (getStringAttr(
+ &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-slant") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("oblique") ))
+ {
+ _descr.Slant = awt::FontSlant_OBLIQUE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("italic") ))
+ {
+ _descr.Slant = awt::FontSlant_ITALIC;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("reverse_oblique") ))
+ {
+ _descr.Slant = awt::FontSlant_REVERSE_OBLIQUE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("reverse_italic") ))
+ {
+ _descr.Slant = awt::FontSlant_REVERSE_ITALIC;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-slant style!") ),
+ Reference< XInterface >(), Any() );
+ }
+ bFontImport = true;
+ }
+
+ // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED
+ if (getStringAttr(
+ &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-underline") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("single") ))
+ {
+ _descr.Underline = awt::FontUnderline::SINGLE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("double") ))
+ {
+ _descr.Underline = awt::FontUnderline::DOUBLE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dotted") ))
+ {
+ _descr.Underline = awt::FontUnderline::DOTTED;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dash") ))
+ {
+ _descr.Underline = awt::FontUnderline::DASH;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("longdash") ))
+ {
+ _descr.Underline = awt::FontUnderline::LONGDASH;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dashdot") ))
+ {
+ _descr.Underline = awt::FontUnderline::DASHDOT;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dashdotdot") ))
+ {
+ _descr.Underline = awt::FontUnderline::DASHDOTDOT;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("smallwave") ))
+ {
+ _descr.Underline = awt::FontUnderline::SMALLWAVE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("wave") ))
+ {
+ _descr.Underline = awt::FontUnderline::WAVE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("doublewave") ))
+ {
+ _descr.Underline = awt::FontUnderline::DOUBLEWAVE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bold") ))
+ {
+ _descr.Underline = awt::FontUnderline::BOLD;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddotted") ))
+ {
+ _descr.Underline = awt::FontUnderline::BOLDDOTTED;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddash") ))
+ {
+ _descr.Underline = awt::FontUnderline::BOLDDASH;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("boldlongdash") ))
+ {
+ _descr.Underline = awt::FontUnderline::BOLDLONGDASH;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddashdot") ))
+ {
+ _descr.Underline = awt::FontUnderline::BOLDDASHDOT;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddashdotdot") ))
+ {
+ _descr.Underline = awt::FontUnderline::BOLDDASHDOTDOT;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("boldwave") ))
+ {
+ _descr.Underline = awt::FontUnderline::BOLDWAVE;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-underline style!") ),
+ Reference< XInterface >(), Any() );
+ }
+ bFontImport = true;
+ }
+
+ // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED
+ if (getStringAttr(
+ &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-strikeout") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("single") ))
+ {
+ _descr.Strikeout = awt::FontStrikeout::SINGLE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("double") ))
+ {
+ _descr.Strikeout = awt::FontStrikeout::DOUBLE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bold") ))
+ {
+ _descr.Strikeout = awt::FontStrikeout::BOLD;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("slash") ))
+ {
+ _descr.Strikeout = awt::FontStrikeout::SLASH;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("x") ))
+ {
+ _descr.Strikeout = awt::FontStrikeout::X;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-strikeout style!") ),
+ Reference< XInterface >(), Any() );
+ }
+ bFontImport = true;
+ }
+
+ // dialog:font-orientation CDATA #IMPLIED
+ if (getStringAttr(
+ &aValue,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("font-orientation") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ _descr.Orientation = aValue.toFloat();
+ bFontImport = true;
+ }
+ // dialog:font-kerning %boolean; #IMPLIED
+ bFontImport |= getBoolAttr(
+ &_descr.Kerning,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("font-kerning") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID );
+ // dialog:font-wordlinemode %boolean; #IMPLIED
+ bFontImport |= getBoolAttr(
+ &_descr.WordLineMode,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("font-wordlinemode") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID );
+
+ // dialog:font-type "(raster|device|scalable)" #IMPLIED
+ if (getStringAttr(
+ &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-type") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("raster") ))
+ {
+ _descr.Type = awt::FontType::RASTER;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("device") ))
+ {
+ _descr.Type = awt::FontType::DEVICE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("scalable") ))
+ {
+ _descr.Type = awt::FontType::SCALABLE;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-type style!") ),
+ Reference< XInterface >(), Any() );
+ }
+ bFontImport = true;
+ }
+
+ // additional properties which are not part of the FontDescriptor struct
+ // dialog:font-relief (none|embossed|engraved) #IMPLIED
+ if (getStringAttr(
+ &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-relief") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") ))
+ {
+ _fontRelief = awt::FontRelief::NONE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("embossed") ))
+ {
+ _fontRelief = awt::FontRelief::EMBOSSED;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("engraved") ))
+ {
+ _fontRelief = awt::FontRelief::ENGRAVED;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-relief style!") ),
+ Reference< XInterface >(), Any() );
+ }
+ bFontImport = true;
+ }
+ // dialog:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED
+ if (getStringAttr(
+ &aValue,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("font-emphasismark") ),
+ _xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") ))
+ {
+ _fontEmphasisMark = awt::FontEmphasisMark::NONE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dot") ))
+ {
+ _fontEmphasisMark = awt::FontEmphasisMark::DOT;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("circle") ))
+ {
+ _fontEmphasisMark = awt::FontEmphasisMark::CIRCLE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("disc") ))
+ {
+ _fontEmphasisMark = awt::FontEmphasisMark::DISC;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("accent") ))
+ {
+ _fontEmphasisMark = awt::FontEmphasisMark::ACCENT;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("above") ))
+ {
+ _fontEmphasisMark = awt::FontEmphasisMark::ABOVE;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("below") ))
+ {
+ _fontEmphasisMark = awt::FontEmphasisMark::BELOW;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-emphasismark style!") ),
+ Reference< XInterface >(), Any() );
+ }
+ bFontImport = true;
+ }
+
+ // ==================================================
+ if (bFontImport)
+ {
+ _hasValue |= 0x8;
+ setFontProperties( xProps );
+ }
+
+ return bFontImport;
+}
+
+//##################################################################################################
+
+//__________________________________________________________________________________________________
+bool ImportContext::importStringProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aValue(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aValue.getLength())
+ {
+ _xControlModel->setPropertyValue( rPropName, makeAny( aValue ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importDoubleProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aValue(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aValue.getLength())
+ {
+ _xControlModel->setPropertyValue( rPropName, makeAny( aValue.toDouble() ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importBooleanProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ sal_Bool bBool;
+ if (getBoolAttr(
+ &bBool, rAttrName, xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ _xControlModel->setPropertyValue( rPropName, makeAny( bBool ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importLongProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aValue(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aValue.getLength())
+ {
+ _xControlModel->setPropertyValue( rPropName, makeAny( toInt32( aValue ) ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importLongProperty(
+ sal_Int32 nOffset,
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aValue(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aValue.getLength())
+ {
+ _xControlModel->setPropertyValue( rPropName, makeAny( toInt32( aValue ) + nOffset ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importHexLongProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aValue(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aValue.getLength())
+ {
+ _xControlModel->setPropertyValue( rPropName, makeAny( toInt32( aValue ) ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importShortProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aValue(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aValue.getLength())
+ {
+ _xControlModel->setPropertyValue( rPropName, makeAny( (sal_Int16)toInt32( aValue ) ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importAlignProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aAlign(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aAlign.getLength())
+ {
+ sal_Int16 nAlign;
+ if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left") ))
+ {
+ nAlign = 0;
+ }
+ else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("center") ))
+ {
+ nAlign = 1;
+ }
+ else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right") ))
+ {
+ nAlign = 2;
+ }
+ else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") ))
+ {
+ nAlign = 0; // default
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid align value!") ),
+ Reference< XInterface >(), Any() );
+ }
+
+ _xControlModel->setPropertyValue( rPropName, makeAny( nAlign ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importVerticalAlignProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aAlign(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aAlign.getLength())
+ {
+ style::VerticalAlignment eAlign;
+
+ if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top") ))
+ {
+ eAlign = style::VerticalAlignment_TOP;
+ }
+ else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("center") ))
+ {
+ eAlign = style::VerticalAlignment_MIDDLE;
+ }
+ else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom") ))
+ {
+ eAlign = style::VerticalAlignment_BOTTOM;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid vertical align value!") ),
+ Reference< XInterface >(), Any() );
+ }
+
+ _xControlModel->setPropertyValue( rPropName, makeAny( eAlign ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importImageAlignProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aAlign(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aAlign.getLength())
+ {
+ sal_Int16 nAlign;
+ if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left") ))
+ {
+ nAlign = 0;
+ }
+ else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top") ))
+ {
+ nAlign = 1;
+ }
+ else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right") ))
+ {
+ nAlign = 2;
+ }
+ else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom") ))
+ {
+ nAlign = 3;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid image align value!") ),
+ Reference< XInterface >(), Any() );
+ }
+
+ _xControlModel->setPropertyValue( rPropName, makeAny( nAlign ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importImagePositionProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aPosition(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aPosition.getLength())
+ {
+ sal_Int16 nPosition;
+ if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left-top") ))
+ {
+ nPosition = awt::ImagePosition::LeftTop;
+ }
+ else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left-center") ))
+ {
+ nPosition = awt::ImagePosition::LeftCenter;
+ }
+ else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left-bottom") ))
+ {
+ nPosition = awt::ImagePosition::LeftBottom;
+ }
+ else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right-top") ))
+ {
+ nPosition = awt::ImagePosition::RightTop;
+ }
+ else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right-center") ))
+ {
+ nPosition = awt::ImagePosition::RightCenter;
+ }
+ else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right-bottom") ))
+ {
+ nPosition = awt::ImagePosition::RightBottom;
+ }
+ else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top-left") ))
+ {
+ nPosition = awt::ImagePosition::AboveLeft;
+ }
+ else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top-center") ))
+ {
+ nPosition = awt::ImagePosition::AboveCenter;
+ }
+ else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top-right") ))
+ {
+ nPosition = awt::ImagePosition::AboveRight;
+ }
+ else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom-left") ))
+ {
+ nPosition = awt::ImagePosition::BelowLeft;
+ }
+ else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom-center") ))
+ {
+ nPosition = awt::ImagePosition::BelowCenter;
+ }
+ else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom-right") ))
+ {
+ nPosition = awt::ImagePosition::BelowRight;
+ }
+ else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("center") ))
+ {
+ nPosition = awt::ImagePosition::Centered;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid image position value!") ),
+ Reference< XInterface >(), Any() );
+ }
+
+ _xControlModel->setPropertyValue( rPropName, makeAny( nPosition ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importButtonTypeProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString buttonType(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (buttonType.getLength())
+ {
+ sal_Int16 nButtonType;
+ if (buttonType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("standard") ))
+ {
+ nButtonType = awt::PushButtonType_STANDARD;
+ }
+ else if (buttonType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ok") ))
+ {
+ nButtonType = awt::PushButtonType_OK;
+ }
+ else if (buttonType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("cancel") ))
+ {
+ nButtonType = awt::PushButtonType_CANCEL;
+ }
+ else if (buttonType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("help") ))
+ {
+ nButtonType = awt::PushButtonType_HELP;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid button-type value!") ),
+ Reference< XInterface >(), Any() );
+ }
+
+ _xControlModel->setPropertyValue( rPropName, makeAny( nButtonType ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importDateFormatProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aFormat(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aFormat.getLength())
+ {
+ sal_Int16 nFormat;
+ if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_short") ))
+ {
+ nFormat = 0;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_short_YY") ))
+ {
+ nFormat = 1;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_short_YYYY") ))
+ {
+ nFormat = 2;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_long") ))
+ {
+ nFormat = 3;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_DDMMYY") ))
+ {
+ nFormat = 4;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_MMDDYY") ))
+ {
+ nFormat = 5;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYMMDD") ))
+ {
+ nFormat = 6;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_DDMMYYYY") ))
+ {
+ nFormat = 7;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_MMDDYYYY") ))
+ {
+ nFormat = 8;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYYYMMDD") ))
+ {
+ nFormat = 9;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYMMDD_DIN5008") ))
+ {
+ nFormat = 10;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYYYMMDD_DIN5008") ))
+ {
+ nFormat = 11;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid date-format value!") ),
+ Reference< XInterface >(), Any() );
+ }
+
+ _xControlModel->setPropertyValue( rPropName, makeAny( nFormat ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importTimeFormatProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aFormat(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aFormat.getLength())
+ {
+ sal_Int16 nFormat;
+ if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("24h_short") ))
+ {
+ nFormat = 0;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("24h_long") ))
+ {
+ nFormat = 1;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("12h_short") ))
+ {
+ nFormat = 2;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("12h_long") ))
+ {
+ nFormat = 3;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Duration_short") ))
+ {
+ nFormat = 4;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Duration_long") ))
+ {
+ nFormat = 5;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid time-format value!") ),
+ Reference< XInterface >(), Any() );
+ }
+
+ _xControlModel->setPropertyValue( rPropName, makeAny( nFormat ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importOrientationProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aOrient(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aOrient.getLength())
+ {
+ sal_Int32 nOrient;
+ if (aOrient.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("horizontal") ))
+ {
+ nOrient = 0;
+ }
+ else if (aOrient.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("vertical") ))
+ {
+ nOrient = 1;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid orientation value!") ),
+ Reference< XInterface >(), Any() );
+ }
+
+ _xControlModel->setPropertyValue( rPropName, makeAny( nOrient ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importLineEndFormatProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aFormat(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aFormat.getLength())
+ {
+ sal_Int16 nFormat;
+ if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("carriage-return") ))
+ {
+ nFormat = awt::LineEndFormat::CARRIAGE_RETURN;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("line-feed") ))
+ {
+ nFormat = awt::LineEndFormat::LINE_FEED;
+ }
+ else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("carriage-return-line-feed") ))
+ {
+ nFormat = awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid line end format value!") ),
+ Reference< XInterface >(), Any() );
+ }
+
+ _xControlModel->setPropertyValue( rPropName, makeAny( nFormat ) );
+ return true;
+ }
+ return false;
+}
+//__________________________________________________________________________________________________
+bool ImportContext::importSelectionTypeProperty(
+ OUString const & rPropName, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+{
+ OUString aSelectionType(
+ xAttributes->getValueByUidName(
+ _pImport->XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aSelectionType.getLength())
+ {
+ view::SelectionType eSelectionType;
+
+ if (aSelectionType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") ))
+ {
+ eSelectionType = view::SelectionType_NONE;
+ }
+ else if (aSelectionType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("single") ))
+ {
+ eSelectionType = view::SelectionType_SINGLE;
+ }
+ else if (aSelectionType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("multi") ))
+ {
+ eSelectionType = view::SelectionType_MULTI;
+ }
+ else if (aSelectionType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("range") ))
+ {
+ eSelectionType = view::SelectionType_RANGE;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("invalid selection type value!") ),
+ Reference< XInterface >(), Any() );
+ }
+
+ _xControlModel->setPropertyValue( rPropName, makeAny( eSelectionType ) );
+ return true;
+ }
+ return false;
+}
+
+//==================================================================================================
+struct StringTriple
+{
+ char const * first;
+ char const * second;
+ char const * third;
+};
+static StringTriple const s_aEventTranslations[] =
+{
+ // from xmloff/source/forms/formevents.cxx
+ // 28.09.2001 tbe added on-adjustmentvaluechange
+ { "com.sun.star.form.XApproveActionListener", "approveAction", "on-approveaction" },
+ { "com.sun.star.awt.XActionListener", "actionPerformed", "on-performaction" },
+ { "com.sun.star.form.XChangeListener", "changed", "on-change" },
+ { "com.sun.star.awt.XTextListener", "textChanged", "on-textchange" },
+ { "com.sun.star.awt.XItemListener", "itemStateChanged", "on-itemstatechange" },
+ { "com.sun.star.awt.XFocusListener", "focusGained", "on-focus" },
+ { "com.sun.star.awt.XFocusListener", "focusLost", "on-blur" },
+ { "com.sun.star.awt.XKeyListener", "keyPressed", "on-keydown" },
+ { "com.sun.star.awt.XKeyListener", "keyReleased", "on-keyup" },
+ { "com.sun.star.awt.XMouseListener", "mouseEntered", "on-mouseover" },
+ { "com.sun.star.awt.XMouseMotionListener", "mouseDragged", "on-mousedrag" },
+ { "com.sun.star.awt.XMouseMotionListener", "mouseMoved", "on-mousemove" },
+ { "com.sun.star.awt.XMouseListener", "mousePressed", "on-mousedown" },
+ { "com.sun.star.awt.XMouseListener", "mouseReleased", "on-mouseup" },
+ { "com.sun.star.awt.XMouseListener", "mouseExited", "on-mouseout" },
+ { "com.sun.star.form.XResetListener", "approveReset", "on-approvereset" },
+ { "com.sun.star.form.XResetListener", "resetted", "on-reset" },
+ { "com.sun.star.form.XSubmitListener", "approveSubmit", "on-submit" },
+ { "com.sun.star.form.XUpdateListener", "approveUpdate", "on-approveupdate" },
+ { "com.sun.star.form.XUpdateListener", "updated", "on-update" },
+ { "com.sun.star.form.XLoadListener", "loaded", "on-load" },
+ { "com.sun.star.form.XLoadListener", "reloading", "on-startreload" },
+ { "com.sun.star.form.XLoadListener", "reloaded", "on-reload" },
+ { "com.sun.star.form.XLoadListener", "unloading", "on-startunload" },
+ { "com.sun.star.form.XLoadListener", "unloaded", "on-unload" },
+ { "com.sun.star.form.XConfirmDeleteListener", "confirmDelete", "on-confirmdelete" },
+ { "com.sun.star.sdb.XRowSetApproveListener", "approveRowChange", "on-approverowchange" },
+ { "com.sun.star.sdbc.XRowSetListener", "rowChanged", "on-rowchange" },
+ { "com.sun.star.sdb.XRowSetApproveListener", "approveCursorMove", "on-approvecursormove" },
+ { "com.sun.star.sdbc.XRowSetListener", "cursorMoved", "on-cursormove" },
+ { "com.sun.star.form.XDatabaseParameterListener", "approveParameter", "on-supplyparameter" },
+ { "com.sun.star.sdb.XSQLErrorListener", "errorOccured", "on-error" },
+ { "com.sun.star.awt.XAdjustmentListener", "adjustmentValueChanged", "on-adjustmentvaluechange" },
+ { 0, 0, 0 }
+};
+extern StringTriple const * const g_pEventTranslations;
+StringTriple const * const g_pEventTranslations = s_aEventTranslations;
+
+//__________________________________________________________________________________________________
+void ImportContext::importEvents(
+ ::std::vector< Reference< xml::input::XElement > > const & rEvents )
+{
+ Reference< script::XScriptEventsSupplier > xSupplier(
+ _xControlModel, UNO_QUERY );
+ if (xSupplier.is())
+ {
+ Reference< container::XNameContainer > xEvents( xSupplier->getEvents() );
+ if (xEvents.is())
+ {
+ for ( size_t nPos = 0; nPos < rEvents.size(); ++nPos )
+ {
+ script::ScriptEventDescriptor descr;
+
+ EventElement * pEventElement = static_cast< EventElement * >( rEvents[ nPos ].get() );
+ sal_Int32 nUid = pEventElement->getUid();
+ OUString aLocalName( pEventElement->getLocalName() );
+ Reference< xml::input::XAttributes > xAttributes(
+ pEventElement->getAttributes() );
+
+ // nowadays script events
+ if (_pImport->XMLNS_SCRIPT_UID == nUid)
+ {
+ if (!getStringAttr( &descr.ScriptType,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "language") ),
+ xAttributes,
+ _pImport->XMLNS_SCRIPT_UID ) ||
+ !getStringAttr( &descr.ScriptCode,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "macro-name") ),
+ xAttributes,
+ _pImport->XMLNS_SCRIPT_UID ))
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "missing language or macro-name "
+ "attribute(s) of event!") ),
+ Reference< XInterface >(), Any() );
+ }
+ if ( descr.ScriptType.equals( OUString( RTL_CONSTASCII_USTRINGPARAM( "StarBasic" ) ) ) )
+ {
+ OUString aLocation;
+ if (getStringAttr( &aLocation,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "location") ),
+ xAttributes,
+ _pImport->XMLNS_SCRIPT_UID ))
+ {
+ // prepend location
+ ::rtl::OUStringBuffer buf;
+ buf.append( aLocation );
+ buf.append( (sal_Unicode)':' );
+ buf.append( descr.ScriptCode );
+ descr.ScriptCode = buf.makeStringAndClear();
+ }
+ }
+ else if ( descr.ScriptType.equals( OUString( RTL_CONSTASCII_USTRINGPARAM( "Script" ) ) ) )
+ {
+ // Check if there is a protocol, if not assume
+ // this is an early scripting framework url ( without
+ // the protocol ) and fix it up!!
+ if ( descr.ScriptCode.indexOf( ':' ) == -1 )
+ {
+ ::rtl::OUStringBuffer buf;
+ buf.append( OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.script:" ) ) );
+ buf.append( descr.ScriptCode );
+ descr.ScriptCode = buf.makeStringAndClear();
+ }
+ }
+
+ // script:event element
+ if (aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
+ {
+ OUString aEventName;
+ if (! getStringAttr(
+ &aEventName,
+ OUString(
+ RTL_CONSTASCII_USTRINGPARAM("event-name") ),
+ xAttributes,
+ _pImport->XMLNS_SCRIPT_UID ))
+ {
+ throw xml::sax::SAXException(
+ OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "missing event-name attribute!") ),
+ Reference< XInterface >(), Any() );
+ }
+
+ // lookup in table
+ ::rtl::OString str(
+ ::rtl::OUStringToOString(
+ aEventName, RTL_TEXTENCODING_ASCII_US ) );
+ StringTriple const * p = g_pEventTranslations;
+ while (p->first)
+ {
+ if (0 == ::rtl_str_compare( p->third, str.getStr() ))
+ {
+ descr.ListenerType = OUString(
+ p->first, ::rtl_str_getLength( p->first ),
+ RTL_TEXTENCODING_ASCII_US );
+ descr.EventMethod = OUString(
+ p->second, ::rtl_str_getLength( p->second ),
+ RTL_TEXTENCODING_ASCII_US );
+ break;
+ }
+ ++p;
+ }
+
+ if (! p->first)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no matching event-name found!") ),
+ Reference< XInterface >(), Any() );
+ }
+ }
+ else // script:listener-event element
+ {
+ OSL_ASSERT( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("listener-event") ) );
+
+ if (!getStringAttr(
+ &descr.ListenerType,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "listener-type") ),
+ xAttributes,
+ _pImport->XMLNS_SCRIPT_UID ) ||
+ !getStringAttr(
+ &descr.EventMethod,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "listener-method") ),
+ xAttributes, _pImport->XMLNS_SCRIPT_UID ))
+ {
+ throw xml::sax::SAXException(
+ OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "missing listener-type or "
+ "listener-method attribute(s)!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // optional listener param
+ getStringAttr(
+ &descr.AddListenerParam,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "listener-param") ),
+ xAttributes, _pImport->XMLNS_SCRIPT_UID );
+ }
+ }
+ else // deprecated dlg:event element
+ {
+ OSL_ASSERT(
+ _pImport->XMLNS_DIALOGS_UID == nUid &&
+ aLocalName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("event") ) );
+
+ if (!getStringAttr( &descr.ListenerType,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "listener-type") ),
+ xAttributes,
+ _pImport->XMLNS_DIALOGS_UID ) ||
+ !getStringAttr( &descr.EventMethod,
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "event-method") ),
+ xAttributes,
+ _pImport->XMLNS_DIALOGS_UID ))
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("missing listener-type or event-method attribute(s)!") ),
+ Reference< XInterface >(), Any() );
+ }
+
+ getStringAttr(
+ &descr.ScriptType,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("script-type") ),
+ xAttributes, _pImport->XMLNS_DIALOGS_UID );
+ getStringAttr(
+ &descr.ScriptCode,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("script-code") ),
+ xAttributes, _pImport->XMLNS_DIALOGS_UID );
+ getStringAttr(
+ &descr.AddListenerParam,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("param") ),
+ xAttributes, _pImport->XMLNS_DIALOGS_UID );
+ }
+
+ ::rtl::OUStringBuffer buf;
+ buf.append( descr.ListenerType );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("::") );
+ buf.append( descr.EventMethod );
+ xEvents->insertByName( buf.makeStringAndClear(), makeAny( descr ) );
+ }
+ }
+ }
+}
+//__________________________________________________________________________________________________
+void ImportContext::importDefaults(
+ sal_Int32 nBaseX, sal_Int32 nBaseY,
+ Reference< xml::input::XAttributes > const & xAttributes,
+ bool supportPrintable )
+{
+ _xControlModel->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ),
+ makeAny( _aId ) );
+
+ importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("TabIndex") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tab-index") ),
+ xAttributes );
+
+ sal_Bool bDisable = sal_False;
+ if (getBoolAttr(
+ &bDisable, OUString( RTL_CONSTASCII_USTRINGPARAM("disabled") ),
+ xAttributes, _pImport->XMLNS_DIALOGS_UID ) &&
+ bDisable)
+ {
+ _xControlModel->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Enabled") ), makeAny( sal_False ) );
+ }
+
+ sal_Bool bVisible = sal_True;
+ if (getBoolAttr(
+ &bVisible, OUString( RTL_CONSTASCII_USTRINGPARAM("visible") ),
+ xAttributes, _pImport->XMLNS_DIALOGS_UID ) && !bVisible)
+ {
+ try
+ {
+
+ _xControlModel->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("EnableVisible") ), makeAny( sal_False ) );
+ }
+ catch( Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ if (!importLongProperty( nBaseX,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("left") ),
+ xAttributes ) ||
+ !importLongProperty( nBaseY,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("top") ),
+ xAttributes ) ||
+ !importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("width") ),
+ xAttributes ) ||
+ !importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("height") ),
+ xAttributes ))
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("missing pos size attribute(s)!") ),
+ Reference< XInterface >(), Any() );
+ }
+
+ if (supportPrintable)
+ {
+ importBooleanProperty(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Printable") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("printable") ),
+ xAttributes );
+ }
+
+ sal_Int32 nLong;
+ if (! getLongAttr(
+ &nLong,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("page") ),
+ xAttributes, _pImport->XMLNS_DIALOGS_UID ))
+ {
+ nLong = 0;
+ }
+ _xControlModel->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Step") ),
+ makeAny( nLong ) );
+
+ importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("tag") ),
+ xAttributes );
+ importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpText") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("help-text") ),
+ xAttributes );
+ importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("help-url") ),
+ xAttributes );
+}
+
+//##################################################################################################
+
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > ElementBase::getParent()
+ throw (RuntimeException)
+{
+ return static_cast< xml::input::XElement * >( _pParent );
+}
+//__________________________________________________________________________________________________
+OUString ElementBase::getLocalName()
+ throw (RuntimeException)
+{
+ return _aLocalName;
+}
+//__________________________________________________________________________________________________
+sal_Int32 ElementBase::getUid()
+ throw (RuntimeException)
+{
+ return _nUid;
+}
+//__________________________________________________________________________________________________
+Reference< xml::input::XAttributes > ElementBase::getAttributes()
+ throw (RuntimeException)
+{
+ return _xAttributes;
+}
+//__________________________________________________________________________________________________
+void ElementBase::ignorableWhitespace(
+ OUString const & /*rWhitespaces*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // not used
+}
+//__________________________________________________________________________________________________
+void ElementBase::characters( OUString const & /*rChars*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // not used, all characters ignored
+}
+//__________________________________________________________________________________________________
+void ElementBase::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+}
+//______________________________________________________________________________
+void ElementBase::processingInstruction(
+ OUString const & /*Target*/, OUString const & /*Data*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+}
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > ElementBase::startChildElement(
+ sal_Int32 /*nUid*/, OUString const & /*rLocalName*/,
+ Reference< xml::input::XAttributes > const & /*xAttributes*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("unexpected element!") ),
+ Reference< XInterface >(), Any() );
+}
+
+//__________________________________________________________________________________________________
+ElementBase::ElementBase(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes,
+ ElementBase * pParent, DialogImport * pImport )
+ SAL_THROW( () )
+ : _pImport( pImport )
+ , _pParent( pParent )
+ , _nUid( nUid )
+ , _aLocalName( rLocalName )
+ , _xAttributes( xAttributes )
+{
+ _pImport->acquire();
+
+ if (_pParent)
+ {
+ _pParent->acquire();
+ }
+}
+//__________________________________________________________________________________________________
+ElementBase::~ElementBase()
+ SAL_THROW( () )
+{
+ _pImport->release();
+
+ if (_pParent)
+ {
+ _pParent->release();
+ }
+
+#if OSL_DEBUG_LEVEL > 1
+ ::rtl::OString aStr( ::rtl::OUStringToOString(
+ _aLocalName, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "ElementBase::~ElementBase(): %s\n", aStr.getStr() );
+#endif
+}
+
+//##################################################################################################
+
+// XRoot
+//
+
+//______________________________________________________________________________
+void DialogImport::startDocument(
+ Reference< xml::input::XNamespaceMapping > const & xNamespaceMapping )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ XMLNS_DIALOGS_UID = xNamespaceMapping->getUidByUri(
+ OUSTR(XMLNS_DIALOGS_URI) );
+ XMLNS_SCRIPT_UID = xNamespaceMapping->getUidByUri(
+ OUSTR(XMLNS_SCRIPT_URI) );
+}
+//__________________________________________________________________________________________________
+void DialogImport::endDocument()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // ignored
+}
+//__________________________________________________________________________________________________
+void DialogImport::processingInstruction(
+ OUString const & /*rTarget*/, OUString const & /*rData*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // ignored for now: xxx todo
+}
+//__________________________________________________________________________________________________
+void DialogImport::setDocumentLocator(
+ Reference< xml::sax::XLocator > const & /*xLocator*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // ignored for now: xxx todo
+}
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > DialogImport::startRootElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ if (XMLNS_DIALOGS_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // window
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("window") ))
+ {
+ return new WindowElement( rLocalName, xAttributes, 0, this );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "illegal root element (expected window) given: ") ) +
+ rLocalName, Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+DialogImport::~DialogImport()
+ SAL_THROW( () )
+{
+#if OSL_DEBUG_LEVEL > 1
+ OSL_TRACE( "DialogImport::~DialogImport().\n" );
+#endif
+}
+//__________________________________________________________________________________________________
+Reference< util::XNumberFormatsSupplier > const & DialogImport::getNumberFormatsSupplier()
+{
+ if (! _xSupplier.is())
+ {
+ Reference< XComponentContext > xContext( getComponentContext() );
+ Reference< util::XNumberFormatsSupplier > xSupplier(
+ xContext->getServiceManager()->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.util.NumberFormatsSupplier") ),
+ xContext ), UNO_QUERY );
+
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! _xSupplier.is())
+ {
+ _xSupplier = xSupplier;
+ }
+ }
+ return _xSupplier;
+}
+
+//__________________________________________________________________________________________________
+void DialogImport::addStyle(
+ OUString const & rStyleId,
+ Reference< xml::input::XElement > const & xStyle )
+ SAL_THROW( () )
+{
+ _styleNames.push_back( rStyleId );
+ _styles.push_back( xStyle );
+}
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > DialogImport::getStyle(
+ OUString const & rStyleId ) const
+ SAL_THROW( () )
+{
+ for ( size_t nPos = 0; nPos < _styleNames.size(); ++nPos )
+ {
+ if (_styleNames[ nPos ] == rStyleId)
+ {
+ return _styles[ nPos ];
+ }
+ }
+ return 0;
+}
+//__________________________________________________________________________________________________
+Reference< script::XLibraryContainer > DialogImport::getScriptLibraryContainer()
+{
+ if( !_xScriptLibraryContainer.is() )
+ {
+ try
+ {
+ Reference< beans::XPropertySet > xProps( _xDoc, UNO_QUERY );
+ if( xProps.is() )
+ _xScriptLibraryContainer.set( xProps->getPropertyValue( OUSTR("BasicLibraries") ), UNO_QUERY );
+ }
+ catch( const Exception& )
+ {
+ }
+ }
+
+ return _xScriptLibraryContainer;
+}
+
+//##################################################################################################
+
+//==================================================================================================
+Reference< xml::sax::XDocumentHandler > SAL_CALL importDialogModel(
+ Reference< container::XNameContainer > const & xDialogModel,
+ Reference< XComponentContext > const & xContext,
+ Reference< XModel > const & xDocument )
+ SAL_THROW( (Exception) )
+{
+ DialogImport* pImport = new DialogImport( xContext, xDialogModel, xDocument );
+ return ::xmlscript::createDocumentHandler(
+ static_cast< xml::input::XRoot * >( pImport ) );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmlflat_imexp/makefile.mk b/xmlscript/source/xmlflat_imexp/makefile.mk
new file mode 100644
index 000000000000..ed4d434afbd0
--- /dev/null
+++ b/xmlscript/source/xmlflat_imexp/makefile.mk
@@ -0,0 +1,50 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=xmlscript
+TARGET=xmlflat_imexp
+NO_BSYMBOLIC=TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
+#-----------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/xmlbas_export.obj \
+ $(SLO)$/xmlbas_import.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/target.pmk
+.ENDIF # L10N_framework
+
+.INCLUDE : target.mk
diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx b/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx
new file mode 100644
index 000000000000..b6e31ba7951b
--- /dev/null
+++ b/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx
@@ -0,0 +1,554 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+#include "xmlbas_export.hxx"
+#include "xmlscript/xmlns.h"
+#include "xmlscript/xml_helper.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/script/XLibraryContainer2.hpp>
+#include <com/sun/star/script/XLibraryContainerPassword.hpp>
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <cppuhelper/implementationentry.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+
+
+//.........................................................................
+namespace xmlscript
+{
+//.........................................................................
+
+ // =============================================================================
+ // component operations
+ // =============================================================================
+
+ ::rtl::OUString getImplementationName_XMLBasicExporter()
+ {
+ static ::rtl::OUString* pImplName = 0;
+ if ( !pImplName )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pImplName )
+ {
+ static ::rtl::OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.xmlscript.XMLBasicExporter" ) );
+ pImplName = &aImplName;
+ }
+ }
+ return *pImplName;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Sequence< ::rtl::OUString > getSupportedServiceNames_XMLBasicExporter()
+ {
+ static Sequence< ::rtl::OUString >* pNames = 0;
+ if ( !pNames )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pNames )
+ {
+ static Sequence< ::rtl::OUString > aNames(1);
+ aNames.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.XMLBasicExporter" ) );
+ pNames = &aNames;
+ }
+ }
+ return *pNames;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ ::rtl::OUString getImplementationName_XMLOasisBasicExporter()
+ {
+ static ::rtl::OUString* pImplName = 0;
+ if ( !pImplName )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pImplName )
+ {
+ static ::rtl::OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.xmlscript.XMLOasisBasicExporter" ) );
+ pImplName = &aImplName;
+ }
+ }
+ return *pImplName;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Sequence< ::rtl::OUString > getSupportedServiceNames_XMLOasisBasicExporter()
+ {
+ static Sequence< ::rtl::OUString >* pNames = 0;
+ if ( !pNames )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pNames )
+ {
+ static Sequence< ::rtl::OUString > aNames(1);
+ aNames.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.XMLOasisBasicExporter" ) );
+ pNames = &aNames;
+ }
+ }
+ return *pNames;
+ }
+
+
+ // =============================================================================
+ // XMLBasicExporterBase
+ // =============================================================================
+
+ XMLBasicExporterBase::XMLBasicExporterBase( const Reference< XComponentContext >& rxContext, sal_Bool bOasis )
+ :m_xContext( rxContext )
+ ,m_bOasis( bOasis )
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+
+ XMLBasicExporterBase::~XMLBasicExporterBase()
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+ // XServiceInfo
+ // -----------------------------------------------------------------------------
+
+ sal_Bool XMLBasicExporterBase::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pNames + aNames.getLength();
+ for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
+ ;
+
+ return pNames != pEnd;
+ }
+
+ // -----------------------------------------------------------------------------
+ // XInitialization
+ // -----------------------------------------------------------------------------
+
+ void XMLBasicExporterBase::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( aArguments.getLength() == 1 )
+ {
+ aArguments[0] >>= m_xHandler;
+
+ if ( !m_xHandler.is() )
+ {
+ throw RuntimeException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMLBasicExporterBase::initialize: invalid argument format!" ) ),
+ Reference< XInterface >() );
+ }
+ }
+ else
+ {
+ throw RuntimeException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMLBasicExporterBase::initialize: invalid number of arguments!" ) ),
+ Reference< XInterface >() );
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ // XExporter
+ // -----------------------------------------------------------------------------
+
+ void XMLBasicExporterBase::setSourceDocument( const Reference< XComponent >& rxDoc )
+ throw (IllegalArgumentException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ m_xModel.set( rxDoc, UNO_QUERY );
+
+ if ( !m_xModel.is() )
+ {
+ throw IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMLBasicExporter::setSourceDocument: no document model!" ) ),
+ Reference< XInterface >(), 1 );
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ // XFilter
+ // -----------------------------------------------------------------------------
+
+sal_Bool XMLBasicExporterBase::filter( const Sequence< beans::PropertyValue >& /*aDescriptor*/ )
+ throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ sal_Bool bReturn = sal_True;
+
+ try
+ {
+ if ( m_xHandler.is() )
+ {
+ m_xHandler->startDocument();
+
+ // ooo/script prefix and URI
+ ::rtl::OUString aPrefix;
+ ::rtl::OUString aURI;
+ if ( m_bOasis )
+ {
+ aPrefix = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_OOO_PREFIX ) );
+ aURI = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_OOO_URI ) );
+ }
+ else
+ {
+ aPrefix = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_SCRIPT_PREFIX ) );
+ aURI = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_SCRIPT_URI ) );
+ }
+
+ // ooo/script:libraries element
+ ::rtl::OUString aLibContElementName( aPrefix );
+ aLibContElementName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":libraries" ) );
+ XMLElement* pLibContElement = new XMLElement( aLibContElementName );
+ Reference< xml::sax::XAttributeList > xLibContAttribs( pLibContElement );
+
+ // ooo/script namespace attribute
+ pLibContElement->addAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "xmlns:" ) ) + aPrefix,
+ aURI );
+
+ // xlink namespace attribute
+ pLibContElement->addAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "xmlns:" XMLNS_XLINK_PREFIX ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK_URI ) ) );
+
+ // <ooo/script:libraries...
+ m_xHandler->ignorableWhitespace( ::rtl::OUString() );
+ m_xHandler->startElement( aLibContElementName, xLibContAttribs );
+
+ Reference< script::XLibraryContainer2 > xLibContainer;
+
+ // try the XEmbeddedScripts interface
+ Reference< document::XEmbeddedScripts > xDocumentScripts( m_xModel, UNO_QUERY );
+ if ( xDocumentScripts.is() )
+ xLibContainer.set( xDocumentScripts->getBasicLibraries().get() );
+
+ if ( !xLibContainer.is() )
+ {
+ // try the "BasicLibraries" property (old-style, for compatibility)
+ Reference< beans::XPropertySet > xPSet( m_xModel, UNO_QUERY );
+ if ( xPSet.is() )
+ xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ) >>= xLibContainer;
+ }
+
+ OSL_ENSURE( xLibContainer.is(), "XMLBasicExporterBase::filter: nowhere to export to!" );
+
+ if ( xLibContainer.is() )
+ {
+ Sequence< ::rtl::OUString > aLibNames = xLibContainer->getElementNames();
+ sal_Int32 nLibCount = aLibNames.getLength();
+ const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
+ for ( sal_Int32 i = 0 ; i < nLibCount ; ++i )
+ {
+ ::rtl::OUString aLibName( pLibNames[i] );
+
+ if ( xLibContainer->hasByName( aLibName ) )
+ {
+ ::rtl::OUString aTrueStr( RTL_CONSTASCII_USTRINGPARAM( "true" ) );
+
+ if ( xLibContainer->isLibraryLink( aLibName ) )
+ {
+ // ooo/script:library-linked element
+ ::rtl::OUString aLibElementName( aPrefix );
+ aLibElementName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":library-linked" ) );
+ XMLElement* pLibElement = new XMLElement( aLibElementName );
+ Reference< xml::sax::XAttributeList > xLibAttribs;
+ xLibAttribs = static_cast< xml::sax::XAttributeList* >( pLibElement );
+
+ // ooo/script:name attribute
+ pLibElement->addAttribute( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":name" ) ),
+ aLibName );
+
+ ::rtl::OUString aLinkURL( xLibContainer->getLibraryLinkURL( aLibName ) );
+ if ( aLinkURL.getLength() )
+ {
+ // xlink:href attribute
+ pLibElement->addAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK_PREFIX ":href" ) ),
+ aLinkURL );
+
+ // xlink:type attribute
+ pLibElement->addAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK_PREFIX ":type" ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "simple" ) ) );
+ }
+
+ if ( xLibContainer->isLibraryReadOnly( aLibName ) )
+ {
+ // ooo/script:readonly attribute
+ pLibElement->addAttribute( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":readonly" ) ),
+ aTrueStr );
+ }
+
+ // <ooo/script:library-linked...
+ m_xHandler->ignorableWhitespace( ::rtl::OUString() );
+ m_xHandler->startElement( aLibElementName, xLibAttribs );
+
+ // ...ooo/script:library-linked>
+ m_xHandler->ignorableWhitespace( ::rtl::OUString() );
+ m_xHandler->endElement( aLibElementName );
+ }
+ else
+ {
+ // ooo/script:library-embedded element
+ ::rtl::OUString aLibElementName( aPrefix );
+ aLibElementName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":library-embedded" ) );
+ XMLElement* pLibElement = new XMLElement( aLibElementName );
+ Reference< xml::sax::XAttributeList > xLibAttribs;
+ xLibAttribs = static_cast< xml::sax::XAttributeList* >( pLibElement );
+
+ // ooo/script:name attribute
+ pLibElement->addAttribute( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":name" ) ),
+ aLibName );
+
+ if ( xLibContainer->isLibraryReadOnly( aLibName ) )
+ {
+ // ooo/script:readonly attribute
+ pLibElement->addAttribute( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":readonly" ) ),
+ aTrueStr );
+ }
+
+ // TODO: password protected libraries
+ Reference< script::XLibraryContainerPassword > xPasswd( xLibContainer, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) )
+ continue;
+
+ // <ooo/script:library-embedded...
+ m_xHandler->ignorableWhitespace( ::rtl::OUString() );
+ m_xHandler->startElement( aLibElementName, xLibAttribs );
+
+ if ( !xLibContainer->isLibraryLoaded( aLibName ) )
+ xLibContainer->loadLibrary( aLibName );
+
+ Reference< container::XNameContainer > xLib;
+ xLibContainer->getByName( aLibName ) >>= xLib;
+
+ if ( xLib.is() )
+ {
+ Sequence< ::rtl::OUString > aModNames = xLib->getElementNames();
+ sal_Int32 nModCount = aModNames.getLength();
+ const ::rtl::OUString* pModNames = aModNames.getConstArray();
+ for ( sal_Int32 j = 0 ; j < nModCount ; ++j )
+ {
+ ::rtl::OUString aModName( pModNames[j] );
+ if ( xLib->hasByName( aModName ) )
+ {
+ // ooo/script:module element
+ ::rtl::OUString aModElementName( aPrefix );
+ aModElementName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":module" ) );
+ XMLElement* pModElement = new XMLElement( aModElementName );
+ Reference< xml::sax::XAttributeList > xModAttribs;
+ xModAttribs = static_cast< xml::sax::XAttributeList* >( pModElement );
+
+ // ooo/script:name attribute
+ pModElement->addAttribute( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":name" ) ),
+ aModName );
+
+ // <ooo/script:module...
+ m_xHandler->ignorableWhitespace( ::rtl::OUString() );
+ m_xHandler->startElement( aModElementName, xModAttribs );
+
+ // ooo/script:source-code element
+ ::rtl::OUString aSourceElementName( aPrefix );
+ aSourceElementName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":source-code" ) );
+ XMLElement* pSourceElement = new XMLElement( aSourceElementName );
+ Reference< xml::sax::XAttributeList > xSourceAttribs;
+ xSourceAttribs = static_cast< xml::sax::XAttributeList* >( pSourceElement );
+
+ // <ooo/script:source-code...
+ m_xHandler->ignorableWhitespace( ::rtl::OUString() );
+ m_xHandler->startElement( aSourceElementName, xSourceAttribs );
+
+ // module data
+ // TODO: write encrypted data for password protected libraries
+ ::rtl::OUString aSource;
+ xLib->getByName( aModName ) >>= aSource;
+ m_xHandler->characters( aSource );
+
+ // TODO: <ooo/script:byte-code>
+
+ // ...ooo/script:source-code>
+ m_xHandler->ignorableWhitespace( ::rtl::OUString() );
+ m_xHandler->endElement( aSourceElementName );
+
+ // ...ooo/script:module>
+ m_xHandler->ignorableWhitespace( ::rtl::OUString() );
+ m_xHandler->endElement( aModElementName );
+ }
+ }
+ }
+
+ // ...ooo/script:library-embedded>
+ m_xHandler->ignorableWhitespace( ::rtl::OUString() );
+ m_xHandler->endElement( aLibElementName );
+ }
+ }
+ }
+ }
+
+ // ...ooo/script:libraries>
+ m_xHandler->ignorableWhitespace( ::rtl::OUString() );
+ m_xHandler->endElement( aLibContElementName );
+
+ m_xHandler->endDocument();
+ }
+ }
+ catch ( container::NoSuchElementException& e )
+ {
+ OSL_TRACE( "XMLBasicExporterBase::filter: caught NoSuchElementException reason %s",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ bReturn = sal_False;
+ }
+ catch ( lang::IllegalArgumentException& e )
+ {
+ OSL_TRACE( "XMLBasicExporterBase::filter: caught IllegalArgumentException reason %s",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ bReturn = sal_False;
+ }
+ catch ( lang::WrappedTargetException& e )
+ {
+ OSL_TRACE( "XMLBasicExporterBase::filter: caught WrappedTargetException reason %s",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ bReturn = sal_False;
+ }
+ catch ( xml::sax::SAXException& e )
+ {
+ OSL_TRACE( "XMLBasicExporterBase::filter: caught SAXException reason %s",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ bReturn = sal_False;
+ }
+
+ return bReturn;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void XMLBasicExporterBase::cancel()
+ throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // cancel export
+ }
+
+
+ // =============================================================================
+ // XMLBasicExporter
+ // =============================================================================
+
+ XMLBasicExporter::XMLBasicExporter( const Reference< XComponentContext >& rxContext )
+ :XMLBasicExporterBase( rxContext, sal_False )
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+
+ XMLBasicExporter::~XMLBasicExporter()
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+ // XServiceInfo
+ // -----------------------------------------------------------------------------
+
+ ::rtl::OUString XMLBasicExporter::getImplementationName( ) throw (RuntimeException)
+ {
+ return getImplementationName_XMLBasicExporter();
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Sequence< ::rtl::OUString > XMLBasicExporter::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ return getSupportedServiceNames_XMLBasicExporter();
+ }
+
+
+ // =============================================================================
+ // XMLOasisBasicExporter
+ // =============================================================================
+
+ XMLOasisBasicExporter::XMLOasisBasicExporter( const Reference< XComponentContext >& rxContext )
+ :XMLBasicExporterBase( rxContext, sal_True )
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+
+ XMLOasisBasicExporter::~XMLOasisBasicExporter()
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+ // XServiceInfo
+ // -----------------------------------------------------------------------------
+
+ ::rtl::OUString XMLOasisBasicExporter::getImplementationName( ) throw (RuntimeException)
+ {
+ return getImplementationName_XMLOasisBasicExporter();
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Sequence< ::rtl::OUString > XMLOasisBasicExporter::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ return getSupportedServiceNames_XMLOasisBasicExporter();
+ }
+
+
+ // =============================================================================
+ // component operations
+ // =============================================================================
+
+ Reference< XInterface > SAL_CALL create_XMLBasicExporter(
+ Reference< XComponentContext > const & xContext )
+ SAL_THROW( () )
+ {
+ return static_cast< lang::XTypeProvider * >( new XMLBasicExporter( xContext ) );
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Reference< XInterface > SAL_CALL create_XMLOasisBasicExporter(
+ Reference< XComponentContext > const & xContext )
+ SAL_THROW( () )
+ {
+ return static_cast< lang::XTypeProvider * >( new XMLOasisBasicExporter( xContext ) );
+ }
+
+ // -----------------------------------------------------------------------------
+
+//.........................................................................
+} // namespace xmlscript
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_export.hxx b/xmlscript/source/xmlflat_imexp/xmlbas_export.hxx
new file mode 100644
index 000000000000..bd425b0f0aad
--- /dev/null
+++ b/xmlscript/source/xmlflat_imexp/xmlbas_export.hxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef XMLSCRIPT_XMLBAS_EXPORT_HXX
+#define XMLSCRIPT_XMLBAS_EXPORT_HXX
+
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <cppuhelper/implbase4.hxx>
+#include <osl/mutex.hxx>
+
+
+//.........................................................................
+namespace xmlscript
+{
+//.........................................................................
+
+ // =============================================================================
+ // class XMLBasicExporterBase
+ // =============================================================================
+
+ typedef ::cppu::WeakImplHelper4<
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::lang::XInitialization,
+ ::com::sun::star::document::XExporter,
+ ::com::sun::star::document::XFilter > XMLBasicExporterBase_BASE;
+
+ class XMLBasicExporterBase : public XMLBasicExporterBase_BASE
+ {
+ private:
+ ::osl::Mutex m_aMutex;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xHandler;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
+ sal_Bool m_bOasis;
+
+ public:
+ XMLBasicExporterBase(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, sal_Bool bOasis );
+ virtual ~XMLBasicExporterBase();
+
+ // XServiceInfo
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+ throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XExporter
+ virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& rxDoc )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ // XFilter
+ virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL cancel()
+ throw (::com::sun::star::uno::RuntimeException);
+ };
+
+
+ // =============================================================================
+ // class XMLBasicExporter
+ // =============================================================================
+
+ class XMLBasicExporter : public XMLBasicExporterBase
+ {
+ public:
+ XMLBasicExporter(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
+ virtual ~XMLBasicExporter();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+ };
+
+
+ // =============================================================================
+ // class XMLOasisBasicExporter
+ // =============================================================================
+
+ class XMLOasisBasicExporter : public XMLBasicExporterBase
+ {
+ public:
+ XMLOasisBasicExporter(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
+ virtual ~XMLOasisBasicExporter();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+ };
+
+//.........................................................................
+} // namespace xmlscript
+//.........................................................................
+
+#endif // XMLSCRIPT_XMLBAS_EXPORT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx b/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx
new file mode 100644
index 000000000000..eb9662fe5121
--- /dev/null
+++ b/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx
@@ -0,0 +1,934 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+#include "xmlbas_import.hxx"
+#include "xmlscript/xmlns.h"
+#include "xmlscript/xml_helper.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/script/XLibraryContainerPassword.hpp>
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <cppuhelper/implementationentry.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+
+
+//.........................................................................
+namespace xmlscript
+{
+//.........................................................................
+
+ // =============================================================================
+ // BasicElementBase
+ // =============================================================================
+
+ BasicElementBase::BasicElementBase( const ::rtl::OUString& rLocalName,
+ const Reference< xml::input::XAttributes >& xAttributes,
+ BasicElementBase* pParent, BasicImport* pImport )
+ :m_pImport( pImport )
+ ,m_pParent( pParent )
+ ,m_aLocalName( rLocalName )
+ ,m_xAttributes( xAttributes )
+ {
+ if ( m_pImport )
+ m_pImport->acquire();
+ if ( m_pParent )
+ m_pParent->acquire();
+ }
+
+ // -----------------------------------------------------------------------------
+
+ BasicElementBase::~BasicElementBase()
+ {
+ if ( m_pImport )
+ m_pImport->release();
+ if ( m_pParent )
+ m_pParent->release();
+ }
+
+ // -----------------------------------------------------------------------------
+
+ bool BasicElementBase::getBoolAttr( sal_Bool* pRet, const ::rtl::OUString& rAttrName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes,
+ sal_Int32 nUid )
+ {
+ if ( xAttributes.is() )
+ {
+ ::rtl::OUString aValue( xAttributes->getValueByUidName( nUid, rAttrName ) );
+ if ( aValue.getLength() )
+ {
+ if ( aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "true" ) ) )
+ {
+ *pRet = sal_True;
+ return true;
+ }
+ else if ( aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "false" ) ) )
+ {
+ *pRet = sal_False;
+ return true;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ rAttrName + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": no boolean value (true|false)!" ) ),
+ Reference< XInterface >(), Any() );
+ }
+ }
+ }
+ return false;
+ }
+
+ // -----------------------------------------------------------------------------
+ // XElement
+ // -----------------------------------------------------------------------------
+
+ Reference< xml::input::XElement > BasicElementBase::getParent()
+ throw (RuntimeException)
+ {
+ return static_cast< xml::input::XElement* >( m_pParent );
+ }
+
+ // -----------------------------------------------------------------------------
+
+ ::rtl::OUString BasicElementBase::getLocalName()
+ throw (RuntimeException)
+ {
+ return m_aLocalName;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ sal_Int32 BasicElementBase::getUid()
+ throw (RuntimeException)
+ {
+ sal_Int32 nId = -1;
+ if ( m_pImport )
+ nId = m_pImport->XMLNS_UID;
+ return nId;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Reference< xml::input::XAttributes > BasicElementBase::getAttributes()
+ throw (RuntimeException)
+ {
+ return m_xAttributes;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Reference< xml::input::XElement > BasicElementBase::startChildElement(
+ sal_Int32 /*nUid*/, const ::rtl::OUString& /*rLocalName*/,
+ const Reference< xml::input::XAttributes >& /*xAttributes*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ throw xml::sax::SAXException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "unexpected element!" ) ),
+ Reference< XInterface >(), Any() );
+ }
+
+ // -----------------------------------------------------------------------------
+
+void BasicElementBase::characters( const ::rtl::OUString& /*rChars*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ // not used, all characters ignored
+ }
+
+ // -----------------------------------------------------------------------------
+
+void BasicElementBase::ignorableWhitespace( const ::rtl::OUString& /*rWhitespaces*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+
+void BasicElementBase::processingInstruction( const ::rtl::OUString& /*rTarget*/, const ::rtl::OUString& /*rData*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void BasicElementBase::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ }
+
+
+ // =============================================================================
+ // BasicLibrariesElement
+ // =============================================================================
+
+ BasicLibrariesElement::BasicLibrariesElement( const ::rtl::OUString& rLocalName,
+ const Reference< xml::input::XAttributes >& xAttributes,
+ BasicElementBase* pParent, BasicImport* pImport,
+ const Reference< script::XLibraryContainer2 >& rxLibContainer )
+ :BasicElementBase( rLocalName, xAttributes, pParent, pImport )
+ ,m_xLibContainer( rxLibContainer )
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+ // XElement
+ // -----------------------------------------------------------------------------
+
+ Reference< xml::input::XElement > BasicLibrariesElement::startChildElement(
+ sal_Int32 nUid, const ::rtl::OUString& rLocalName,
+ const Reference< xml::input::XAttributes >& xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ Reference< xml::input::XElement > xElement;
+
+ if ( nUid != m_pImport->XMLNS_UID )
+ {
+ throw xml::sax::SAXException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "illegal namespace!" ) ),
+ Reference< XInterface >(), Any() );
+ }
+ else if ( rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "library-linked" ) ) )
+ {
+ if ( xAttributes.is() )
+ {
+ ::rtl::OUString aName = xAttributes->getValueByUidName(
+ m_pImport->XMLNS_UID,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "name" ) ) );
+
+ ::rtl::OUString aStorageURL = xAttributes->getValueByUidName(
+ m_pImport->XMLNS_XLINK_UID,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "href" ) ) );
+
+ sal_Bool bReadOnly = sal_False;
+ getBoolAttr( &bReadOnly,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "readonly" ) ),
+ xAttributes, m_pImport->XMLNS_UID );
+
+ if ( m_xLibContainer.is() )
+ {
+ try
+ {
+ Reference< container::XNameAccess > xLib(
+ m_xLibContainer->createLibraryLink( aName, aStorageURL, bReadOnly ) );
+ if ( xLib.is() )
+ xElement.set( new BasicElementBase( rLocalName, xAttributes, this, m_pImport ) );
+ }
+ catch ( container::ElementExistException& e )
+ {
+ OSL_TRACE( "BasicLibrariesElement::startChildElement: caught ElementExceptionExist reason %s",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ }
+ catch ( lang::IllegalArgumentException& e )
+ {
+ OSL_TRACE( "BasicLibrariesElement::startChildElement: caught IllegalArgumentException reason %s",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ }
+ }
+ }
+ }
+ else if ( rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "library-embedded" ) ) )
+ {
+ // TODO: create password protected libraries
+
+ if ( xAttributes.is() )
+ {
+ ::rtl::OUString aName = xAttributes->getValueByUidName(
+ m_pImport->XMLNS_UID,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "name" ) ) );
+
+ sal_Bool bReadOnly = sal_False;
+ getBoolAttr( &bReadOnly,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "readonly" ) ),
+ xAttributes, m_pImport->XMLNS_UID );
+
+ if ( m_xLibContainer.is() )
+ {
+ try
+ {
+ Reference< container::XNameContainer > xLib;
+ if ( m_xLibContainer->hasByName( aName ) )
+ {
+ // Standard library
+ m_xLibContainer->getByName( aName ) >>= xLib;
+ }
+ else
+ {
+ xLib.set( m_xLibContainer->createLibrary( aName ) );
+ }
+
+ if ( xLib.is() )
+ xElement.set( new BasicEmbeddedLibraryElement( rLocalName, xAttributes, this, m_pImport, m_xLibContainer, aName, bReadOnly ) );
+ }
+ catch ( lang::IllegalArgumentException& e )
+ {
+ OSL_TRACE( "BasicLibrariesElement::startChildElement: caught IllegalArgumentException reason %s",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ }
+ }
+ }
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "expected library-linked or library-embedded element!" ) ),
+ Reference< XInterface >(), Any() );
+ }
+
+ return xElement;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void BasicLibrariesElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ }
+
+
+ // =============================================================================
+ // BasicEmbeddedLibraryElement
+ // =============================================================================
+
+ BasicEmbeddedLibraryElement::BasicEmbeddedLibraryElement( const ::rtl::OUString& rLocalName,
+ const Reference< xml::input::XAttributes >& xAttributes,
+ BasicElementBase* pParent, BasicImport* pImport,
+ const Reference< script::XLibraryContainer2 >& rxLibContainer,
+ const ::rtl::OUString& rLibName, bool bReadOnly )
+ :BasicElementBase( rLocalName, xAttributes, pParent, pImport )
+ ,m_xLibContainer( rxLibContainer )
+ ,m_aLibName( rLibName )
+ ,m_bReadOnly( bReadOnly )
+ {
+ try
+ {
+ if ( m_xLibContainer.is() && m_xLibContainer->hasByName( m_aLibName ) )
+ m_xLibContainer->getByName( m_aLibName ) >>= m_xLib;
+ }
+ catch ( lang::WrappedTargetException& e )
+ {
+ OSL_TRACE( "BasicEmbeddedLibraryElement CTOR: caught WrappedTargetException reason %s",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ // XElement
+ // -----------------------------------------------------------------------------
+
+ Reference< xml::input::XElement > BasicEmbeddedLibraryElement::startChildElement(
+ sal_Int32 nUid, const ::rtl::OUString& rLocalName,
+ const Reference< xml::input::XAttributes >& xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ Reference< xml::input::XElement > xElement;
+
+ if ( nUid != m_pImport->XMLNS_UID )
+ {
+ throw xml::sax::SAXException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "illegal namespace!" ) ),
+ Reference< XInterface >(), Any() );
+ }
+ else if ( rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "module" ) ) )
+ {
+ if ( xAttributes.is() )
+ {
+ ::rtl::OUString aName = xAttributes->getValueByUidName(
+ m_pImport->XMLNS_UID,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "name" ) ) );
+
+ if ( m_xLib.is() && aName.getLength() )
+ xElement.set( new BasicModuleElement( rLocalName, xAttributes, this, m_pImport, m_xLib, aName ) );
+ }
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "expected module element!" ) ),
+ Reference< XInterface >(), Any() );
+ }
+
+ return xElement;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void BasicEmbeddedLibraryElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ if ( m_xLibContainer.is() && m_xLibContainer->hasByName( m_aLibName ) && m_bReadOnly )
+ m_xLibContainer->setLibraryReadOnly( m_aLibName, m_bReadOnly );
+ }
+
+
+ // =============================================================================
+ // BasicModuleElement
+ // =============================================================================
+
+ BasicModuleElement::BasicModuleElement( const ::rtl::OUString& rLocalName,
+ const Reference< xml::input::XAttributes >& xAttributes,
+ BasicElementBase* pParent, BasicImport* pImport,
+ const Reference< container::XNameContainer >& rxLib, const ::rtl::OUString& rName )
+ :BasicElementBase( rLocalName, xAttributes, pParent, pImport )
+ ,m_xLib( rxLib )
+ ,m_aName( rName )
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+ // XElement
+ // -----------------------------------------------------------------------------
+
+ Reference< xml::input::XElement > BasicModuleElement::startChildElement(
+ sal_Int32 nUid, const ::rtl::OUString& rLocalName,
+ const Reference< xml::input::XAttributes >& xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ // TODO: <byte-code>
+
+ Reference< xml::input::XElement > xElement;
+
+ if ( nUid != m_pImport->XMLNS_UID )
+ {
+ throw xml::sax::SAXException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "illegal namespace!" ) ),
+ Reference< XInterface >(), Any() );
+ }
+ else if ( rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "source-code" ) ) )
+ {
+ // TODO: password protected libraries
+
+ if ( xAttributes.is() )
+ {
+ if ( m_xLib.is() && m_aName.getLength() )
+ xElement.set( new BasicSourceCodeElement( rLocalName, xAttributes, this, m_pImport, m_xLib, m_aName ) );
+ }
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "expected source-code element!" ) ),
+ Reference< XInterface >(), Any() );
+ }
+
+ return xElement;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void BasicModuleElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ }
+
+
+ // =============================================================================
+ // BasicSourceCodeElement
+ // =============================================================================
+
+ BasicSourceCodeElement::BasicSourceCodeElement( const ::rtl::OUString& rLocalName,
+ const Reference< xml::input::XAttributes >& xAttributes,
+ BasicElementBase* pParent, BasicImport* pImport,
+ const Reference< container::XNameContainer >& rxLib, const ::rtl::OUString& rName )
+ :BasicElementBase( rLocalName, xAttributes, pParent, pImport )
+ ,m_xLib( rxLib )
+ ,m_aName( rName )
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+ // XElement
+ // -----------------------------------------------------------------------------
+
+ void BasicSourceCodeElement::characters( const ::rtl::OUString& rChars )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ m_aBuffer.append( rChars );
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void BasicSourceCodeElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ try
+ {
+ if ( m_xLib.is() && m_aName.getLength() )
+ {
+ Any aElement;
+ aElement <<= m_aBuffer.makeStringAndClear();
+ m_xLib->insertByName( m_aName, aElement );
+ }
+ }
+ catch ( container::ElementExistException& e )
+ {
+ OSL_TRACE( "BasicSourceCodeElement::endElement: caught ElementExceptionExist reason %s",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ }
+ catch ( lang::IllegalArgumentException& e )
+ {
+ OSL_TRACE( "BasicSourceCodeElement::endElement: caught IllegalArgumentException reason %s",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ }
+ catch ( lang::WrappedTargetException& e )
+ {
+ OSL_TRACE( "BasicSourceCodeElement::endElement: caught WrappedTargetException reason %s",
+ ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ }
+ }
+
+
+ // =============================================================================
+ // BasicImport
+ // =============================================================================
+
+ BasicImport::BasicImport( const Reference< frame::XModel >& rxModel, sal_Bool bOasis )
+ :m_xModel( rxModel )
+ ,m_bOasis( bOasis )
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+
+ BasicImport::~BasicImport()
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+ // XRoot
+ // -----------------------------------------------------------------------------
+
+ void BasicImport::startDocument( const Reference< xml::input::XNamespaceMapping >& xNamespaceMapping )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ if ( xNamespaceMapping.is() )
+ {
+ ::rtl::OUString aURI;
+ if ( m_bOasis )
+ aURI = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_OOO_URI ) );
+ else
+ aURI = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_SCRIPT_URI ) );
+ XMLNS_UID = xNamespaceMapping->getUidByUri( aURI );
+ XMLNS_XLINK_UID = xNamespaceMapping->getUidByUri( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK_URI ) ) );
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void BasicImport::endDocument()
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+
+void BasicImport::processingInstruction( const ::rtl::OUString& /*rTarget*/, const ::rtl::OUString& /*rData*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+
+void BasicImport::setDocumentLocator( const Reference< xml::sax::XLocator >& /*xLocator*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Reference< xml::input::XElement > BasicImport::startRootElement( sal_Int32 nUid, const ::rtl::OUString& rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ Reference< xml::input::XElement > xElement;
+
+ if ( nUid != XMLNS_UID )
+ {
+ throw xml::sax::SAXException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "illegal namespace!" ) ),
+ Reference< XInterface >(), Any() );
+ }
+ else if ( rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "libraries" ) ) )
+ {
+ Reference< script::XLibraryContainer2 > xLibContainer;
+
+ // try the XEmbeddedScripts interface
+ Reference< document::XEmbeddedScripts > xDocumentScripts( m_xModel, UNO_QUERY );
+ if ( xDocumentScripts.is() )
+ xLibContainer.set( xDocumentScripts->getBasicLibraries().get() );
+
+ if ( !xLibContainer.is() )
+ {
+ // try the "BasicLibraries" property (old-style, for compatibility)
+ Reference< beans::XPropertySet > xPSet( m_xModel, UNO_QUERY );
+ if ( xPSet.is() )
+ xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ) >>= xLibContainer;
+ }
+
+ OSL_ENSURE( xLibContainer.is(), "BasicImport::startRootElement: nowhere to import to!" );
+
+ if ( xLibContainer.is() )
+ {
+ xElement.set( new BasicLibrariesElement( rLocalName, xAttributes, 0, this, xLibContainer ) );
+ }
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "illegal root element (expected libraries) given: " ) ) +
+ rLocalName, Reference< XInterface >(), Any() );
+ }
+
+ return xElement;
+ }
+
+
+ // =============================================================================
+ // component operations
+ // =============================================================================
+
+ ::rtl::OUString getImplementationName_XMLBasicImporter()
+ {
+ static ::rtl::OUString* pImplName = 0;
+ if ( !pImplName )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pImplName )
+ {
+ static ::rtl::OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.xmlscript.XMLBasicImporter" ) );
+ pImplName = &aImplName;
+ }
+ }
+ return *pImplName;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Sequence< ::rtl::OUString > getSupportedServiceNames_XMLBasicImporter()
+ {
+ static Sequence< ::rtl::OUString >* pNames = 0;
+ if ( !pNames )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pNames )
+ {
+ static Sequence< ::rtl::OUString > aNames(1);
+ aNames.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.XMLBasicImporter" ) );
+ pNames = &aNames;
+ }
+ }
+ return *pNames;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ ::rtl::OUString getImplementationName_XMLOasisBasicImporter()
+ {
+ static ::rtl::OUString* pImplName = 0;
+ if ( !pImplName )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pImplName )
+ {
+ static ::rtl::OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.xmlscript.XMLOasisBasicImporter" ) );
+ pImplName = &aImplName;
+ }
+ }
+ return *pImplName;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Sequence< ::rtl::OUString > getSupportedServiceNames_XMLOasisBasicImporter()
+ {
+ static Sequence< ::rtl::OUString >* pNames = 0;
+ if ( !pNames )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pNames )
+ {
+ static Sequence< ::rtl::OUString > aNames(1);
+ aNames.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.XMLOasisBasicImporter" ) );
+ pNames = &aNames;
+ }
+ }
+ return *pNames;
+ }
+
+
+ // =============================================================================
+ // XMLBasicImporterBase
+ // =============================================================================
+
+ XMLBasicImporterBase::XMLBasicImporterBase( const Reference< XComponentContext >& rxContext, sal_Bool bOasis )
+ :m_xContext( rxContext )
+ ,m_bOasis( bOasis )
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+
+ XMLBasicImporterBase::~XMLBasicImporterBase()
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+ // XServiceInfo
+ // -----------------------------------------------------------------------------
+
+ sal_Bool XMLBasicImporterBase::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pNames + aNames.getLength();
+ for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
+ ;
+
+ return pNames != pEnd;
+ }
+
+ // -----------------------------------------------------------------------------
+ // XImporter
+ // -----------------------------------------------------------------------------
+
+ void XMLBasicImporterBase::setTargetDocument( const Reference< XComponent >& rxDoc )
+ throw (IllegalArgumentException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ m_xModel.set( rxDoc, UNO_QUERY );
+
+ if ( !m_xModel.is() )
+ {
+ throw IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMLBasicExporter::setTargetDocument: no document model!" ) ),
+ Reference< XInterface >(), 1 );
+ }
+
+ if ( m_xContext.is() )
+ {
+ Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() );
+ if ( xSMgr.is() )
+ {
+ Reference < xml::input::XRoot > xRoot( new BasicImport( m_xModel, m_bOasis ) );
+ Sequence < Any > aArgs( 1 );
+ aArgs[0] <<= xRoot;
+ m_xHandler.set( xSMgr->createInstanceWithArgumentsAndContext(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.input.SaxDocumentHandler" ) ),
+ aArgs, m_xContext ), UNO_QUERY );
+ }
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ // XDocumentHandler
+ // -----------------------------------------------------------------------------
+
+ void XMLBasicImporterBase::startDocument()
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_xHandler.is() )
+ m_xHandler->startDocument();
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void XMLBasicImporterBase::endDocument()
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_xHandler.is() )
+ m_xHandler->endDocument();
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void XMLBasicImporterBase::startElement( const ::rtl::OUString& aName,
+ const Reference< xml::sax::XAttributeList >& xAttribs )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_xHandler.is() )
+ m_xHandler->startElement( aName, xAttribs );
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void XMLBasicImporterBase::endElement( const ::rtl::OUString& aName )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_xHandler.is() )
+ m_xHandler->endElement( aName );
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void XMLBasicImporterBase::characters( const ::rtl::OUString& aChars )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_xHandler.is() )
+ m_xHandler->characters( aChars );
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void XMLBasicImporterBase::ignorableWhitespace( const ::rtl::OUString& aWhitespaces )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_xHandler.is() )
+ m_xHandler->ignorableWhitespace( aWhitespaces );
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void XMLBasicImporterBase::processingInstruction( const ::rtl::OUString& aTarget,
+ const ::rtl::OUString& aData )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_xHandler.is() )
+ m_xHandler->processingInstruction( aTarget, aData );
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void XMLBasicImporterBase::setDocumentLocator( const Reference< xml::sax::XLocator >& xLocator )
+ throw (xml::sax::SAXException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_xHandler.is() )
+ m_xHandler->setDocumentLocator( xLocator );
+ }
+
+
+ // =============================================================================
+ // XMLBasicImporter
+ // =============================================================================
+
+ XMLBasicImporter::XMLBasicImporter( const Reference< XComponentContext >& rxContext )
+ :XMLBasicImporterBase( rxContext, sal_False )
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+
+ XMLBasicImporter::~XMLBasicImporter()
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+ // XServiceInfo
+ // -----------------------------------------------------------------------------
+
+ ::rtl::OUString XMLBasicImporter::getImplementationName( ) throw (RuntimeException)
+ {
+ return getImplementationName_XMLBasicImporter();
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Sequence< ::rtl::OUString > XMLBasicImporter::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ return getSupportedServiceNames_XMLBasicImporter();
+ }
+
+
+ // =============================================================================
+ // XMLOasisBasicImporter
+ // =============================================================================
+
+ XMLOasisBasicImporter::XMLOasisBasicImporter( const Reference< XComponentContext >& rxContext )
+ :XMLBasicImporterBase( rxContext, sal_True )
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+
+ XMLOasisBasicImporter::~XMLOasisBasicImporter()
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+ // XServiceInfo
+ // -----------------------------------------------------------------------------
+
+ ::rtl::OUString XMLOasisBasicImporter::getImplementationName( ) throw (RuntimeException)
+ {
+ return getImplementationName_XMLOasisBasicImporter();
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Sequence< ::rtl::OUString > XMLOasisBasicImporter::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ return getSupportedServiceNames_XMLOasisBasicImporter();
+ }
+
+
+ // =============================================================================
+ // component operations
+ // =============================================================================
+
+ Reference< XInterface > SAL_CALL create_XMLBasicImporter(
+ Reference< XComponentContext > const & xContext )
+ SAL_THROW( () )
+ {
+ return static_cast< lang::XTypeProvider * >( new XMLBasicImporter( xContext ) );
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Reference< XInterface > SAL_CALL create_XMLOasisBasicImporter(
+ Reference< XComponentContext > const & xContext )
+ SAL_THROW( () )
+ {
+ return static_cast< lang::XTypeProvider * >( new XMLOasisBasicImporter( xContext ) );
+ }
+
+ // -----------------------------------------------------------------------------
+
+//.........................................................................
+} // namespace xmlscript
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx b/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx
new file mode 100644
index 000000000000..96567f3e2eb5
--- /dev/null
+++ b/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx
@@ -0,0 +1,348 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef XMLSCRIPT_XMLBAS_IMPORT_HXX
+#define XMLSCRIPT_XMLBAS_IMPORT_HXX
+
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/script/XLibraryContainer2.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/xml/input/XRoot.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/ustrbuf.hxx>
+
+
+//.........................................................................
+namespace xmlscript
+{
+//.........................................................................
+
+ // =============================================================================
+ // class BasicElementBase
+ // =============================================================================
+
+ class BasicImport;
+
+ typedef ::cppu::WeakImplHelper1<
+ ::com::sun::star::xml::input::XElement > BasicElementBase_BASE;
+
+ class BasicElementBase : public BasicElementBase_BASE
+ {
+ protected:
+ BasicImport* m_pImport;
+ BasicElementBase* m_pParent;
+ ::rtl::OUString m_aLocalName;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes > m_xAttributes;
+
+ bool getBoolAttr( sal_Bool* pRet, const ::rtl::OUString& rAttrName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes,
+ sal_Int32 nUid );
+
+ public:
+ BasicElementBase( const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes,
+ BasicElementBase* pParent, BasicImport* pImport );
+ virtual ~BasicElementBase();
+
+ // XElement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XElement > SAL_CALL getParent()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getLocalName()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getUid()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes > SAL_CALL getAttributes()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XElement > SAL_CALL startChildElement(
+ sal_Int32 nUid, const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL characters( const ::rtl::OUString& rChars )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL ignorableWhitespace(
+ const ::rtl::OUString& rWhitespaces )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL processingInstruction(
+ const ::rtl::OUString& rTarget, const ::rtl::OUString& rData )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ };
+
+
+ // =============================================================================
+ // class BasicLibrariesElement
+ // =============================================================================
+
+ class BasicLibrariesElement : public BasicElementBase
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer2 > m_xLibContainer;
+
+ public:
+ BasicLibrariesElement( const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes,
+ BasicElementBase* pParent, BasicImport* pImport,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer2 >& rxLibContainer );
+
+ // XElement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XElement > SAL_CALL startChildElement(
+ sal_Int32 nUid, const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ };
+
+
+ // =============================================================================
+ // class BasicEmbeddedLibraryElement
+ // =============================================================================
+
+ class BasicEmbeddedLibraryElement : public BasicElementBase
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer2 > m_xLibContainer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xLib;
+ ::rtl::OUString m_aLibName;
+ bool m_bReadOnly;
+
+ public:
+ BasicEmbeddedLibraryElement( const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes,
+ BasicElementBase* pParent, BasicImport* pImport,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer2 >& rxLibContainer,
+ const ::rtl::OUString& rLibName, bool bReadOnly );
+
+ // XElement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XElement > SAL_CALL startChildElement(
+ sal_Int32 nUid, const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ };
+
+
+ // =============================================================================
+ // class BasicModuleElement
+ // =============================================================================
+
+ class BasicModuleElement : public BasicElementBase
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xLib;
+ ::rtl::OUString m_aName;
+
+ public:
+ BasicModuleElement( const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes,
+ BasicElementBase* pParent, BasicImport* pImport,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxLib,
+ const ::rtl::OUString& rName );
+
+ // XElement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XElement > SAL_CALL startChildElement(
+ sal_Int32 nUid, const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ };
+
+
+ // =============================================================================
+ // class BasicSourceCodeElement
+ // =============================================================================
+
+ class BasicSourceCodeElement : public BasicElementBase
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xLib;
+ ::rtl::OUString m_aName;
+ ::rtl::OUStringBuffer m_aBuffer;
+
+ public:
+ BasicSourceCodeElement( const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes,
+ BasicElementBase* pParent, BasicImport* pImport,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxLib,
+ const ::rtl::OUString& rName );
+
+ // XElement
+ virtual void SAL_CALL characters( const ::rtl::OUString& rChars )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ };
+
+
+ // =============================================================================
+ // class BasicImport
+ // =============================================================================
+
+ typedef ::cppu::WeakImplHelper1<
+ ::com::sun::star::xml::input::XRoot > BasicImport_BASE;
+
+ class BasicImport : public BasicImport_BASE
+ {
+ friend class BasicElementBase;
+ friend class BasicLibrariesElement;
+ friend class BasicEmbeddedLibraryElement;
+ friend class BasicModuleElement;
+
+ private:
+ sal_Int32 XMLNS_UID;
+ sal_Int32 XMLNS_XLINK_UID;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
+ sal_Bool m_bOasis;
+
+ public:
+ BasicImport( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel, sal_Bool bOasis );
+ virtual ~BasicImport();
+
+ // XRoot
+ virtual void SAL_CALL startDocument(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XNamespaceMapping >& xNamespaceMapping )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL endDocument()
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL processingInstruction(
+ const ::rtl::OUString& rTarget, const ::rtl::OUString& rData )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDocumentLocator(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XElement > SAL_CALL startRootElement(
+ sal_Int32 nUid, const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ };
+
+
+ // =============================================================================
+ // class XMLBasicImporterBase
+ // =============================================================================
+
+ typedef ::cppu::WeakImplHelper3<
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::document::XImporter,
+ ::com::sun::star::xml::sax::XDocumentHandler > XMLBasicImporterBase_BASE;
+
+ class XMLBasicImporterBase : public XMLBasicImporterBase_BASE
+ {
+ private:
+ ::osl::Mutex m_aMutex;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xHandler;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
+ sal_Bool m_bOasis;
+
+ public:
+ XMLBasicImporterBase(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, sal_Bool bOasis );
+ virtual ~XMLBasicImporterBase();
+
+ // XServiceInfo
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XImporter
+ virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& rxDoc )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument()
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL endDocument()
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL startElement( const ::rtl::OUString& aName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL endElement( const ::rtl::OUString& aName )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL characters( const ::rtl::OUString& aChars )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator )
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ };
+
+
+ // =============================================================================
+ // class XMLBasicImporter
+ // =============================================================================
+
+ class XMLBasicImporter : public XMLBasicImporterBase
+ {
+ public:
+ XMLBasicImporter(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
+ virtual ~XMLBasicImporter();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+ };
+
+
+ // =============================================================================
+ // class XMLOasisBasicImporter
+ // =============================================================================
+
+ class XMLOasisBasicImporter : public XMLBasicImporterBase
+ {
+ public:
+ XMLOasisBasicImporter(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
+ virtual ~XMLOasisBasicImporter();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+ };
+
+//.........................................................................
+} // namespace xmlscript
+//.........................................................................
+
+#endif // XMLSCRIPT_XMLBAS_IMPORT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmllib_imexp/imp_share.hxx b/xmlscript/source/xmllib_imexp/imp_share.hxx
new file mode 100644
index 000000000000..a3728cb4488b
--- /dev/null
+++ b/xmlscript/source/xmllib_imexp/imp_share.hxx
@@ -0,0 +1,266 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <xmlscript/xmllib_imexp.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+
+#include <com/sun/star/xml/input/XRoot.hpp>
+
+#include <vector>
+
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+
+
+using namespace ::rtl;
+using namespace ::std;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace xmlscript
+{
+//
+inline sal_Int32 toInt32( OUString const & rStr ) SAL_THROW( () )
+{
+ sal_Int32 nVal;
+ if (rStr.getLength() > 2 && rStr[ 0 ] == '0' && rStr[ 1 ] == 'x')
+ {
+ nVal = rStr.copy( 2 ).toInt32( 16 );
+ }
+ else
+ {
+ nVal = rStr.toInt32();
+ }
+ return nVal;
+}
+inline bool getBoolAttr(
+ sal_Bool * pRet, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes, sal_Int32 uid )
+{
+ OUString aValue(
+ xAttributes->getValueByUidName( uid, rAttrName ) );
+ if (aValue.getLength())
+ {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("true") ))
+ {
+ *pRet = sal_True;
+ return true;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("false") ))
+ {
+ *pRet = sal_False;
+ return true;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ rAttrName +
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ ": no boolean value (true|false)!") ),
+ Reference< XInterface >(), Any() );
+ }
+ }
+ return false;
+}
+
+inline bool getStringAttr(
+ OUString * pRet, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes, sal_Int32 uid )
+{
+ *pRet = xAttributes->getValueByUidName( uid, rAttrName );
+ return (pRet->getLength() > 0);
+}
+
+inline bool getLongAttr(
+ sal_Int32 * pRet, OUString const & rAttrName,
+ Reference< xml::input::XAttributes > const & xAttributes,
+ sal_Int32 uid )
+{
+ OUString aValue(
+ xAttributes->getValueByUidName( uid, rAttrName ) );
+ if (aValue.getLength())
+ {
+ *pRet = toInt32( aValue );
+ return true;
+ }
+ return false;
+}
+
+//==================================================================================================
+// Library import
+
+//==================================================================================================
+struct LibraryImport
+ : public ::cppu::WeakImplHelper1< xml::input::XRoot >
+{
+ friend class LibrariesElement;
+ friend class LibraryElement;
+
+ LibDescriptorArray* mpLibArray;
+ LibDescriptor* mpLibDesc; // Single library mode
+
+ sal_Int32 XMLNS_LIBRARY_UID;
+ sal_Int32 XMLNS_XLINK_UID;
+
+public:
+ inline LibraryImport( LibDescriptorArray* pLibArray )
+ SAL_THROW( () )
+ : mpLibArray( pLibArray )
+ , mpLibDesc( NULL ) {}
+ // Single library mode
+ inline LibraryImport( LibDescriptor* pLibDesc )
+ SAL_THROW( () )
+ : mpLibArray( NULL )
+ , mpLibDesc( pLibDesc ) {}
+ virtual ~LibraryImport()
+ SAL_THROW( () );
+
+ // XRoot
+ virtual void SAL_CALL startDocument(
+ Reference< xml::input::XNamespaceMapping > const & xNamespaceMapping )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL endDocument()
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL processingInstruction(
+ OUString const & rTarget, OUString const & rData )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL setDocumentLocator(
+ Reference< xml::sax::XLocator > const & xLocator )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual Reference< xml::input::XElement > SAL_CALL startRootElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException);
+};
+
+//==================================================================================================
+class LibElementBase
+ : public ::cppu::WeakImplHelper1< xml::input::XElement >
+{
+protected:
+ LibraryImport * _pImport;
+ LibElementBase * _pParent;
+
+ OUString _aLocalName;
+ Reference< xml::input::XAttributes > _xAttributes;
+
+public:
+ LibElementBase(
+ OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes,
+ LibElementBase * pParent, LibraryImport * pImport )
+ SAL_THROW( () );
+ virtual ~LibElementBase()
+ SAL_THROW( () );
+
+ // XElement
+ virtual Reference< xml::input::XElement > SAL_CALL getParent()
+ throw (RuntimeException);
+ virtual OUString SAL_CALL getLocalName()
+ throw (RuntimeException);
+ virtual sal_Int32 SAL_CALL getUid()
+ throw (RuntimeException);
+ virtual Reference< xml::input::XAttributes > SAL_CALL getAttributes()
+ throw (RuntimeException);
+ virtual void SAL_CALL ignorableWhitespace(
+ OUString const & rWhitespaces )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL characters( OUString const & rChars )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL processingInstruction(
+ OUString const & rTarget, OUString const & rData )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual Reference< xml::input::XElement > SAL_CALL startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException);
+};
+
+//==================================================================================================
+
+class LibrariesElement : public LibElementBase
+{
+ friend class LibraryElement;
+
+protected:
+ vector< LibDescriptor > mLibDescriptors;
+
+public:
+ virtual Reference< xml::input::XElement > SAL_CALL startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (xml::sax::SAXException, RuntimeException);
+
+ LibrariesElement(
+ OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes,
+ LibElementBase * pParent, LibraryImport * pImport )
+ SAL_THROW( () )
+ : LibElementBase( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+//==================================================================================================
+
+class LibraryElement : public LibElementBase
+{
+protected:
+ vector< OUString > mElements;
+
+public:
+
+ virtual Reference< xml::input::XElement > SAL_CALL startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (xml::sax::SAXException, RuntimeException);
+
+ LibraryElement(
+ OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes,
+ LibElementBase * pParent, LibraryImport * pImport )
+ SAL_THROW( () )
+ : LibElementBase( rLocalName, xAttributes, pParent, pImport )
+ {}
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmllib_imexp/makefile.mk b/xmlscript/source/xmllib_imexp/makefile.mk
new file mode 100644
index 000000000000..c6ef65a43393
--- /dev/null
+++ b/xmlscript/source/xmllib_imexp/makefile.mk
@@ -0,0 +1,50 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=xmlscript
+TARGET=xmllib_imexp
+NO_BSYMBOLIC=TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
+#-----------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/xmllib_import.obj \
+ $(SLO)$/xmllib_export.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/target.pmk
+
+.ENDIF # L10N_framework
+
+.INCLUDE : target.mk
diff --git a/xmlscript/source/xmllib_imexp/xmllib_export.cxx b/xmlscript/source/xmllib_imexp/xmllib_export.cxx
new file mode 100644
index 000000000000..d731fed9f10b
--- /dev/null
+++ b/xmlscript/source/xmllib_imexp/xmllib_export.cxx
@@ -0,0 +1,178 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+
+#include <xmlscript/xmllib_imexp.hxx>
+#include <xmlscript/xml_helper.hxx>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star;
+using namespace rtl;
+
+namespace xmlscript
+{
+
+static OUString aTrueStr ( RTL_CONSTASCII_USTRINGPARAM("true") );
+static OUString aFalseStr( RTL_CONSTASCII_USTRINGPARAM("false") );
+
+//##################################################################################################
+
+
+//==================================================================================================
+
+void
+SAL_CALL exportLibraryContainer(
+ Reference< xml::sax::XExtendedDocumentHandler > const & xOut,
+ const LibDescriptorArray* pLibArray )
+ SAL_THROW( (Exception) )
+{
+ xOut->startDocument();
+
+ OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM(
+ "<!DOCTYPE library:libraries PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
+ " \"libraries.dtd\">" ) );
+ xOut->unknown( aDocTypeStr );
+ xOut->ignorableWhitespace( OUString() );
+
+
+ OUString aLibrariesName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":libraries") );
+ XMLElement* pLibsElement = new XMLElement( aLibrariesName );
+ Reference< xml::sax::XAttributeList > xAttributes( pLibsElement );
+
+ pLibsElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_LIBRARY_PREFIX) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_URI) ) );
+ pLibsElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_XLINK_PREFIX) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_XLINK_URI) ) );
+
+
+ xOut->ignorableWhitespace( OUString() );
+ xOut->startElement( aLibrariesName, xAttributes );
+
+ int nLibCount = pLibArray->mnLibCount;
+ for( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+ {
+ LibDescriptor& rLib = pLibArray->mpLibs[i];
+
+ OUString aLibraryName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":library") );
+ XMLElement* pLibElement = new XMLElement( aLibraryName );
+ Reference< xml::sax::XAttributeList > xLibElementAttribs;
+ xLibElementAttribs = static_cast< xml::sax::XAttributeList* >( pLibElement );
+
+ pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":name") ),
+ rLib.aName );
+
+
+ if( rLib.aStorageURL.getLength() )
+ {
+ pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_XLINK_PREFIX ":href") ),
+ rLib.aStorageURL );
+ pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_XLINK_PREFIX ":type") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("simple") ) );
+ }
+
+ pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":link") ),
+ rLib.bLink ? aTrueStr : aFalseStr );
+
+ if( rLib.bLink )
+ {
+ pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":readonly") ),
+ rLib.bReadOnly ? aTrueStr : aFalseStr );
+ }
+
+ pLibElement->dump( xOut.get() );
+ }
+
+ xOut->ignorableWhitespace( OUString() );
+ xOut->endElement( aLibrariesName );
+
+ xOut->endDocument();
+}
+
+//==================================================================================================
+
+void
+SAL_CALL exportLibrary(
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler > const & xOut,
+ const LibDescriptor& rLib )
+ SAL_THROW( (::com::sun::star::uno::Exception) )
+{
+ xOut->startDocument();
+
+ OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM(
+ "<!DOCTYPE library:library PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
+ " \"library.dtd\">" ) );
+ xOut->unknown( aDocTypeStr );
+ xOut->ignorableWhitespace( OUString() );
+
+
+ OUString aLibraryName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":library") );
+ XMLElement* pLibElement = new XMLElement( aLibraryName );
+ Reference< xml::sax::XAttributeList > xAttributes( pLibElement );
+
+ pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_LIBRARY_PREFIX) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_URI) ) );
+
+ pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":name") ),
+ rLib.aName );
+
+ pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":readonly") ),
+ rLib.bReadOnly ? aTrueStr : aFalseStr );
+
+ pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":passwordprotected") ),
+ rLib.bPasswordProtected ? aTrueStr : aFalseStr );
+
+ if( rLib.bPreload )
+ pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":preload") ), aTrueStr );
+
+ sal_Int32 nElementCount = rLib.aElementNames.getLength();
+ if( nElementCount )
+ {
+ const OUString* pElementNames = rLib.aElementNames.getConstArray();
+ for( sal_Int32 i = 0 ; i < nElementCount ; i++ )
+ {
+ XMLElement* pElement = new XMLElement( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":element" ) ) );
+ Reference< xml::sax::XAttributeList > xElementAttribs;
+ xElementAttribs = static_cast< xml::sax::XAttributeList* >( pElement );
+
+ pElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":name") ),
+ pElementNames[i] );
+
+ pLibElement->addSubElement( pElement );
+ }
+ }
+
+ pLibElement->dump( xOut.get() );
+
+ xOut->endDocument();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmllib_imexp/xmllib_import.cxx b/xmlscript/source/xmllib_imexp/xmllib_import.cxx
new file mode 100644
index 000000000000..a1fd0fff2b2f
--- /dev/null
+++ b/xmlscript/source/xmllib_imexp/xmllib_import.cxx
@@ -0,0 +1,375 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+#include "imp_share.hxx"
+
+#include <osl/diagnose.h>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <xmlscript/xml_import.hxx>
+#include <comphelper/processfactory.hxx>
+
+
+namespace xmlscript
+{
+
+//##################################################################################################
+
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > LibElementBase::getParent()
+ throw (RuntimeException)
+{
+ return static_cast< xml::input::XElement * >( _pParent );
+}
+//__________________________________________________________________________________________________
+OUString LibElementBase::getLocalName()
+ throw (RuntimeException)
+{
+ return _aLocalName;
+}
+//__________________________________________________________________________________________________
+sal_Int32 LibElementBase::getUid()
+ throw (RuntimeException)
+{
+ return _pImport->XMLNS_LIBRARY_UID;
+}
+//__________________________________________________________________________________________________
+Reference< xml::input::XAttributes > LibElementBase::getAttributes()
+ throw (RuntimeException)
+{
+ return _xAttributes;
+}
+//__________________________________________________________________________________________________
+void LibElementBase::ignorableWhitespace(
+ OUString const & /*rWhitespaces*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+}
+//__________________________________________________________________________________________________
+void LibElementBase::characters( OUString const & /*rChars*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // not used, all characters ignored
+}
+
+//__________________________________________________________________________________________________
+void LibElementBase::processingInstruction(
+ OUString const & /*rTarget*/, OUString const & /*rData*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+}
+
+//__________________________________________________________________________________________________
+void LibElementBase::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+}
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > LibElementBase::startChildElement(
+ sal_Int32 /*nUid*/, OUString const & /*rLocalName*/,
+ Reference< xml::input::XAttributes > const & /*xAttributes*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("unexpected element!") ),
+ Reference< XInterface >(), Any() );
+}
+
+//__________________________________________________________________________________________________
+LibElementBase::LibElementBase(
+ OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes,
+ LibElementBase * pParent, LibraryImport * pImport )
+ SAL_THROW( () )
+ : _pImport( pImport )
+ , _pParent( pParent )
+ , _aLocalName( rLocalName )
+ , _xAttributes( xAttributes )
+{
+ _pImport->acquire();
+
+ if (_pParent)
+ {
+ _pParent->acquire();
+ }
+}
+//__________________________________________________________________________________________________
+LibElementBase::~LibElementBase()
+ SAL_THROW( () )
+{
+ _pImport->release();
+
+ if (_pParent)
+ {
+ _pParent->release();
+ }
+
+#if OSL_DEBUG_LEVEL > 1
+ OString aStr( OUStringToOString( _aLocalName, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "LibElementBase::~LibElementBase(): %s\n", aStr.getStr() );
+#endif
+}
+
+//##################################################################################################
+
+// XRoot
+
+//______________________________________________________________________________
+void LibraryImport::startDocument(
+ Reference< xml::input::XNamespaceMapping > const & xNamespaceMapping )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ XMLNS_LIBRARY_UID = xNamespaceMapping->getUidByUri(
+ OUSTR(XMLNS_LIBRARY_URI) );
+ XMLNS_XLINK_UID = xNamespaceMapping->getUidByUri(
+ OUSTR(XMLNS_XLINK_URI) );
+}
+//__________________________________________________________________________________________________
+void LibraryImport::endDocument()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+}
+//__________________________________________________________________________________________________
+void LibraryImport::processingInstruction(
+ OUString const & /*rTarget*/, OUString const & /*rData*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+}
+//__________________________________________________________________________________________________
+void LibraryImport::setDocumentLocator(
+ Reference< xml::sax::XLocator > const & /*xLocator*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+}
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > LibraryImport::startRootElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ if (XMLNS_LIBRARY_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ else if (mpLibArray && rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("libraries") ))
+ {
+ return new LibrariesElement( rLocalName, xAttributes, 0, this );
+ }
+ else if (mpLibDesc && rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("library") ))
+ {
+ LibDescriptor& aDesc = *mpLibDesc;
+ aDesc.bLink = aDesc.bReadOnly = aDesc.bPasswordProtected = aDesc.bPreload = sal_False;
+
+ aDesc.aName = xAttributes->getValueByUidName(
+ XMLNS_LIBRARY_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("name") ) );
+ getBoolAttr(
+ &aDesc.bReadOnly,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ), xAttributes,
+ XMLNS_LIBRARY_UID );
+ getBoolAttr(
+ &aDesc.bPasswordProtected,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("passwordprotected") ),
+ xAttributes, XMLNS_LIBRARY_UID );
+ getBoolAttr(
+ &aDesc.bPreload,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("preload") ),
+ xAttributes, XMLNS_LIBRARY_UID );
+
+ return new LibraryElement( rLocalName, xAttributes, 0, this );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal root element (expected libraries) given: ") ) +
+ rLocalName, Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+LibraryImport::~LibraryImport()
+ SAL_THROW( () )
+{
+#if OSL_DEBUG_LEVEL > 1
+ OSL_TRACE( "LibraryImport::~LibraryImport().\n" );
+#endif
+}
+
+//##################################################################################################
+
+
+// libraries
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > LibrariesElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ if (_pImport->XMLNS_LIBRARY_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // library
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("library") ))
+ {
+ LibDescriptor aDesc;
+ aDesc.bLink = aDesc.bReadOnly = aDesc.bPasswordProtected = aDesc.bPreload = sal_False;
+
+ aDesc.aName = xAttributes->getValueByUidName(
+ _pImport->XMLNS_LIBRARY_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("name") ) );
+ aDesc.aStorageURL = xAttributes->getValueByUidName(
+ _pImport->XMLNS_XLINK_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("href") ) );
+ getBoolAttr(
+ &aDesc.bLink,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("link") ),
+ xAttributes, _pImport->XMLNS_LIBRARY_UID );
+ getBoolAttr(
+ &aDesc.bReadOnly,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("readonly") ),
+ xAttributes, _pImport->XMLNS_LIBRARY_UID );
+ getBoolAttr(
+ &aDesc.bPasswordProtected,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("passwordprotected") ),
+ xAttributes, _pImport->XMLNS_LIBRARY_UID );
+
+ mLibDescriptors.push_back( aDesc );
+ return new LibraryElement( rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected styles ot bulletinboard element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void LibrariesElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ sal_Int32 nLibCount = _pImport->mpLibArray->mnLibCount = (sal_Int32)mLibDescriptors.size();
+ _pImport->mpLibArray->mpLibs = new LibDescriptor[ nLibCount ];
+
+ for( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+ {
+ const LibDescriptor& rLib = mLibDescriptors[i];
+ _pImport->mpLibArray->mpLibs[i] = rLib;
+ }
+}
+
+// library
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > LibraryElement::startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ if (_pImport->XMLNS_LIBRARY_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // library
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("element") ))
+ {
+ OUString aValue( xAttributes->getValueByUidName(
+ _pImport->XMLNS_LIBRARY_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("name") ) ) );
+ if (aValue.getLength())
+ mElements.push_back( aValue );
+
+ return new LibElementBase( rLocalName, xAttributes, this, _pImport );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("expected styles ot bulletinboard element!") ),
+ Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+void LibraryElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ sal_Int32 nElementCount = mElements.size();
+ Sequence< OUString > aElementNames( nElementCount );
+ OUString* pElementNames = aElementNames.getArray();
+ for( sal_Int32 i = 0 ; i < nElementCount ; i++ )
+ pElementNames[i] = mElements[i];
+
+ LibDescriptor* pLib = _pImport->mpLibDesc;
+ if( !pLib )
+ pLib = &static_cast< LibrariesElement* >( _pParent )->mLibDescriptors.back();
+ pLib->aElementNames = aElementNames;
+}
+
+
+//##################################################################################################
+
+Reference< ::com::sun::star::xml::sax::XDocumentHandler >
+SAL_CALL importLibraryContainer( LibDescriptorArray* pLibArray )
+ SAL_THROW( (Exception) )
+{
+ return ::xmlscript::createDocumentHandler(
+ static_cast< xml::input::XRoot * >( new LibraryImport( pLibArray ) ) );
+}
+
+//##################################################################################################
+
+::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >
+SAL_CALL importLibrary( LibDescriptor& rLib )
+ SAL_THROW( (::com::sun::star::uno::Exception) )
+{
+ return ::xmlscript::createDocumentHandler(
+ static_cast< xml::input::XRoot * >( new LibraryImport( &rLib ) ) );
+}
+
+
+//##################################################################################################
+
+LibDescriptorArray::LibDescriptorArray( sal_Int32 nLibCount )
+{
+ mnLibCount = nLibCount;
+ mpLibs = new LibDescriptor[ mnLibCount ];
+}
+
+LibDescriptorArray::~LibDescriptorArray()
+{
+ delete[] mpLibs;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmlmod_imexp/imp_share.hxx b/xmlscript/source/xmlmod_imexp/imp_share.hxx
new file mode 100644
index 000000000000..3e63aa7a4e3e
--- /dev/null
+++ b/xmlscript/source/xmlmod_imexp/imp_share.hxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <xmlscript/xmlmod_imexp.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/ustrbuf.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+
+#include <com/sun/star/xml/input/XRoot.hpp>
+
+#include <vector>
+
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+
+
+using namespace ::rtl;
+using namespace ::std;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace xmlscript
+{
+
+//==================================================================================================
+// Script module import
+
+//==================================================================================================
+struct ModuleImport
+ : public ::cppu::WeakImplHelper1< xml::input::XRoot >
+{
+ friend class ModuleElement;
+
+ ModuleDescriptor& mrModuleDesc;
+
+ sal_Int32 XMLNS_SCRIPT_UID;
+ sal_Int32 XMLNS_LIBRARY_UID;
+ sal_Int32 XMLNS_XLINK_UID;
+
+public:
+ inline ModuleImport( ModuleDescriptor& rModuleDesc )
+ SAL_THROW( () )
+ : mrModuleDesc( rModuleDesc ) {}
+ virtual ~ModuleImport()
+ SAL_THROW( () );
+
+ // XRoot
+ virtual void SAL_CALL startDocument(
+ Reference< xml::input::XNamespaceMapping > const & xNamespaceMapping )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL endDocument()
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL processingInstruction(
+ OUString const & rTarget, OUString const & rData )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL setDocumentLocator(
+ Reference< xml::sax::XLocator > const & xLocator )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual Reference< xml::input::XElement > SAL_CALL startRootElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException);
+};
+
+//==================================================================================================
+class ModuleElement
+ : public ::cppu::WeakImplHelper1< xml::input::XElement >
+{
+protected:
+ ModuleImport * _pImport;
+ ModuleElement * _pParent;
+
+ OUString _aLocalName;
+ Reference< xml::input::XAttributes > _xAttributes;
+ ::rtl::OUStringBuffer _StrBuffer;
+
+public:
+ ModuleElement(
+ OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes,
+ ModuleElement * pParent, ModuleImport * pImport )
+ SAL_THROW( () );
+ virtual ~ModuleElement()
+ SAL_THROW( () );
+
+ // XElement
+ virtual Reference< xml::input::XElement > SAL_CALL getParent()
+ throw (RuntimeException);
+ virtual OUString SAL_CALL getLocalName()
+ throw (RuntimeException);
+ virtual sal_Int32 SAL_CALL getUid()
+ throw (RuntimeException);
+ virtual Reference< xml::input::XAttributes > SAL_CALL getAttributes()
+ throw (RuntimeException);
+ virtual void SAL_CALL ignorableWhitespace(
+ OUString const & rWhitespaces )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL characters( OUString const & rChars )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL processingInstruction(
+ OUString const & rTarget, OUString const & rData )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual Reference< xml::input::XElement > SAL_CALL startChildElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException);
+};
+
+//==================================================================================================
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmlmod_imexp/makefile.mk b/xmlscript/source/xmlmod_imexp/makefile.mk
new file mode 100644
index 000000000000..174bf94c75ae
--- /dev/null
+++ b/xmlscript/source/xmlmod_imexp/makefile.mk
@@ -0,0 +1,49 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=xmlscript
+TARGET=xmlmod_imexp
+NO_BSYMBOLIC=TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
+#-----------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/xmlmod_import.obj \
+ $(SLO)$/xmlmod_export.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/target.pmk
+
+.ENDIF # L10N_framework
+.INCLUDE : target.mk
diff --git a/xmlscript/source/xmlmod_imexp/xmlmod_export.cxx b/xmlscript/source/xmlmod_imexp/xmlmod_export.cxx
new file mode 100644
index 000000000000..782e6d343818
--- /dev/null
+++ b/xmlscript/source/xmlmod_imexp/xmlmod_export.cxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+
+#include <xmlscript/xmlmod_imexp.hxx>
+#include <xmlscript/xml_helper.hxx>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star;
+using namespace rtl;
+
+namespace xmlscript
+{
+
+//==================================================================================================
+
+void
+SAL_CALL exportScriptModule(
+ Reference< xml::sax::XExtendedDocumentHandler > const & xOut,
+ const ModuleDescriptor& rMod )
+ SAL_THROW( (Exception) )
+{
+ xOut->startDocument();
+
+ OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM(
+ "<!DOCTYPE script:module PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
+ " \"module.dtd\">" ) );
+ xOut->unknown( aDocTypeStr );
+ xOut->ignorableWhitespace( OUString() );
+
+ OUString aModuleName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":module") );
+ XMLElement* pModElement = new XMLElement( aModuleName );
+ Reference< xml::sax::XAttributeList > xAttributes( pModElement );
+
+ pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_SCRIPT_PREFIX) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_URI) ) );
+
+ pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":name") ),
+ rMod.aName );
+ pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":language") ),
+ rMod.aLanguage );
+ if( rMod.aModuleType.getLength()>0 )
+ pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":moduleType") ),
+ rMod.aModuleType );
+
+ xOut->ignorableWhitespace( OUString() );
+ xOut->startElement( aModuleName, xAttributes );
+ xOut->characters( rMod.aCode );
+ xOut->endElement( aModuleName );
+ xOut->endDocument();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx b/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx
new file mode 100644
index 000000000000..efae2852eec6
--- /dev/null
+++ b/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx
@@ -0,0 +1,232 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+#include "imp_share.hxx"
+
+#include <osl/diagnose.h>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <xmlscript/xml_import.hxx>
+#include <comphelper/processfactory.hxx>
+
+
+namespace xmlscript
+{
+
+//##################################################################################################
+
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > ModuleElement::getParent()
+ throw (RuntimeException)
+{
+ return static_cast< xml::input::XElement * >( _pParent );
+}
+//__________________________________________________________________________________________________
+OUString ModuleElement::getLocalName()
+ throw (RuntimeException)
+{
+ return _aLocalName;
+}
+//__________________________________________________________________________________________________
+sal_Int32 ModuleElement::getUid()
+ throw (RuntimeException)
+{
+ return _pImport->XMLNS_SCRIPT_UID;
+}
+//__________________________________________________________________________________________________
+Reference< xml::input::XAttributes > ModuleElement::getAttributes()
+ throw (RuntimeException)
+{
+ return _xAttributes;
+}
+//__________________________________________________________________________________________________
+void ModuleElement::ignorableWhitespace(
+ OUString const & /*rWhitespaces*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // not used
+}
+//__________________________________________________________________________________________________
+void ModuleElement::characters( OUString const & rChars )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ _StrBuffer.append( rChars );
+}
+//__________________________________________________________________________________________________
+void ModuleElement::processingInstruction(
+ OUString const & /*rTarget*/, OUString const & /*rData*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+}
+//__________________________________________________________________________________________________
+void ModuleElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ _pImport->mrModuleDesc.aCode = _StrBuffer.makeStringAndClear();
+}
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > ModuleElement::startChildElement(
+ sal_Int32 /*nUid*/, OUString const & /*rLocalName*/,
+ Reference< xml::input::XAttributes > const & /*xAttributes*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("unexpected element!") ),
+ Reference< XInterface >(), Any() );
+}
+
+//__________________________________________________________________________________________________
+ModuleElement::ModuleElement(
+ OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes,
+ ModuleElement * pParent, ModuleImport * pImport )
+ SAL_THROW( () )
+ : _pImport( pImport )
+ , _pParent( pParent )
+ , _aLocalName( rLocalName )
+ , _xAttributes( xAttributes )
+{
+ _pImport->acquire();
+
+ if (_pParent)
+ {
+ _pParent->acquire();
+ }
+}
+//__________________________________________________________________________________________________
+ModuleElement::~ModuleElement()
+ SAL_THROW( () )
+{
+ _pImport->release();
+
+ if (_pParent)
+ {
+ _pParent->release();
+ }
+
+#if OSL_DEBUG_LEVEL > 1
+ OString aStr( OUStringToOString( _aLocalName, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "ModuleElement::~ModuleElement(): %s\n", aStr.getStr() );
+#endif
+}
+
+//##################################################################################################
+
+// XRoot
+
+//______________________________________________________________________________
+void ModuleImport::startDocument(
+ Reference< xml::input::XNamespaceMapping > const & xNamespaceMapping )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ XMLNS_SCRIPT_UID = xNamespaceMapping->getUidByUri(
+ OUSTR(XMLNS_SCRIPT_URI) );
+ XMLNS_LIBRARY_UID = xNamespaceMapping->getUidByUri(
+ OUSTR(XMLNS_LIBRARY_URI) );
+ XMLNS_XLINK_UID = xNamespaceMapping->getUidByUri(
+ OUSTR(XMLNS_XLINK_URI) );
+}
+
+//__________________________________________________________________________________________________
+void ModuleImport::endDocument()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // ignored
+}
+//__________________________________________________________________________________________________
+void ModuleImport::processingInstruction(
+ OUString const & /*rTarget*/, OUString const & /*rData*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+}
+//__________________________________________________________________________________________________
+void ModuleImport::setDocumentLocator(
+ Reference< xml::sax::XLocator > const & /*xLocator*/ )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+}
+//__________________________________________________________________________________________________
+Reference< xml::input::XElement > ModuleImport::startRootElement(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::input::XAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ if (XMLNS_SCRIPT_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // window
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("module") ))
+ {
+ mrModuleDesc.aName = xAttributes->getValueByUidName(
+ XMLNS_SCRIPT_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("name") ) );
+ mrModuleDesc.aLanguage = xAttributes->getValueByUidName(
+ XMLNS_SCRIPT_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("language") ) );
+ mrModuleDesc.aModuleType = xAttributes->getValueByUidName(
+ XMLNS_SCRIPT_UID,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("moduleType") ) );
+
+ return new ModuleElement( rLocalName, xAttributes, 0, this );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "illegal root element (expected module) given: ") ) +
+ rLocalName, Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+ModuleImport::~ModuleImport()
+ SAL_THROW( () )
+{
+#if OSL_DEBUG_LEVEL > 1
+ OSL_TRACE( "ModuleImport::~ModuleImport().\n" );
+#endif
+}
+
+//##################################################################################################
+
+Reference< xml::sax::XDocumentHandler >
+SAL_CALL importScriptModule( ModuleDescriptor& rMod )
+ SAL_THROW( (Exception) )
+{
+ return ::xmlscript::createDocumentHandler(
+ static_cast< xml::input::XRoot * >( new ModuleImport( rMod ) ) );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/test/imexp.cxx b/xmlscript/test/imexp.cxx
new file mode 100644
index 000000000000..45a76ffc15fa
--- /dev/null
+++ b/xmlscript/test/imexp.cxx
@@ -0,0 +1,244 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlscript.hxx"
+
+#include <stdio.h>
+#include <rtl/memory.h>
+#include "osl/file.h"
+
+#include <rtl/ustrbuf.hxx>
+
+#include <xmlscript/xmldlg_imexp.hxx>
+#include <xmlscript/xml_helper.hxx>
+
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <cppuhelper/implbase2.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/regpathhelper.hxx>
+
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+
+#include <com/sun/star/io/XActiveDataSource.hpp>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <com/sun/star/awt/XToolkit.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XDialog.hpp>
+
+#include <com/sun/star/container/XNameContainer.hpp>
+
+
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+
+
+Reference< XComponentContext > createInitialComponentContext(
+ OUString const & inst_dir )
+{
+ Reference< XComponentContext > xContext;
+
+ try
+ {
+ OUString file_url;
+ oslFileError rc = osl_getFileURLFromSystemPath(
+ inst_dir.pData, &file_url.pData );
+ OSL_ASSERT( osl_File_E_None == rc );
+
+ ::rtl::OUString unorc = file_url + OUString(
+ RTL_CONSTASCII_USTRINGPARAM("/program/" SAL_CONFIGFILE("uno")) );
+
+ return defaultBootstrap_InitialComponentContext( unorc );
+ }
+
+ catch( Exception& rExc )
+ {
+ OString aStr( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_ENSURE( 0, aStr.getStr() );
+ }
+
+ return xContext;
+}
+
+
+// -----------------------------------------------------------------------
+
+Reference< container::XNameContainer > importFile(
+ char const * fname,
+ Reference< XComponentContext > const & xContext )
+{
+ // create the input stream
+ FILE *f = ::fopen( fname, "rb" );
+ if (f)
+ {
+ ::fseek( f, 0 ,SEEK_END );
+ int nLength = ::ftell( f );
+ ::fseek( f, 0, SEEK_SET );
+
+ ByteSequence bytes( nLength );
+ ::fread( bytes.getArray(), nLength, 1, f );
+ ::fclose( f );
+
+ Reference< container::XNameContainer > xModel( xContext->getServiceManager()->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ), xContext ), UNO_QUERY );
+ ::xmlscript::importDialogModel( ::xmlscript::createInputStream( bytes ), xModel, xContext );
+
+ return xModel;
+ }
+ else
+ {
+ throw Exception( OUString( RTL_CONSTASCII_USTRINGPARAM("### Cannot read file!") ),
+ Reference< XInterface >() );
+ }
+}
+
+void exportToFile(
+ char const * fname,
+ Reference< container::XNameContainer > const & xModel,
+ Reference< XComponentContext > const & xContext )
+{
+ Reference< io::XInputStreamProvider > xProvider( ::xmlscript::exportDialogModel( xModel, xContext ) );
+ Reference< io::XInputStream > xStream( xProvider->createInputStream() );
+
+ Sequence< sal_Int8 > bytes;
+ sal_Int32 nRead = xStream->readBytes( bytes, xStream->available() );
+ for (;;)
+ {
+ Sequence< sal_Int8 > readBytes;
+ nRead = xStream->readBytes( readBytes, 1024 );
+ if (! nRead)
+ break;
+ OSL_ASSERT( readBytes.getLength() >= nRead );
+
+ sal_Int32 nPos = bytes.getLength();
+ bytes.realloc( nPos + nRead );
+ ::rtl_copyMemory( bytes.getArray() + nPos, readBytes.getConstArray(), (sal_uInt32)nRead );
+ }
+
+ FILE * f = ::fopen( fname, "w" );
+ ::fwrite( bytes.getConstArray(), 1, bytes.getLength(), f );
+ ::fflush( f );
+ ::fclose( f );
+}
+
+
+
+class MyApp : public Application
+{
+public:
+ void Main();
+};
+
+MyApp aMyApp;
+
+// -----------------------------------------------------------------------
+
+void MyApp::Main()
+{
+ if (GetCommandLineParamCount() < 2)
+ {
+ OSL_ENSURE( 0, "usage: imexp inst_dir inputfile [outputfile]\n" );
+ return;
+ }
+
+ Reference< XComponentContext > xContext(
+ createInitialComponentContext( OUString( GetCommandLineParam( 0 ) ) ) );
+ Reference< lang::XMultiServiceFactory > xMSF(
+ xContext->getServiceManager(), UNO_QUERY );
+
+ try
+ {
+ ::comphelper::setProcessServiceFactory( xMSF );
+
+ Reference< awt::XToolkit> xToolkit( xMSF->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.ExtToolkit" ) ) ), UNO_QUERY );
+
+ // import dialogs
+ OString aParam1( OUStringToOString(
+ OUString( GetCommandLineParam( 1 ) ),
+ RTL_TEXTENCODING_ASCII_US ) );
+ Reference< container::XNameContainer > xModel(
+ importFile( aParam1.getStr(), xContext ) );
+ OSL_ASSERT( xModel.is() );
+
+ Reference< awt::XControl > xDlg( xMSF->createInstance(
+ OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialog" ) ) ), UNO_QUERY );
+ xDlg->setModel( Reference< awt::XControlModel >::query( xModel ) );
+ xDlg->createPeer( xToolkit, 0 );
+ Reference< awt::XDialog > xD( xDlg, UNO_QUERY );
+ xD->execute();
+
+ if (GetCommandLineParamCount() == 3)
+ {
+ // write modified dialogs
+ OString aParam2( OUStringToOString(
+ OUString( GetCommandLineParam( 2 ) ), RTL_TEXTENCODING_ASCII_US ) );
+ exportToFile( aParam2.getStr(), xModel, xContext );
+ }
+ }
+ catch (xml::sax::SAXException & rExc)
+ {
+ OString aStr( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ uno::Exception exc;
+ if (rExc.WrappedException >>= exc)
+ {
+ aStr += OString( " >>> " );
+ aStr += OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US );
+ }
+ OSL_ENSURE( 0, aStr.getStr() );
+ }
+ catch (uno::Exception & rExc)
+ {
+ OString aStr( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_ENSURE( 0, aStr.getStr() );
+ }
+
+ Reference< lang::XComponent > xComp( xContext, UNO_QUERY );
+ if (xComp.is())
+ {
+ xComp->dispose();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlscript/test/makefile.mk b/xmlscript/test/makefile.mk
new file mode 100644
index 000000000000..2bf8f2116106
--- /dev/null
+++ b/xmlscript/test/makefile.mk
@@ -0,0 +1,85 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=xmlscript
+TARGET=imexp
+TARGETTYPE=GUI
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES= \
+ imexp.cxx
+
+OBJFILES= \
+ $(OBJ)$/imexp.obj
+
+APP1TARGET=$(TARGET)
+APP1OBJS=$(OBJFILES)
+APP1STDLIBS= \
+ $(TOOLSLIB) \
+ $(SOTLIB) \
+ $(SVTOOLLIB) \
+ $(COMPHELPERLIB) \
+ $(VCLLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB) \
+ $(XMLSCRIPTLIB)
+
+APP1DEF= $(MISC)$/imexp.def
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
+# ------------------------------------------------------------------
+# Windows
+# ------------------------------------------------------------------
+
+.IF "$(GUI)" == "WIN"
+
+$(MISC)$/imexp.def: makefile.mk
+ echo NAME imexp >$@
+ echo DESCRIPTION 'XML dialog im-/ exporter' >>$@
+ echo EXETYPE WINDOWS >>$@
+ echo STUB 'winSTUB.EXE' >>$@
+ echo PROTMODE >>$@
+ echo CODE PRELOAD MOVEABLE DISCARDABLE >>$@
+ echo DATA PRELOAD MOVEABLE MULTIPLE >>$@
+ echo HEAPSIZE 8192 >>$@
+ echo STACKSIZE 32768 >>$@
+
+.ENDIF
diff --git a/xmlscript/test/test.xml b/xmlscript/test/test.xml
new file mode 100644
index 000000000000..7b0f9e802741
--- /dev/null
+++ b/xmlscript/test/test.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE dialog:dialogs SYSTEM "../dtd/dialog.dtd">
+
+<window xmlns="http://openoffice.org/2000/dialog"
+ xmlns:dlg="http://openoffice.org/2000/dialog"
+ xmlns:script="http://openoffice.org/2000/script"
+ style-id="dialog"
+ id="window1" title="Test-Dialog" left="50" top="50" height="690" width="400"
+ closeable="true" moveable="true" resizeable="true" disabled="false"
+>
+
+ <script:event script:event-name="on-rowchange" script:macro-name="ExecutingMacro" script:location="application" script:language="StarBasic"/>
+
+ <dlg:styles xmlns:dlg="http://openoffice.org/2000/dialog">
+ <dlg:style style-id="bla" background-color="0xffffff" dlg:text-color="255" dlg:textline-color="0xff0000" dlg:font-underline="single"/>
+ <dlg:style style-id="bla3" background-color="888888" dlg:text-color="0xffffff" font-name="Arial" font-height="24" font-relief="embossed" font-emphasismark="dot"/>
+ <dlg:style style-id="no_border" border="none" fill-color="0xff"/>
+ <dlg:style style-id="dialog" border="3d" dlg:text-color="255" dlg:textline-color="0xff0000"/>
+ </dlg:styles>
+
+ <dlg:bulletinboard xmlns:ns="http://www.fake" xmlns:dlg="http://openoffice.org/2000/dialog">
+
+ <button dlg:id="button1" ns:value="hallo" dlg:left="50" ns:top="50" ns:checked="true" width="50" height="50" style-id="bla3" xmlns:ns="http://openoffice.org/2000/dialog">
+ <dlg:event listener-type="com.sun.star.awt.XKeyListener" event-method="keyReleased" script-type="StarBasic" script-code="application:ExecutingMacro"/>
+ <script:event script:event-name="on-rowchange" script:macro-name="ExecutingMacro" script:location="application" script:language="StarBasic"/>
+ <script:listener-event script:macro-name="ExecutingMacro" script:location="application" script:language="StarBasic" script:listener-type="com.sun.star.awt.XMouseListener" script:listener-method="mouseEntered"/>
+ <script:listener-event script:macro-name="ExecutingMacro" script:location="application" script:language="StarBasic" script:listener-type="com.sun.star.awt.XMouseListener" script:listener-method="mousePressed" script:listener-param="parameter0, so this will never ever be a script:event, but always a script:listener-event element!"/>
+ </button>
+
+ <button dlg:id="button3" dlg:image-src="file:///f|src641/xmlscript/test/w3c.jpg" dlg:image-align="right" ns:value="help button" dlg:left="250" ns:top="50" width="50" height="50" style-id="bla" button-type="help" xmlns:ns="http://openoffice.org/2000/dialog"/>
+
+ <checkbox id="check1" help-text="helphelphelp!!!" help-url="http://www.xml.org" value="checked" left="50" top="150" width="100" height="20" checked="true"/>
+ <checkbox id="check2" value="dontknow" left="50" top="170" width="100" height="20" tristate="true"/>
+ <checkbox id="check3" value="tristate_checked" left="50" top="190" width="100" height="20" checked="true" tristate="true"/>
+
+ <menulist id="list1" multiselection="true" left="50" top="400" width="100" height="100">
+ <menupopup>
+ <menuitem value="item1"/>
+ <menuitem value="item2 sel" selected="true"/>
+ <menuitem value="item3 sel" selected="true"/>
+ </menupopup>
+ </menulist>
+
+ <dlg:menulist id="list2" left="250" top="400" width="100" height="100">
+ <menupopup>
+ <menuitem value="item4" selected="false"/>
+ <menuitem value="item5 sel" selected="true"/>
+ <menuitem value="item6"/>
+ </menupopup>
+ </dlg:menulist>
+
+ <combobox id="combo1" value="combotext1" left="250" top="150" width="50" height="50">
+ <menupopup>
+ <menuitem value="Citem1"/>
+ <menuitem value="Citem2"/>
+ </menupopup>
+ </combobox>
+
+ <combobox id="combo2" value="combotext2" left="310" top="150" width="50" height="50" spin="true">
+ <menupopup>
+ <menuitem value="Citem3"/>
+ <menuitem value="Citem4"/>
+ </menupopup>
+ </combobox>
+
+ <radiogroup>
+ <radio id="radio1" value="default radio" left="50" top="250" width="100" height="20"/>
+ <radio id="radio2" value="checked" left="50" top="270" width="100" height="20" checked="true"/>
+ <radio id="radio3" value="unchecked" left="50" top="290" width="100" height="20" checked="false"/>
+ </radiogroup>
+
+ <titledbox id="groupbox1" left="250" top="250" width="120" height="100">
+ <script:listener-event script:macro-name="ExecutingMacro" script:location="application" script:language="StarBasic" script:listener-type="com.sun.star.awt.XMouseListener" script:listener-method="mouseEntered"/>
+ <title value="grouped"/>
+ <radio id="radio5" value="default radio" left="5" top="15" width="100" height="20"/>
+ <radio id="radio7" value="unchecked" left="5" top="35" width="100" height="20" checked="false"/>
+ <radio id="radio8" value="checked" left="5" top="55" width="100" height="20" checked="true"/>
+ </titledbox>
+
+ <text id="fixed1" left="50" top="520" width="180" height="20" value="fixed text is here..." multiline="true" align="center">
+ <script:listener-event script:macro-name="ExecutingMacro" script:location="application" script:language="StarBasic" script:listener-type="com.sun.star.awt.XMouseListener" script:listener-method="mouseEntered"/>
+ </text>
+ <textfield id="field1" left="250" top="520" width="50" height="40" value="edit no text here..." readonly="true" vscroll="true" multiline="true" align="right" style-id="no_border"/>
+ <textfield id="field2" left="320" top="520" width="50" height="40" value="hidden text" hscroll="true" echochar="*" align="left"/>
+ <img id="image1" scale-image="true" left="50" top="585" width="80" height="20" src="file:///f|src641/xmlscript/test/w3c.jpg">
+ <script:listener-event script:macro-name="ExecutingMacro" script:location="application" script:language="StarBasic" script:listener-type="com.sun.star.awt.XMouseListener" script:listener-method="mouseEntered"/>
+ </img>
+ <filecontrol id="file1" left="150" top="585" width="100" height="20" value="../../test/w3c.jpg"/>
+
+ <datefield id="datefield1" left="20" top="610" width="100" height="20" show-century="false" date-format="short_DDMMYY" spin="true" value="20010301"/>
+ <timefield id="time1" left="20" top="635" width="100" height="20" time-format="24h_long" value-min="0" value-max="24000000" strict-format="true" value="12000000" spin="true"/>
+ <patternfield id="pattern1" maxlength="4" left="20" top="0" width="100" height="20" value="pattern" strict-format="true" readonly="true"/>
+ <currencyfield id="currency1" left="200" top="610" width="100" height="20" value="5.6075" value-min="0.5" value-max="10.0" value-step="0.1" spin="true" thousands-separator="true" currency-symbol="$" prepend-symbol="true"/>
+ <numericfield id="numeric1" left="200" top="635" width="100" height="20" value="5.6075" value-min="0.5" value-max="10.0" value-step="0.1" thousands-separator="true"/>
+ <fixedline style-id="bla3" id="fixedline1" left="20" top="660" width="150" height="20" value="FixedLineLabel" align="horizontal"/>
+ <progressmeter style-id="no_border" id="progress1" left="200" top="660" width="80" height="20" align="horizontal" value="50" value-min="0" value-max="80"/>
+ <scrollbar style-id="dialog" id="scrollbar1" left="300" top="660" width="80" height="20" align="horizontal" curpos="50" maxpos="200" increment="1" pageincrement="10"/>
+
+ <formattedfield style-id="dialog" treat-as-number="true" id="ffield0" left="20" top="110" width="80" height="20" align="center" text="first ffield"
+ dlg:value-max="750" dlg:value-min="0" dlg:value="2" spin="true"/>
+ <formattedfield style-id="dialog" id="ffield1" left="250" top="110" width="80" height="20" align="center" text="second ffield"
+ dlg:format-code="[$$-409]#.##0,00;[ROT]-[$$-409]#.##0,00" dlg:format-locale="de;DE;WIN" dlg:value-max="750" dlg:value-min="0" dlg:value="4" spin="true"/>
+
+ </dlg:bulletinboard>
+
+</window>
diff --git a/xmlscript/test/w3c.jpg b/xmlscript/test/w3c.jpg
new file mode 100644
index 000000000000..c541c20dcd1b
--- /dev/null
+++ b/xmlscript/test/w3c.jpg
Binary files differ
diff --git a/xmlscript/util/makefile.mk b/xmlscript/util/makefile.mk
new file mode 100644
index 000000000000..bc259db75455
--- /dev/null
+++ b/xmlscript/util/makefile.mk
@@ -0,0 +1,77 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=xmlscript
+TARGET=xcr
+NO_BSYMBOLIC=TRUE
+#USE_DEFFILE=TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+#-------------------------------------------------------------------
+
+LIB1TARGET= $(SLB)$/$(TARGET).lib
+
+LIB1FILES= \
+ $(SLB)$/xml_helper.lib \
+ $(SLB)$/xmldlg_imexp.lib \
+ $(SLB)$/xmllib_imexp.lib \
+ $(SLB)$/xmlmod_imexp.lib \
+ $(SLB)$/xmlflat_imexp.lib \
+ $(SLB)$/misc.lib
+
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+
+SHL1LIBS= \
+ $(LIB1TARGET)
+
+SHL1STDLIBS= \
+ $(COMPHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEFLIB1NAME= $(TARGET)
+DEF1DEPN= $(MISC)$/$(SHL1TARGET).flt
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+$(MISC)$/$(SHL1TARGET).flt : makefile.mk xcr.flt
+ @echo ------------------------------
+ @echo Making: $@
+ $(TYPE) xcr.flt > $@
diff --git a/xmlscript/util/target.pmk b/xmlscript/util/target.pmk
new file mode 100644
index 000000000000..907ec41dd90f
--- /dev/null
+++ b/xmlscript/util/target.pmk
@@ -0,0 +1,35 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+.IF "$(debug)" != ""
+
+# msvc++: no inlining
+.IF "$(COM)" == "MSC"
+CFLAGS += /Ob0
+.ENDIF
+
+.ENDIF
+
diff --git a/xmlscript/util/xcr.flt b/xmlscript/util/xcr.flt
new file mode 100644
index 000000000000..e9a7f0344007
--- /dev/null
+++ b/xmlscript/util/xcr.flt
@@ -0,0 +1,13 @@
+??_7
+??_8
+??_C
+??_E
+??_F
+??_G
+??_H
+??_I
+0Imp
+Impl@@
+Imp@@
+__CT
+_STL