1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*63bba73cSAndrew Rist * distributed with this work for additional information
6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at
10*63bba73cSAndrew Rist *
11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*63bba73cSAndrew Rist *
13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the
17*63bba73cSAndrew Rist * specific language governing permissions and limitations
18*63bba73cSAndrew Rist * under the License.
19*63bba73cSAndrew Rist *
20*63bba73cSAndrew Rist *************************************************************/
21*63bba73cSAndrew Rist
22*63bba73cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir #include "layerimport.hxx"
27cdf0e10cSrcweir #include "formenums.hxx"
28cdf0e10cSrcweir #include "elementimport.hxx"
29cdf0e10cSrcweir #include "officeforms.hxx"
30cdf0e10cSrcweir #include "strings.hxx"
31cdf0e10cSrcweir #include "formstyles.hxx"
32cdf0e10cSrcweir #include <xmloff/xmlictxt.hxx>
33cdf0e10cSrcweir #include <xmloff/xmlstyle.hxx>
34cdf0e10cSrcweir #include <xmloff/families.hxx>
35cdf0e10cSrcweir #include <xmloff/xmlprmap.hxx>
36cdf0e10cSrcweir #include <xmloff/prstylei.hxx>
37cdf0e10cSrcweir #include <xmloff/xmlimp.hxx>
38cdf0e10cSrcweir #include "XMLEventImportHelper.hxx"
39cdf0e10cSrcweir #include <xmloff/xmlimppr.hxx>
40cdf0e10cSrcweir #include <xmloff/xmlnumfi.hxx>
41cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
42cdf0e10cSrcweir #include <com/sun/star/form/FormSubmitEncoding.hpp>
43cdf0e10cSrcweir #include <com/sun/star/form/FormSubmitMethod.hpp>
44cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp>
45cdf0e10cSrcweir #include <com/sun/star/form/NavigationBarMode.hpp>
46cdf0e10cSrcweir #include <com/sun/star/form/TabulatorCycle.hpp>
47cdf0e10cSrcweir #include <com/sun/star/form/FormButtonType.hpp>
48cdf0e10cSrcweir #include <com/sun/star/awt/ScrollBarOrientation.hpp>
49cdf0e10cSrcweir #include <com/sun/star/awt/VisualEffect.hpp>
50cdf0e10cSrcweir #include <com/sun/star/form/ListSourceType.hpp>
51cdf0e10cSrcweir #include <tools/wintypes.hxx> // for check states
52cdf0e10cSrcweir #include <com/sun/star/lang/Locale.hpp>
53cdf0e10cSrcweir #include <xmloff/controlpropertyhdl.hxx>
54cdf0e10cSrcweir #include "controlpropertymap.hxx"
55cdf0e10cSrcweir #include "formevents.hxx"
56cdf0e10cSrcweir #include "formcellbinding.hxx"
57cdf0e10cSrcweir #include "xmloff/xformsimport.hxx"
58cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
59cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
60cdf0e10cSrcweir #include <rtl/logfile.hxx>
61cdf0e10cSrcweir #include <algorithm>
62cdf0e10cSrcweir
63cdf0e10cSrcweir SV_IMPL_REF( SvXMLStylesContext );
64cdf0e10cSrcweir
65cdf0e10cSrcweir //.........................................................................
66cdf0e10cSrcweir namespace xmloff
67cdf0e10cSrcweir {
68cdf0e10cSrcweir //.........................................................................
69cdf0e10cSrcweir
70cdf0e10cSrcweir using namespace ::com::sun::star::uno;
71cdf0e10cSrcweir using namespace ::com::sun::star::awt;
72cdf0e10cSrcweir using namespace ::com::sun::star::lang;
73cdf0e10cSrcweir using namespace ::com::sun::star::beans;
74cdf0e10cSrcweir using namespace ::com::sun::star::container;
75cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
76cdf0e10cSrcweir using namespace ::com::sun::star::xml;
77cdf0e10cSrcweir using namespace ::com::sun::star::util;
78cdf0e10cSrcweir using namespace ::com::sun::star::form;
79cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
80cdf0e10cSrcweir
81cdf0e10cSrcweir //=====================================================================
82cdf0e10cSrcweir //= OFormLayerXMLImport_Impl
83cdf0e10cSrcweir //=====================================================================
84cdf0e10cSrcweir //---------------------------------------------------------------------
OFormLayerXMLImport_Impl(SvXMLImport & _rImporter)85cdf0e10cSrcweir OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter)
86cdf0e10cSrcweir :m_rImporter(_rImporter)
87cdf0e10cSrcweir ,m_pAutoStyles(NULL)
88cdf0e10cSrcweir {
89cdf0e10cSrcweir // build the attribute2property map
90cdf0e10cSrcweir // string properties which are exported as attributes
91cdf0e10cSrcweir m_aAttributeMetaData.addStringProperty(
92cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_NAME), PROPERTY_NAME);
93cdf0e10cSrcweir m_aAttributeMetaData.addStringProperty(
94cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_IMAGE_DATA), PROPERTY_IMAGEURL);
95cdf0e10cSrcweir m_aAttributeMetaData.addStringProperty(
96cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_LABEL), PROPERTY_LABEL);
97cdf0e10cSrcweir m_aAttributeMetaData.addStringProperty(
98cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_TARGET_LOCATION), PROPERTY_TARGETURL);
99cdf0e10cSrcweir m_aAttributeMetaData.addStringProperty(
100cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_TITLE), PROPERTY_TITLE);
101cdf0e10cSrcweir m_aAttributeMetaData.addStringProperty(
102cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_TARGET_FRAME), PROPERTY_TARGETFRAME, "_blank");
103cdf0e10cSrcweir m_aAttributeMetaData.addStringProperty(
104cdf0e10cSrcweir OAttributeMetaData::getDatabaseAttributeName(DA_DATA_FIELD), PROPERTY_DATAFIELD);
105cdf0e10cSrcweir m_aAttributeMetaData.addStringProperty(
106cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faCommand), PROPERTY_COMMAND);
107cdf0e10cSrcweir m_aAttributeMetaData.addStringProperty(
108cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faDatasource), PROPERTY_DATASOURCENAME);
109cdf0e10cSrcweir m_aAttributeMetaData.addStringProperty(
110cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faFilter), PROPERTY_FILTER);
111cdf0e10cSrcweir m_aAttributeMetaData.addStringProperty(
112cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faOrder), PROPERTY_ORDER);
113cdf0e10cSrcweir
114cdf0e10cSrcweir // properties not added because they're already present in another form
115cdf0e10cSrcweir OSL_ENSURE(
116cdf0e10cSrcweir 0 == ::rtl::OUString::createFromAscii(OAttributeMetaData::getCommonControlAttributeName(CCA_TARGET_LOCATION)).compareToAscii(
117cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faAction)),
118cdf0e10cSrcweir "OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl: invalid attribute names (1)!");
119cdf0e10cSrcweir // if this fails, we would have to add a translation from faAction->PROPERTY_TARGETURL
120cdf0e10cSrcweir // We did not because we already have one CCA_TARGET_LOCATION->PROPERTY_TARGETURL,
121cdf0e10cSrcweir // and CCA_TARGET_LOCATION and faAction should be represented by the same attribute
122cdf0e10cSrcweir
123cdf0e10cSrcweir OSL_ENSURE(
124cdf0e10cSrcweir 0 == ::rtl::OUString::createFromAscii(OAttributeMetaData::getCommonControlAttributeName(CCA_NAME)).compareToAscii(
125cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faName)),
126cdf0e10cSrcweir "OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl: invalid attribute names (2)!");
127cdf0e10cSrcweir // the same for faName, CCA_NAME and PROPERTY_NAME
128cdf0e10cSrcweir
129cdf0e10cSrcweir // boolean properties which are exported as attributes
130cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
131cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_SELECTED), PROPERTY_STATE, sal_False);
132cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
133cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_DISABLED), PROPERTY_ENABLED, sal_False, sal_True);
134cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
135cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_DROPDOWN), PROPERTY_DROPDOWN, sal_False);
136cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
137cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_PRINTABLE), PROPERTY_PRINTABLE, sal_True);
138cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
139cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_READONLY), PROPERTY_READONLY, sal_False);
140cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
141cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_SELECTED), PROPERTY_DEFAULT_STATE, sal_False);
142cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
143cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_TAB_STOP), PROPERTY_TABSTOP, sal_True);
144cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
145cdf0e10cSrcweir OAttributeMetaData::getDatabaseAttributeName(DA_CONVERT_EMPTY), PROPERTY_EMPTY_IS_NULL, sal_False);
146cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
147cdf0e10cSrcweir OAttributeMetaData::getSpecialAttributeName(SCA_VALIDATION), PROPERTY_STRICTFORMAT, sal_False);
148cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
149cdf0e10cSrcweir OAttributeMetaData::getSpecialAttributeName(SCA_MULTI_LINE), PROPERTY_MULTILINE, sal_False);
150cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
151cdf0e10cSrcweir OAttributeMetaData::getSpecialAttributeName(SCA_AUTOMATIC_COMPLETION), PROPERTY_AUTOCOMPLETE, sal_False);
152cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
153cdf0e10cSrcweir OAttributeMetaData::getSpecialAttributeName(SCA_MULTIPLE), PROPERTY_MULTISELECTION, sal_False);
154cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
155cdf0e10cSrcweir OAttributeMetaData::getSpecialAttributeName(SCA_DEFAULT_BUTTON), PROPERTY_DEFAULTBUTTON, sal_False);
156cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
157cdf0e10cSrcweir OAttributeMetaData::getSpecialAttributeName(SCA_IS_TRISTATE), PROPERTY_TRISTATE, sal_False);
158cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
159cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faAllowDeletes), PROPERTY_ALLOWDELETES, sal_True);
160cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
161cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faAllowInserts), PROPERTY_ALLOWINSERTS, sal_True);
162cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
163cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faAllowUpdates), PROPERTY_ALLOWUPDATES, sal_True);
164cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
165cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faApplyFilter), PROPERTY_APPLYFILTER, sal_False);
166cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
167cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faEscapeProcessing), PROPERTY_ESCAPEPROCESSING, sal_True);
168cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
169cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faIgnoreResult), PROPERTY_IGNORERESULT, sal_False);
170cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
171cdf0e10cSrcweir OAttributeMetaData::getSpecialAttributeName( SCA_TOGGLE ), PROPERTY_TOGGLE, sal_False );
172cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
173cdf0e10cSrcweir OAttributeMetaData::getSpecialAttributeName( SCA_FOCUS_ON_CLICK ), PROPERTY_FOCUS_ON_CLICK, sal_True );
174cdf0e10cSrcweir m_aAttributeMetaData.addBooleanProperty(
175cdf0e10cSrcweir OAttributeMetaData::getDatabaseAttributeName( DA_INPUT_REQUIRED ), PROPERTY_INPUT_REQUIRED, sal_False );
176cdf0e10cSrcweir
177cdf0e10cSrcweir // the int16 attributes
178cdf0e10cSrcweir m_aAttributeMetaData.addInt16Property(
179cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_MAX_LENGTH), PROPERTY_MAXTEXTLENGTH, 0);
180cdf0e10cSrcweir m_aAttributeMetaData.addInt16Property(
181cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_SIZE), PROPERTY_LINECOUNT, 5);
182cdf0e10cSrcweir m_aAttributeMetaData.addInt16Property(
183cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_TAB_INDEX), PROPERTY_TABINDEX, 0);
184cdf0e10cSrcweir m_aAttributeMetaData.addInt16Property(
185cdf0e10cSrcweir OAttributeMetaData::getDatabaseAttributeName(DA_BOUND_COLUMN), PROPERTY_BOUNDCOLUMN, 0);
186cdf0e10cSrcweir
187cdf0e10cSrcweir // the int32 attributes
188cdf0e10cSrcweir m_aAttributeMetaData.addInt32Property(
189cdf0e10cSrcweir OAttributeMetaData::getSpecialAttributeName( SCA_PAGE_STEP_SIZE ), PROPERTY_BLOCK_INCREMENT, 10 );
190cdf0e10cSrcweir
191cdf0e10cSrcweir // the enum attributes
192cdf0e10cSrcweir m_aAttributeMetaData.addEnumProperty(
193cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName( CCA_VISUAL_EFFECT ), PROPERTY_VISUAL_EFFECT,
194cdf0e10cSrcweir VisualEffect::LOOK3D, OEnumMapper::getEnumMap( OEnumMapper::epVisualEffect ),
195cdf0e10cSrcweir &::getCppuType( static_cast< sal_Int16* >( NULL ) ) );
196cdf0e10cSrcweir m_aAttributeMetaData.addEnumProperty(
197cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName( CCA_ORIENTATION ), PROPERTY_ORIENTATION,
198cdf0e10cSrcweir ScrollBarOrientation::HORIZONTAL, OEnumMapper::getEnumMap( OEnumMapper::epOrientation ),
199cdf0e10cSrcweir &::getCppuType( static_cast< sal_Int32* >( NULL ) ) );
200cdf0e10cSrcweir m_aAttributeMetaData.addEnumProperty(
201cdf0e10cSrcweir OAttributeMetaData::getCommonControlAttributeName(CCA_BUTTON_TYPE), PROPERTY_BUTTONTYPE,
202cdf0e10cSrcweir FormButtonType_PUSH, OEnumMapper::getEnumMap(OEnumMapper::epButtonType),
203cdf0e10cSrcweir &::getCppuType( static_cast<FormButtonType*>(NULL) ));
204cdf0e10cSrcweir m_aAttributeMetaData.addEnumProperty(
205cdf0e10cSrcweir OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE_TYPE), PROPERTY_LISTSOURCETYPE,
206cdf0e10cSrcweir ListSourceType_VALUELIST, OEnumMapper::getEnumMap(OEnumMapper::epListSourceType),
207cdf0e10cSrcweir &::getCppuType( static_cast<ListSourceType*>(NULL) ));
208cdf0e10cSrcweir m_aAttributeMetaData.addEnumProperty(
209cdf0e10cSrcweir OAttributeMetaData::getSpecialAttributeName(SCA_STATE), PROPERTY_DEFAULT_STATE, STATE_NOCHECK,
210cdf0e10cSrcweir OEnumMapper::getEnumMap(OEnumMapper::epCheckState),
211cdf0e10cSrcweir &::getCppuType( static_cast< sal_Int16* >(NULL)));
212cdf0e10cSrcweir m_aAttributeMetaData.addEnumProperty(
213cdf0e10cSrcweir OAttributeMetaData::getSpecialAttributeName(SCA_CURRENT_STATE), PROPERTY_STATE, STATE_NOCHECK,
214cdf0e10cSrcweir OEnumMapper::getEnumMap(OEnumMapper::epCheckState),
215cdf0e10cSrcweir &::getCppuType( static_cast< sal_Int16* >(NULL)));
216cdf0e10cSrcweir m_aAttributeMetaData.addEnumProperty(
217cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faEnctype), PROPERTY_SUBMIT_ENCODING,
218cdf0e10cSrcweir FormSubmitEncoding_URL, OEnumMapper::getEnumMap(OEnumMapper::epSubmitEncoding),
219cdf0e10cSrcweir &::getCppuType( static_cast<FormSubmitEncoding*>(NULL) ));
220cdf0e10cSrcweir m_aAttributeMetaData.addEnumProperty(
221cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faMethod), PROPERTY_SUBMIT_METHOD,
222cdf0e10cSrcweir FormSubmitMethod_GET, OEnumMapper::getEnumMap(OEnumMapper::epSubmitMethod),
223cdf0e10cSrcweir &::getCppuType( static_cast<FormSubmitMethod*>(NULL) ));
224cdf0e10cSrcweir m_aAttributeMetaData.addEnumProperty(
225cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faCommandType), PROPERTY_COMMAND_TYPE,
226cdf0e10cSrcweir CommandType::COMMAND, OEnumMapper::getEnumMap(OEnumMapper::epCommandType));
227cdf0e10cSrcweir m_aAttributeMetaData.addEnumProperty(
228cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faNavigationMode), PROPERTY_NAVIGATION,
229cdf0e10cSrcweir NavigationBarMode_NONE, OEnumMapper::getEnumMap(OEnumMapper::epNavigationType),
230cdf0e10cSrcweir &::getCppuType( static_cast<NavigationBarMode*>(NULL) ));
231cdf0e10cSrcweir m_aAttributeMetaData.addEnumProperty(
232cdf0e10cSrcweir OAttributeMetaData::getFormAttributeName(faTabbingCycle), PROPERTY_CYCLE,
233cdf0e10cSrcweir TabulatorCycle_RECORDS, OEnumMapper::getEnumMap(OEnumMapper::epTabCyle),
234cdf0e10cSrcweir &::getCppuType( static_cast<TabulatorCycle*>(NULL) ));
235cdf0e10cSrcweir
236cdf0e10cSrcweir // 'initialize'
237cdf0e10cSrcweir m_aCurrentPageIds = m_aControlIds.end();
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
240cdf0e10cSrcweir //---------------------------------------------------------------------
~OFormLayerXMLImport_Impl()241cdf0e10cSrcweir OFormLayerXMLImport_Impl::~OFormLayerXMLImport_Impl()
242cdf0e10cSrcweir {
243cdf0e10cSrcweir // outlined to allow forward declaration of OAttribute2Property in the header
244cdf0e10cSrcweir
245cdf0e10cSrcweir if (m_pAutoStyles)
246cdf0e10cSrcweir m_pAutoStyles->ReleaseRef();
247cdf0e10cSrcweir }
248cdf0e10cSrcweir
249cdf0e10cSrcweir //---------------------------------------------------------------------
setAutoStyleContext(SvXMLStylesContext * _pNewContext)250cdf0e10cSrcweir void OFormLayerXMLImport_Impl::setAutoStyleContext(SvXMLStylesContext* _pNewContext)
251cdf0e10cSrcweir {
252cdf0e10cSrcweir OSL_ENSURE(!m_pAutoStyles, "OFormLayerXMLImport_Impl::setAutoStyleContext: not to be called twice!");
253cdf0e10cSrcweir m_pAutoStyles = _pNewContext;
254cdf0e10cSrcweir if (m_pAutoStyles)
255cdf0e10cSrcweir m_pAutoStyles->AddRef();
256cdf0e10cSrcweir }
257cdf0e10cSrcweir
258cdf0e10cSrcweir //---------------------------------------------------------------------
applyControlNumberStyle(const Reference<XPropertySet> & _rxControlModel,const::rtl::OUString & _rControlNumerStyleName)259cdf0e10cSrcweir void OFormLayerXMLImport_Impl::applyControlNumberStyle(const Reference< XPropertySet >& _rxControlModel, const ::rtl::OUString& _rControlNumerStyleName)
260cdf0e10cSrcweir {
261cdf0e10cSrcweir OSL_ENSURE(_rxControlModel.is() && (0 != _rControlNumerStyleName.getLength()),
262cdf0e10cSrcweir "OFormLayerXMLImport_Impl::applyControlNumberStyle: invalid arguments (this will crash)!");
263cdf0e10cSrcweir
264cdf0e10cSrcweir OSL_ENSURE(m_pAutoStyles, "OFormLayerXMLImport_Impl::applyControlNumberStyle: have no auto style context!");
265cdf0e10cSrcweir if (!m_pAutoStyles)
266cdf0e10cSrcweir {
267cdf0e10cSrcweir m_pAutoStyles = m_rImporter.GetShapeImport()->GetAutoStylesContext();
268cdf0e10cSrcweir if (m_pAutoStyles)
269cdf0e10cSrcweir m_pAutoStyles->AddRef();
270cdf0e10cSrcweir }
271cdf0e10cSrcweir
272cdf0e10cSrcweir if (m_pAutoStyles)
273cdf0e10cSrcweir {
274cdf0e10cSrcweir const SvXMLStyleContext* pStyle = m_pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_DATA_STYLE, _rControlNumerStyleName);
275cdf0e10cSrcweir if (pStyle)
276cdf0e10cSrcweir {
277cdf0e10cSrcweir const SvXMLNumFormatContext* pDataStyle = static_cast<const SvXMLNumFormatContext*>(pStyle);
278cdf0e10cSrcweir
279cdf0e10cSrcweir // set this format at the control model
280cdf0e10cSrcweir try
281cdf0e10cSrcweir {
282cdf0e10cSrcweir // the models number format supplier and formats
283cdf0e10cSrcweir Reference< XNumberFormatsSupplier > xFormatsSupplier;
284cdf0e10cSrcweir _rxControlModel->getPropertyValue(PROPERTY_FORMATSSUPPLIER) >>= xFormatsSupplier;
285cdf0e10cSrcweir Reference< XNumberFormats > xFormats;
286cdf0e10cSrcweir if (xFormatsSupplier.is())
287cdf0e10cSrcweir xFormats = xFormatsSupplier->getNumberFormats();
288cdf0e10cSrcweir OSL_ENSURE(xFormats.is(), "OFormLayerXMLImport_Impl::applyControlNumberStyle: could not obtain the controls number formats!");
289cdf0e10cSrcweir
290cdf0e10cSrcweir // obtain a key
291cdf0e10cSrcweir if (xFormats.is())
292cdf0e10cSrcweir {
293cdf0e10cSrcweir sal_Int32 nFormatKey = const_cast<SvXMLNumFormatContext*>(pDataStyle)->CreateAndInsert( xFormatsSupplier );
294cdf0e10cSrcweir OSL_ENSURE(-1 != nFormatKey, "OFormLayerXMLImport_Impl::applyControlNumberStyle: could not obtain a format key!");
295cdf0e10cSrcweir
296cdf0e10cSrcweir // set the format on the control model
297cdf0e10cSrcweir _rxControlModel->setPropertyValue(PROPERTY_FORMATKEY, makeAny(nFormatKey));
298cdf0e10cSrcweir }
299cdf0e10cSrcweir }
300cdf0e10cSrcweir catch(const Exception&)
301cdf0e10cSrcweir {
302cdf0e10cSrcweir OSL_ENSURE(sal_False, "OFormLayerXMLImport_Impl::applyControlNumberStyle: couldn't set the format!");
303cdf0e10cSrcweir }
304cdf0e10cSrcweir }
305cdf0e10cSrcweir else
306cdf0e10cSrcweir OSL_ENSURE(sal_False, "OFormLayerXMLImport_Impl::applyControlNumberStyle: did not find the style with the given name!");
307cdf0e10cSrcweir }
308cdf0e10cSrcweir }
309cdf0e10cSrcweir
310cdf0e10cSrcweir //---------------------------------------------------------------------
registerCellValueBinding(const Reference<XPropertySet> & _rxControlModel,const::rtl::OUString & _rCellAddress)311cdf0e10cSrcweir void OFormLayerXMLImport_Impl::registerCellValueBinding( const Reference< XPropertySet >& _rxControlModel, const ::rtl::OUString& _rCellAddress )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir OSL_ENSURE( _rxControlModel.is() && _rCellAddress.getLength(),
314cdf0e10cSrcweir "OFormLayerXMLImport_Impl::registerCellValueBinding: invalid arguments!" );
315cdf0e10cSrcweir m_aCellValueBindings.push_back( ModelStringPair( _rxControlModel, _rCellAddress ) );
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
318cdf0e10cSrcweir //---------------------------------------------------------------------
registerXFormsValueBinding(const Reference<XPropertySet> & _rxControlModel,const::rtl::OUString & _rBindingID)319cdf0e10cSrcweir void OFormLayerXMLImport_Impl::registerXFormsValueBinding(
320cdf0e10cSrcweir const Reference< XPropertySet >& _rxControlModel,
321cdf0e10cSrcweir const ::rtl::OUString& _rBindingID )
322cdf0e10cSrcweir {
323cdf0e10cSrcweir // TODO: is an empty binding name allowed?
324cdf0e10cSrcweir OSL_ENSURE( _rxControlModel.is(), "need model" );
325cdf0e10cSrcweir
326cdf0e10cSrcweir m_aXFormsValueBindings.push_back(
327cdf0e10cSrcweir ModelStringPair( _rxControlModel, _rBindingID ) );
328cdf0e10cSrcweir }
329cdf0e10cSrcweir
330cdf0e10cSrcweir //---------------------------------------------------------------------
registerXFormsListBinding(const Reference<XPropertySet> & _rxControlModel,const::rtl::OUString & _rBindingID)331cdf0e10cSrcweir void OFormLayerXMLImport_Impl::registerXFormsListBinding(
332cdf0e10cSrcweir const Reference< XPropertySet >& _rxControlModel,
333cdf0e10cSrcweir const ::rtl::OUString& _rBindingID )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir // TODO: is an empty binding name allowed?
336cdf0e10cSrcweir OSL_ENSURE( _rxControlModel.is(), "need model" );
337cdf0e10cSrcweir
338cdf0e10cSrcweir m_aXFormsListBindings.push_back(
339cdf0e10cSrcweir ModelStringPair( _rxControlModel, _rBindingID ) );
340cdf0e10cSrcweir }
341cdf0e10cSrcweir
342cdf0e10cSrcweir //---------------------------------------------------------------------
registerXFormsSubmission(const Reference<XPropertySet> & _rxControlModel,const::rtl::OUString & _rSubmissionID)343cdf0e10cSrcweir void OFormLayerXMLImport_Impl::registerXFormsSubmission(
344cdf0e10cSrcweir const Reference< XPropertySet >& _rxControlModel,
345cdf0e10cSrcweir const ::rtl::OUString& _rSubmissionID )
346cdf0e10cSrcweir {
347cdf0e10cSrcweir // TODO: is an empty binding name allowed?
348cdf0e10cSrcweir OSL_ENSURE( _rxControlModel.is(), "need model" );
349cdf0e10cSrcweir
350cdf0e10cSrcweir m_aXFormsSubmissions.push_back(
351cdf0e10cSrcweir ModelStringPair( _rxControlModel, _rSubmissionID ) );
352cdf0e10cSrcweir }
353cdf0e10cSrcweir
354cdf0e10cSrcweir //---------------------------------------------------------------------
registerCellRangeListSource(const Reference<XPropertySet> & _rxControlModel,const::rtl::OUString & _rCellRangeAddress)355cdf0e10cSrcweir void OFormLayerXMLImport_Impl::registerCellRangeListSource( const Reference< XPropertySet >& _rxControlModel, const ::rtl::OUString& _rCellRangeAddress )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir OSL_ENSURE( _rxControlModel.is() && _rCellRangeAddress.getLength(),
358cdf0e10cSrcweir "OFormLayerXMLImport_Impl::registerCellRangeListSource: invalid arguments!" );
359cdf0e10cSrcweir m_aCellRangeListSources.push_back( ModelStringPair( _rxControlModel, _rCellRangeAddress ) );
360cdf0e10cSrcweir }
361cdf0e10cSrcweir //---------------------------------------------------------------------
getStyleElement(const::rtl::OUString & _rStyleName) const362cdf0e10cSrcweir const SvXMLStyleContext* OFormLayerXMLImport_Impl::getStyleElement(const ::rtl::OUString& _rStyleName) const
363cdf0e10cSrcweir {
364cdf0e10cSrcweir OSL_ENSURE( m_pAutoStyles, "OFormLayerXMLImport_Impl::getStyleElement: have no auto style context!" );
365cdf0e10cSrcweir // did you use setAutoStyleContext?
366cdf0e10cSrcweir
367cdf0e10cSrcweir const SvXMLStyleContext* pControlStyle =
368cdf0e10cSrcweir m_pAutoStyles ? m_pAutoStyles->FindStyleChildContext( XML_STYLE_FAMILY_TEXT_PARAGRAPH, _rStyleName ) : NULL;
369cdf0e10cSrcweir OSL_ENSURE( pControlStyle || !m_pAutoStyles,
370cdf0e10cSrcweir ::rtl::OString( "OFormLayerXMLImport_Impl::getStyleElement: did not find the style named \"" )
371cdf0e10cSrcweir += ::rtl::OString( _rStyleName.getStr(), _rStyleName.getLength(), RTL_TEXTENCODING_ASCII_US )
372cdf0e10cSrcweir += ::rtl::OString( "\"!" ) );
373cdf0e10cSrcweir return pControlStyle;
374cdf0e10cSrcweir }
375cdf0e10cSrcweir
376cdf0e10cSrcweir //---------------------------------------------------------------------
enterEventContext()377cdf0e10cSrcweir void OFormLayerXMLImport_Impl::enterEventContext()
378cdf0e10cSrcweir {
379cdf0e10cSrcweir // install our own translation table. We need to disable the other tables because of name conflicts.
380cdf0e10cSrcweir m_rImporter.GetEventImport().PushTranslationTable();
381cdf0e10cSrcweir m_rImporter.GetEventImport().AddTranslationTable(g_pFormsEventTranslation);
382cdf0e10cSrcweir }
383cdf0e10cSrcweir
384cdf0e10cSrcweir //---------------------------------------------------------------------
leaveEventContext()385cdf0e10cSrcweir void OFormLayerXMLImport_Impl::leaveEventContext()
386cdf0e10cSrcweir {
387cdf0e10cSrcweir // install the original event tables.
388cdf0e10cSrcweir m_rImporter.GetEventImport().PopTranslationTable();
389cdf0e10cSrcweir }
390cdf0e10cSrcweir
391cdf0e10cSrcweir //---------------------------------------------------------------------
registerControlId(const Reference<XPropertySet> & _rxControl,const::rtl::OUString & _rId)392cdf0e10cSrcweir void OFormLayerXMLImport_Impl::registerControlId(const Reference< XPropertySet >& _rxControl, const ::rtl::OUString& _rId)
393cdf0e10cSrcweir {
394cdf0e10cSrcweir OSL_ENSURE(m_aCurrentPageIds != m_aControlIds.end(), "OFormLayerXMLImport_Impl::registerControlId: no current page!");
395cdf0e10cSrcweir OSL_ENSURE(_rId.getLength(), "OFormLayerXMLImport_Impl::registerControlId: invalid (empty) control id!");
396cdf0e10cSrcweir
397cdf0e10cSrcweir OSL_ENSURE(m_aCurrentPageIds->second.end() == m_aCurrentPageIds->second.find(_rId), "OFormLayerXMLImport_Impl::registerControlId: control id already used!");
398cdf0e10cSrcweir m_aCurrentPageIds->second[_rId] = _rxControl;
399cdf0e10cSrcweir }
400cdf0e10cSrcweir
401cdf0e10cSrcweir //---------------------------------------------------------------------
registerControlReferences(const Reference<XPropertySet> & _rxControl,const::rtl::OUString & _rReferringControls)402cdf0e10cSrcweir void OFormLayerXMLImport_Impl::registerControlReferences(const Reference< XPropertySet >& _rxControl, const ::rtl::OUString& _rReferringControls)
403cdf0e10cSrcweir {
404cdf0e10cSrcweir OSL_ENSURE(_rReferringControls.getLength(), "OFormLayerXMLImport_Impl::registerControlReferences: invalid (empty) control id list!");
405cdf0e10cSrcweir OSL_ENSURE(_rxControl.is(), "OFormLayerXMLImport_Impl::registerControlReferences: invalid (NULL) control!");
406cdf0e10cSrcweir m_aControlReferences.push_back( ModelStringPair( _rxControl, _rReferringControls ) );
407cdf0e10cSrcweir }
408cdf0e10cSrcweir
409cdf0e10cSrcweir //---------------------------------------------------------------------
startPage(const Reference<XDrawPage> & _rxDrawPage)410cdf0e10cSrcweir void OFormLayerXMLImport_Impl::startPage(const Reference< XDrawPage >& _rxDrawPage)
411cdf0e10cSrcweir {
412cdf0e10cSrcweir m_xCurrentPageFormsSupp.clear();
413cdf0e10cSrcweir
414cdf0e10cSrcweir OSL_ENSURE(_rxDrawPage.is(), "OFormLayerXMLImport_Impl::startPage: NULL page!");
415cdf0e10cSrcweir m_xCurrentPageFormsSupp = m_xCurrentPageFormsSupp.query( _rxDrawPage );
416cdf0e10cSrcweir OSL_ENSURE( m_xCurrentPageFormsSupp.is(), "OFormLayerXMLImport_Impl::startPage: invalid draw page (no XFormsSupplier)!" );
417cdf0e10cSrcweir if ( !m_xCurrentPageFormsSupp.is() )
418cdf0e10cSrcweir return;
419cdf0e10cSrcweir
420cdf0e10cSrcweir // add a new entry to our page map
421cdf0e10cSrcweir ::std::pair< MapDrawPage2MapIterator, bool > aPagePosition;
422cdf0e10cSrcweir aPagePosition =
423cdf0e10cSrcweir m_aControlIds.insert(MapDrawPage2Map::value_type(_rxDrawPage, MapString2PropertySet()));
424cdf0e10cSrcweir OSL_ENSURE(aPagePosition.second, "OFormLayerXMLImport_Impl::startPage: already imported this page!");
425cdf0e10cSrcweir m_aCurrentPageIds = aPagePosition.first;
426cdf0e10cSrcweir }
427cdf0e10cSrcweir
428cdf0e10cSrcweir //---------------------------------------------------------------------
endPage()429cdf0e10cSrcweir void OFormLayerXMLImport_Impl::endPage()
430cdf0e10cSrcweir {
431cdf0e10cSrcweir OSL_ENSURE( m_xCurrentPageFormsSupp.is(), "OFormLayerXMLImport_Impl::endPage: sure you called startPage before?" );
432cdf0e10cSrcweir
433cdf0e10cSrcweir // do some knittings for the controls which are referring to each other
434cdf0e10cSrcweir try
435cdf0e10cSrcweir {
436cdf0e10cSrcweir static const sal_Unicode s_nSeparator = ',';
437cdf0e10cSrcweir ::rtl::OUString sReferring;
438cdf0e10cSrcweir ::rtl::OUString sCurrentReferring;
439cdf0e10cSrcweir ::rtl::OUString sSeparator(&s_nSeparator, 1);
440cdf0e10cSrcweir Reference< XPropertySet > xCurrentReferring;
441cdf0e10cSrcweir sal_Int32 nSeparator, nPrevSep;
442cdf0e10cSrcweir ::std::vector< ModelStringPair >::const_iterator aEnd = m_aControlReferences.end();
443cdf0e10cSrcweir for ( ::std::vector< ModelStringPair >::const_iterator aReferences = m_aControlReferences.begin();
444cdf0e10cSrcweir aReferences != aEnd;
445cdf0e10cSrcweir ++aReferences
446cdf0e10cSrcweir )
447cdf0e10cSrcweir {
448cdf0e10cSrcweir // the list of control ids is comma separated
449cdf0e10cSrcweir
450cdf0e10cSrcweir // in a list of n ids there are only n-1 separators ... have to catch this last id
451cdf0e10cSrcweir // -> normalize the list
452cdf0e10cSrcweir sReferring = aReferences->second;
453cdf0e10cSrcweir sReferring += sSeparator;
454cdf0e10cSrcweir
455cdf0e10cSrcweir nPrevSep = -1;
456cdf0e10cSrcweir while (-1 != (nSeparator = sReferring.indexOf(s_nSeparator, nPrevSep + 1)))
457cdf0e10cSrcweir {
458cdf0e10cSrcweir sCurrentReferring = sReferring.copy(nPrevSep + 1, nSeparator - nPrevSep - 1);
459cdf0e10cSrcweir xCurrentReferring = lookupControlId(sCurrentReferring);
460cdf0e10cSrcweir if (xCurrentReferring.is())
461cdf0e10cSrcweir // if this condition fails, this is an error, but lookupControlId should have asserted this ...
462cdf0e10cSrcweir xCurrentReferring->setPropertyValue( PROPERTY_CONTROLLABEL, makeAny( aReferences->first ) );
463cdf0e10cSrcweir
464cdf0e10cSrcweir nPrevSep = nSeparator;
465cdf0e10cSrcweir }
466cdf0e10cSrcweir }
467cdf0e10cSrcweir }
468cdf0e10cSrcweir catch(Exception&)
469cdf0e10cSrcweir {
470cdf0e10cSrcweir OSL_ENSURE(sal_False, "OFormLayerXMLImport_Impl::endPage: unable to knit the control references (caught an exception)!");
471cdf0e10cSrcweir }
472cdf0e10cSrcweir
473cdf0e10cSrcweir // now that we have all children of the forms collection, attach the events
474cdf0e10cSrcweir Reference< XIndexAccess > xIndexContainer;
475cdf0e10cSrcweir if ( m_xCurrentPageFormsSupp.is() && m_xCurrentPageFormsSupp->hasForms() )
476cdf0e10cSrcweir xIndexContainer = xIndexContainer.query( m_xCurrentPageFormsSupp->getForms() );
477cdf0e10cSrcweir if ( xIndexContainer.is() )
478cdf0e10cSrcweir ODefaultEventAttacherManager::setEvents( xIndexContainer );
479cdf0e10cSrcweir
480cdf0e10cSrcweir // clear the structures for the control references.
481cdf0e10cSrcweir m_aControlReferences.clear();
482cdf0e10cSrcweir
483cdf0e10cSrcweir // and no we have no current page anymore
484cdf0e10cSrcweir m_aCurrentPageIds = m_aControlIds.end();
485cdf0e10cSrcweir }
486cdf0e10cSrcweir
487cdf0e10cSrcweir //---------------------------------------------------------------------
lookupControlId(const::rtl::OUString & _rControlId)488cdf0e10cSrcweir Reference< XPropertySet > OFormLayerXMLImport_Impl::lookupControlId(const ::rtl::OUString& _rControlId)
489cdf0e10cSrcweir {
490cdf0e10cSrcweir OSL_ENSURE(m_aCurrentPageIds != m_aControlIds.end(), "OFormLayerXMLImport_Impl::lookupControlId: no current page!");
491cdf0e10cSrcweir Reference< XPropertySet > xReturn;
492cdf0e10cSrcweir if (m_aCurrentPageIds != m_aControlIds.end())
493cdf0e10cSrcweir {
494cdf0e10cSrcweir ConstMapString2PropertySetIterator aPos = m_aCurrentPageIds->second.find(_rControlId);
495cdf0e10cSrcweir if (m_aCurrentPageIds->second.end() != aPos)
496cdf0e10cSrcweir xReturn = aPos->second;
497cdf0e10cSrcweir else
498cdf0e10cSrcweir OSL_ENSURE(sal_False, "OFormLayerXMLImport_Impl::lookupControlId: invalid control id (did not find it)!");
499cdf0e10cSrcweir }
500cdf0e10cSrcweir return xReturn;
501cdf0e10cSrcweir }
502cdf0e10cSrcweir
503cdf0e10cSrcweir //---------------------------------------------------------------------
createOfficeFormsContext(SvXMLImport & _rImport,sal_uInt16 _nPrefix,const rtl::OUString & _rLocalName)504cdf0e10cSrcweir SvXMLImportContext* OFormLayerXMLImport_Impl::createOfficeFormsContext(
505cdf0e10cSrcweir SvXMLImport& _rImport,
506cdf0e10cSrcweir sal_uInt16 _nPrefix,
507cdf0e10cSrcweir const rtl::OUString& _rLocalName)
508cdf0e10cSrcweir {
509cdf0e10cSrcweir return new OFormsRootImport( _rImport, _nPrefix, _rLocalName );
510cdf0e10cSrcweir }
511cdf0e10cSrcweir
512cdf0e10cSrcweir //---------------------------------------------------------------------
createContext(const sal_uInt16 _nPrefix,const rtl::OUString & _rLocalName,const Reference<sax::XAttributeList> &)513cdf0e10cSrcweir SvXMLImportContext* OFormLayerXMLImport_Impl::createContext(const sal_uInt16 _nPrefix, const rtl::OUString& _rLocalName,
514cdf0e10cSrcweir const Reference< sax::XAttributeList >&)
515cdf0e10cSrcweir {
516cdf0e10cSrcweir SvXMLImportContext* pContext = NULL;
517cdf0e10cSrcweir if ( 0 == _rLocalName.compareToAscii( "form" ) )
518cdf0e10cSrcweir {
519cdf0e10cSrcweir if ( m_xCurrentPageFormsSupp.is() )
520cdf0e10cSrcweir pContext = new OFormImport(*this, *this, _nPrefix, _rLocalName, m_xCurrentPageFormsSupp->getForms() );
521cdf0e10cSrcweir }
522cdf0e10cSrcweir else if ( ( _nPrefix == XML_NAMESPACE_XFORMS
523cdf0e10cSrcweir && ( xmloff::token::IsXMLToken( _rLocalName, xmloff::token::XML_MODEL ) ) )
524cdf0e10cSrcweir )
525cdf0e10cSrcweir {
526cdf0e10cSrcweir pContext = createXFormsModelContext( m_rImporter, _nPrefix, _rLocalName );
527cdf0e10cSrcweir }
528cdf0e10cSrcweir
529cdf0e10cSrcweir if ( !pContext )
530cdf0e10cSrcweir {
531cdf0e10cSrcweir OSL_ENSURE( false, "unknown element" );
532cdf0e10cSrcweir pContext =
533cdf0e10cSrcweir new SvXMLImportContext(m_rImporter, _nPrefix, _rLocalName);
534cdf0e10cSrcweir }
535cdf0e10cSrcweir
536cdf0e10cSrcweir return pContext;
537cdf0e10cSrcweir }
538cdf0e10cSrcweir
539cdf0e10cSrcweir //---------------------------------------------------------------------
seekPage(const Reference<XDrawPage> & _rxDrawPage)540cdf0e10cSrcweir void OFormLayerXMLImport_Impl::seekPage(const Reference< XDrawPage >& _rxDrawPage)
541cdf0e10cSrcweir {
542cdf0e10cSrcweir OSL_ENSURE(m_aCurrentPageIds == m_aControlIds.end(), "OFormLayerXMLImport_Impl::seekPage: importing another page currently! This will smash your import!");
543cdf0e10cSrcweir m_aCurrentPageIds = m_aControlIds.find(_rxDrawPage);
544cdf0e10cSrcweir OSL_ENSURE(m_aCurrentPageIds != m_aControlIds.end(), "OFormLayerXMLImport_Impl::seekPage: did not find the given page (perhaps it has not been imported, yet?)!");
545cdf0e10cSrcweir }
546cdf0e10cSrcweir
547cdf0e10cSrcweir //---------------------------------------------------------------------
documentDone()548cdf0e10cSrcweir void OFormLayerXMLImport_Impl::documentDone( )
549cdf0e10cSrcweir {
550cdf0e10cSrcweir SvXMLImport& rImport = getGlobalContext();
551cdf0e10cSrcweir if ( ( rImport.getImportFlags() & IMPORT_CONTENT ) == 0 )
552cdf0e10cSrcweir return;
553cdf0e10cSrcweir
554cdf0e10cSrcweir // create (and bind) the spreadsheet cell bindings
555cdf0e10cSrcweir if ( !m_aCellValueBindings.empty()
556cdf0e10cSrcweir && FormCellBindingHelper::isCellBindingAllowed( rImport.GetModel() )
557cdf0e10cSrcweir )
558cdf0e10cSrcweir {
559cdf0e10cSrcweir static ::rtl::OUString s_sIndex( RTL_CONSTASCII_USTRINGPARAM( ":index" ) );
560cdf0e10cSrcweir ::std::vector< ModelStringPair >::const_iterator aEnd = m_aCellValueBindings.end();
561cdf0e10cSrcweir for ( ::std::vector< ModelStringPair >::const_iterator aCellBindings = m_aCellValueBindings.begin();
562cdf0e10cSrcweir aCellBindings != aEnd;
563cdf0e10cSrcweir ++aCellBindings
564cdf0e10cSrcweir )
565cdf0e10cSrcweir {
566cdf0e10cSrcweir try
567cdf0e10cSrcweir {
568cdf0e10cSrcweir FormCellBindingHelper aHelper( aCellBindings->first, rImport.GetModel() );
569cdf0e10cSrcweir OSL_ENSURE( aHelper.isCellBindingAllowed(), "OFormLayerXMLImport_Impl::documentDone: can't bind this control model!" );
570cdf0e10cSrcweir if ( aHelper.isCellBindingAllowed() )
571cdf0e10cSrcweir {
572cdf0e10cSrcweir // There are special bindings for listboxes. See
573cdf0e10cSrcweir // OListAndComboImport::doRegisterCellValueBinding for a comment on this HACK.
574cdf0e10cSrcweir ::rtl::OUString sBoundCellAddress( aCellBindings->second );
575cdf0e10cSrcweir sal_Int32 nIndicator = sBoundCellAddress.lastIndexOf( s_sIndex );
576cdf0e10cSrcweir
577cdf0e10cSrcweir bool bUseIndexBinding = false;
578cdf0e10cSrcweir if ( nIndicator != -1 )
579cdf0e10cSrcweir {
580cdf0e10cSrcweir sBoundCellAddress = sBoundCellAddress.copy( 0, nIndicator );
581cdf0e10cSrcweir bUseIndexBinding = true;
582cdf0e10cSrcweir }
583cdf0e10cSrcweir
584cdf0e10cSrcweir aHelper.setBinding( aHelper.createCellBindingFromStringAddress( sBoundCellAddress, bUseIndexBinding ) );
585cdf0e10cSrcweir }
586cdf0e10cSrcweir }
587cdf0e10cSrcweir catch( const Exception& )
588cdf0e10cSrcweir {
589cdf0e10cSrcweir OSL_ENSURE( sal_False, "OFormLayerXMLImport_Impl::documentDone: caught an exception while binding to a cell!" );
590cdf0e10cSrcweir }
591cdf0e10cSrcweir }
592cdf0e10cSrcweir m_aCellValueBindings.clear();
593cdf0e10cSrcweir }
594cdf0e10cSrcweir
595cdf0e10cSrcweir // the same for the spreadsheet cell range list sources
596cdf0e10cSrcweir if ( !m_aCellRangeListSources.empty()
597cdf0e10cSrcweir && FormCellBindingHelper::isListCellRangeAllowed( rImport.GetModel() )
598cdf0e10cSrcweir )
599cdf0e10cSrcweir {
600cdf0e10cSrcweir for ( ::std::vector< ModelStringPair >::const_iterator aRangeBindings = m_aCellRangeListSources.begin();
601cdf0e10cSrcweir aRangeBindings != m_aCellRangeListSources.end();
602cdf0e10cSrcweir ++aRangeBindings
603cdf0e10cSrcweir )
604cdf0e10cSrcweir {
605cdf0e10cSrcweir try
606cdf0e10cSrcweir {
607cdf0e10cSrcweir FormCellBindingHelper aHelper( aRangeBindings->first, rImport.GetModel() );
608cdf0e10cSrcweir OSL_ENSURE( aHelper.isListCellRangeAllowed(), "OFormLayerXMLImport_Impl::documentDone: can't bind this control model!" );
609cdf0e10cSrcweir if ( aHelper.isListCellRangeAllowed() )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir aHelper.setListSource( aHelper.createCellListSourceFromStringAddress( aRangeBindings->second ) );
612cdf0e10cSrcweir }
613cdf0e10cSrcweir }
614cdf0e10cSrcweir catch( const Exception& )
615cdf0e10cSrcweir {
616cdf0e10cSrcweir OSL_ENSURE( sal_False, "OFormLayerXMLImport_Impl::documentDone: caught an exception while binding to a cell range!" );
617cdf0e10cSrcweir }
618cdf0e10cSrcweir }
619cdf0e10cSrcweir m_aCellRangeListSources.clear();
620cdf0e10cSrcweir }
621cdf0e10cSrcweir
622cdf0e10cSrcweir // process XForms-bindings; call registerXFormsValueBinding for each
623cdf0e10cSrcweir std::for_each( m_aXFormsValueBindings.begin(),
624cdf0e10cSrcweir m_aXFormsValueBindings.end(),
625cdf0e10cSrcweir bind1st( ptr_fun( bindXFormsValueBinding ),
626cdf0e10cSrcweir rImport.GetModel() ) );
627cdf0e10cSrcweir // same for list bindings
628cdf0e10cSrcweir std::for_each( m_aXFormsListBindings.begin(),
629cdf0e10cSrcweir m_aXFormsListBindings.end(),
630cdf0e10cSrcweir bind1st( ptr_fun( bindXFormsListBinding ),
631cdf0e10cSrcweir rImport.GetModel() ) );
632cdf0e10cSrcweir // same for submissions
633cdf0e10cSrcweir std::for_each( m_aXFormsSubmissions.begin(),
634cdf0e10cSrcweir m_aXFormsSubmissions.end(),
635cdf0e10cSrcweir bind1st( ptr_fun( bindXFormsSubmission ),
636cdf0e10cSrcweir rImport.GetModel() ) );
637cdf0e10cSrcweir }
638cdf0e10cSrcweir
639cdf0e10cSrcweir //.........................................................................
640cdf0e10cSrcweir } // namespace xmloff
641cdf0e10cSrcweir //.........................................................................
642cdf0e10cSrcweir
643