xref: /aoo42x/main/svx/source/form/datanavi.cxx (revision cdf0e10c)
1  /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 #include "datanavi.hxx"
32 #include "fmservs.hxx"
33 
34 #include "datanavi.hrc"
35 #include "svx/fmresids.hrc"
36 #include "fmhelp.hrc"
37 #include <svx/svxids.hrc>
38 #include <tools/rcid.h>
39 #include <tools/diagnose_ex.h>
40 #include "svx/xmlexchg.hxx"
41 #include <svx/dialmgr.hxx>
42 #include <svx/fmshell.hxx>
43 #include <svtools/miscopt.hxx>
44 #include <unotools/pathoptions.hxx>
45 #include <unotools/viewoptions.hxx>
46 #include <svtools/svtools.hrc>
47 #include <sfx2/app.hxx>
48 #include <sfx2/filedlghelper.hxx>
49 #include <sfx2/objitem.hxx>
50 #include <sfx2/viewfrm.hxx>
51 #include <sfx2/objsh.hxx>
52 #include <sfx2/bindings.hxx>
53 #include <sfx2/dispatch.hxx>
54 #include <com/sun/star/beans/PropertyAttribute.hpp>
55 #include <com/sun/star/container/XSet.hpp>
56 #include <com/sun/star/datatransfer/XTransferable.hpp>
57 #include <com/sun/star/frame/XController.hpp>
58 #include <com/sun/star/frame/XFramesSupplier.hpp>
59 #include <com/sun/star/frame/XModel.hpp>
60 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
61 #include <com/sun/star/xforms/XFormsSupplier.hpp>
62 #include <com/sun/star/xml/dom/XDocument.hpp>
63 #include <com/sun/star/xml/dom/DOMException.hpp>
64 #include <com/sun/star/form/binding/XValueBinding.hpp>
65 #include <comphelper/processfactory.hxx>
66 #include <rtl/logfile.hxx>
67 
68 using namespace ::com::sun::star::beans;
69 using namespace ::com::sun::star::container;
70 using namespace ::com::sun::star::datatransfer;
71 using namespace ::com::sun::star::frame;
72 using namespace ::com::sun::star::uno;
73 using namespace ::com::sun::star::xml::dom::events;
74 using namespace ::svx;
75 
76 namespace css = ::com::sun::star;
77 
78 #define CFGNAME_DATANAVIGATOR		DEFINE_CONST_UNICODE("DataNavigator")
79 #define CFGNAME_SHOWDETAILS			DEFINE_CONST_UNICODE("ShowDetails")
80 #define MSG_VARIABLE				DEFINE_CONST_UNICODE("%1")
81 #define MODELNAME					DEFINE_CONST_UNICODE("$MODELNAME")
82 #define INSTANCENAME				DEFINE_CONST_UNICODE("$INSTANCENAME")
83 #define ELEMENTNAME					DEFINE_CONST_UNICODE("$ELEMENTNAME")
84 #define ATTRIBUTENAME               DEFINE_CONST_UNICODE("$ATTRIBUTENAME")
85 #define SUBMISSIONNAME              DEFINE_CONST_UNICODE("$SUBMISSIONNAME")
86 #define BINDINGNAME                 DEFINE_CONST_UNICODE("$BINDINGNAME")
87 
88 //............................................................................
89 namespace svxform
90 {
91 //............................................................................
92 
93 	// properties of instance
94 	#define PN_INSTANCE_MODEL		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Instance" ) )
95 	#define PN_INSTANCE_ID			::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) )
96     #define PN_INSTANCE_URL         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) )
97     #define PN_INSTANCE_URLONCE     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URLOnce" ) )
98 
99 	// properties of binding
100 	#define PN_BINDING_ID			::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BindingID" ) )
101 	#define PN_BINDING_EXPR			::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BindingExpression" ) )
102 	#define PN_BINDING_MODEL		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) )
103 	#define PN_BINDING_NAMESPACES	::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModelNamespaces" ) )
104 	#define PN_BINDING_MODELID		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModelID" ) )
105 	#define PN_READONLY_EXPR		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ReadonlyExpression" ) )
106 	#define PN_RELEVANT_EXPR		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RelevantExpression" ) )
107 	#define PN_REQUIRED_EXPR		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RequiredExpression" ) )
108 	#define PN_CONSTRAINT_EXPR		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConstraintExpression" ) )
109 	#define PN_CALCULATE_EXPR		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CalculateExpression" ) )
110 	#define PN_BINDING_TYPE			::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ) )
111 	#define PN_BINDING_READONLY		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ReadOnly" ) )
112 	#define PN_BINDING_ENABLED		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) )
113 
114 	// properties of submission
115 	#define PN_SUBMISSION_ID		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) )
116 	#define PN_SUBMISSION_BIND		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bind" ) )
117 	#define PN_SUBMISSION_REF		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Ref" ) )
118 	#define PN_SUBMISSION_ACTION	::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Action" ) )
119 	#define PN_SUBMISSION_METHOD	::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Method" ) )
120 	#define PN_SUBMISSION_MODEL		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) )
121 	#define PN_SUBMISSION_REPLACE	::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Replace" ) )
122 
123 	// submission methods
124 	#define SUBMITMETHOD_POST		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "post" ) )
125 	#define SUBMITMETHOD_GET		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "get" ) )
126 	#define SUBMITMETHOD_PUT		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "put" ) )
127 
128 	// other const strings
129 	#define TRUE_VALUE				::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true()" ) )
130 	#define FALSE_VALUE				::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false()" ) )
131 	#define NEW_ELEMENT				::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "newElement" ) )
132     #define NEW_ATTRIBUTE           ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "newAttribute" ) )
133     #define EVENTTYPE_SUBTREE       ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DOMSubtreeModified" ) )
134     #define EVENTTYPE_CHARDATA      ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DOMCharacterDataModified" ) )
135     #define EVENTTYPE_ATTR          ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DOMAttrModified" ) )
136 
137 	#define MIN_PAGE_COUNT			3 // at least one instance, one submission and one binding page
138 
139 	struct ItemNode
140 	{
141 		Reference< css::xml::dom::XNode >	m_xNode;
142 		Reference< XPropertySet > 			m_xPropSet;
143 
144 		ItemNode( const Reference< css::xml::dom::XNode >& _rxNode ) :
145 			m_xNode( _rxNode ) {}
146 		ItemNode( const Reference< XPropertySet >& _rxSet ) :
147 			m_xPropSet( _rxSet ) {}
148 
149 		DataGroupType	GetDataGroupType() const;
150 	};
151 
152 	//========================================================================
153 	// class DataTreeListBox
154 	//========================================================================
155 	DataTreeListBox::DataTreeListBox( XFormsPage* pPage, DataGroupType _eGroup, const ResId& rResId ) :
156 
157 		SvTreeListBox( pPage, rResId ),
158 
159 		m_pXFormsPage	( pPage ),
160 		m_eGroup		( _eGroup )
161 
162 	{
163 		EnableContextMenuHandling();
164 
165 		if ( DGTInstance == m_eGroup )
166 			SetDragDropMode( SV_DRAGDROP_CTRL_MOVE |SV_DRAGDROP_CTRL_COPY | SV_DRAGDROP_APP_COPY );
167 	}
168 
169 	DataTreeListBox::~DataTreeListBox()
170 	{
171 		DeleteAndClear();
172 	}
173 
174 	sal_Int8 DataTreeListBox::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
175 	{
176 		return DND_ACTION_NONE;
177 	}
178 	sal_Int8 DataTreeListBox::ExecuteDrop( const ExecuteDropEvent& /*rEvt*/ )
179 	{
180 		return DND_ACTION_NONE;
181 	}
182 	void DataTreeListBox::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
183 	{
184 		SvLBoxEntry* pSelected = FirstSelected();
185 		if ( !pSelected )
186 			// no drag without an entry
187 			return;
188 
189         if ( m_eGroup == DGTBinding )
190             // for the moment, bindings cannot be dragged.
191             // #i59395# / 2005-12-15 / frank.schoenheit@sun.com
192             return;
193 
194 		// GetServiceNameForNode() requires a datatype repository which
195 		// will be automatically build if requested???
196 		Reference< css::xforms::XModel > xModel( m_pXFormsPage->GetXFormsHelper(), UNO_QUERY );
197         Reference< css::xforms::XDataTypeRepository > xDataTypes =
198             xModel->getDataTypeRepository();
199         if(!xDataTypes.is())
200 			return;
201 
202 		using namespace ::com::sun::star::uno;
203 		typedef com::sun::star::form::binding::XValueBinding XValueBinding_t;
204 
205 		ItemNode *pItemNode = static_cast<ItemNode*>(pSelected->GetUserData());
206 
207         if ( !pItemNode )
208         {
209             // the only known (and allowed?) case where this happens are sub-entries of a submission
210             // entry
211             DBG_ASSERT( DGTSubmission == m_eGroup, "DataTreeListBox::StartDrag: how this?" );
212             pSelected = GetParent( pSelected );
213             DBG_ASSERT( pSelected && !GetParent( pSelected ), "DataTreeListBox::StartDrag: what kind of entry *is* this?" );
214                 // on the submission page, we have only top-level entries (the submission themself)
215                 // plus direct children of those (facets of a submission)
216             pItemNode = pSelected ? static_cast< ItemNode* >( pSelected->GetUserData() ) : NULL;
217             if ( !pItemNode )
218                 return;
219         }
220 
221 		OXFormsDescriptor desc;
222 		desc.szName = GetEntryText(pSelected);
223 		if(pItemNode->m_xNode.is()) {
224 			// a valid node interface tells us that we need to create a control from a binding
225 			desc.szServiceName = m_pXFormsPage->GetServiceNameForNode(pItemNode->m_xNode);
226 			desc.xPropSet = m_pXFormsPage->GetBindingForNode(pItemNode->m_xNode);
227 			DBG_ASSERT( desc.xPropSet.is(), "DataTreeListBox::StartDrag(): invalid node binding" );
228 		}
229 		else {
230 			desc.szServiceName = FM_COMPONENT_COMMANDBUTTON;
231 			desc.xPropSet = pItemNode->m_xPropSet;
232 		}
233 		OXFormsTransferable *pTransferable = new OXFormsTransferable(desc);
234 		Reference< XTransferable > xEnsureDelete = pTransferable;
235 		if(pTransferable) {
236 			EndSelection();
237 			pTransferable->StartDrag( this, DND_ACTION_COPY );
238 		}
239 	}
240 
241 	PopupMenu* DataTreeListBox::CreateContextMenu()
242 	{
243 		PopupMenu* pMenu = new PopupMenu( SVX_RES( RID_MENU_DATANAVIGATOR ) );
244 		if ( DGTInstance == m_eGroup )
245 		    pMenu->RemoveItem( pMenu->GetItemPos( TBI_ITEM_ADD ) );
246 		else
247 		{
248 		    pMenu->RemoveItem( pMenu->GetItemPos( TBI_ITEM_ADD_ELEMENT ) );
249 		    pMenu->RemoveItem( pMenu->GetItemPos( TBI_ITEM_ADD_ATTRIBUTE ) );
250 
251 			if ( DGTSubmission == m_eGroup )
252 			{
253 				pMenu->SetItemText( TBI_ITEM_ADD, SVX_RESSTR( RID_STR_DATANAV_ADD_SUBMISSION ) );
254 				pMenu->SetItemText( TBI_ITEM_EDIT, SVX_RESSTR( RID_STR_DATANAV_EDIT_SUBMISSION ) );
255 				pMenu->SetItemText( TBI_ITEM_REMOVE, SVX_RESSTR( RID_STR_DATANAV_REMOVE_SUBMISSION ) );
256 			}
257 			else
258 			{
259 				pMenu->SetItemText( TBI_ITEM_ADD, SVX_RESSTR( RID_STR_DATANAV_ADD_BINDING ) );
260 				pMenu->SetItemText( TBI_ITEM_EDIT, SVX_RESSTR( RID_STR_DATANAV_EDIT_BINDING ) );
261 				pMenu->SetItemText( TBI_ITEM_REMOVE, SVX_RESSTR( RID_STR_DATANAV_REMOVE_BINDING ) );
262 			}
263 		}
264 		m_pXFormsPage->EnableMenuItems( pMenu );
265 		return pMenu;
266 	}
267 
268 	void DataTreeListBox::ExcecuteContextMenuAction( sal_uInt16 _nSelectedPopupEntry )
269 	{
270 		m_pXFormsPage->DoMenuAction( _nSelectedPopupEntry );
271 	}
272 
273 	void DataTreeListBox::RemoveEntry( SvLBoxEntry* _pEntry )
274 	{
275 		if ( _pEntry )
276 		{
277 			delete static_cast< ItemNode* >( _pEntry->GetUserData() );
278 			SvTreeListBox::GetModel()->Remove( _pEntry );
279 		}
280 	}
281 
282 	void DataTreeListBox::DeleteAndClear()
283 	{
284 		sal_uIntPtr i, nCount = GetEntryCount();
285 		for ( i = 0; i < nCount; ++i )
286 		{
287 			SvLBoxEntry* pEntry = GetEntry(i);
288 			if ( pEntry )
289 				delete static_cast< ItemNode* >( pEntry->GetUserData() );
290 		}
291 
292 		Clear();
293 	}
294 
295 	//========================================================================
296 	// class XFormsPage
297 	//========================================================================
298 	XFormsPage::XFormsPage( Window* pParent, DataNavigatorWindow* _pNaviWin, DataGroupType _eGroup ) :
299 
300 		TabPage( pParent, SVX_RES( RID_SVX_XFORMS_TABPAGES ) ),
301 
302 		m_aToolBox		( this, SVX_RES( TB_ITEMS ) ),
303 		m_aItemList		( this, _eGroup, SVX_RES( LB_ITEMS ) ),
304 		m_pNaviWin		( _pNaviWin ),
305 		m_bHasModel		( false ),
306 		m_eGroup		( _eGroup ),
307 		m_TbxImageList	( SVX_RES( IL_TBX_BMPS ) ),
308 		m_TbxHCImageList( SVX_RES( IL_TBX_BMPS_HC ) )
309 
310 	{
311 		FreeResource();
312 
313 		const ImageList& rImageList =
314 			GetBackground().GetColor().IsDark() ? m_TbxHCImageList : m_TbxImageList;
315 		m_aToolBox.SetItemImage( TBI_ITEM_ADD, rImageList.GetImage( IID_ITEM_ADD ) );
316 		m_aToolBox.SetItemImage( TBI_ITEM_ADD_ELEMENT, rImageList.GetImage( IID_ITEM_ADD_ELEMENT ) );
317 		m_aToolBox.SetItemImage( TBI_ITEM_ADD_ATTRIBUTE, rImageList.GetImage( IID_ITEM_ADD_ATTRIBUTE ) );
318 		m_aToolBox.SetItemImage( TBI_ITEM_EDIT, rImageList.GetImage( IID_ITEM_EDIT ) );
319 		m_aToolBox.SetItemImage( TBI_ITEM_REMOVE, rImageList.GetImage( IID_ITEM_REMOVE ) );
320 
321 		if ( DGTInstance == m_eGroup )
322 		    m_aToolBox.RemoveItem( m_aToolBox.GetItemPos( TBI_ITEM_ADD ) );
323 		else
324 		{
325 		    m_aToolBox.RemoveItem( m_aToolBox.GetItemPos( TBI_ITEM_ADD_ELEMENT ) );
326 		    m_aToolBox.RemoveItem( m_aToolBox.GetItemPos( TBI_ITEM_ADD_ATTRIBUTE ) );
327 
328 			if ( DGTSubmission == m_eGroup )
329 			{
330 				m_aToolBox.SetItemText( TBI_ITEM_ADD, SVX_RESSTR( RID_STR_DATANAV_ADD_SUBMISSION ) );
331 				m_aToolBox.SetItemText( TBI_ITEM_EDIT, SVX_RESSTR( RID_STR_DATANAV_EDIT_SUBMISSION ) );
332 				m_aToolBox.SetItemText( TBI_ITEM_REMOVE, SVX_RESSTR( RID_STR_DATANAV_REMOVE_SUBMISSION ) );
333 			}
334 			else
335 			{
336 				m_aToolBox.SetItemText( TBI_ITEM_ADD, SVX_RESSTR( RID_STR_DATANAV_ADD_BINDING ) );
337 				m_aToolBox.SetItemText( TBI_ITEM_EDIT, SVX_RESSTR( RID_STR_DATANAV_EDIT_BINDING ) );
338 				m_aToolBox.SetItemText( TBI_ITEM_REMOVE, SVX_RESSTR( RID_STR_DATANAV_REMOVE_BINDING ) );
339 			}
340 		}
341 
342 		const Size aTbxSz( m_aToolBox.CalcWindowSizePixel() );
343 		m_aToolBox.SetSizePixel( aTbxSz );
344 	    m_aToolBox.SetOutStyle( SvtMiscOptions().GetToolboxStyle() );
345 		m_aToolBox.SetSelectHdl( LINK( this, XFormsPage, TbxSelectHdl ) );
346 		Point aPos = m_aItemList.GetPosPixel();
347 		aPos.Y() = aTbxSz.Height();
348 		m_aItemList.SetPosPixel( aPos );
349 
350 		m_aItemList.SetSelectHdl( LINK( this, XFormsPage, ItemSelectHdl ) );
351 		m_aItemList.SetNodeDefaultImages();
352 		WinBits nBits = WB_BORDER | WB_TABSTOP | WB_HIDESELECTION | WB_NOINITIALSELECTION;
353 		if ( DGTInstance == m_eGroup || DGTSubmission == m_eGroup )
354 			nBits |= WB_HASBUTTONS | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONSATROOT;
355 		m_aItemList.SetStyle( m_aItemList.GetStyle() | nBits  );
356 		m_aItemList.Show();
357 		ItemSelectHdl( &m_aItemList );
358 	}
359 	//------------------------------------------------------------------------
360 	XFormsPage::~XFormsPage()
361 	{
362 	}
363 	//------------------------------------------------------------------------
364 	IMPL_LINK( XFormsPage, TbxSelectHdl, ToolBox *, EMPTYARG )
365 	{
366 		DoToolBoxAction( m_aToolBox.GetCurItemId() );
367 		return 0;
368 	}
369 	//------------------------------------------------------------------------
370 	IMPL_LINK( XFormsPage, ItemSelectHdl, DataTreeListBox *, EMPTYARG )
371 	{
372 		EnableMenuItems( NULL );
373 		return 0;
374 	}
375 	//------------------------------------------------------------------------
376 	void XFormsPage::AddChildren(
377 		SvLBoxEntry* _pParent, const ImageList& _rImgLst,
378 		const Reference< css::xml::dom::XNode >& _xNode )
379 	{
380 		DBG_ASSERT( m_xUIHelper.is(), "XFormsPage::AddChildren(): invalid UIHelper" );
381 
382 		try
383 		{
384 			Reference< css::xml::dom::XNodeList > xNodeList = _xNode->getChildNodes();
385 			if ( xNodeList.is() )
386 			{
387 				bool bShowDetails = m_pNaviWin->IsShowDetails();
388 				sal_Int32 i, nNodeCount = xNodeList->getLength();
389 				for ( i = 0; i < nNodeCount; ++i )
390 				{
391 					Reference< css::xml::dom::XNode > xChild = xNodeList->item(i);
392 					css::xml::dom::NodeType eChildType = xChild->getNodeType();
393 					Image aExpImg, aCollImg;
394 					switch ( eChildType )
395 					{
396 					    case css::xml::dom::NodeType_ATTRIBUTE_NODE:
397 							aExpImg = aCollImg = _rImgLst.GetImage( IID_ATTRIBUTE );
398 							break;
399 					    case css::xml::dom::NodeType_ELEMENT_NODE:
400 							aExpImg = aCollImg = _rImgLst.GetImage( IID_ELEMENT );
401 							break;
402 						case css::xml::dom::NodeType_TEXT_NODE:
403 							aExpImg = aCollImg = _rImgLst.GetImage( IID_TEXT );
404 							break;
405 						default:
406 							aExpImg = aCollImg = _rImgLst.GetImage( IID_OTHER );
407 					}
408 
409 					::rtl::OUString sName = m_xUIHelper->getNodeDisplayName( xChild, bShowDetails );
410 					if ( sName.getLength() > 0 )
411 					{
412 						ItemNode* pNode = new ItemNode( xChild );
413 						SvLBoxEntry* pEntry = m_aItemList.InsertEntry(
414 							sName, aExpImg, aCollImg, _pParent, sal_False, LIST_APPEND, pNode );
415 						if ( xChild->hasAttributes() )
416 						{
417 							Reference< css::xml::dom::XNamedNodeMap > xMap = xChild->getAttributes();
418 							if ( xMap.is() )
419 							{
420 								aExpImg = aCollImg = _rImgLst.GetImage( IID_ATTRIBUTE );
421 								sal_Int32 j, nMapLen = xMap->getLength();
422 								for ( j = 0; j < nMapLen; ++j )
423 								{
424 									Reference< css::xml::dom::XNode > xAttr = xMap->item(j);
425 									pNode = new ItemNode( xAttr );
426 									::rtl::OUString sAttrName =
427 										m_xUIHelper->getNodeDisplayName( xAttr, bShowDetails );
428 									m_aItemList.InsertEntry(
429 										sAttrName, aExpImg, aCollImg,
430 										pEntry, sal_False, LIST_APPEND, pNode );
431 								}
432 							}
433 						}
434 						if ( xChild->hasChildNodes() )
435 							AddChildren( pEntry, _rImgLst, xChild );
436 					}
437 				}
438 			}
439 		}
440         catch( Exception& )
441 		{
442             DBG_UNHANDLED_EXCEPTION();
443 		}
444 	}
445 	//------------------------------------------------------------------------
446 	bool XFormsPage::DoToolBoxAction( sal_uInt16 _nToolBoxID ) {
447 
448 		bool bHandled = false;
449         bool bIsDocModified = false;
450         m_pNaviWin->DisableNotify( true );
451 
452         switch ( _nToolBoxID )
453         {
454         case TBI_ITEM_ADD:
455         case TBI_ITEM_ADD_ELEMENT:
456         case TBI_ITEM_ADD_ATTRIBUTE:
457 		{
458 			bHandled = true;
459 			Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
460 			DBG_ASSERT( xModel.is(), "XFormsPage::DoToolBoxAction(): Action without model" );
461 			if ( DGTSubmission == m_eGroup )
462 			{
463 				AddSubmissionDialog aDlg( this, NULL, m_xUIHelper );
464 				if ( aDlg.Execute() == RET_OK && aDlg.GetNewSubmission().is() )
465 				{
466 					try
467 					{
468 						Reference< css::xforms::XSubmission > xNewSubmission = aDlg.GetNewSubmission();
469 						Reference< XSet > xSubmissions( xModel->getSubmissions(), UNO_QUERY );
470 						xSubmissions->insert( makeAny( xNewSubmission ) );
471 						Reference< XPropertySet > xNewPropSet( xNewSubmission, UNO_QUERY );
472 						SvLBoxEntry* pEntry = AddEntry( xNewPropSet );
473 						m_aItemList.Select( pEntry, sal_True );
474                         bIsDocModified = true;
475 					}
476 					catch ( Exception& )
477 					{
478 						DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while adding submission" );
479 					}
480 				}
481 			}
482 			else
483 			{
484 				DataItemType eType = DITElement;
485 				SvLBoxEntry* pEntry = m_aItemList.FirstSelected();
486 				ItemNode* pNode = NULL;
487 				Reference< css::xml::dom::XNode > xParentNode;
488 				Reference< XPropertySet > xNewBinding;
489 				sal_uInt16 nResId = 0;
490 				bool bIsElement = true;
491 				if ( DGTInstance == m_eGroup )
492 				{
493                     if ( m_sInstanceURL.Len() > 0 )
494                     {
495                         LinkedInstanceWarningBox aMsgBox( this );
496                         if ( aMsgBox.Execute() != RET_OK )
497                             return bHandled;
498                     }
499 
500                     DBG_ASSERT( pEntry, "XFormsPage::DoToolBoxAction(): no entry" );
501 					ItemNode* pParentNode = static_cast< ItemNode* >( pEntry->GetUserData() );
502 					DBG_ASSERT( pParentNode, "XFormsPage::DoToolBoxAction(): no parent node" );
503 					xParentNode = pParentNode->m_xNode;
504 					Reference< css::xml::dom::XNode > xNewNode;
505 					if ( TBI_ITEM_ADD_ELEMENT == _nToolBoxID )
506 					{
507 						try
508 						{
509 							nResId = RID_STR_DATANAV_ADD_ELEMENT;
510 							xNewNode = m_xUIHelper->createElement( xParentNode, NEW_ELEMENT );
511 						}
512 						catch ( Exception& )
513 						{
514 							DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while create element" );
515 						}
516 					}
517 					else
518 					{
519 						nResId = RID_STR_DATANAV_ADD_ATTRIBUTE;
520 						bIsElement = false;
521 						eType = DITAttribute;
522 						try
523 						{
524 							xNewNode = m_xUIHelper->createAttribute( xParentNode, NEW_ATTRIBUTE );
525 						}
526 						catch ( Exception& )
527 						{
528 							DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while create attribute" );
529 						}
530 					}
531 
532 					try
533 					{
534 						xNewNode = xParentNode->appendChild( xNewNode );
535 					}
536 					catch ( css::xml::dom::DOMException& e )
537 					{
538 						if ( e.Code == css::xml::dom::DOMExceptionType_DOMSTRING_SIZE_ERR )
539 						{
540 							DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): domexception: size error" );
541 						}
542 						DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): domexception while append child" );
543 					}
544 					catch ( Exception& )
545 					{
546 						DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while append child" );
547 					}
548 
549 					try
550 					{
551 						Reference< css::xml::dom::XNode > xPNode;
552 						if ( xNewNode.is() )
553 						 	xPNode = xNewNode->getParentNode();
554                         // attributes don't have parents in the DOM model
555 						DBG_ASSERT( TBI_ITEM_ADD_ATTRIBUTE == _nToolBoxID
556 									|| xPNode.is(), "XFormsPage::DoToolboxAction(): node not added" );
557 					}
558 					catch ( Exception& )
559 					{
560                         DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
561 					}
562 
563 					try
564 					{
565 						m_xUIHelper->getBindingForNode( xNewNode, sal_True );
566 					}
567 					catch ( Exception& )
568 					{
569 						DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while get binding for node" );
570 					}
571 					pNode = new ItemNode( xNewNode );
572 				}
573 				else
574 				{
575 					try
576 					{
577 						nResId = RID_STR_DATANAV_ADD_BINDING;
578 						xNewBinding = xModel->createBinding();
579 						Reference< XSet > xBindings( xModel->getBindings(), UNO_QUERY );
580 						xBindings->insert( makeAny( xNewBinding ) );
581 						pNode = new ItemNode( xNewBinding );
582 						eType = DITBinding;
583 					}
584 					catch ( Exception& )
585 					{
586 						DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while adding binding" );
587 					}
588 				}
589 
590 				AddDataItemDialog aDlg( this, pNode, m_xUIHelper );
591 				aDlg.SetText( SVX_RESSTR( nResId ) );
592 				aDlg.InitText( eType );
593 				short nReturn = aDlg.Execute();
594 				if (  DGTInstance == m_eGroup )
595 				{
596 					if ( RET_OK == nReturn )
597 					{
598 						SvLBoxEntry* pNewEntry = AddEntry( pNode, bIsElement );
599 						m_aItemList.MakeVisible( pNewEntry );
600 						m_aItemList.Select( pNewEntry, sal_True );
601                         bIsDocModified = true;
602 					}
603 					else
604 					{
605 						try
606 						{
607 							Reference< css::xml::dom::XNode > xPNode;
608 							Reference< css::xml::dom::XNode > xNode =
609 								xParentNode->removeChild( pNode->m_xNode );
610 							if ( xNode.is() )
611 								xPNode = xNode->getParentNode();
612 							DBG_ASSERT( !xPNode.is(), "XFormsPage::RemoveEntry(): node not removed" );
613 							delete pNode;
614 						}
615 						catch ( Exception& )
616 						{
617                             DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
618 						}
619 					}
620 				}
621 				else
622 				{
623 					if ( RET_OK == nReturn )
624 					{
625 						SvLBoxEntry* pNewEntry = AddEntry( xNewBinding );
626                         m_aItemList.Select( pNewEntry, sal_True );
627                         bIsDocModified = true;
628 					}
629 					else
630 					{
631 						try
632 						{
633 							Reference< XSet > xBindings( xModel->getBindings(), UNO_QUERY );
634 							xBindings->remove( makeAny( xNewBinding ) );
635 						}
636 						catch ( Exception& )
637 						{
638                             DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
639 						}
640 					}
641 					delete pNode;
642 				}
643 			}
644 		}
645         break;
646 
647         case TBI_ITEM_EDIT:
648 		{
649 			bHandled = true;
650 			SvLBoxEntry* pEntry = m_aItemList.FirstSelected();
651 			if ( pEntry )
652 			{
653 				if ( DGTSubmission == m_eGroup && m_aItemList.GetParent( pEntry ) )
654 					pEntry = m_aItemList.GetParent( pEntry );
655 				ItemNode* pNode = static_cast< ItemNode* >( pEntry->GetUserData() );
656 				if ( DGTInstance == m_eGroup || DGTBinding == m_eGroup )
657 				{
658                     if ( DGTInstance == m_eGroup && m_sInstanceURL.Len() > 0 )
659                     {
660                         LinkedInstanceWarningBox aMsgBox( this );
661                         if ( aMsgBox.Execute() != RET_OK )
662                             return bHandled;
663                     }
664 
665 					AddDataItemDialog aDlg( this, pNode, m_xUIHelper );
666 					DataItemType eType = DITElement;
667 					sal_uInt16 nResId = RID_STR_DATANAV_EDIT_ELEMENT;
668 					if ( pNode && pNode->m_xNode.is() )
669 					{
670 						try
671 						{
672 							css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType();
673 							if ( eChildType == css::xml::dom::NodeType_ATTRIBUTE_NODE )
674 							{
675 								nResId = RID_STR_DATANAV_EDIT_ATTRIBUTE;
676 								eType = DITAttribute;
677 							}
678 						}
679 						catch ( Exception& )
680 						{
681                             DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
682 						}
683 					}
684 					else if ( DGTBinding == m_eGroup )
685 					{
686 						nResId = RID_STR_DATANAV_EDIT_BINDING;
687 						eType = DITBinding;
688 					}
689 					aDlg.SetText( SVX_RESSTR( nResId ) );
690 					aDlg.InitText( eType );
691 					if ( aDlg.Execute() == RET_OK )
692 					{
693 						// Set the new name
694 						String sNewName;
695 						if ( DGTInstance == m_eGroup )
696 						{
697 							try
698 							{
699 								sNewName = m_xUIHelper->getNodeDisplayName(
700 									pNode->m_xNode, m_pNaviWin->IsShowDetails() );
701 							}
702 							catch ( Exception& )
703 							{
704                                 DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
705 							}
706 						}
707 						else
708 						{
709 							try
710 							{
711 								String sDelim( RTL_CONSTASCII_STRINGPARAM( ": " ) );
712 								::rtl::OUString sTemp;
713 								pNode->m_xPropSet->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
714 								sNewName += String( sTemp );
715 								sNewName += sDelim;
716 								pNode->m_xPropSet->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
717 								sNewName += String( sTemp );
718 							}
719 							catch ( Exception& )
720 							{
721                                 DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
722 							}
723 						}
724 
725 						m_aItemList.SetEntryText( pEntry, sNewName );
726                         bIsDocModified = true;
727 					}
728 				}
729 				else
730 				{
731 					AddSubmissionDialog aDlg( this, pNode, m_xUIHelper );
732 					aDlg.SetText( SVX_RESSTR( RID_STR_DATANAV_EDIT_SUBMISSION ) );
733 					if ( aDlg.Execute() == RET_OK )
734                     {
735 						EditEntry( pNode->m_xPropSet );
736                         bIsDocModified = true;
737                     }
738 				}
739 			}
740 		}
741         break;
742 
743         case TBI_ITEM_REMOVE:
744         {
745 			bHandled = true;
746             if ( DGTInstance == m_eGroup && m_sInstanceURL.Len() > 0 )
747             {
748                 LinkedInstanceWarningBox aMsgBox( this );
749                 if ( aMsgBox.Execute() != RET_OK )
750                     return bHandled;
751             }
752             bIsDocModified = RemoveEntry();
753         }
754         break;
755 
756         case MID_INSERT_CONTROL:
757         {
758             OSL_ENSURE( false, "XFormsPage::DoToolboxAction: MID_INSERT_CONTROL not implemented, yet!" );
759         }
760         break;
761 
762         default:
763             OSL_ENSURE( false, "XFormsPage::DoToolboxAction: unknown ID!" );
764             break;
765         }
766 
767         m_pNaviWin->DisableNotify( false );
768 		EnableMenuItems( NULL );
769         if ( bIsDocModified )
770             m_pNaviWin->SetDocModified();
771 		return bHandled;
772 	}
773 
774 	//------------------------------------------------------------------------
775 	SvLBoxEntry* XFormsPage::AddEntry( ItemNode* _pNewNode, bool _bIsElement )
776 	{
777 		SvLBoxEntry* pParent = m_aItemList.FirstSelected();
778 		const ImageList& rImageList = GetSettings().GetStyleSettings().GetHighContrastMode()
779 			? m_pNaviWin->GetItemHCImageList()
780 			: m_pNaviWin->GetItemImageList();
781 		sal_uInt16 nImageID = ( _bIsElement ) ? IID_ELEMENT : IID_ATTRIBUTE;
782 		Image aImage = rImageList.GetImage( nImageID );
783 		::rtl::OUString sName;
784 		try
785 		{
786 			sName = m_xUIHelper->getNodeDisplayName(
787 				_pNewNode->m_xNode, m_pNaviWin->IsShowDetails() );
788 		}
789 		catch ( Exception& )
790 		{
791             DBG_UNHANDLED_EXCEPTION();
792 		}
793 		return m_aItemList.InsertEntry(
794 			sName, aImage, aImage, pParent, sal_False, LIST_APPEND, _pNewNode );
795 	}
796 	//------------------------------------------------------------------------
797     class lcl_ResourceString
798     {
799     protected:
800         lcl_ResourceString()
801         {
802         }
803 
804         lcl_ResourceString( const lcl_ResourceString& );
805 
806         virtual ~lcl_ResourceString()
807         {
808         }
809 
810         // load UI resources from resource file
811         void init()
812         {
813             // create a resource manager, for the svx resource file
814             // and the UI locale
815             ByteString aResourceFile( "svx" );
816             ResMgr* pResMgr = ResMgr::CreateResMgr(
817                 aResourceFile.GetBuffer(),
818                 Application::GetSettings().GetUILocale() );
819 
820             // load the resources for the AddSubmission modal dialog.
821             // This will create our own resource context.
822             ResId aRes( RID_SVXDLG_ADD_SUBMISSION, *pResMgr );
823             aRes.SetRT( RSC_MODALDIALOG );
824             pResMgr->GetResource( aRes );
825 
826             // now, we can access the local resources from the dialog's
827             // resource context
828             _initResources(pResMgr);
829 
830             // clean up: remove context, and delete the resource manager
831             // ( Increment(..) is needed since PopContext() requires that
832             //   the file pointer is at the end. )
833             pResMgr->Increment( pResMgr->GetRemainSize() );
834             pResMgr->PopContext();
835             delete pResMgr;
836         }
837 
838         // load resources... to be overloaded in sub-classes
839         virtual void _initResources( ResMgr* pMgr ) = 0;
840     };
841 
842     class lcl_ReplaceString : public lcl_ResourceString
843     {
844         rtl::OUString m_sDoc_UI;
845         rtl::OUString m_sInstance_UI;
846         rtl::OUString m_sNone_UI;
847 
848         rtl::OUString m_sDoc_API;
849         rtl::OUString m_sInstance_API;
850         rtl::OUString m_sNone_API;
851 
852         lcl_ReplaceString() :
853             lcl_ResourceString(),
854             m_sDoc_API(      RTL_CONSTASCII_USTRINGPARAM("all") ),
855             m_sInstance_API( RTL_CONSTASCII_USTRINGPARAM("instance") ),
856             m_sNone_API(     RTL_CONSTASCII_USTRINGPARAM("none") )
857         {
858             init();
859         }
860 
861         lcl_ReplaceString( const lcl_ReplaceString& );
862 
863         virtual ~lcl_ReplaceString()
864         {
865         }
866 
867         // load UI resources from resource file
868         virtual void _initResources( ResMgr * pMgr )
869         {
870             // now, we can access the local resources from the dialog's
871             // resource context
872             m_sDoc_UI      = String( ResId( STR_REPLACE_DOC, *pMgr ) );
873             m_sInstance_UI = String( ResId( STR_REPLACE_INST, *pMgr ) );
874             m_sNone_UI     = String( ResId( STR_REPLACE_NONE, *pMgr ) );
875         }
876 
877     public:
878 
879         /** create and obtain the singleton instance */
880         static const lcl_ReplaceString& get()
881         {
882             // keep the singleton instance here
883             static lcl_ReplaceString* m_pInstance = NULL;
884 
885             if( m_pInstance == NULL )
886                 m_pInstance = new lcl_ReplaceString();
887             return *m_pInstance;
888         }
889 
890         /** convert submission replace string from API value to UI value.
891             Use 'none' as default. */
892         rtl::OUString toUI( const rtl::OUString& rStr ) const
893         {
894             if( rStr == m_sDoc_API )
895                 return m_sDoc_UI;
896             else if( rStr == m_sInstance_API )
897                 return m_sInstance_UI;
898             else
899                 return m_sNone_UI;
900         }
901 
902         /** convert submission replace string from UI to API.
903             Use 'none' as default. */
904         rtl::OUString toAPI( const rtl::OUString& rStr ) const
905         {
906             if( rStr == m_sDoc_UI )
907                 return m_sDoc_API;
908             else if( rStr == m_sInstance_UI )
909                 return m_sInstance_API;
910             else
911                 return m_sNone_API;
912         }
913     };
914 
915     class lcl_MethodString : public lcl_ResourceString
916     {
917         rtl::OUString m_sPost_UI;
918         rtl::OUString m_sPut_UI;
919         rtl::OUString m_sGet_UI;
920 
921         rtl::OUString m_sPost_API;
922         rtl::OUString m_sPut_API;
923         rtl::OUString m_sGet_API;
924 
925         lcl_MethodString() :
926             lcl_ResourceString(),
927             m_sPost_API( RTL_CONSTASCII_USTRINGPARAM("post") ),
928             m_sPut_API(  RTL_CONSTASCII_USTRINGPARAM("put") ),
929             m_sGet_API(  RTL_CONSTASCII_USTRINGPARAM("get") )
930         {
931             init();
932         }
933 
934         lcl_MethodString( const lcl_MethodString& );
935 
936         virtual ~lcl_MethodString()
937         {
938         }
939 
940         // load UI resources from resource file
941         virtual void _initResources(ResMgr* pMgr)
942         {
943             m_sPost_UI = String( ResId( STR_METHOD_POST, *pMgr ) );
944             m_sPut_UI  = String( ResId( STR_METHOD_PUT, *pMgr ) );
945             m_sGet_UI  = String( ResId( STR_METHOD_GET, *pMgr ) );
946         }
947 
948     public:
949 
950         /** create and obtain the singleton instance */
951         static const lcl_MethodString& get()
952         {
953             // keep the singleton instance here
954             static lcl_MethodString* m_pInstance = NULL;
955 
956             if( m_pInstance == NULL )
957                 m_pInstance = new lcl_MethodString();
958             return *m_pInstance;
959         }
960 
961         /** convert from API to UI; put is default. */
962         rtl::OUString toUI( const rtl::OUString& rStr ) const
963         {
964             if( rStr == m_sGet_API )
965                 return m_sGet_UI;
966             else if( rStr == m_sPost_API )
967                 return m_sPost_UI;
968             else
969                 return m_sPut_UI;
970         }
971 
972         /** convert from UI to API; put is default */
973         rtl::OUString toAPI( const rtl::OUString& rStr ) const
974         {
975             if( rStr == m_sGet_UI )
976                 return m_sGet_API;
977             else if( rStr == m_sPost_UI )
978                 return m_sPost_API;
979             else
980                 return m_sPut_API;
981         }
982     };
983 
984 	//------------------------------------------------------------------------
985 	SvLBoxEntry* XFormsPage::AddEntry( const Reference< XPropertySet >& _rEntry )
986 	{
987 		SvLBoxEntry* pEntry = NULL;
988 		const ImageList& rImageList = GetSettings().GetStyleSettings().GetHighContrastMode()
989 			? m_pNaviWin->GetItemHCImageList()
990 			: m_pNaviWin->GetItemImageList();
991 		Image aImage = rImageList.GetImage( IID_ELEMENT );
992 
993 		ItemNode* pNode = new ItemNode( _rEntry );
994 		rtl::OUString sTemp;
995 
996 		if ( DGTSubmission == m_eGroup )
997 		{
998 			try
999 			{
1000 				// ID
1001 				_rEntry->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp;
1002 				pEntry = m_aItemList.InsertEntry( sTemp, aImage, aImage, NULL, sal_False, LIST_APPEND, pNode );
1003 				// Action
1004 				_rEntry->getPropertyValue( PN_SUBMISSION_ACTION ) >>= sTemp;
1005 				String sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_ACTION );
1006 				sEntry += String( sTemp );
1007 				m_aItemList.InsertEntry( sEntry, aImage, aImage, pEntry );
1008 				// Method
1009 				_rEntry->getPropertyValue( PN_SUBMISSION_METHOD ) >>= sTemp;
1010 				sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_METHOD );
1011 				sEntry += String( lcl_MethodString::get().toUI( sTemp ) );
1012 				m_aItemList.InsertEntry( sEntry, aImage, aImage, pEntry );
1013 				// Ref
1014 				_rEntry->getPropertyValue( PN_SUBMISSION_REF ) >>= sTemp;
1015 				sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_REF );
1016 				sEntry += String( sTemp );
1017 				m_aItemList.InsertEntry( sEntry, aImage, aImage, pEntry );
1018 				// Bind
1019 				_rEntry->getPropertyValue( PN_SUBMISSION_BIND ) >>= sTemp;
1020 				sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_BIND );
1021 				sEntry += String( sTemp );
1022 				m_aItemList.InsertEntry( sEntry, aImage, aImage, pEntry );
1023 				// Replace
1024 				_rEntry->getPropertyValue( PN_SUBMISSION_REPLACE ) >>= sTemp;
1025 				sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_REPLACE );
1026 				sEntry += String( lcl_ReplaceString::get().toUI( sTemp ) );
1027 				m_aItemList.InsertEntry( sEntry, aImage, aImage, pEntry );
1028 			}
1029 			catch ( Exception& )
1030 			{
1031                 DBG_ERRORFILE( "XFormsPage::AddEntry(Ref): exception caught" );
1032 			}
1033 		}
1034 		else // then Binding Page
1035 		{
1036 			try
1037 			{
1038 				String sDelim( RTL_CONSTASCII_STRINGPARAM( ": " ) );
1039 				::rtl::OUString sName;
1040 				_rEntry->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
1041 				sName += String( sTemp );
1042 				sName += sDelim;
1043 				_rEntry->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
1044 				sName += String( sTemp );
1045 				pEntry = m_aItemList.InsertEntry(
1046 					sName, aImage, aImage, NULL, sal_False, LIST_APPEND, pNode );
1047 			}
1048 			catch ( Exception& )
1049 			{
1050                 DBG_ERRORFILE( "XFormsPage::AddEntry(Ref): exception caught" );
1051 			}
1052 		}
1053 
1054 		return pEntry;
1055 	}
1056 
1057 	//------------------------------------------------------------------------
1058 	void XFormsPage::EditEntry( const Reference< XPropertySet >& _rEntry )
1059 	{
1060 		SvLBoxEntry* pEntry = NULL;
1061 		rtl::OUString sTemp;
1062 
1063 		if ( DGTSubmission == m_eGroup )
1064 		{
1065 			try
1066 			{
1067 				pEntry = m_aItemList.FirstSelected();
1068 
1069                 // #i36262# may be called for submission entry *or* for
1070                 // submission children. If we don't have any children, we
1071                 // assume the latter case and use the parent
1072                 if( m_aItemList.GetEntry( pEntry, 0 ) == NULL )
1073                 {
1074                     pEntry = m_aItemList.GetModel()->GetParent( pEntry );
1075                 }
1076 
1077 				_rEntry->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp;
1078 				m_aItemList.SetEntryText( pEntry, sTemp );
1079 
1080 				_rEntry->getPropertyValue( PN_SUBMISSION_BIND ) >>= sTemp;
1081 				String sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_BIND );
1082 				sEntry += String( sTemp );
1083 				sal_uIntPtr nPos = 0;
1084 				SvLBoxEntry* pChild = m_aItemList.GetEntry( pEntry, nPos++ );
1085 				m_aItemList.SetEntryText( pChild, sEntry );
1086 				_rEntry->getPropertyValue( PN_SUBMISSION_REF ) >>= sTemp;
1087 				sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_REF );
1088 				sEntry += String( sTemp );
1089 				pChild = m_aItemList.GetEntry( pEntry, nPos++ );
1090 				m_aItemList.SetEntryText( pChild, sEntry );
1091 				_rEntry->getPropertyValue( PN_SUBMISSION_ACTION ) >>= sTemp;
1092 				sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_ACTION );
1093 				sEntry += String( sTemp );
1094 				pChild = m_aItemList.GetEntry( pEntry, nPos++ );
1095 				m_aItemList.SetEntryText( pChild, sEntry );
1096 				_rEntry->getPropertyValue( PN_SUBMISSION_METHOD ) >>= sTemp;
1097 				sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_METHOD );
1098 				sEntry += String( lcl_MethodString::get().toUI( sTemp ) );
1099 				pChild = m_aItemList.GetEntry( pEntry, nPos++ );
1100 				m_aItemList.SetEntryText( pChild, sEntry );
1101 				_rEntry->getPropertyValue( PN_SUBMISSION_REPLACE ) >>= sTemp;
1102 				sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_REPLACE );
1103 				sEntry += String( lcl_ReplaceString::get().toUI( sTemp ) );
1104 				pChild = m_aItemList.GetEntry( pEntry, nPos++ );
1105 				m_aItemList.SetEntryText( pChild, sEntry );
1106 			}
1107 			catch ( Exception& )
1108 			{
1109                 DBG_ERRORFILE( "XFormsPage::EditEntry(): exception caught" );
1110 			}
1111 		}
1112 	}
1113 
1114 	//------------------------------------------------------------------------
1115     bool XFormsPage::RemoveEntry()
1116 	{
1117         bool bRet = false;
1118 		SvLBoxEntry* pEntry = m_aItemList.FirstSelected();
1119 		if ( pEntry &&
1120              ( DGTInstance != m_eGroup || m_aItemList.GetParent( pEntry ) ) )
1121 		{
1122 			Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
1123 			DBG_ASSERT( xModel.is(), "XFormsPage::RemoveEntry(): no model" );
1124 			ItemNode* pNode = static_cast< ItemNode* >( pEntry->GetUserData() );
1125 			DBG_ASSERT( pNode, "XFormsPage::RemoveEntry(): no node" );
1126 
1127 			if ( DGTInstance == m_eGroup )
1128 			{
1129 				try
1130 				{
1131 					DBG_ASSERT( pNode->m_xNode.is(), "XFormsPage::RemoveEntry(): no XNode" );
1132 					css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType();
1133 					bool bIsElement = ( eChildType == css::xml::dom::NodeType_ELEMENT_NODE );
1134 					sal_uInt16 nResId = bIsElement ? RID_QRY_REMOVE_ELEMENT : RID_QRY_REMOVE_ATTRIBUTE;
1135 					String sVar = bIsElement ? ELEMENTNAME : ATTRIBUTENAME;
1136 					QueryBox aQBox( this, SVX_RES( nResId ) );
1137 					String sMessText = aQBox.GetMessText();
1138 					sMessText.SearchAndReplace(
1139 						sVar, m_xUIHelper->getNodeDisplayName( pNode->m_xNode, sal_False ) );
1140 					aQBox.SetMessText( sMessText );
1141 					if ( aQBox.Execute() == RET_YES )
1142 					{
1143 						SvLBoxEntry* pParent = m_aItemList.GetParent( pEntry );
1144 						DBG_ASSERT( pParent, "XFormsPage::RemoveEntry(): no parent entry" );
1145 						ItemNode* pParentNode = static_cast< ItemNode* >( pParent->GetUserData() );
1146 						DBG_ASSERT( pParentNode && pParentNode->m_xNode.is(), "XFormsPage::RemoveEntry(): no parent XNode" );
1147 
1148 						Reference< css::xml::dom::XNode > xPNode;
1149 						Reference< css::xml::dom::XNode > xNode =
1150 							pParentNode->m_xNode->removeChild( pNode->m_xNode );
1151 						if ( xNode.is() )
1152 							xPNode = xNode->getParentNode();
1153 						DBG_ASSERT( !xPNode.is(), "XFormsPage::RemoveEntry(): node not removed" );
1154                         bRet = true;
1155 					}
1156 				}
1157 				catch ( Exception& )
1158 				{
1159                     DBG_ERRORFILE( "XFormsPage::RemoveEntry(): exception caught" );
1160 				}
1161 			}
1162 			else
1163 			{
1164                 DBG_ASSERT( pNode->m_xPropSet.is(), "XFormsPage::RemoveEntry(): no propset" );
1165                 bool bSubmission = ( DGTSubmission == m_eGroup );
1166                 sal_uInt16 nResId = bSubmission ? RID_QRY_REMOVE_SUBMISSION : RID_QRY_REMOVE_BINDING;
1167                 rtl::OUString sProperty = bSubmission ? PN_SUBMISSION_ID : PN_BINDING_ID;
1168                 String sSearch = bSubmission ? SUBMISSIONNAME : BINDINGNAME;
1169                 rtl::OUString sName;
1170                 try
1171                 {
1172                     pNode->m_xPropSet->getPropertyValue( sProperty ) >>= sName;
1173                 }
1174                 catch ( Exception& )
1175                 {
1176                     DBG_ERRORFILE( "XFormsPage::RemoveEntry(): exception caught" );
1177                 }
1178                 QueryBox aQBox( this, SVX_RES( nResId ) );
1179                 String sMessText = aQBox.GetMessText();
1180                 sMessText.SearchAndReplace( sSearch, String( sName ) );
1181                 aQBox.SetMessText( sMessText );
1182                 if ( aQBox.Execute() == RET_YES )
1183                 {
1184                     try
1185                     {
1186                         if ( bSubmission )
1187                             xModel->getSubmissions()->remove( makeAny( pNode->m_xPropSet ) );
1188                         else // then Binding Page
1189                             xModel->getBindings()->remove( makeAny( pNode->m_xPropSet ) );
1190                         bRet = true;
1191                     }
1192                     catch ( Exception& )
1193                     {
1194                         DBG_ERRORFILE( "XFormsPage::RemoveEntry(): exception caught" );
1195                     }
1196                 }
1197 			}
1198 
1199             if ( bRet )
1200                 m_aItemList.RemoveEntry( pEntry );
1201 		}
1202 
1203         return bRet;
1204 	}
1205 
1206 	//------------------------------------------------------------------------
1207 	long XFormsPage::Notify( NotifyEvent& rNEvt )
1208 	{
1209 		long nHandled = 0;
1210 
1211 		if ( rNEvt.GetType() == EVENT_KEYINPUT )
1212 		{
1213 			sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
1214 
1215 			switch ( nCode )
1216 			{
1217 				case KEY_DELETE:
1218 					nHandled = DoMenuAction( TBI_ITEM_REMOVE );
1219 					break;
1220 			}
1221 		}
1222 
1223 		return nHandled ? nHandled : Window::Notify( rNEvt );
1224 	}
1225 	//------------------------------------------------------------------------
1226 	void XFormsPage::Resize()
1227 	{
1228 		Size aSize = GetOutputSizePixel();
1229 		Size aTbxSize = m_aToolBox.GetSizePixel();
1230 		aTbxSize.Width() = aSize.Width();
1231 		m_aToolBox.SetSizePixel( aTbxSize );
1232 		aSize.Width() -= 4;
1233 		aSize.Height() -= ( 4 + aTbxSize.Height() );
1234 		m_aItemList.SetPosSizePixel( Point( 2, 2 + aTbxSize.Height() ), aSize );
1235 	}
1236 	//------------------------------------------------------------------------
1237     String XFormsPage::SetModel( const Reference< css::xforms::XModel >& _xModel, sal_uInt16 _nPagePos )
1238 	{
1239 		DBG_ASSERT( _xModel.is(), "XFormsPage::SetModel(): invalid model" );
1240 
1241 		m_xUIHelper = Reference< css::xforms::XFormsUIHelper1 >( _xModel, UNO_QUERY );
1242 		String sRet;
1243 		m_bHasModel = true;
1244 		const ImageList& rImageList = GetSettings().GetStyleSettings().GetHighContrastMode()
1245 			? m_pNaviWin->GetItemHCImageList()
1246 			: m_pNaviWin->GetItemImageList();
1247 
1248 		switch ( m_eGroup )
1249 		{
1250 			case DGTInstance :
1251 			{
1252                 DBG_ASSERT( _nPagePos != TAB_PAGE_NOTFOUND, "XFormsPage::SetModel(): invalid page position" );
1253 				try
1254 				{
1255                     Reference< XContainer > xContainer( _xModel->getInstances(), UNO_QUERY );
1256                     if ( xContainer.is() )
1257                         m_pNaviWin->AddContainerBroadcaster( xContainer );
1258 
1259 					sal_uInt16 nIter = 0;
1260 					Reference< XEnumerationAccess > xNumAccess( _xModel->getInstances(), UNO_QUERY );
1261 					if ( xNumAccess.is() )
1262 					{
1263 						Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
1264 						if ( xNum.is() && xNum->hasMoreElements() )
1265 						{
1266 							while ( xNum->hasMoreElements() )
1267 							{
1268                                 if ( nIter == _nPagePos )
1269 								{
1270 									Sequence< PropertyValue > xPropSeq;
1271 									Any aAny = xNum->nextElement();
1272 									if ( aAny >>= xPropSeq )
1273 										sRet = LoadInstance( xPropSeq, rImageList );
1274 									else
1275 									{
1276 										DBG_ERRORFILE( "XFormsPage::SetModel(): invalid instance" );
1277 									}
1278 									break;
1279 								}
1280 								else
1281 								{
1282 									xNum->nextElement();
1283 									nIter++;
1284 								}
1285 							}
1286 						}
1287 					}
1288 				}
1289 			    catch( Exception& )
1290 				{
1291 					DBG_ERRORFILE( "XFormsPage::SetModel(): exception caught" );
1292 				}
1293 				break;
1294 			}
1295 
1296 			case DGTSubmission :
1297 			{
1298                 DBG_ASSERT( TAB_PAGE_NOTFOUND == _nPagePos, "XFormsPage::SetModel(): invalid page position" );
1299 				try
1300 				{
1301                     Reference< XContainer > xContainer( _xModel->getSubmissions(), UNO_QUERY );
1302                     if ( xContainer.is() )
1303                         m_pNaviWin->AddContainerBroadcaster( xContainer );
1304 
1305                     Reference< XEnumerationAccess > xNumAccess( _xModel->getSubmissions(), UNO_QUERY );
1306 					if ( xNumAccess.is() )
1307 					{
1308 						Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
1309 						if ( xNum.is() && xNum->hasMoreElements() )
1310 						{
1311 							while ( xNum->hasMoreElements() )
1312 							{
1313 								Reference< XPropertySet > xPropSet;
1314 								Any aAny = xNum->nextElement();
1315 								if ( aAny >>= xPropSet )
1316 									AddEntry( xPropSet );
1317 							}
1318 						}
1319 					}
1320 				}
1321 			    catch( Exception& )
1322 				{
1323 					DBG_ERRORFILE( "XFormsPage::SetModel(): exception caught" );
1324 				}
1325 				break;
1326 			}
1327 
1328 			case DGTBinding :
1329 			{
1330                 DBG_ASSERT( TAB_PAGE_NOTFOUND == _nPagePos, "XFormsPage::SetModel(): invalid page position" );
1331 				try
1332 				{
1333                     Reference< XContainer > xContainer( _xModel->getBindings(), UNO_QUERY );
1334                     if ( xContainer.is() )
1335                         m_pNaviWin->AddContainerBroadcaster( xContainer );
1336 
1337 					Reference< XEnumerationAccess > xNumAccess( _xModel->getBindings(), UNO_QUERY );
1338 					if ( xNumAccess.is() )
1339 					{
1340 						Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
1341 						if ( xNum.is() && xNum->hasMoreElements() )
1342 						{
1343 							Image aImage1 = rImageList.GetImage( IID_ELEMENT );
1344 							Image aImage2 = rImageList.GetImage( IID_ELEMENT );
1345 							String sDelim( RTL_CONSTASCII_STRINGPARAM( ": " ) );
1346 							while ( xNum->hasMoreElements() )
1347 							{
1348 								Reference< XPropertySet > xPropSet;
1349 								Any aAny = xNum->nextElement();
1350 								if ( aAny >>= xPropSet )
1351 								{
1352 									String sEntry;
1353 									rtl::OUString sTemp;
1354 									xPropSet->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
1355 									sEntry += String( sTemp );
1356 									sEntry += sDelim;
1357 									xPropSet->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
1358 									sEntry += String( sTemp );
1359 
1360 									ItemNode* pNode = new ItemNode( xPropSet );
1361 									m_aItemList.InsertEntry(
1362 										sEntry, aImage1, aImage2, NULL, sal_False, LIST_APPEND, pNode );
1363 								}
1364 							}
1365 						}
1366 					}
1367 				}
1368 			    catch( Exception& )
1369 				{
1370 					DBG_ERRORFILE( "XFormsPage::SetModel(): exception caught" );
1371 				}
1372 				break;
1373 			}
1374             default:
1375                 DBG_ERROR( "XFormsPage::SetModel: unknown group!" );
1376                 break;
1377 		}
1378 
1379         EnableMenuItems( NULL );
1380 
1381         return sRet;
1382 	}
1383 	//------------------------------------------------------------------------
1384 	void XFormsPage::ClearModel()
1385 	{
1386 		m_bHasModel = false;
1387 		m_aItemList.DeleteAndClear();
1388 	}
1389 	//------------------------------------------------------------------------
1390 	String XFormsPage::LoadInstance(
1391 		const Sequence< PropertyValue >& _xPropSeq, const ImageList& _rImgLst )
1392 	{
1393 		String sRet;
1394 		rtl::OUString sTemp;
1395 		rtl::OUString sInstModel = PN_INSTANCE_MODEL;
1396 		rtl::OUString sInstName = PN_INSTANCE_ID;
1397         rtl::OUString sInstURL = PN_INSTANCE_URL;
1398 		const PropertyValue* pProps = _xPropSeq.getConstArray();
1399 		const PropertyValue* pPropsEnd = pProps + _xPropSeq.getLength();
1400 		for ( ; pProps != pPropsEnd; ++pProps )
1401 		{
1402 			if ( sInstModel.compareTo( pProps->Name ) == 0 )
1403 			{
1404 				Reference< css::xml::dom::XNode > xRoot;
1405 				if ( pProps->Value >>= xRoot )
1406 				{
1407 					try
1408 					{
1409                         Reference< XEventTarget > xTarget( xRoot, UNO_QUERY );
1410                         if ( xTarget.is() )
1411                             m_pNaviWin->AddEventBroadcaster( xTarget );
1412 
1413                     #if OSL_DEBUG_LEVEL > 0
1414 						css::xml::dom::NodeType eNodeType = xRoot->getNodeType(); (void)eNodeType;
1415                     #endif
1416 						::rtl::OUString sNodeName =
1417 							m_xUIHelper->getNodeDisplayName( xRoot, m_pNaviWin->IsShowDetails() );
1418 						if ( sNodeName.getLength() == 0 )
1419 							sNodeName = xRoot->getNodeName();
1420 						if ( xRoot->hasChildNodes() )
1421 							AddChildren( NULL, _rImgLst, xRoot );
1422 					}
1423 					catch ( Exception& )
1424 					{
1425                         DBG_ERRORFILE( "XFormsPage::LoadInstance(): exception caught" );
1426 					}
1427 				}
1428 			}
1429 			else if ( sInstName.compareTo( pProps->Name ) == 0 && ( pProps->Value >>= sTemp ) )
1430 				m_sInstanceName = sRet = sTemp;
1431 			else if ( sInstURL.compareTo( pProps->Name ) == 0 && ( pProps->Value >>= sTemp ) )
1432 				m_sInstanceURL = sTemp;
1433 		}
1434 
1435 		return sRet;
1436 	}
1437 
1438 	//------------------------------------------------------------------------
1439 	bool XFormsPage::DoMenuAction( sal_uInt16 _nMenuID )
1440 	{
1441 		return DoToolBoxAction( _nMenuID );
1442 	}
1443 
1444 	//------------------------------------------------------------------------
1445 	void XFormsPage::EnableMenuItems( Menu* _pMenu )
1446 	{
1447 		sal_Bool bEnableAdd = sal_False;
1448 		sal_Bool bEnableEdit = sal_False;
1449 		sal_Bool bEnableRemove = sal_False;
1450 
1451 		SvLBoxEntry* pEntry = m_aItemList.FirstSelected();
1452 		if ( pEntry )
1453 		{
1454 			bEnableAdd = sal_True;
1455 			bool bSubmitChild = false;
1456 			if ( DGTSubmission == m_eGroup && m_aItemList.GetParent( pEntry ) )
1457 			{
1458 				pEntry = m_aItemList.GetParent( pEntry );
1459 				bSubmitChild = true;
1460 			}
1461 			ItemNode* pNode = static_cast< ItemNode* >( pEntry->GetUserData() );
1462 			if ( pNode && ( pNode->m_xNode.is() || pNode->m_xPropSet.is() ) )
1463 			{
1464 				bEnableEdit = sal_True;
1465 				bEnableRemove = ( bSubmitChild != true );
1466 				if ( DGTInstance == m_eGroup && !m_aItemList.GetParent( pEntry ) )
1467 					bEnableRemove = sal_False;
1468 				if ( pNode->m_xNode.is() )
1469 				{
1470 					try
1471 					{
1472 						css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType();
1473 						if ( eChildType != css::xml::dom::NodeType_ELEMENT_NODE
1474 							&& eChildType != css::xml::dom::NodeType_DOCUMENT_NODE )
1475 						{
1476 							bEnableAdd = sal_False;
1477 						}
1478 					}
1479 					catch ( Exception& )
1480 					{
1481                        DBG_ERRORFILE( "XFormsPage::EnableMenuItems(): exception caught" );
1482 					}
1483 				}
1484 			}
1485 		}
1486 		else if ( m_eGroup != DGTInstance )
1487 			bEnableAdd = sal_True;
1488 
1489 		m_aToolBox.EnableItem( TBI_ITEM_ADD, bEnableAdd );
1490 		m_aToolBox.EnableItem( TBI_ITEM_ADD_ELEMENT, bEnableAdd );
1491 		m_aToolBox.EnableItem( TBI_ITEM_ADD_ATTRIBUTE, bEnableAdd );
1492 		m_aToolBox.EnableItem( TBI_ITEM_EDIT, bEnableEdit );
1493 		m_aToolBox.EnableItem( TBI_ITEM_REMOVE, bEnableRemove );
1494 
1495 		if ( _pMenu )
1496 		{
1497 			_pMenu->EnableItem( TBI_ITEM_ADD, bEnableAdd );
1498 			_pMenu->EnableItem( TBI_ITEM_ADD_ELEMENT, bEnableAdd );
1499 			_pMenu->EnableItem( TBI_ITEM_ADD_ATTRIBUTE, bEnableAdd );
1500 			_pMenu->EnableItem( TBI_ITEM_EDIT, bEnableEdit );
1501 			_pMenu->EnableItem( TBI_ITEM_REMOVE, bEnableRemove );
1502 		}
1503 		if ( DGTInstance == m_eGroup )
1504 		{
1505 			sal_uInt16 nResId1 = RID_STR_DATANAV_EDIT_ELEMENT;
1506 			sal_uInt16 nResId2 = RID_STR_DATANAV_REMOVE_ELEMENT;
1507 			if ( pEntry )
1508 			{
1509 				ItemNode* pNode = static_cast< ItemNode* >( pEntry->GetUserData() );
1510 				if ( pNode && pNode->m_xNode.is() )
1511 				{
1512 					try
1513 					{
1514 						css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType();
1515 						if ( eChildType == css::xml::dom::NodeType_ATTRIBUTE_NODE )
1516 						{
1517 							nResId1 = RID_STR_DATANAV_EDIT_ATTRIBUTE;
1518 							nResId2 = RID_STR_DATANAV_REMOVE_ATTRIBUTE;
1519 						}
1520 					}
1521 					catch ( Exception& )
1522 					{
1523                        DBG_ERRORFILE( "XFormsPage::EnableMenuItems(): exception caught" );
1524 					}
1525 				}
1526 			}
1527 			m_aToolBox.SetItemText( TBI_ITEM_EDIT, SVX_RESSTR( nResId1 ) );
1528 			m_aToolBox.SetItemText( TBI_ITEM_REMOVE, SVX_RESSTR( nResId2 ) );
1529 			if ( _pMenu )
1530 			{
1531 				_pMenu->SetItemText( TBI_ITEM_EDIT, SVX_RESSTR( nResId1 ) );
1532 				_pMenu->SetItemText( TBI_ITEM_REMOVE, SVX_RESSTR( nResId2 ) );
1533 			}
1534 		}
1535 	}
1536 
1537 
1538 	//========================================================================
1539 	// class DataNavigatorWindow
1540 	//========================================================================
1541 	DataNavigatorWindow::DataNavigatorWindow( Window* pParent, SfxBindings* pBindings ) :
1542 
1543 		Window( pParent, SVX_RES( RID_SVXWIN_DATANAVIGATOR ) ),
1544 
1545 		m_aModelsBox		( this, SVX_RES( LB_MODELS ) ),
1546 		m_aModelBtn			( this, SVX_RES( MB_MODELS ) ),
1547 		m_aTabCtrl			( this, SVX_RES( TC_ITEMS ) ),
1548 		m_aInstanceBtn		( this, SVX_RES( MB_INSTANCES ) ),
1549 
1550 		m_pInstPage			( NULL ),
1551 		m_pSubmissionPage	( NULL ),
1552 		m_pBindingPage		( NULL ),
1553 
1554 		m_nMinWidth			( 0 ),
1555 		m_nMinHeight		( 0 ),
1556 		m_nBorderHeight		( 0 ),
1557 		m_nLastSelectedPos	( LISTBOX_ENTRY_NOTFOUND ),
1558 		m_bShowDetails		( false ),
1559         m_bIsNotifyDisabled ( false ),
1560 
1561 		m_aItemImageList	(		SVX_RES( IL_ITEM_BMPS ) ),
1562         m_aItemHCImageList  (       SVX_RES( IL_ITEM_BMPS_HC ) ),
1563         m_xDataListener     ( new DataListener( this ) )
1564 
1565 	{
1566 		FreeResource();
1567 
1568 		// init minimal metric
1569 		m_a2Size = LogicToPixel( Size( 2, 2 ), MAP_APPFONT );
1570 		m_a3Size = LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
1571 		Size aOutSz = GetOutputSizePixel();
1572 		Size aLogSize = PixelToLogic( aOutSz, MAP_APPFONT );
1573 		m_nMinWidth = aLogSize.Width();
1574 		m_nMinHeight = aLogSize.Height();
1575 		m_nBorderHeight = 4*m_a3Size.Height() +
1576 			m_aModelBtn.GetSizePixel().Height() + m_aInstanceBtn.GetSizePixel().Height();
1577 
1578 		// handler
1579 		m_aModelsBox.SetSelectHdl( LINK( this, DataNavigatorWindow, ModelSelectHdl ) );
1580 		Link aLink = LINK( this, DataNavigatorWindow, MenuSelectHdl );
1581 		m_aModelBtn.SetSelectHdl( aLink );
1582 		m_aInstanceBtn.SetSelectHdl( aLink );
1583 		aLink = LINK( this, DataNavigatorWindow, MenuActivateHdl );
1584 		m_aModelBtn.SetActivateHdl( aLink );
1585 		m_aInstanceBtn.SetActivateHdl( aLink );
1586 		m_aTabCtrl.SetActivatePageHdl( LINK( this, DataNavigatorWindow, ActivatePageHdl ) );
1587         m_aUpdateTimer.SetTimeout( 2000 );
1588         m_aUpdateTimer.SetTimeoutHdl( LINK( this, DataNavigatorWindow, UpdateHdl ) );
1589 
1590 		// init tabcontrol
1591 		m_aTabCtrl.Show();
1592 		sal_Int32 nPageId = TID_INSTANCE;
1593 		SvtViewOptions aViewOpt( E_TABDIALOG, CFGNAME_DATANAVIGATOR );
1594 		if ( aViewOpt.Exists() )
1595 		{
1596 			nPageId = aViewOpt.GetPageID();
1597 			aViewOpt.GetUserItem(CFGNAME_SHOWDETAILS) >>= m_bShowDetails;
1598 		}
1599 
1600 		Menu* pMenu = m_aInstanceBtn.GetPopupMenu();
1601 		pMenu->SetItemBits( MID_SHOW_DETAILS, MIB_CHECKABLE );
1602 		pMenu->CheckItem( MID_SHOW_DETAILS, m_bShowDetails );
1603 
1604 		m_aTabCtrl.SetCurPageId( static_cast< sal_uInt16 >( nPageId ) );
1605 		ActivatePageHdl( &m_aTabCtrl );
1606 
1607         // get our frame
1608         DBG_ASSERT( pBindings != NULL,
1609                     "DataNavigatorWindow::LoadModels(): no SfxBindings; can't get frame" );
1610         m_xFrame = Reference<XFrame>(
1611             pBindings->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(),
1612             UNO_QUERY );
1613         DBG_ASSERT( m_xFrame.is(), "DataNavigatorWindow::LoadModels(): no frame" );
1614         // add frameaction listener
1615         Reference< XFrameActionListener > xListener(
1616             static_cast< XFrameActionListener* >( m_xDataListener.get() ), UNO_QUERY );
1617         m_xFrame->addFrameActionListener( xListener );
1618 
1619         // load xforms models of the current document
1620 		LoadModels();
1621 	}
1622 	//------------------------------------------------------------------------
1623 	DataNavigatorWindow::~DataNavigatorWindow()
1624 	{
1625 		SvtViewOptions aViewOpt( E_TABDIALOG, CFGNAME_DATANAVIGATOR );
1626 		aViewOpt.SetPageID( static_cast< sal_Int32 >( m_aTabCtrl.GetCurPageId() ) );
1627 		Any aAny;
1628 		aAny <<= m_bShowDetails;
1629 		aViewOpt.SetUserItem(CFGNAME_SHOWDETAILS,aAny);
1630 
1631 		delete m_pInstPage;
1632 		delete m_pSubmissionPage;
1633 		delete m_pBindingPage;
1634 
1635 		sal_Int32 i, nCount = m_aPageList.size();
1636 		for ( i = 0; i < nCount; ++i )
1637 			delete m_aPageList[i];
1638         Reference< XFrameActionListener > xListener(
1639             static_cast< XFrameActionListener* >( m_xDataListener.get() ), UNO_QUERY );
1640         m_xFrame->removeFrameActionListener( xListener );
1641         RemoveBroadcaster();
1642         m_xDataListener.clear();
1643     }
1644 
1645 	// -----------------------------------------------------------------------
1646 	IMPL_LINK( DataNavigatorWindow, ModelSelectHdl, ListBox *, pBox )
1647 	{
1648 		sal_uInt16 nPos = m_aModelsBox.GetSelectEntryPos();
1649         // pBox == NULL, if you want to force a new fill.
1650 		if ( nPos != m_nLastSelectedPos || !pBox )
1651 		{
1652 			m_nLastSelectedPos = nPos;
1653             ClearAllPageModels( pBox != NULL );
1654 			InitPages();
1655 			SetPageModel();
1656 		}
1657 
1658 		return 0;
1659 	}
1660 	// -----------------------------------------------------------------------
1661 	IMPL_LINK( DataNavigatorWindow, MenuSelectHdl, MenuButton *, pBtn )
1662 	{
1663         bool bIsDocModified = false;
1664 		Reference< css::xforms::XFormsUIHelper1 > xUIHelper;
1665 		sal_uInt16 nSelectedPos = m_aModelsBox.GetSelectEntryPos();
1666         ::rtl::OUString sSelectedModel( m_aModelsBox.GetEntry( nSelectedPos ) );
1667 		Reference< css::xforms::XModel > xModel;
1668 		try
1669 		{
1670 			Any aAny = m_xDataContainer->getByName( sSelectedModel );
1671 			if ( aAny >>= xModel )
1672 				xUIHelper = Reference< css::xforms::XFormsUIHelper1 >( xModel, UNO_QUERY );
1673 		}
1674 		catch ( Exception& )
1675 		{
1676             DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1677 		}
1678 		DBG_ASSERT( xUIHelper.is(), "DataNavigatorWindow::MenuSelectHdl(): no UIHelper" );
1679 
1680         m_bIsNotifyDisabled = true;
1681 
1682         if ( &m_aModelBtn == pBtn )
1683 		{
1684 			switch ( pBtn->GetCurItemId() )
1685 			{
1686 				case MID_MODELS_ADD :
1687 				{
1688                     AddModelDialog aDlg( this, false );
1689 					bool bShowDialog = true;
1690 					while ( bShowDialog )
1691 					{
1692 						bShowDialog = false;
1693 						if ( aDlg.Execute() == RET_OK )
1694 						{
1695 							String sNewName = aDlg.GetName();
1696                             sal_Bool bDocumentData = aDlg.GetModifyDoc();
1697 
1698 							if ( m_aModelsBox.GetEntryPos( sNewName ) != LISTBOX_ENTRY_NOTFOUND )
1699 							{
1700 								// error: model name already exists
1701 								ErrorBox aErrBox( this, SVX_RES( RID_ERR_DOUBLE_MODELNAME ) );
1702 								String sMessText = aErrBox.GetMessText();
1703 								sMessText.SearchAndReplace( MSG_VARIABLE, sNewName );
1704 								aErrBox.SetMessText( sMessText );
1705 								aErrBox.Execute();
1706 								bShowDialog = true;
1707 							}
1708 							else
1709 							{
1710 								try
1711 								{
1712 									// add new model to frame model
1713 									Reference< css::xforms::XModel > xNewModel(
1714                                         xUIHelper->newModel( m_xFrameModel, sNewName ), UNO_SET_THROW );
1715 
1716                                     Reference< XPropertySet > xModelProps( xNewModel, UNO_QUERY_THROW );
1717                                     xModelProps->setPropertyValue(
1718                                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExternalData" ) ),
1719                                         makeAny( sal_Bool( !bDocumentData ) ) );
1720 
1721                                     sal_uInt16 nNewPos = m_aModelsBox.InsertEntry( sNewName );
1722 									m_aModelsBox.SelectEntryPos( nNewPos );
1723 									ModelSelectHdl( &m_aModelsBox );
1724                                     bIsDocModified = true;
1725 								}
1726 								catch ( Exception& )
1727 								{
1728                                     DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1729 								}
1730 							}
1731 						}
1732 					}
1733 					break;
1734 				}
1735 				case MID_MODELS_EDIT :
1736 				{
1737                     AddModelDialog aDlg( this, true );
1738 					aDlg.SetName( sSelectedModel );
1739 
1740                     bool bDocumentData( false );
1741                     try
1742                     {
1743 				        Reference< css::xforms::XFormsSupplier > xFormsSupp( m_xFrameModel, UNO_QUERY_THROW );
1744 				        Reference< XNameContainer > xXForms( xFormsSupp->getXForms(), UNO_SET_THROW );
1745                         Reference< XPropertySet > xModelProps( xXForms->getByName( sSelectedModel ), UNO_QUERY_THROW );
1746                         sal_Bool bExternalData = sal_False;
1747                         OSL_VERIFY( xModelProps->getPropertyValue(
1748                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExternalData" ) ) ) >>= bExternalData );
1749                         bDocumentData = ( bExternalData == sal_False );
1750                     }
1751                     catch( const Exception& )
1752                     {
1753                     	DBG_UNHANDLED_EXCEPTION();
1754                     }
1755                     aDlg.SetModifyDoc( bDocumentData );
1756 
1757 					if ( aDlg.Execute() == RET_OK )
1758 					{
1759                         if ( aDlg.GetModifyDoc() != bool( bDocumentData ) )
1760                         {
1761                             bDocumentData = aDlg.GetModifyDoc();
1762                             try
1763                             {
1764 				                Reference< css::xforms::XFormsSupplier > xFormsSupp( m_xFrameModel, UNO_QUERY_THROW );
1765 				                Reference< XNameContainer > xXForms( xFormsSupp->getXForms(), UNO_SET_THROW );
1766                                 Reference< XPropertySet > xModelProps( xXForms->getByName( sSelectedModel ), UNO_QUERY_THROW );
1767                                 xModelProps->setPropertyValue(
1768                                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExternalData" ) ),
1769                                     makeAny( sal_Bool( !bDocumentData ) ) );
1770                                 bIsDocModified = true;
1771                             }
1772                             catch( const Exception& )
1773                             {
1774                             	DBG_UNHANDLED_EXCEPTION();
1775                             }
1776                         }
1777 
1778                         String sNewName = aDlg.GetName();
1779 						if ( sNewName.Len() > 0 && ( sNewName != String( sSelectedModel ) ) )
1780 						{
1781 							try
1782 							{
1783 								xUIHelper->renameModel( m_xFrameModel, sSelectedModel, sNewName );
1784 
1785 								m_aModelsBox.RemoveEntry( nSelectedPos );
1786 								nSelectedPos = m_aModelsBox.InsertEntry( sNewName );
1787 								m_aModelsBox.SelectEntryPos( nSelectedPos );
1788                                 bIsDocModified = true;
1789 							}
1790 							catch ( Exception& )
1791 							{
1792 								DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1793 							}
1794 						}
1795 					}
1796 					break;
1797 				}
1798 				case MID_MODELS_REMOVE :
1799 				{
1800 					QueryBox aQBox( this, SVX_RES( RID_QRY_REMOVE_MODEL ) );
1801 					String sText = aQBox.GetMessText();
1802 					sText.SearchAndReplace( MODELNAME, sSelectedModel );
1803 					aQBox.SetMessText( sText );
1804 					if ( aQBox.Execute() == RET_YES )
1805 					{
1806 						try
1807 						{
1808 							xUIHelper->removeModel( m_xFrameModel, sSelectedModel );
1809 						}
1810 						catch ( Exception& )
1811 						{
1812                             DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1813 						}
1814 						m_aModelsBox.RemoveEntry( nSelectedPos );
1815 						if ( m_aModelsBox.GetEntryCount() <= nSelectedPos )
1816 							nSelectedPos = m_aModelsBox.GetEntryCount() - 1;
1817 						m_aModelsBox.SelectEntryPos( nSelectedPos );
1818 						ModelSelectHdl( &m_aModelsBox );
1819                         bIsDocModified = true;
1820 					}
1821 					break;
1822 				}
1823 				default:
1824 				{
1825 					DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" );
1826 				}
1827 			}
1828 		}
1829 		else if ( &m_aInstanceBtn == pBtn )
1830 		{
1831 			switch ( pBtn->GetCurItemId() )
1832 			{
1833 				case MID_INSTANCES_ADD :
1834 				{
1835                     AddInstanceDialog aDlg( this, false );
1836 					if ( aDlg.Execute() == RET_OK )
1837 					{
1838                         sal_uInt16 nInst = GetNewPageId();
1839 						::rtl::OUString sName = aDlg.GetName();
1840 						::rtl::OUString sURL = aDlg.GetURL();
1841 						bool bLinkOnce = aDlg.IsLinkInstance();
1842 						try
1843 						{
1844 							Reference< css::xml::dom::XDocument > xNewInst =
1845 								xUIHelper->newInstance( sName, sURL, !bLinkOnce );
1846 						}
1847 						catch ( Exception& )
1848 						{
1849                             DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1850 						}
1851 						ModelSelectHdl( NULL );
1852 						m_aTabCtrl.SetCurPageId( nInst );
1853 						XFormsPage* pPage = GetCurrentPage( nInst );
1854 						pPage->SetInstanceName(sName);
1855 						pPage->SetInstanceURL(sURL);
1856 						pPage->SetLinkOnce(bLinkOnce);
1857 						ActivatePageHdl( &m_aTabCtrl );
1858                         bIsDocModified = true;
1859 					}
1860 					break;
1861 				}
1862 				case MID_INSTANCES_EDIT :
1863 				{
1864 					sal_uInt16 nId = 0;
1865 					XFormsPage* pPage = GetCurrentPage( nId );
1866 					if ( pPage )
1867 					{
1868                         AddInstanceDialog aDlg( this, true );
1869 						aDlg.SetName( pPage->GetInstanceName() );
1870 						aDlg.SetURL( pPage->GetInstanceURL() );
1871 						aDlg.SetLinkInstance( pPage->GetLinkOnce() );
1872 						String sOldName = aDlg.GetName();
1873 						if ( aDlg.Execute() == RET_OK )
1874 						{
1875 							String sNewName = aDlg.GetName();
1876 							::rtl::OUString sURL = aDlg.GetURL();
1877 							bool bLinkOnce = aDlg.IsLinkInstance();
1878 							try
1879 							{
1880 								xUIHelper->renameInstance( sOldName,
1881 														   sNewName,
1882 														   sURL,
1883 														   !bLinkOnce );
1884 							}
1885 							catch ( Exception& )
1886 							{
1887                                 DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1888 							}
1889 							pPage->SetInstanceName(sNewName);
1890 							pPage->SetInstanceURL(sURL);
1891 							pPage->SetLinkOnce(bLinkOnce);
1892 							m_aTabCtrl.SetPageText( nId, sNewName );
1893                             bIsDocModified = true;
1894 						}
1895 					}
1896 					break;
1897 				}
1898 				case MID_INSTANCES_REMOVE :
1899 				{
1900 					sal_uInt16 nId = 0;
1901 					XFormsPage* pPage = GetCurrentPage( nId );
1902 					if ( pPage )
1903 					{
1904 						String sInstName = pPage->GetInstanceName();
1905 						QueryBox aQBox( this, SVX_RES( RID_QRY_REMOVE_INSTANCE ) );
1906 						String sMessText = aQBox.GetMessText();
1907 						sMessText.SearchAndReplace( INSTANCENAME, sInstName );
1908 						aQBox.SetMessText( sMessText );
1909 						if ( aQBox.Execute() == RET_YES )
1910 						{
1911 							bool bDoRemove = false;
1912 							if ( nId > TID_INSTANCE )
1913 							{
1914 								PageList::iterator aPageListEnd = m_aPageList.end();
1915 								PageList::iterator aFoundPage =
1916 									std::find( m_aPageList.begin(), aPageListEnd, pPage );
1917 								if ( aFoundPage != aPageListEnd )
1918 								{
1919 									m_aPageList.erase( aFoundPage );
1920 									delete pPage;
1921 									bDoRemove = true;
1922 								}
1923 							}
1924 							else
1925 							{
1926 								DELETEZ( m_pInstPage );
1927 								bDoRemove = true;
1928 							}
1929 
1930 							if ( bDoRemove )
1931 							{
1932 								try
1933 								{
1934 									xUIHelper->removeInstance( sInstName );
1935 								}
1936 								catch ( Exception& )
1937 								{
1938                                     DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1939 								}
1940 								m_aTabCtrl.RemovePage( nId );
1941 								m_aTabCtrl.SetCurPageId( TID_INSTANCE );
1942 								ModelSelectHdl( NULL );
1943                                 bIsDocModified = true;
1944 							}
1945 						}
1946 					}
1947 					break;
1948 				}
1949 				case MID_SHOW_DETAILS :
1950 				{
1951 					m_bShowDetails = !m_bShowDetails;
1952 					m_aInstanceBtn.GetPopupMenu()->CheckItem( MID_SHOW_DETAILS, m_bShowDetails );
1953                     ModelSelectHdl( &m_aModelsBox );
1954 					break;
1955 				}
1956 				default:
1957 				{
1958 					DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" );
1959 				}
1960 			}
1961 		}
1962 		else
1963 		{
1964 			DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): wrong button" );
1965 		}
1966 
1967         m_bIsNotifyDisabled = false;
1968 
1969         if ( bIsDocModified )
1970             SetDocModified();
1971         return 0;
1972 	}
1973 	// -----------------------------------------------------------------------
1974 	IMPL_LINK( DataNavigatorWindow, MenuActivateHdl, MenuButton *, pBtn )
1975 	{
1976 		Menu* pMenu = pBtn->GetPopupMenu();
1977 
1978 		if ( &m_aInstanceBtn == pBtn )
1979 		{
1980 			bool bIsInstPage = ( m_aTabCtrl.GetCurPageId() >= TID_INSTANCE );
1981 			pMenu->EnableItem( MID_INSTANCES_EDIT, bIsInstPage );
1982 			pMenu->EnableItem( MID_INSTANCES_REMOVE,
1983 				bIsInstPage && m_aTabCtrl.GetPageCount() > MIN_PAGE_COUNT );
1984 			pMenu->EnableItem( MID_SHOW_DETAILS, bIsInstPage );
1985 		}
1986 		else if ( &m_aModelBtn == pBtn )
1987 		{
1988 			// we need at least one model!
1989 			pMenu->EnableItem( MID_MODELS_REMOVE, m_aModelsBox.GetEntryCount() > 1 );
1990 		}
1991 		else
1992 		{
1993 			DBG_ERRORFILE( "DataNavigatorWindow::MenuActivateHdl(): wrong button" );
1994 		}
1995 		return 0;
1996 	}
1997     // -----------------------------------------------------------------------
1998     IMPL_LINK( DataNavigatorWindow, ActivatePageHdl, TabControl *, EMPTYARG )
1999     {
2000         sal_uInt16 nId = 0;
2001         XFormsPage* pPage = GetCurrentPage( nId );
2002         if ( pPage )
2003         {
2004             m_aTabCtrl.SetTabPage( nId, pPage );
2005             if ( m_xDataContainer.is() && !pPage->HasModel() )
2006                 SetPageModel();
2007         }
2008 
2009         return 0;
2010     }
2011     // -----------------------------------------------------------------------
2012     IMPL_LINK( DataNavigatorWindow, UpdateHdl, Timer *, EMPTYARG )
2013     {
2014         ModelSelectHdl( NULL );
2015         return 0;
2016     }
2017 	// -----------------------------------------------------------------------
2018 	XFormsPage* DataNavigatorWindow::GetCurrentPage( sal_uInt16& rCurId )
2019 	{
2020 		rCurId = m_aTabCtrl.GetCurPageId();
2021 		XFormsPage* pPage = NULL;
2022 		switch ( rCurId )
2023 		{
2024 			case TID_SUBMISSION:
2025 			{
2026 				if ( !m_pSubmissionPage )
2027 					m_pSubmissionPage = new XFormsPage( &m_aTabCtrl, this, DGTSubmission );
2028 				pPage = m_pSubmissionPage;
2029 				break;
2030 			}
2031 
2032 			case TID_BINDINGS:
2033 			{
2034 				if ( !m_pBindingPage )
2035 					m_pBindingPage = new XFormsPage( &m_aTabCtrl, this, DGTBinding );
2036 				pPage = m_pBindingPage;
2037 				break;
2038 			}
2039 
2040 			case TID_INSTANCE:
2041 			{
2042 				if ( !m_pInstPage )
2043 					m_pInstPage = new XFormsPage( &m_aTabCtrl, this, DGTInstance );
2044 				pPage = m_pInstPage;
2045 				break;
2046 			}
2047 		}
2048 
2049 		if ( rCurId > TID_INSTANCE )
2050 		{
2051             sal_uInt16 nPos = m_aTabCtrl.GetPagePos( rCurId );
2052             if ( HasFirstInstancePage() && nPos > 0 )
2053                 nPos--;
2054 			if ( m_aPageList.size() > nPos )
2055 				pPage = m_aPageList[nPos];
2056 			else
2057 			{
2058 				pPage = new XFormsPage( &m_aTabCtrl, this, DGTInstance );
2059 				m_aPageList.push_back( pPage );
2060 			}
2061 		}
2062 
2063 		return pPage;
2064 	}
2065 	// -----------------------------------------------------------------------
2066 	void DataNavigatorWindow::LoadModels()
2067 	{
2068 		if ( !m_xFrameModel.is() )
2069 		{
2070             // get model of active frame
2071             Reference< XController > xCtrl = m_xFrame->getController();
2072 	        if ( xCtrl.is() )
2073 			{
2074 				try
2075 				{
2076 				    m_xFrameModel = xCtrl->getModel();
2077 				}
2078 				catch ( Exception& )
2079 				{
2080 					DBG_ERRORFILE( "DataNavigatorWindow::LoadModels(): exception caught" );
2081 				}
2082 			}
2083 		}
2084 
2085 		if ( m_xFrameModel.is() )
2086 		{
2087 			try
2088 			{
2089 				::rtl::OUString sURL = m_xFrameModel->getURL();
2090 				Reference< css::xforms::XFormsSupplier > xFormsSupp( m_xFrameModel, UNO_QUERY );
2091 				if ( xFormsSupp.is() )
2092 				{
2093 					Reference< XNameContainer > xContainer = xFormsSupp->getXForms();
2094 					if ( xContainer.is() )
2095 					{
2096 						m_xDataContainer = xContainer;
2097 						Sequence< ::rtl::OUString > aNameList = m_xDataContainer->getElementNames();
2098 						sal_Int32 i, nCount = aNameList.getLength();
2099 						::rtl::OUString* pNames = aNameList.getArray();
2100 						for ( i = 0; i < nCount; ++i )
2101 						{
2102 							Any aAny = m_xDataContainer->getByName( pNames[i] );
2103 							Reference< css::xforms::XModel > xFormsModel;
2104 							if ( aAny >>= xFormsModel )
2105 								m_aModelsBox.InsertEntry( xFormsModel->getID() );
2106 						}
2107 					}
2108 				}
2109 			}
2110 			catch( Exception& )
2111 			{
2112 				DBG_ERRORFILE( "DataNavigatorWindow::LoadModels(): exception caught" );
2113 			}
2114 		}
2115 
2116 		if ( m_aModelsBox.GetEntryCount() > 0 )
2117 		{
2118 			m_aModelsBox.SelectEntryPos(0);
2119 			ModelSelectHdl( &m_aModelsBox );
2120 		}
2121 	}
2122 	// -----------------------------------------------------------------------
2123 	void DataNavigatorWindow::SetPageModel()
2124 	{
2125 		rtl::OUString sModel( m_aModelsBox.GetSelectEntry() );
2126 		try
2127 		{
2128 			Any aAny = m_xDataContainer->getByName( sModel );
2129 			Reference< css::xforms::XModel > xFormsModel;
2130 			if ( aAny >>= xFormsModel )
2131 			{
2132                 sal_uInt16 nPagePos = TAB_PAGE_NOTFOUND;
2133 				sal_uInt16 nId = 0;
2134 				XFormsPage* pPage = GetCurrentPage( nId );
2135                 DBG_ASSERT( pPage, "DataNavigatorWindow::SetPageModel(): no page" );
2136                 if ( nId >= TID_INSTANCE )
2137                     // instance page
2138                     nPagePos = m_aTabCtrl.GetPagePos( nId );
2139                 m_bIsNotifyDisabled = true;
2140                 String sText = pPage->SetModel( xFormsModel, nPagePos );
2141                 m_bIsNotifyDisabled = false;
2142 				if ( sText.Len() > 0 )
2143 					m_aTabCtrl.SetPageText( nId, sText );
2144 			}
2145 		}
2146 		catch ( NoSuchElementException& )
2147 		{
2148 			DBG_ERRORFILE( "DataNavigatorWindow::SetPageModel(): no such element" );
2149 		}
2150         catch( Exception& )
2151 		{
2152 			DBG_ERRORFILE( "DataNavigatorWindow::SetPageModel(): unexpected exception" );
2153 		}
2154 	}
2155 	// -----------------------------------------------------------------------
2156 	void DataNavigatorWindow::InitPages()
2157 	{
2158 		rtl::OUString sModel( m_aModelsBox.GetSelectEntry() );
2159 		try
2160 		{
2161 			Any aAny = m_xDataContainer->getByName( sModel );
2162 			Reference< css::xforms::XModel > xModel;
2163 			if ( aAny >>= xModel )
2164 			{
2165 				Reference< XEnumerationAccess > xNumAccess( xModel->getInstances(), UNO_QUERY );
2166 				if ( xNumAccess.is() )
2167 				{
2168 					Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
2169 					if ( xNum.is() && xNum->hasMoreElements() )
2170 					{
2171 						sal_Int32 nAlreadyLoadedCount = m_aPageList.size();
2172                         if ( !HasFirstInstancePage() && nAlreadyLoadedCount > 0 )
2173                             nAlreadyLoadedCount--;
2174 						sal_Int32 nIdx = 0;
2175 						while ( xNum->hasMoreElements() )
2176 						{
2177 							if ( nIdx > nAlreadyLoadedCount )
2178 							{
2179 								Sequence< PropertyValue > xPropSeq;
2180 								if ( xNum->nextElement() >>= xPropSeq )
2181 									CreateInstancePage( xPropSeq );
2182 								else
2183 								{
2184 									DBG_ERRORFILE( "DataNavigator::InitPages(): invalid instance" );
2185 								}
2186 							}
2187 							else
2188 								xNum->nextElement();
2189 							nIdx++;
2190 						}
2191 					}
2192 				}
2193 			}
2194 		}
2195 		catch ( NoSuchElementException& )
2196 		{
2197 			DBG_ERRORFILE( "DataNavigatorWindow::SetPageModel(): no such element" );
2198 		}
2199         catch( Exception& )
2200 		{
2201 			DBG_ERRORFILE( "DataNavigatorWindow::SetPageModel(): unexpected exception" );
2202 		}
2203 	}
2204 	// -----------------------------------------------------------------------
2205     void DataNavigatorWindow::ClearAllPageModels( bool bClearPages )
2206 	{
2207 		if ( m_pInstPage )
2208 			m_pInstPage->ClearModel();
2209 		if ( m_pSubmissionPage )
2210 			m_pSubmissionPage->ClearModel();
2211 		if ( m_pBindingPage )
2212 			m_pBindingPage->ClearModel();
2213 
2214 		sal_Int32 i, nCount = m_aPageList.size();
2215         for ( i = 0; i < nCount; ++i )
2216         {
2217             XFormsPage* pPage = m_aPageList[i];
2218             pPage->ClearModel();
2219             if ( bClearPages )
2220                 delete pPage;
2221         }
2222 
2223         if ( bClearPages )
2224         {
2225             m_aPageList.clear();
2226             while ( m_aTabCtrl.GetPageCount() > MIN_PAGE_COUNT )
2227                 m_aTabCtrl.RemovePage( m_aTabCtrl.GetPageId( 1 ) );
2228         }
2229 	}
2230 	// -----------------------------------------------------------------------
2231 	void DataNavigatorWindow::CreateInstancePage( const Sequence< PropertyValue >& _xPropSeq )
2232 	{
2233 		rtl::OUString sInstName;
2234 		rtl::OUString sID( PN_INSTANCE_ID );
2235 		const PropertyValue* pProps = _xPropSeq.getConstArray();
2236 		const PropertyValue* pPropsEnd = pProps + _xPropSeq.getLength();
2237 		for ( ; pProps != pPropsEnd; ++pProps )
2238 		{
2239 			if ( sID.compareTo( pProps->Name ) == 0 )
2240 			{
2241 				pProps->Value >>= sInstName;
2242 				break;
2243 			}
2244 		}
2245 
2246         sal_uInt16 nPageId = GetNewPageId();
2247 		if ( sInstName.getLength() == 0 )
2248 		{
2249             DBG_ERRORFILE( "DataNavigatorWindow::CreateInstancePage(): instance without name" );
2250             String sTemp = String::CreateFromAscii( "untitled" );
2251             sTemp += String::CreateFromInt32( nPageId );
2252 			sInstName = sTemp;
2253 		}
2254         m_aTabCtrl.InsertPage( nPageId, sInstName, m_aTabCtrl.GetPageCount() - 2 );
2255 	}
2256 
2257     //------------------------------------------------------------------------
2258     bool DataNavigatorWindow::HasFirstInstancePage() const
2259     {
2260         return ( m_aTabCtrl.GetPageId( 0 ) == TID_INSTANCE );
2261     }
2262 
2263     //------------------------------------------------------------------------
2264     sal_uInt16 DataNavigatorWindow::GetNewPageId() const
2265     {
2266         sal_uInt16 i, nMax = 0, nCount = m_aTabCtrl.GetPageCount();
2267         for ( i = 0; i < nCount; ++i )
2268         {
2269             if ( nMax < m_aTabCtrl.GetPageId(i) )
2270                 nMax = m_aTabCtrl.GetPageId(i);
2271         }
2272         return ( nMax + 1 );
2273     }
2274 
2275 	//------------------------------------------------------------------------
2276 	void DataNavigatorWindow::Resize()
2277 	{
2278 		Window::Resize();
2279 
2280 		Size aOutSz = GetOutputSizePixel();
2281 		long nWidth = Max( aOutSz.Width(), m_nMinWidth );
2282 		long nHeight = Max( aOutSz.Height(), m_nMinHeight );
2283 
2284 		Size aSz = m_aModelsBox.GetSizePixel();
2285 		aSz.Width() = nWidth - 3*m_a3Size.Width() - m_aModelBtn.GetSizePixel().Width();
2286 		m_aModelsBox.SetSizePixel( aSz );
2287 		Point aPos = m_aModelBtn.GetPosPixel();
2288 		aPos.X() = m_aModelsBox.GetPosPixel().X() + aSz.Width() + m_a3Size.Width();
2289 		m_aModelBtn.SetPosPixel( aPos );
2290 
2291 		aSz = m_aTabCtrl.GetSizePixel();
2292 		aSz.Width() = nWidth - 2*m_a3Size.Width();
2293 		aSz.Height() = nHeight - m_nBorderHeight;
2294 		m_aTabCtrl.SetSizePixel( aSz );
2295 		// Instance button positioning
2296 		aPos = m_aInstanceBtn.GetPosPixel();
2297 		// right aligned
2298 		aPos.X() = nWidth - m_aInstanceBtn.GetSizePixel().Width() - m_a3Size.Width();
2299 		// under the tabcontrol
2300 		aPos.Y() = m_aTabCtrl.GetPosPixel().Y() + aSz.Height() + m_a3Size.Height();
2301 		m_aInstanceBtn.SetPosPixel( aPos );
2302 	}
2303 
2304     //------------------------------------------------------------------------
2305     void DataNavigatorWindow::SetDocModified()
2306     {
2307         SfxObjectShell* pCurrentDoc = SfxObjectShell::Current();
2308         DBG_ASSERT( pCurrentDoc, "DataNavigatorWindow::SetDocModified(): no objectshell" );
2309         if ( !pCurrentDoc->IsModified() && pCurrentDoc->IsEnableSetModified() )
2310             pCurrentDoc->SetModified();
2311     }
2312 
2313     //------------------------------------------------------------------------
2314     void DataNavigatorWindow::NotifyChanges( bool _bLoadAll )
2315     {
2316         if ( !m_bIsNotifyDisabled )
2317         {
2318             if ( _bLoadAll )
2319             {
2320                 // reset all members
2321                 RemoveBroadcaster();
2322                 m_xDataContainer.clear();
2323                 m_xFrameModel.clear();
2324                 m_aModelsBox.Clear();
2325                 m_nLastSelectedPos = LISTBOX_ENTRY_NOTFOUND;
2326                 // for a reload
2327                 LoadModels();
2328             }
2329             else
2330                 m_aUpdateTimer.Start();
2331         }
2332     }
2333 
2334     //------------------------------------------------------------------------
2335     void DataNavigatorWindow::AddContainerBroadcaster( const XContainer_ref& xContainer )
2336     {
2337         Reference< XContainerListener > xListener(
2338             static_cast< XContainerListener* >( m_xDataListener.get() ), UNO_QUERY );
2339         xContainer->addContainerListener( xListener );
2340         m_aContainerList.push_back( xContainer );
2341     }
2342 
2343     //------------------------------------------------------------------------
2344     void DataNavigatorWindow::AddEventBroadcaster( const XEventTarget_ref& xTarget )
2345     {
2346         Reference< XEventListener > xListener(
2347             static_cast< XEventListener* >( m_xDataListener.get() ), UNO_QUERY );
2348         xTarget->addEventListener( EVENTTYPE_CHARDATA, xListener, true );
2349         xTarget->addEventListener( EVENTTYPE_CHARDATA, xListener, false );
2350         xTarget->addEventListener( EVENTTYPE_ATTR, xListener, true );
2351         xTarget->addEventListener( EVENTTYPE_ATTR, xListener, false );
2352         m_aEventTargetList.push_back( xTarget );
2353     }
2354 
2355     //------------------------------------------------------------------------
2356     void DataNavigatorWindow::RemoveBroadcaster()
2357     {
2358         Reference< XContainerListener > xContainerListener(
2359             static_cast< XContainerListener* >( m_xDataListener.get() ), UNO_QUERY );
2360         sal_Int32 i, nCount = m_aContainerList.size();
2361         for ( i = 0; i < nCount; ++i )
2362             m_aContainerList[i]->removeContainerListener( xContainerListener );
2363         Reference< XEventListener > xEventListener(
2364             static_cast< XEventListener* >( m_xDataListener.get() ), UNO_QUERY );
2365         nCount = m_aEventTargetList.size();
2366         for ( i = 0; i < nCount; ++i )
2367         {
2368             m_aEventTargetList[i]->removeEventListener( EVENTTYPE_CHARDATA, xEventListener, true );
2369             m_aEventTargetList[i]->removeEventListener( EVENTTYPE_CHARDATA, xEventListener, false );
2370             m_aEventTargetList[i]->removeEventListener( EVENTTYPE_ATTR, xEventListener, true );
2371             m_aEventTargetList[i]->removeEventListener( EVENTTYPE_ATTR, xEventListener, false );
2372         }
2373     }
2374 
2375     //========================================================================
2376 	// class DataNavigator
2377 	//========================================================================
2378 	DBG_NAME(DataNavigator)
2379 	//------------------------------------------------------------------------
2380 	DataNavigator::DataNavigator( SfxBindings* _pBindings, SfxChildWindow* _pMgr, Window* _pParent ) :
2381 
2382 		SfxDockingWindow( _pBindings, _pMgr, _pParent,
2383 						  WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_ROLLABLE|WB_3DLOOK|WB_DOCKABLE) ),
2384 		SfxControllerItem( SID_FM_DATANAVIGATOR_CONTROL, *_pBindings ),
2385 
2386 		m_aDataWin( this, _pBindings )
2387 
2388 	{
2389 		DBG_CTOR(DataNavigator,NULL);
2390 
2391 		SetHelpId( HID_DATA_NAVIGATOR_WIN );
2392 		SetText( SVX_RES( RID_STR_DATANAVIGATOR ) );
2393 
2394 		Size aSize = m_aDataWin.GetOutputSizePixel();
2395 		Size aLogSize = PixelToLogic( aSize, MAP_APPFONT );
2396 		SfxDockingWindow::SetFloatingSize( aLogSize );
2397 
2398 		m_aDataWin.Show();
2399 	}
2400 
2401 	//------------------------------------------------------------------------
2402 	DataNavigator::~DataNavigator()
2403 	{
2404 		DBG_DTOR(DataNavigator,NULL);
2405 	}
2406 
2407 	//-----------------------------------------------------------------------
2408 	void DataNavigator::Update( FmFormShell* /*pFormShell*/ )
2409 	{
2410 	}
2411 	//-----------------------------------------------------------------------
2412 	void DataNavigator::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
2413 	{
2414 		if ( !pState  || SID_FM_DATANAVIGATOR_CONTROL != nSID )
2415 			return;
2416 
2417 		if ( eState >= SFX_ITEM_AVAILABLE )
2418 		{
2419 			FmFormShell* pShell = PTR_CAST( FmFormShell,((SfxObjectItem*)pState)->GetShell() );
2420 			Update( pShell );
2421 		}
2422 		else
2423 			Update( NULL );
2424 	}
2425 
2426 	//-----------------------------------------------------------------------
2427 	void DataNavigator::GetFocus()
2428 	{
2429 		SfxDockingWindow::GetFocus();
2430 	}
2431 
2432 	//-----------------------------------------------------------------------
2433 	sal_Bool DataNavigator::Close()
2434 	{
2435 		Update( NULL );
2436 		return SfxDockingWindow::Close();
2437 	}
2438 
2439 	//-----------------------------------------------------------------------
2440 	Size DataNavigator::CalcDockingSize( SfxChildAlignment eAlign )
2441 	{
2442         if ( ( eAlign == SFX_ALIGN_TOP ) || ( eAlign == SFX_ALIGN_BOTTOM ) )
2443 			return Size();
2444 
2445 		return SfxDockingWindow::CalcDockingSize( eAlign );
2446 	}
2447 
2448 	//-----------------------------------------------------------------------
2449 	SfxChildAlignment DataNavigator::CheckAlignment( SfxChildAlignment eActAlign, SfxChildAlignment eAlign )
2450 	{
2451 		switch ( eAlign )
2452 		{
2453 			case SFX_ALIGN_LEFT:
2454 			case SFX_ALIGN_RIGHT:
2455 			case SFX_ALIGN_NOALIGNMENT:
2456 				return eAlign;
2457             default:
2458                 break;
2459 		}
2460 		return eActAlign;
2461 	}
2462 
2463 	//------------------------------------------------------------------------
2464 	void DataNavigator::Resize()
2465 	{
2466 		SfxDockingWindow::Resize();
2467 
2468 		Size aLogOutputSize = PixelToLogic( GetOutputSizePixel(), MAP_APPFONT );
2469 		Size aLogExplSize = aLogOutputSize;
2470 		aLogExplSize.Width() -= 2;
2471 		aLogExplSize.Height() -= 2;
2472 
2473 		Point aExplPos = LogicToPixel( Point(1,1), MAP_APPFONT );
2474 		Size aExplSize = LogicToPixel( aLogExplSize, MAP_APPFONT );
2475 
2476 		m_aDataWin.SetPosSizePixel( aExplPos, aExplSize );
2477 	}
2478 
2479 
2480 	//========================================================================
2481 	// class NavigatorFrameManager
2482 	//========================================================================
2483 
2484 	//-----------------------------------------------------------------------
2485 	SFX_IMPL_DOCKINGWINDOW( DataNavigatorManager, SID_FM_SHOW_DATANAVIGATOR )
2486 
2487 	//-----------------------------------------------------------------------
2488 	DataNavigatorManager::DataNavigatorManager(
2489 		Window* _pParent, sal_uInt16 _nId, SfxBindings* _pBindings, SfxChildWinInfo* _pInfo ) :
2490 
2491 		SfxChildWindow( _pParent, _nId )
2492 
2493 	{
2494 		pWindow = new DataNavigator( _pBindings, this, _pParent );
2495 		eChildAlignment = SFX_ALIGN_RIGHT;
2496         pWindow->SetSizePixel( Size( 250, 400 ) );
2497 		( (SfxDockingWindow*)pWindow )->Initialize( _pInfo );
2498 	}
2499 
2500 	//========================================================================
2501 	// class AddDataItemDialog
2502 	//========================================================================
2503 
2504 	AddDataItemDialog::AddDataItemDialog(
2505 		Window* pParent, ItemNode* _pNode,
2506 		const Reference< css::xforms::XFormsUIHelper1 >& _rUIHelper ) :
2507 
2508 		ModalDialog( pParent, SVX_RES( RID_SVXDLG_ADD_DATAITEM ) ),
2509 
2510 		m_aItemFL		( this, SVX_RES( FL_ITEM ) ),
2511 		m_aNameFT		( this, SVX_RES( FT_NAME ) ),
2512 		m_aNameED		( this, SVX_RES( ED_NAME ) ),
2513 		m_aDefaultFT	( this, SVX_RES( FT_DEFAULT ) ),
2514 		m_aDefaultED	( this, SVX_RES( ED_DEFAULT ) ),
2515 		m_aDefaultBtn	( this, SVX_RES( PB_DEFAULT ) ),
2516 		m_aSettingsFL	( this, SVX_RES( FL_SETTINGS ) ),
2517 		m_aDataTypeFT	( this, SVX_RES( FT_DATATYPE ) ),
2518 		m_aDataTypeLB	( this, SVX_RES( LB_DATATYPE ) ),
2519 		m_aRequiredCB	( this, SVX_RES( CB_REQUIRED ) ),
2520 		m_aRequiredBtn	( this, SVX_RES( PB_REQUIRED ) ),
2521 		m_aRelevantCB	( this, SVX_RES( CB_RELEVANT ) ),
2522 		m_aRelevantBtn	( this, SVX_RES( PB_RELEVANT ) ),
2523 		m_aConstraintCB	( this, SVX_RES( CB_CONSTRAINT ) ),
2524 		m_aConstraintBtn( this, SVX_RES( PB_CONSTRAINT ) ),
2525 		m_aReadonlyCB	( this, SVX_RES( CB_READONLY ) ),
2526 		m_aReadonlyBtn	( this, SVX_RES( PB_READONLY ) ),
2527 		m_aCalculateCB	( this, SVX_RES( CB_CALCULATE ) ),
2528 		m_aCalculateBtn	( this, SVX_RES( PB_CALCULATE ) ),
2529 		m_aButtonsFL	( this, SVX_RES( FL_DATANAV_BTN ) ),
2530 		m_aOKBtn		( this, SVX_RES( BTN_DATANAV_OK ) ),
2531 		m_aEscBtn		( this, SVX_RES( BTN_DATANAV_ESC ) ),
2532 		m_aHelpBtn		( this, SVX_RES( BTN_DATANAV_HELP ) ),
2533 
2534 		m_xUIHelper		( _rUIHelper ),
2535 		m_pItemNode		( _pNode ),
2536 		m_eItemType		( DITNone ),
2537 		m_sFL_Element	( SVX_RES( STR_FIXEDLINE_ELEMENT ) ),
2538 		m_sFL_Attribute	( SVX_RES( STR_FIXEDLINE_ATTRIBUTE ) ),
2539         m_sFL_Binding   ( SVX_RES( STR_FIXEDLINE_BINDING ) ),
2540         m_sFT_BindingExp( SVX_RES( STR_FIXEDTEXT_BINDING ) )
2541 
2542 	{
2543 		FreeResource();
2544         m_aDataTypeLB.SetDropDownLineCount( 10 );
2545 
2546         InitDialog();
2547 		InitFromNode();
2548 		InitDataTypeBox();
2549 		CheckHdl( NULL );
2550 	}
2551 
2552 	//------------------------------------------------------------------------
2553 	AddDataItemDialog::~AddDataItemDialog()
2554 	{
2555 		if ( m_xTempBinding.is() )
2556 		{
2557 			Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
2558 			if ( xModel.is() )
2559 			{
2560 				try
2561 				{
2562 					Reference < XSet > xBindings = xModel->getBindings();
2563 					if ( xBindings.is() )
2564 						xBindings->remove( makeAny( m_xTempBinding ) );
2565 				}
2566 				catch ( Exception& )
2567 				{
2568 					DBG_ERRORFILE( "AddDataItemDialog::Dtor(): exception caught" );
2569 				}
2570 			}
2571 		}
2572         if( m_xUIHelper.is()  &&  m_xBinding.is() )
2573         {
2574             // remove binding, if it does not convey 'useful' information
2575             m_xUIHelper->removeBindingIfUseless( m_xBinding );
2576         }
2577 	}
2578 
2579 	//------------------------------------------------------------------------
2580 	IMPL_LINK( AddDataItemDialog, CheckHdl, CheckBox *, pBox )
2581 	{
2582 		// Condition buttons are only enable if their check box is checked
2583 		m_aReadonlyBtn.Enable( m_aReadonlyCB.IsChecked() );
2584 		m_aRequiredBtn.Enable( m_aRequiredCB.IsChecked() );
2585 		m_aRelevantBtn.Enable( m_aRelevantCB.IsChecked() );
2586 		m_aConstraintBtn.Enable( m_aConstraintCB.IsChecked() );
2587 		m_aCalculateBtn.Enable( m_aCalculateCB.IsChecked() );
2588 
2589 		if ( pBox && m_xTempBinding.is() )
2590 		{
2591 			::rtl::OUString sTemp, sPropName;
2592 			if ( &m_aRequiredCB == pBox )
2593 				sPropName = PN_REQUIRED_EXPR;
2594 			else if ( &m_aRelevantCB == pBox )
2595 				sPropName = PN_RELEVANT_EXPR;
2596 			else if ( &m_aConstraintCB == pBox )
2597 				sPropName = PN_CONSTRAINT_EXPR;
2598 			else if ( &m_aReadonlyCB == pBox )
2599 				sPropName = PN_READONLY_EXPR;
2600 			else if ( &m_aCalculateCB == pBox )
2601 				sPropName = PN_CALCULATE_EXPR;
2602 			bool bIsChecked = ( pBox->IsChecked() != sal_False );
2603 			m_xTempBinding->getPropertyValue( sPropName ) >>= sTemp;
2604 			if ( bIsChecked && sTemp.getLength() == 0 )
2605 				sTemp = TRUE_VALUE;
2606 			else if ( !bIsChecked && sTemp.getLength() > 0 )
2607 				sTemp = ::rtl::OUString();
2608 			m_xTempBinding->setPropertyValue( sPropName, makeAny( sTemp ) );
2609 		}
2610 
2611 		return 0;
2612 	}
2613 
2614 	//------------------------------------------------------------------------
2615 	IMPL_LINK( AddDataItemDialog, ConditionHdl, PushButton *, pBtn )
2616 	{
2617 		::rtl::OUString sTemp, sPropName;
2618 		if ( &m_aDefaultBtn == pBtn )
2619 			sPropName = PN_BINDING_EXPR;
2620 		else if ( &m_aRequiredBtn == pBtn )
2621 			sPropName = PN_REQUIRED_EXPR;
2622 		else if ( &m_aRelevantBtn == pBtn )
2623 			sPropName = PN_RELEVANT_EXPR;
2624 		else if ( &m_aConstraintBtn == pBtn )
2625 			sPropName = PN_CONSTRAINT_EXPR;
2626 		else if ( &m_aReadonlyBtn == pBtn )
2627 			sPropName = PN_READONLY_EXPR;
2628 		else if ( &m_aCalculateBtn == pBtn )
2629 			sPropName = PN_CALCULATE_EXPR;
2630 		AddConditionDialog aDlg( this, sPropName, m_xTempBinding );
2631 		bool bIsDefBtn = ( &m_aDefaultBtn == pBtn );
2632 		String sCondition;
2633 		if ( bIsDefBtn )
2634 			sCondition = m_aDefaultED.GetText();
2635 		else
2636 		{
2637 			m_xTempBinding->getPropertyValue( sPropName ) >>= sTemp;
2638 			if ( sTemp.getLength() == 0 )
2639 				sTemp = TRUE_VALUE;
2640 			sCondition = sTemp;
2641 		}
2642 		aDlg.SetCondition( sCondition );
2643 
2644 		if ( aDlg.Execute() == RET_OK )
2645 		{
2646 			String sNewCondition = aDlg.GetCondition();
2647 			if ( bIsDefBtn )
2648 				m_aDefaultED.SetText( sNewCondition );
2649 			else
2650 			{
2651 
2652 				m_xTempBinding->setPropertyValue(
2653 					sPropName, makeAny( ::rtl::OUString( sNewCondition ) ) );
2654 			}
2655 		}
2656 		return 0;
2657 	}
2658 
2659 	void copyPropSet( const Reference< XPropertySet >& xFrom, Reference< XPropertySet >& xTo )
2660 	{
2661 	    DBG_ASSERT( xFrom.is(), "copyPropSet(): no source" );
2662 	    DBG_ASSERT( xTo.is(), "copyPropSet(): no target" );
2663 
2664 		try
2665 		{
2666 		    // get property names & infos, and iterate over target properties
2667 		    Sequence< Property > aProperties = xTo->getPropertySetInfo()->getProperties();
2668 		    sal_Int32 nProperties = aProperties.getLength();
2669 		    const Property* pProperties = aProperties.getConstArray();
2670 		    Reference< XPropertySetInfo > xFromInfo = xFrom->getPropertySetInfo();
2671 		    for ( sal_Int32 i = 0; i < nProperties; ++i )
2672 		    {
2673 		        const ::rtl::OUString& rName = pProperties[i].Name;
2674 
2675 		        // if both set have the property, copy the value
2676 		        // (catch and ignore exceptions, if any)
2677 		        if ( xFromInfo->hasPropertyByName( rName ) )
2678 		        {
2679 					// don't set readonly properties
2680 		            Property aProperty = xFromInfo->getPropertyByName( rName );
2681 		            if ( ( aProperty.Attributes & PropertyAttribute::READONLY ) == 0 )
2682 		                xTo->setPropertyValue(rName, xFrom->getPropertyValue( rName ));
2683 		        }
2684 		        // else: no property? then ignore.
2685 		    }
2686 		}
2687 		catch ( Exception& )
2688 		{
2689             DBG_ERRORFILE( "copyPropSet(): exception caught" );
2690 		}
2691 	}
2692 
2693 	//------------------------------------------------------------------------
2694 	IMPL_LINK( AddDataItemDialog, OKHdl, OKButton *, EMPTYARG )
2695 	{
2696         bool bIsHandleBinding = ( DITBinding == m_eItemType );
2697         bool bIsHandleText = ( DITText == m_eItemType );
2698 		::rtl::OUString sNewName( m_aNameED.GetText() );
2699 
2700         if ( ( !bIsHandleBinding && !bIsHandleText && !m_xUIHelper->isValidXMLName( sNewName ) ) ||
2701 			 ( bIsHandleBinding && sNewName.getLength() == 0 ) )
2702 		{
2703 			// Error and don't close the dialog
2704 			ErrorBox aErrBox( this, SVX_RES( RID_ERR_INVALID_XMLNAME ) );
2705 			String sMessText = aErrBox.GetMessText();
2706 			sMessText.SearchAndReplace( MSG_VARIABLE, sNewName );
2707 			aErrBox.SetMessText( sMessText );
2708 			aErrBox.Execute();
2709 			return 0;
2710 		}
2711 
2712         ::rtl::OUString sDataType( m_aDataTypeLB.GetSelectEntry() );
2713         m_xTempBinding->setPropertyValue( PN_BINDING_TYPE, makeAny( sDataType ) );
2714 
2715         if ( bIsHandleBinding )
2716 		{
2717 			// copy properties from temp binding to original binding
2718             copyPropSet( m_xTempBinding, m_pItemNode->m_xPropSet );
2719 			try
2720 			{
2721                 ::rtl::OUString sValue = m_aNameED.GetText();
2722 				m_pItemNode->m_xPropSet->setPropertyValue( PN_BINDING_ID, makeAny( sValue ) );
2723 				sValue = m_aDefaultED.GetText();
2724 				m_pItemNode->m_xPropSet->setPropertyValue( PN_BINDING_EXPR, makeAny( sValue ) );
2725 			}
2726 			catch ( Exception& )
2727 			{
2728                 DBG_ERRORFILE( "AddDataDialog::OKHdl(): exception caught" );
2729 			}
2730 		}
2731 		else
2732 		{
2733 			// copy properties from temp binding to original binding
2734 			copyPropSet( m_xTempBinding, m_xBinding );
2735 			try
2736 			{
2737                 if ( bIsHandleText )
2738                     m_xUIHelper->setNodeValue( m_pItemNode->m_xNode, m_aDefaultED.GetText() );
2739                 else
2740                 {
2741                     Reference< css::xml::dom::XNode > xNewNode =
2742                         m_xUIHelper->renameNode( m_pItemNode->m_xNode, m_aNameED.GetText() );
2743                     m_xUIHelper->setNodeValue( xNewNode, m_aDefaultED.GetText() );
2744                     m_pItemNode->m_xNode = xNewNode;
2745                 }
2746 			}
2747 			catch ( Exception& )
2748 			{
2749                 DBG_ERRORFILE( "AddDataDialog::OKHdl(): exception caught" );
2750 			}
2751 		}
2752 		// then close the dialog
2753 		EndDialog( RET_OK );
2754 		return 0;
2755 	}
2756 
2757 	//------------------------------------------------------------------------
2758 	void AddDataItemDialog::InitDialog()
2759 	{
2760 		// set handler
2761 		Link aLink = LINK( this, AddDataItemDialog, CheckHdl );
2762 		m_aRequiredCB.SetClickHdl( aLink );
2763 		m_aRelevantCB.SetClickHdl( aLink );
2764 		m_aConstraintCB.SetClickHdl( aLink );
2765 		m_aReadonlyCB.SetClickHdl( aLink );
2766 		m_aCalculateCB.SetClickHdl( aLink );
2767 
2768 		aLink = LINK( this, AddDataItemDialog, ConditionHdl );
2769 		m_aDefaultBtn.SetClickHdl( aLink );
2770 		m_aRequiredBtn.SetClickHdl( aLink );
2771 		m_aRelevantBtn.SetClickHdl( aLink );
2772 		m_aConstraintBtn.SetClickHdl( aLink );
2773 		m_aReadonlyBtn.SetClickHdl( aLink );
2774 		m_aCalculateBtn.SetClickHdl( aLink );
2775 
2776 		m_aOKBtn.SetClickHdl( LINK( this, AddDataItemDialog, OKHdl ) );
2777 	}
2778 
2779 	//------------------------------------------------------------------------
2780 	void AddDataItemDialog::InitFromNode()
2781 	{
2782 		if ( m_pItemNode )
2783 		{
2784 			if ( m_pItemNode->m_xNode.is() )
2785 			{
2786 				try
2787 				{
2788 					// detect type of the node
2789 					css::xml::dom::NodeType eChildType = m_pItemNode->m_xNode->getNodeType();
2790 					switch ( eChildType )
2791 					{
2792 						case css::xml::dom::NodeType_ATTRIBUTE_NODE:
2793 							m_eItemType = DITAttribute;
2794 							break;
2795 						case css::xml::dom::NodeType_ELEMENT_NODE:
2796 							m_eItemType = DITElement;
2797 							break;
2798 						case css::xml::dom::NodeType_TEXT_NODE:
2799 							m_eItemType = DITText;
2800 							break;
2801                         default:
2802                             DBG_ERROR( "AddDataItemDialog::InitFronNode: cannot handle this node type!" );
2803                             break;
2804 					}
2805 
2806 					/** Get binding of the node and clone it
2807 						Then use this temporary binding in the dialog.
2808 						When the user click OK the temporary binding will be copied
2809 						into the original binding.
2810 					 */
2811 
2812 					Reference< css::xml::dom::XNode > xNode = m_pItemNode->m_xNode;
2813                     m_xBinding = m_xUIHelper->getBindingForNode( xNode, sal_True );
2814                     if ( m_xBinding.is() )
2815                     {
2816                         Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
2817                         if ( xModel.is() )
2818                         {
2819                             m_xTempBinding = m_xUIHelper->cloneBindingAsGhost( m_xBinding );
2820                             Reference < XSet > xBindings = xModel->getBindings();
2821                             if ( xBindings.is() )
2822                                 xBindings->insert( makeAny( m_xTempBinding ) );
2823                         }
2824                     }
2825 
2826                     if ( m_eItemType != DITText )
2827                     {
2828                         ::rtl::OUString sName( m_xUIHelper->getNodeName( m_pItemNode->m_xNode ) );
2829                         m_aNameED.SetText( sName );
2830                     }
2831 					m_aDefaultED.SetText( m_pItemNode->m_xNode->getNodeValue() );
2832 				}
2833 				catch( Exception& )
2834 				{
2835 					DBG_ERRORFILE( "AddDataItemDialog::InitFromNode(): exception caught" );
2836 				}
2837 			}
2838 			else if ( m_pItemNode->m_xPropSet.is() )
2839 			{
2840 				m_eItemType = DITBinding;
2841 				Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
2842 				if ( xModel.is() )
2843                 {
2844 					try
2845 					{
2846 						m_xTempBinding = m_xUIHelper->cloneBindingAsGhost( m_pItemNode->m_xPropSet );
2847 						Reference < XSet > xBindings = xModel->getBindings();
2848 						if ( xBindings.is() )
2849 							xBindings->insert( makeAny( m_xTempBinding ) );
2850 					}
2851 					catch ( Exception& )
2852 					{
2853                         DBG_ERRORFILE( "AddDataItemDialog::InitFromNode(): exception caught" );
2854 					}
2855                 }
2856 				rtl::OUString sTemp;
2857 				try
2858 				{
2859 					Reference< XPropertySetInfo > xInfo = m_pItemNode->m_xPropSet->getPropertySetInfo();
2860 					if ( xInfo->hasPropertyByName( PN_BINDING_ID ) )
2861 					{
2862 						m_pItemNode->m_xPropSet->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
2863 						m_aNameED.SetText( sTemp );
2864 						m_pItemNode->m_xPropSet->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
2865 						m_aDefaultED.SetText( sTemp );
2866 					}
2867 					else if ( xInfo->hasPropertyByName( PN_SUBMISSION_BIND ) )
2868 					{
2869 						m_pItemNode->m_xPropSet->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp;
2870 						m_aNameED.SetText( sTemp );
2871 					}
2872 				}
2873 				catch( Exception& )
2874 				{
2875 					DBG_ERRORFILE( "AddDataItemDialog::InitFromNode(): exception caught" );
2876 				}
2877 
2878 				Size a3and1Sz = LogicToPixel( Size( 3, 1 ), MAP_APPFONT );
2879 				Size aNewSz = m_aDefaultED.GetSizePixel();
2880 				Point aNewPnt = m_aDefaultED.GetPosPixel();
2881 				aNewPnt.Y() += a3and1Sz.Height();
2882 				aNewSz.Width() -= ( m_aDefaultBtn.GetSizePixel().Width() + a3and1Sz.Width() );
2883 				m_aDefaultED.SetPosSizePixel( aNewPnt, aNewSz );
2884 				m_aDefaultBtn.Show();
2885 			}
2886 
2887             if ( m_xTempBinding.is() )
2888 			{
2889 				::rtl::OUString sTemp;
2890 				try
2891 				{
2892 					if ( ( m_xTempBinding->getPropertyValue( PN_REQUIRED_EXPR ) >>= sTemp )
2893 	    				&& sTemp.getLength() > 0 )
2894 						m_aRequiredCB.Check( sal_True );
2895 					if ( ( m_xTempBinding->getPropertyValue( PN_RELEVANT_EXPR ) >>= sTemp )
2896 						&& sTemp.getLength() > 0 )
2897 						m_aRelevantCB.Check( sal_True );
2898 					if ( ( m_xTempBinding->getPropertyValue( PN_CONSTRAINT_EXPR ) >>= sTemp )
2899 						&& sTemp.getLength() > 0 )
2900 						m_aConstraintCB.Check( sal_True );
2901 					if ( ( m_xTempBinding->getPropertyValue( PN_READONLY_EXPR ) >>= sTemp )
2902 						&& sTemp.getLength() > 0 )
2903 						m_aReadonlyCB.Check( sal_True );
2904 					if ( ( m_xTempBinding->getPropertyValue( PN_CALCULATE_EXPR ) >>= sTemp )
2905 						&& sTemp.getLength() > 0 )
2906 						m_aCalculateCB.Check( sal_True );
2907 				}
2908 				catch ( Exception& )
2909 				{
2910                     DBG_ERRORFILE( "AddDataItemDialog::InitFromNode(): exception caught" );
2911 				}
2912 			}
2913 		}
2914 
2915         if ( DITText == m_eItemType )
2916         {
2917             long nDelta = m_aButtonsFL.GetPosPixel().Y() - m_aSettingsFL.GetPosPixel().Y();
2918             size_t i = 0;
2919             Window* pWinsForHide[] =
2920             {
2921                 &m_aSettingsFL, &m_aDataTypeFT, &m_aDataTypeLB, &m_aRequiredCB,
2922                 &m_aRequiredBtn, &m_aRelevantCB, &m_aRelevantBtn, &m_aConstraintCB,
2923                 &m_aConstraintBtn, &m_aReadonlyCB, &m_aReadonlyBtn, &m_aCalculateCB,
2924                 &m_aCalculateBtn
2925             };
2926             Window** pCurrent = pWinsForHide;
2927             for ( ; i < sizeof( pWinsForHide ) / sizeof( pWinsForHide[ 0 ] ); ++i, ++pCurrent )
2928                 (*pCurrent)->Hide();
2929 
2930             Window* pWinsForMove[] =
2931             {
2932                 &m_aButtonsFL, &m_aOKBtn, &m_aEscBtn, &m_aHelpBtn
2933             };
2934             pCurrent = pWinsForMove;
2935             for ( i = 0; i < sizeof( pWinsForMove ) / sizeof( pWinsForMove[ 0 ] ); ++i, ++pCurrent )
2936             {
2937                 Point aNewPos = (*pCurrent)->GetPosPixel();
2938                 aNewPos.Y() -= nDelta;
2939                 (*pCurrent)->SetPosPixel( aNewPos );
2940             }
2941             Size aNewWinSz = GetSizePixel();
2942             aNewWinSz.Height() -= nDelta;
2943             SetSizePixel( aNewWinSz );
2944 
2945             m_aNameFT.Disable();
2946             m_aNameED.Disable();
2947         }
2948 	}
2949 
2950 	//------------------------------------------------------------------------
2951 	void AddDataItemDialog::InitDataTypeBox()
2952 	{
2953         if ( m_eItemType != DITText )
2954         {
2955             Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
2956             if ( xModel.is() )
2957             {
2958                 try
2959                 {
2960                     Reference< css::xforms::XDataTypeRepository > xDataTypes =
2961                         xModel->getDataTypeRepository();
2962                     if ( xDataTypes.is() )
2963                     {
2964                         Sequence< ::rtl::OUString > aNameList = xDataTypes->getElementNames();
2965                         sal_Int32 i, nCount = aNameList.getLength();
2966                         ::rtl::OUString* pNames = aNameList.getArray();
2967                         for ( i = 0; i < nCount; ++i )
2968                             m_aDataTypeLB.InsertEntry( pNames[i] );
2969                     }
2970 
2971                     if ( m_xTempBinding.is() )
2972                     {
2973                         rtl::OUString sTemp;
2974                         if ( m_xTempBinding->getPropertyValue( PN_BINDING_TYPE ) >>= sTemp )
2975                         {
2976                             sal_uInt16 nPos = m_aDataTypeLB.GetEntryPos( String( sTemp ) );
2977                             if ( LISTBOX_ENTRY_NOTFOUND == nPos )
2978                                 nPos = m_aDataTypeLB.InsertEntry( sTemp );
2979                             m_aDataTypeLB.SelectEntryPos( nPos );
2980                         }
2981                     }
2982                 }
2983                 catch ( Exception& )
2984                 {
2985                     DBG_ERRORFILE( "AddDataItemDialog::InitDataTypeBox(): exception caught" );
2986                 }
2987             }
2988         }
2989 	}
2990 
2991 	void AddDataItemDialog::InitText( DataItemType _eType )
2992 	{
2993 		String sText;
2994 
2995 		switch ( _eType )
2996 		{
2997 			case DITAttribute :
2998 			{
2999 				sText = m_sFL_Attribute;
3000 				break;
3001 			}
3002 
3003 			case DITBinding :
3004 			{
3005 				sText = m_sFL_Binding;
3006                 m_aDefaultFT.SetText( m_sFT_BindingExp );
3007 				break;
3008 			}
3009 
3010 			default:
3011 			{
3012 				sText = m_sFL_Element;
3013 			}
3014 		}
3015 
3016 		m_aItemFL.SetText( sText );
3017 	}
3018 
3019 	//========================================================================
3020 	// class AddConditionDialog
3021 	//========================================================================
3022 
3023 	AddConditionDialog::AddConditionDialog(
3024 		Window* pParent, const ::rtl::OUString& _rPropertyName,
3025 		const Reference< XPropertySet >& _rPropSet ) :
3026 
3027 		ModalDialog( pParent, SVX_RES( RID_SVXDLG_ADD_CONDITION ) ),
3028 
3029 		m_aConditionFT		( this, SVX_RES( FT_CONDITION ) ),
3030 		m_aConditionED		( this, SVX_RES( ED_CONDITION ) ),
3031 		m_aResultFT			( this, SVX_RES( FT_RESULT ) ),
3032 		m_aResultWin		( this, SVX_RES( FT_RESULT_PREVIEW ) ),
3033 		m_aEditNamespacesBtn( this, SVX_RES( PB_EDIT_NAMESPACES ) ),
3034 		m_aButtonsFL		( this, SVX_RES( FL_DATANAV_BTN ) ),
3035 		m_aOKBtn			( this, SVX_RES( BTN_DATANAV_OK ) ),
3036 		m_aEscBtn			( this, SVX_RES( BTN_DATANAV_ESC ) ),
3037 		m_aHelpBtn			( this, SVX_RES( BTN_DATANAV_HELP ) ),
3038 
3039 		m_sPropertyName		( _rPropertyName ),
3040 		m_xBinding			( _rPropSet )
3041 
3042 	{
3043 		FreeResource();
3044 
3045 		DBG_ASSERT( m_xBinding.is(), "AddConditionDialog::Ctor(): no Binding" );
3046 
3047 		m_aResultWin.SetBackground( m_aConditionED.GetBackground() );
3048 		m_aConditionED.SetModifyHdl( LINK( this, AddConditionDialog, ModifyHdl ) );
3049 		m_aEditNamespacesBtn.SetClickHdl( LINK( this, AddConditionDialog, EditHdl ) );
3050 		m_aOKBtn.SetClickHdl( LINK( this, AddConditionDialog, OKHdl ) );
3051 		m_aResultTimer.SetTimeout( 500 );
3052 		m_aResultTimer.SetTimeoutHdl( LINK( this, AddConditionDialog, ResultHdl ) );
3053 
3054 		if ( m_sPropertyName.getLength() > 0 )
3055 		{
3056 			try
3057 			{
3058 				rtl::OUString sTemp;
3059 				if ( ( m_xBinding->getPropertyValue( m_sPropertyName ) >>= sTemp )
3060 					&& sTemp.getLength() > 0 )
3061 				{
3062 					m_aConditionED.SetText( sTemp );
3063 				}
3064 				else
3065 				{
3066 //!					m_xBinding->setPropertyValue( m_sPropertyName, makeAny( TRUE_VALUE ) );
3067 					m_aConditionED.SetText( TRUE_VALUE );
3068 				}
3069 
3070 				Reference< css::xforms::XModel > xModel;
3071 				if ( ( m_xBinding->getPropertyValue( PN_BINDING_MODEL ) >>= xModel ) && xModel.is() )
3072 					m_xUIHelper = Reference< css::xforms::XFormsUIHelper1 >( xModel, UNO_QUERY );
3073 			}
3074 			catch ( Exception& )
3075 			{
3076 				DBG_ERRORFILE( "AddConditionDialog::Ctor(): exception caught" );
3077 			}
3078 		}
3079 
3080 		DBG_ASSERT( m_xUIHelper.is(), "AddConditionDialog::Ctor(): no UIHelper" );
3081 		ResultHdl( &m_aResultTimer );
3082 	}
3083 
3084 	//------------------------------------------------------------------------
3085 	AddConditionDialog::~AddConditionDialog()
3086 	{
3087 	}
3088 
3089 	//------------------------------------------------------------------------
3090 	IMPL_LINK( AddConditionDialog, EditHdl, PushButton *, EMPTYARG )
3091 	{
3092 		Reference< XNameContainer > xNameContnr;
3093 		try
3094 		{
3095 			m_xBinding->getPropertyValue( PN_BINDING_NAMESPACES ) >>= xNameContnr;
3096 		}
3097 		catch ( Exception& )
3098 		{
3099             DBG_ERRORFILE( "AddDataItemDialog::EditHdl(): exception caught" );
3100 		}
3101 		NamespaceItemDialog aDlg( this, xNameContnr );
3102 		aDlg.Execute();
3103 		try
3104 		{
3105 			m_xBinding->setPropertyValue( PN_BINDING_NAMESPACES, makeAny( xNameContnr ) );
3106 		}
3107 		catch ( Exception& )
3108 		{
3109 			DBG_ERRORFILE( "AddDataItemDialog::EditHdl(): exception caught" );
3110 		}
3111 		return 0;
3112 	}
3113 
3114 	//------------------------------------------------------------------------
3115 	IMPL_LINK( AddConditionDialog, OKHdl, OKButton *, EMPTYARG )
3116 	{
3117 /*!!!
3118         try
3119         {
3120             if ( m_xBinding.is() )
3121                 m_xBinding->setPropertyValue( m_sPropertyName, makeAny( ::rtl::OUString( m_aConditionED.GetText() ) ) );
3122         }
3123         catch( const Exception& )
3124         {
3125         	DBG_ERRORFILE( "AddConditionDialog, OKHdl: caught an exception!" );
3126         }
3127 */
3128 		EndDialog( RET_OK );
3129 		return 0;
3130 	}
3131 
3132 	//------------------------------------------------------------------------
3133 	IMPL_LINK( AddConditionDialog, ModifyHdl, MultiLineEdit *, EMPTYARG )
3134 	{
3135 		m_aResultTimer.Start();
3136 		return 0;
3137 	}
3138 
3139 	//------------------------------------------------------------------------
3140 	IMPL_LINK( AddConditionDialog, ResultHdl, Timer *, EMPTYARG )
3141 	{
3142 		String sCondition = m_aConditionED.GetText().EraseLeadingChars().EraseTrailingChars();
3143 		String sResult;
3144 		if ( sCondition.Len() > 0 )
3145 		{
3146 			try
3147 			{
3148 				sResult = m_xUIHelper->getResultForExpression( m_xBinding, ( m_sPropertyName == PN_BINDING_EXPR ), sCondition );
3149 			}
3150 			catch ( Exception& )
3151 			{
3152 				DBG_ERRORFILE( "AddConditionDialog::ResultHdl(): exception caught" );
3153 			}
3154 		}
3155 		m_aResultWin.SetText( sResult );
3156 		return 0;
3157 	}
3158 
3159 	//========================================================================
3160 	// class NamespaceItemDialog
3161 	//========================================================================
3162 
3163 	NamespaceItemDialog::NamespaceItemDialog(
3164 		AddConditionDialog* _pCondDlg, Reference< XNameContainer >& _rContainer ) :
3165 
3166 		ModalDialog( _pCondDlg, SVX_RES( RID_SVXDLG_NAMESPACE_ITEM ) ),
3167 
3168 		m_aNamespacesFT			( this, SVX_RES( FT_NAMESPACES ) ),
3169 		m_aNamespacesList		( this, SVX_RES( LB_NAMESPACES ) ),
3170 		m_aAddNamespaceBtn		( this, SVX_RES( PB_ADD_NAMESPACE ) ),
3171 		m_aEditNamespaceBtn		( this, SVX_RES( PB_EDIT_NAMESPACE ) ),
3172 		m_aDeleteNamespaceBtn	( this, SVX_RES( PB_DELETE_NAMESPACE ) ),
3173 		m_aButtonsFL			( this, SVX_RES( FL_DATANAV_BTN ) ),
3174 		m_aOKBtn				( this, SVX_RES( BTN_DATANAV_OK ) ),
3175 		m_aEscBtn				( this, SVX_RES( BTN_DATANAV_ESC ) ),
3176 		m_aHelpBtn				( this, SVX_RES( BTN_DATANAV_HELP ) ),
3177 
3178 		m_pConditionDlg			( _pCondDlg ),
3179 		m_rNamespaces			( _rContainer )
3180 
3181 	{
3182 		static long aStaticTabs[]= { 3, 0, 35, 200 };
3183 		m_aNamespacesList.SvxSimpleTable::SetTabs( aStaticTabs );
3184 		String sHeader = String( SVX_RES( STR_HEADER_PREFIX ) );
3185 		sHeader += '\t';
3186 		sHeader += String( SVX_RES( STR_HEADER_URL ) );
3187 		m_aNamespacesList.InsertHeaderEntry(
3188 			sHeader, HEADERBAR_APPEND, HIB_LEFT /*| HIB_FIXEDPOS | HIB_FIXED*/ );
3189 
3190 		FreeResource();
3191 
3192 		m_aNamespacesList.SetSelectHdl( LINK( this, NamespaceItemDialog, SelectHdl ) );
3193 		Link aLink = LINK( this, NamespaceItemDialog, ClickHdl );
3194 		m_aAddNamespaceBtn.SetClickHdl( aLink );
3195 		m_aEditNamespaceBtn.SetClickHdl( aLink );
3196 		m_aDeleteNamespaceBtn.SetClickHdl( aLink );
3197 		m_aOKBtn.SetClickHdl( LINK( this, NamespaceItemDialog, OKHdl ) );
3198 
3199 		LoadNamespaces();
3200 		SelectHdl( &m_aNamespacesList );
3201 	}
3202 
3203 	//------------------------------------------------------------------------
3204 	NamespaceItemDialog::~NamespaceItemDialog()
3205 	{
3206 	}
3207 
3208 	//------------------------------------------------------------------------
3209 	IMPL_LINK( NamespaceItemDialog, SelectHdl, SvxSimpleTable *,  EMPTYARG )
3210 	{
3211 		sal_Bool bEnable = ( m_aNamespacesList.FirstSelected() != NULL );
3212 		m_aEditNamespaceBtn.Enable( bEnable );
3213 		m_aDeleteNamespaceBtn.Enable( bEnable );
3214 
3215 		return 0;
3216 	}
3217 
3218 	//------------------------------------------------------------------------
3219 	IMPL_LINK( NamespaceItemDialog, ClickHdl, PushButton *, pBtn )
3220 	{
3221 		if ( &m_aAddNamespaceBtn == pBtn )
3222 		{
3223 			ManageNamespaceDialog aDlg( this, m_pConditionDlg, false );
3224 			if ( aDlg.Execute() == RET_OK )
3225 			{
3226 				String sEntry = aDlg.GetPrefix();
3227 				sEntry += '\t';
3228 				sEntry += aDlg.GetURL();
3229 				m_aNamespacesList.InsertEntry( sEntry );
3230 			}
3231 		}
3232 		else if ( &m_aEditNamespaceBtn == pBtn )
3233 		{
3234 			ManageNamespaceDialog aDlg( this, m_pConditionDlg, true );
3235 			SvLBoxEntry* pEntry = m_aNamespacesList.FirstSelected();
3236 			DBG_ASSERT( pEntry, "NamespaceItemDialog::ClickHdl(): no entry" );
3237 			String sPrefix( m_aNamespacesList.GetEntryText( pEntry, 0 ) );
3238 			aDlg.SetNamespace(
3239 				sPrefix,
3240 				m_aNamespacesList.GetEntryText( pEntry, 1 ) );
3241 			if ( aDlg.Execute() == RET_OK )
3242 			{
3243                 // if a prefix was changed, mark the old prefix as 'removed'
3244                 if( sPrefix != aDlg.GetPrefix() )
3245                     m_aRemovedList.push_back( sPrefix );
3246 
3247 				m_aNamespacesList.SetEntryText( aDlg.GetPrefix(), pEntry, 0 );
3248 				m_aNamespacesList.SetEntryText( aDlg.GetURL(), pEntry, 1 );
3249 			}
3250 		}
3251 		else if ( &m_aDeleteNamespaceBtn == pBtn )
3252 		{
3253 			SvLBoxEntry* pEntry = m_aNamespacesList.FirstSelected();
3254 			DBG_ASSERT( pEntry, "NamespaceItemDialog::ClickHdl(): no entry" );
3255 			::rtl::OUString sPrefix( m_aNamespacesList.GetEntryText( pEntry, 0 ) );
3256 			m_aRemovedList.push_back( sPrefix );
3257 			m_aNamespacesList.GetModel()->Remove( pEntry );
3258 		}
3259 		else
3260 		{
3261 			DBG_ERRORFILE( "NamespaceItemDialog::ClickHdl(): invalid button" );
3262 		}
3263 
3264 		SelectHdl( &m_aNamespacesList );
3265 		return 0;
3266 	}
3267 
3268 	//------------------------------------------------------------------------
3269 	IMPL_LINK( NamespaceItemDialog, OKHdl, OKButton *, EMPTYARG )
3270 	{
3271 		try
3272 		{
3273 			// update namespace container
3274 			sal_Int32 i, nRemovedCount = m_aRemovedList.size();
3275 			for( i = 0; i < nRemovedCount; ++i )
3276 				m_rNamespaces->removeByName( m_aRemovedList[i] );
3277 
3278 			sal_Int32 nEntryCount = m_aNamespacesList.GetEntryCount();
3279 			for( i = 0; i < nEntryCount; ++i )
3280 			{
3281 				SvLBoxEntry* pEntry = m_aNamespacesList.GetEntry(i);
3282 				::rtl::OUString sPrefix( m_aNamespacesList.GetEntryText( pEntry, 0 ) );
3283 				::rtl::OUString sURL( m_aNamespacesList.GetEntryText( pEntry, 1 ) );
3284 
3285 				if ( m_rNamespaces->hasByName( sPrefix ) )
3286 					m_rNamespaces->replaceByName( sPrefix, makeAny( sURL ) );
3287 				else
3288 					m_rNamespaces->insertByName( sPrefix, makeAny( sURL ) );
3289 			}
3290 		}
3291 		catch ( Exception& )
3292 		{
3293             DBG_ERRORFILE( "NamespaceItemDialog::OKHdl(): exception caught" );
3294 		}
3295 		// and close the dialog
3296 		EndDialog( RET_OK );
3297 		return 0;
3298 	}
3299 
3300 	//------------------------------------------------------------------------
3301 	void NamespaceItemDialog::LoadNamespaces()
3302 	{
3303 		try
3304 		{
3305 			Sequence< ::rtl::OUString > aAllNames = m_rNamespaces->getElementNames();
3306 			const ::rtl::OUString* pAllNames = aAllNames.getConstArray();
3307 			const ::rtl::OUString* pAllNamesEnd = pAllNames + aAllNames.getLength();
3308 			for ( ; pAllNames != pAllNamesEnd; ++pAllNames )
3309 			{
3310 				::rtl::OUString sURL;
3311 				::rtl::OUString sPrefix = *pAllNames;
3312 				if ( m_rNamespaces->hasByName( sPrefix ) )
3313 				{
3314 					Any aAny = m_rNamespaces->getByName( sPrefix );
3315 					if ( aAny >>= sURL )
3316 					{
3317 						String sEntry( sPrefix );
3318 						sEntry += '\t';
3319 						sEntry += String( sURL );
3320 
3321 						m_aNamespacesList.InsertEntry( sEntry );
3322 					}
3323 				}
3324 			}
3325 		}
3326 		catch ( Exception& )
3327 		{
3328             DBG_ERRORFILE( "NamespaceItemDialog::LoadNamespaces(): exception caught" );
3329 		}
3330 	}
3331 
3332 	//========================================================================
3333 	// class ManageNamespaceDialog
3334 	//========================================================================
3335 
3336 	ManageNamespaceDialog::ManageNamespaceDialog(
3337 		Window* pParent, AddConditionDialog* _pCondDlg, bool _bIsEdit ) :
3338 
3339 		ModalDialog( pParent, SVX_RES( RID_SVXDLG_MANAGE_NAMESPACE ) ),
3340 
3341 		m_aPrefixFT		( this, SVX_RES( FT_PREFIX ) ),
3342 		m_aPrefixED		( this, SVX_RES( ED_PREFIX ) ),
3343 		m_aUrlFT		( this, SVX_RES( FT_URL ) ),
3344 		m_aUrlED		( this, SVX_RES( ED_URL ) ),
3345 		m_aButtonsFL	( this, SVX_RES( FL_DATANAV_BTN ) ),
3346 		m_aOKBtn		( this, SVX_RES( BTN_DATANAV_OK ) ),
3347 		m_aEscBtn		( this, SVX_RES( BTN_DATANAV_ESC ) ),
3348 		m_aHelpBtn		( this, SVX_RES( BTN_DATANAV_HELP ) ),
3349 
3350 		m_pConditionDlg	( _pCondDlg )
3351 
3352 	{
3353 		if ( _bIsEdit )
3354 			SetText( String( SVX_RES( STR_EDIT_TEXT ) ) );
3355 
3356 		FreeResource();
3357 
3358 		m_aOKBtn.SetClickHdl( LINK( this, ManageNamespaceDialog, OKHdl ) );
3359 	}
3360 
3361 	//------------------------------------------------------------------------
3362 	ManageNamespaceDialog::~ManageNamespaceDialog()
3363 	{
3364 	}
3365 
3366 	//------------------------------------------------------------------------
3367 	IMPL_LINK( ManageNamespaceDialog, OKHdl, OKButton *, EMPTYARG )
3368 	{
3369 		String sPrefix = m_aPrefixED.GetText();
3370 
3371 		try
3372 		{
3373 			if ( !m_pConditionDlg->GetUIHelper()->isValidPrefixName( sPrefix ) )
3374 			{
3375 				ErrorBox aErrBox( this, SVX_RES( RID_ERR_INVALID_XMLPREFIX ) );
3376 				String sMessText = aErrBox.GetMessText();
3377 				sMessText.SearchAndReplace( MSG_VARIABLE, sPrefix );
3378 				aErrBox.SetMessText( sMessText );
3379 				aErrBox.Execute();
3380 				return 0;
3381 			}
3382 		}
3383 		catch ( Exception& )
3384 		{
3385             DBG_ERRORFILE( "ManageNamespacesDialog::OKHdl(): exception caught" );
3386 		}
3387 
3388 		// no error so close the dialog
3389 		EndDialog( RET_OK );
3390 		return 0;
3391 	}
3392 
3393 	//========================================================================
3394 	// class AddSubmissionDialog
3395 	//========================================================================
3396 
3397 	AddSubmissionDialog::AddSubmissionDialog(
3398 		Window* pParent, ItemNode* _pNode,
3399 		const Reference< css::xforms::XFormsUIHelper1 >& _rUIHelper ) :
3400 
3401 		ModalDialog( pParent, SVX_RES( RID_SVXDLG_ADD_SUBMISSION ) ),
3402 
3403 		m_aSubmissionFL	( this, SVX_RES( FL_SUBMISSION ) ),
3404 		m_aNameFT		( this, SVX_RES( FT_SUBMIT_NAME ) ),
3405 		m_aNameED		( this, SVX_RES( ED_SUBMIT_NAME ) ),
3406 		m_aActionFT		( this, SVX_RES( FT_SUBMIT_ACTION ) ),
3407 		m_aActionED		( this, SVX_RES( ED_SUBMIT_ACTION ) ),
3408 		m_aMethodFT		( this, SVX_RES( FT_SUBMIT_METHOD ) ),
3409 		m_aMethodLB		( this, SVX_RES( LB_SUBMIT_METHOD ) ),
3410 		m_aRefFT		( this, SVX_RES( FT_SUBMIT_REF ) ),
3411 		m_aRefED		( this, SVX_RES( ED_SUBMIT_REF ) ),
3412 		m_aRefBtn		( this, SVX_RES( PB_SUBMIT_REF ) ),
3413 		m_aBindFT		( this, SVX_RES( FT_SUBMIT_BIND ) ),
3414 		m_aBindLB		( this, SVX_RES( LB_SUBMIT_BIND ) ),
3415 		m_aReplaceFT	( this, SVX_RES( FT_SUBMIT_REPLACE ) ),
3416 		m_aReplaceLB	( this, SVX_RES( LB_SUBMIT_REPLACE ) ),
3417 
3418 		m_aButtonsFL	( this, SVX_RES( FL_DATANAV_BTN ) ),
3419 		m_aOKBtn		( this, SVX_RES( BTN_DATANAV_OK ) ),
3420 		m_aEscBtn		( this, SVX_RES( BTN_DATANAV_ESC ) ),
3421 		m_aHelpBtn		( this, SVX_RES( BTN_DATANAV_HELP ) ),
3422 
3423 		m_pItemNode		( _pNode ),
3424 		m_xUIHelper		( _rUIHelper )
3425 
3426 	{
3427 		FillAllBoxes(); // we need local resources here, so call before FreeResource!!!
3428 
3429 		FreeResource();
3430 
3431 		m_aRefBtn.SetClickHdl( LINK( this, AddSubmissionDialog, RefHdl ) );
3432 		m_aOKBtn.SetClickHdl( LINK( this, AddSubmissionDialog, OKHdl ) );
3433 	}
3434 
3435 	//------------------------------------------------------------------------
3436 	AddSubmissionDialog::~AddSubmissionDialog()
3437 	{
3438         // #i38991# if we have added a binding, we need to remove it as well.
3439         if( m_xCreatedBinding.is() && m_xUIHelper.is() )
3440             m_xUIHelper->removeBindingIfUseless( m_xCreatedBinding );
3441 	}
3442 
3443 	//------------------------------------------------------------------------
3444 	IMPL_LINK( AddSubmissionDialog, RefHdl, PushButton *, EMPTYARG )
3445 	{
3446 		AddConditionDialog aDlg( this, PN_BINDING_EXPR, m_xTempBinding );
3447 		aDlg.SetCondition( m_aRefED.GetText() );
3448 		if ( aDlg.Execute() == RET_OK )
3449 			m_aRefED.SetText( aDlg.GetCondition() );
3450 
3451 		return 0;
3452 	}
3453 
3454 	//------------------------------------------------------------------------
3455 	IMPL_LINK( AddSubmissionDialog, OKHdl, OKButton *, EMPTYARG )
3456 	{
3457 		rtl::OUString sName(m_aNameED.GetText());
3458 		if(!sName.getLength()) {
3459 
3460 	        ErrorBox aErrorBox(this,SVX_RES(RID_ERR_EMPTY_SUBMISSIONNAME));
3461 			aErrorBox.SetText( Application::GetDisplayName() );
3462 			aErrorBox.Execute();
3463 			return 0;
3464 		}
3465 
3466 		if ( !m_xSubmission.is() )
3467 		{
3468 			DBG_ASSERT( !m_xNewSubmission.is(),
3469 				"AddSubmissionDialog::OKHdl(): new submission already exists" );
3470 
3471 			// add a new submission
3472 			Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
3473 			if ( xModel.is() )
3474 			{
3475 				try
3476 				{
3477 					m_xNewSubmission = xModel->createSubmission();
3478 					m_xSubmission = Reference< XPropertySet >( m_xNewSubmission, UNO_QUERY );
3479 				}
3480 				catch ( Exception& )
3481 				{
3482                     DBG_ERRORFILE( "AddSubmissionDialog::OKHdl(): exception caught" );
3483 				}
3484 			}
3485 		}
3486 
3487 		if ( m_xSubmission.is() )
3488 		{
3489 			rtl::OUString sTemp = m_aNameED.GetText();
3490 			try
3491 			{
3492 				m_xSubmission->setPropertyValue( PN_SUBMISSION_ID, makeAny( sTemp ) );
3493 				sTemp = m_aActionED.GetText();
3494 				m_xSubmission->setPropertyValue( PN_SUBMISSION_ACTION, makeAny( sTemp ) );
3495 				sTemp = lcl_MethodString::get().toAPI( m_aMethodLB.GetSelectEntry() );
3496 				m_xSubmission->setPropertyValue( PN_SUBMISSION_METHOD, makeAny( sTemp ) );
3497 				sTemp = m_aRefED.GetText();
3498 				m_xSubmission->setPropertyValue( PN_SUBMISSION_REF, makeAny( sTemp ) );
3499                 String sEntry = m_aBindLB.GetSelectEntry();
3500                 sEntry.Erase( sEntry.Search( ':' ) );
3501                 sTemp = sEntry;
3502 				m_xSubmission->setPropertyValue( PN_SUBMISSION_BIND, makeAny( sTemp ) );
3503 				sTemp = lcl_ReplaceString::get().toAPI( m_aReplaceLB.GetSelectEntry() );
3504 				m_xSubmission->setPropertyValue( PN_SUBMISSION_REPLACE, makeAny( sTemp ) );
3505 			}
3506 			catch ( Exception& )
3507 			{
3508 				DBG_ERRORFILE( "AddSubmissionDialog::OKHdl(): exception caught" );
3509 			}
3510 		}
3511 
3512 		EndDialog( RET_OK );
3513 		return 0;
3514 	}
3515 
3516 	//------------------------------------------------------------------------
3517 	void AddSubmissionDialog::FillAllBoxes()
3518 	{
3519 		// method box
3520 		m_aMethodLB.InsertEntry( String( SVX_RES( STR_METHOD_POST	) ) );
3521 		m_aMethodLB.InsertEntry( String( SVX_RES( STR_METHOD_PUT ) ) );
3522 		m_aMethodLB.InsertEntry( String( SVX_RES( STR_METHOD_GET ) ) );
3523 		m_aMethodLB.SelectEntryPos(0);
3524 
3525 		// binding box
3526 		Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
3527 		if ( xModel.is() )
3528 		{
3529 			try
3530 			{
3531 				Reference< XEnumerationAccess > xNumAccess( xModel->getBindings(), UNO_QUERY );
3532 				if ( xNumAccess.is() )
3533 				{
3534 					Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
3535 					if ( xNum.is() && xNum->hasMoreElements() )
3536 					{
3537 						String sDelim( RTL_CONSTASCII_STRINGPARAM( ": " ) );
3538 						while ( xNum->hasMoreElements() )
3539 						{
3540 							Reference< XPropertySet > xPropSet;
3541 							Any aAny = xNum->nextElement();
3542 							if ( aAny >>= xPropSet )
3543 							{
3544 								String sEntry;
3545 								rtl::OUString sTemp;
3546 								xPropSet->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
3547 								sEntry += String( sTemp );
3548 								sEntry += sDelim;
3549 								xPropSet->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
3550 								sEntry += String( sTemp );
3551 								m_aBindLB.InsertEntry( sEntry );
3552 
3553 								if ( !m_xTempBinding.is() )
3554 									m_xTempBinding = xPropSet;
3555 							}
3556 						}
3557 					}
3558 				}
3559 			}
3560 			catch ( Exception& )
3561 			{
3562                 DBG_ERRORFILE( "AddSubmissionDialog::FillAllBoxes(): exception caught" );
3563 			}
3564 		}
3565 
3566         // #i36342# we need a temporary binding; create one if no existing binding
3567         // is found
3568         if( !m_xTempBinding.is() )
3569         {
3570             m_xCreatedBinding = m_xUIHelper->getBindingForNode(
3571                 Reference<css::xml::dom::XNode>(
3572                     xModel->getDefaultInstance()->getDocumentElement(),
3573                     UNO_QUERY_THROW ),
3574                 sal_True );
3575             m_xTempBinding = m_xCreatedBinding;
3576         }
3577 
3578 		// replace box
3579 		m_aReplaceLB.InsertEntry( String( SVX_RES( STR_REPLACE_NONE ) ) );
3580 		m_aReplaceLB.InsertEntry( String( SVX_RES( STR_REPLACE_INST ) ) );
3581 		m_aReplaceLB.InsertEntry( String( SVX_RES( STR_REPLACE_DOC ) ) );
3582 
3583 
3584 		// init the controls with the values of the submission
3585 		if ( m_pItemNode && m_pItemNode->m_xPropSet.is() )
3586 		{
3587 			m_xSubmission = m_pItemNode->m_xPropSet;
3588 			rtl::OUString sTemp;
3589 			try
3590 			{
3591 				m_xSubmission->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp;
3592 				m_aNameED.SetText( sTemp );
3593 				m_xSubmission->getPropertyValue( PN_SUBMISSION_ACTION ) >>= sTemp;
3594 				m_aActionED.SetText( sTemp );
3595 				m_xSubmission->getPropertyValue( PN_SUBMISSION_REF ) >>= sTemp;
3596 				m_aRefED.SetText( sTemp );
3597 
3598 				m_xSubmission->getPropertyValue( PN_SUBMISSION_METHOD ) >>= sTemp;
3599                 sTemp = lcl_MethodString::get().toUI( sTemp );
3600 				sal_uInt16 nPos = m_aMethodLB.GetEntryPos( String( sTemp ) );
3601 				if ( LISTBOX_ENTRY_NOTFOUND == nPos )
3602 					nPos = m_aMethodLB.InsertEntry( sTemp );
3603 				m_aMethodLB.SelectEntryPos( nPos );
3604 
3605 				m_xSubmission->getPropertyValue( PN_SUBMISSION_BIND ) >>= sTemp;
3606 				nPos = m_aBindLB.GetEntryPos( String( sTemp ) );
3607 				if ( LISTBOX_ENTRY_NOTFOUND == nPos )
3608 					nPos = m_aBindLB.InsertEntry( sTemp );
3609 				m_aBindLB.SelectEntryPos( nPos );
3610 
3611 				m_xSubmission->getPropertyValue( PN_SUBMISSION_REPLACE ) >>= sTemp;
3612                 sTemp = lcl_ReplaceString::get().toUI( sTemp );
3613 				if ( sTemp.getLength() == 0 )
3614 					sTemp = m_aReplaceLB.GetEntry(0); // first entry == "none"
3615 				nPos = m_aReplaceLB.GetEntryPos( String( sTemp ) );
3616 				if ( LISTBOX_ENTRY_NOTFOUND == nPos )
3617 					nPos = m_aReplaceLB.InsertEntry( sTemp );
3618 				m_aReplaceLB.SelectEntryPos( nPos );
3619 			}
3620 			catch ( Exception& )
3621 			{
3622 				DBG_ERRORFILE( "AddSubmissionDialog::FillAllBoxes(): exception caught" );
3623 			}
3624 		}
3625 
3626         m_aRefBtn.Enable( m_xTempBinding.is() );
3627 	}
3628 
3629 	//========================================================================
3630 	// class AddModelDialog
3631 	//========================================================================
3632 
3633     AddModelDialog::AddModelDialog( Window* pParent, bool _bEdit ) :
3634 
3635 		ModalDialog( pParent, SVX_RES( RID_SVXDLG_ADD_MODEL ) ),
3636 
3637 		m_aModelFL		( this, SVX_RES( FL_MODEL ) ),
3638 		m_aNameFT		( this, SVX_RES( FT_MODEL_NAME ) ),
3639 		m_aNameED		( this, SVX_RES( ED_MODEL_NAME ) ),
3640         m_aModifyCB     ( this, SVX_RES( CB_MODIFIES_DOCUMENT ) ),
3641 		m_aButtonsFL	( this, SVX_RES( FL_DATANAV_BTN ) ),
3642 		m_aOKBtn		( this, SVX_RES( BTN_DATANAV_OK ) ),
3643 		m_aEscBtn		( this, SVX_RES( BTN_DATANAV_ESC ) ),
3644 		m_aHelpBtn		( this, SVX_RES( BTN_DATANAV_HELP ) )
3645 
3646 	{
3647         if ( _bEdit )
3648             SetText( String( SVX_RES( STR_EDIT_TEXT ) ) );
3649 
3650         FreeResource();
3651 	}
3652 
3653 	AddModelDialog::~AddModelDialog()
3654 	{
3655 	}
3656 
3657 	//========================================================================
3658 	// class AddInstanceDialog
3659 	//========================================================================
3660 
3661     AddInstanceDialog::AddInstanceDialog( Window* pParent, bool _bEdit ) :
3662 
3663 		ModalDialog( pParent, SVX_RES( RID_SVXDLG_ADD_INSTANCE ) ),
3664 
3665 		m_aInstanceFL		( this, SVX_RES( FL_INSTANCE ) ),
3666 		m_aNameFT			( this, SVX_RES( FT_INST_NAME ) ),
3667 		m_aNameED			( this, SVX_RES( ED_INST_NAME ) ),
3668 		m_aURLFT			( this, SVX_RES( FT_INST_URL ) ),
3669 		m_aURLED			( this, SVX_RES( ED_INST_URL ) ),
3670 		m_aFilePickerBtn	( this, SVX_RES( PB_FILEPICKER ) ),
3671 		m_aLinkInstanceCB	( this, SVX_RES( CB_INST_LINKINST ) ),
3672 		m_aButtonsFL		( this, SVX_RES( FL_DATANAV_BTN ) ),
3673 		m_aOKBtn			( this, SVX_RES( BTN_DATANAV_OK ) ),
3674 		m_aEscBtn			( this, SVX_RES( BTN_DATANAV_ESC ) ),
3675 		m_aHelpBtn			( this, SVX_RES( BTN_DATANAV_HELP ) )
3676 
3677 	{
3678         if ( _bEdit )
3679             SetText( String( SVX_RES( STR_EDIT_TEXT ) ) );
3680 
3681         FreeResource();
3682 
3683 		m_aURLED.DisableHistory();
3684 		m_aFilePickerBtn.SetClickHdl( LINK( this, AddInstanceDialog, FilePickerHdl ) );
3685 
3686 		// load the filter name from fps_office resource
3687 		m_sAllFilterName = String( ResId( STR_FILTERNAME_ALL, *CREATEVERSIONRESMGR(fps_office) ) );
3688 	}
3689 
3690 	AddInstanceDialog::~AddInstanceDialog()
3691 	{
3692 	}
3693 
3694 	//------------------------------------------------------------------------
3695 	IMPL_LINK( AddInstanceDialog, FilePickerHdl, PushButton *, EMPTYARG )
3696 	{
3697     	::sfx2::FileDialogHelper aDlg(
3698             css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
3699 		INetURLObject aFile( SvtPathOptions().GetWorkPath() );
3700 
3701 		aDlg.AddFilter( m_sAllFilterName, DEFINE_CONST_UNICODE(FILEDIALOG_FILTER_ALL) );
3702 		String sFilterName( DEFINE_CONST_UNICODE("XML") );
3703 		aDlg.AddFilter( sFilterName, DEFINE_CONST_UNICODE("*.xml") );
3704 		aDlg.SetCurrentFilter( sFilterName );
3705 		aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
3706 
3707 		if( aDlg.Execute() == ERRCODE_NONE )
3708 			m_aURLED.SetText( aDlg.GetPath() );
3709 
3710 		return 0;
3711 	}
3712 
3713     //========================================================================
3714     // class LinkedInstanceWarningBox
3715     //========================================================================
3716 
3717     LinkedInstanceWarningBox::LinkedInstanceWarningBox( Window* pParent ) :
3718 
3719         MessBox( pParent, SVX_RES( RID_QRY_LINK_WARNING ) )
3720 
3721     {
3722         SetText( Application::GetDisplayName() );
3723         SetImage( QueryBox::GetStandardImage() );
3724         AddButton( SVX_RESSTR( RID_STR_DATANAV_LINKWARN_BUTTON ), BUTTONID_OK, BUTTONDIALOG_DEFBUTTON );
3725         AddButton( BUTTON_CANCEL, BUTTONID_CANCEL, BUTTONDIALOG_CANCELBUTTON );
3726     }
3727 
3728 //............................................................................
3729 }	// namespace svxform
3730 //............................................................................
3731 
3732 
3733