1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datanavi.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include "datanavi.hxx"
35 #include "fmservs.hxx"
37 #include "datanavi.hrc"
38 #include "fmresids.hrc"
40 #include <svx/svxids.hrc>
41 #include <tools/rcid.h>
42 #include <tools/diagnose_ex.h>
43 #include "xmlexchg.hxx"
44 #include <svx/dialmgr.hxx>
45 #include <svx/fmshell.hxx>
46 #include <svtools/miscopt.hxx>
47 #include <svtools/pathoptions.hxx>
48 #include <svtools/viewoptions.hxx>
49 #include <svtools/svtools.hrc>
50 #include <sfx2/app.hxx>
51 #include <sfx2/filedlghelper.hxx>
52 #include <sfx2/objitem.hxx>
53 #include <sfx2/viewfrm.hxx>
54 #include <sfx2/objsh.hxx>
55 #include <sfx2/bindings.hxx>
56 #include <sfx2/dispatch.hxx>
57 #include <com/sun/star/beans/PropertyAttribute.hpp>
58 #include <com/sun/star/container/XSet.hpp>
59 #include <com/sun/star/datatransfer/XTransferable.hpp>
60 #include <com/sun/star/frame/XController.hpp>
61 #include <com/sun/star/frame/XFramesSupplier.hpp>
62 #include <com/sun/star/frame/XModel.hpp>
63 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
64 #include <com/sun/star/xforms/XFormsSupplier.hpp>
65 #include <com/sun/star/xml/dom/XDocument.hpp>
66 #include <com/sun/star/xml/dom/DOMException.hpp>
67 #include <com/sun/star/form/binding/XValueBinding.hpp>
68 #include <comphelper/processfactory.hxx>
69 #include <rtl/logfile.hxx>
71 using namespace ::com::sun::star::beans
;
72 using namespace ::com::sun::star::container
;
73 using namespace ::com::sun::star::datatransfer
;
74 using namespace ::com::sun::star::frame
;
75 using namespace ::com::sun::star::uno
;
76 using namespace ::com::sun::star::xml::dom::events
;
77 using namespace ::svx
;
79 namespace css
= ::com::sun::star
;
81 #define CFGNAME_DATANAVIGATOR DEFINE_CONST_UNICODE("DataNavigator")
82 #define CFGNAME_SHOWDETAILS DEFINE_CONST_UNICODE("ShowDetails")
83 #define MSG_VARIABLE DEFINE_CONST_UNICODE("%1")
84 #define MODELNAME DEFINE_CONST_UNICODE("$MODELNAME")
85 #define INSTANCENAME DEFINE_CONST_UNICODE("$INSTANCENAME")
86 #define ELEMENTNAME DEFINE_CONST_UNICODE("$ELEMENTNAME")
87 #define ATTRIBUTENAME DEFINE_CONST_UNICODE("$ATTRIBUTENAME")
88 #define SUBMISSIONNAME DEFINE_CONST_UNICODE("$SUBMISSIONNAME")
89 #define BINDINGNAME DEFINE_CONST_UNICODE("$BINDINGNAME")
91 //............................................................................
94 //............................................................................
96 // properties of instance
97 #define PN_INSTANCE_MODEL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Instance" ) )
98 #define PN_INSTANCE_ID ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) )
99 #define PN_INSTANCE_URL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) )
100 #define PN_INSTANCE_URLONCE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URLOnce" ) )
102 // properties of binding
103 #define PN_BINDING_ID ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BindingID" ) )
104 #define PN_BINDING_EXPR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BindingExpression" ) )
105 #define PN_BINDING_MODEL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) )
106 #define PN_BINDING_NAMESPACES ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModelNamespaces" ) )
107 #define PN_BINDING_MODELID ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModelID" ) )
108 #define PN_READONLY_EXPR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ReadonlyExpression" ) )
109 #define PN_RELEVANT_EXPR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RelevantExpression" ) )
110 #define PN_REQUIRED_EXPR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RequiredExpression" ) )
111 #define PN_CONSTRAINT_EXPR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConstraintExpression" ) )
112 #define PN_CALCULATE_EXPR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CalculateExpression" ) )
113 #define PN_BINDING_TYPE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ) )
114 #define PN_BINDING_READONLY ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ReadOnly" ) )
115 #define PN_BINDING_ENABLED ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) )
117 // properties of submission
118 #define PN_SUBMISSION_ID ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) )
119 #define PN_SUBMISSION_BIND ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bind" ) )
120 #define PN_SUBMISSION_REF ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Ref" ) )
121 #define PN_SUBMISSION_ACTION ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Action" ) )
122 #define PN_SUBMISSION_METHOD ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Method" ) )
123 #define PN_SUBMISSION_MODEL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) )
124 #define PN_SUBMISSION_REPLACE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Replace" ) )
126 // submission methods
127 #define SUBMITMETHOD_POST ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "post" ) )
128 #define SUBMITMETHOD_GET ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "get" ) )
129 #define SUBMITMETHOD_PUT ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "put" ) )
131 // other const strings
132 #define TRUE_VALUE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true()" ) )
133 #define FALSE_VALUE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false()" ) )
134 #define NEW_ELEMENT ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "newElement" ) )
135 #define NEW_ATTRIBUTE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "newAttribute" ) )
136 #define EVENTTYPE_SUBTREE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DOMSubtreeModified" ) )
137 #define EVENTTYPE_CHARDATA ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DOMCharacterDataModified" ) )
138 #define EVENTTYPE_ATTR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DOMAttrModified" ) )
140 #define MIN_PAGE_COUNT 3 // at least one instance, one submission and one binding page
144 Reference
< css::xml::dom::XNode
> m_xNode
;
145 Reference
< XPropertySet
> m_xPropSet
;
147 ItemNode( const Reference
< css::xml::dom::XNode
>& _rxNode
) :
148 m_xNode( _rxNode
) {}
149 ItemNode( const Reference
< XPropertySet
>& _rxSet
) :
150 m_xPropSet( _rxSet
) {}
152 DataGroupType
GetDataGroupType() const;
155 //========================================================================
156 // class DataTreeListBox
157 //========================================================================
158 DataTreeListBox::DataTreeListBox( XFormsPage
* pPage
, DataGroupType _eGroup
, const ResId
& rResId
) :
160 SvTreeListBox( pPage
, rResId
),
162 m_pXFormsPage ( pPage
),
166 EnableContextMenuHandling();
168 if ( DGTInstance
== m_eGroup
)
169 SetDragDropMode( SV_DRAGDROP_CTRL_MOVE
|SV_DRAGDROP_CTRL_COPY
| SV_DRAGDROP_APP_COPY
);
172 DataTreeListBox::~DataTreeListBox()
177 sal_Int8
DataTreeListBox::AcceptDrop( const AcceptDropEvent
& /*rEvt*/ )
179 return DND_ACTION_NONE
;
181 sal_Int8
DataTreeListBox::ExecuteDrop( const ExecuteDropEvent
& /*rEvt*/ )
183 return DND_ACTION_NONE
;
185 void DataTreeListBox::StartDrag( sal_Int8
/*_nAction*/, const Point
& /*_rPosPixel*/ )
187 SvLBoxEntry
* pSelected
= FirstSelected();
189 // no drag without an entry
192 if ( m_eGroup
== DGTBinding
)
193 // for the moment, bindings cannot be dragged.
194 // #i59395# / 2005-12-15 / frank.schoenheit@sun.com
197 // GetServiceNameForNode() requires a datatype repository which
198 // will be automatically build if requested???
199 Reference
< css::xforms::XModel
> xModel( m_pXFormsPage
->GetXFormsHelper(), UNO_QUERY
);
200 Reference
< css::xforms::XDataTypeRepository
> xDataTypes
=
201 xModel
->getDataTypeRepository();
205 using namespace ::com::sun::star::uno
;
206 typedef com::sun::star::form::binding::XValueBinding XValueBinding_t
;
208 ItemNode
*pItemNode
= static_cast<ItemNode
*>(pSelected
->GetUserData());
212 // the only known (and allowed?) case where this happens are sub-entries of a submission
214 DBG_ASSERT( DGTSubmission
== m_eGroup
, "DataTreeListBox::StartDrag: how this?" );
215 pSelected
= GetParent( pSelected
);
216 DBG_ASSERT( pSelected
&& !GetParent( pSelected
), "DataTreeListBox::StartDrag: what kind of entry *is* this?" );
217 // on the submission page, we have only top-level entries (the submission themself)
218 // plus direct children of those (facets of a submission)
219 pItemNode
= pSelected
? static_cast< ItemNode
* >( pSelected
->GetUserData() ) : NULL
;
224 OXFormsDescriptor desc
;
225 desc
.szName
= GetEntryText(pSelected
);
226 if(pItemNode
->m_xNode
.is()) {
227 // a valid node interface tells us that we need to create a control from a binding
228 desc
.szServiceName
= m_pXFormsPage
->GetServiceNameForNode(pItemNode
->m_xNode
);
229 desc
.xPropSet
= m_pXFormsPage
->GetBindingForNode(pItemNode
->m_xNode
);
230 DBG_ASSERT( desc
.xPropSet
.is(), "DataTreeListBox::StartDrag(): invalid node binding" );
233 desc
.szServiceName
= FM_COMPONENT_COMMANDBUTTON
;
234 desc
.xPropSet
= pItemNode
->m_xPropSet
;
236 OXFormsTransferable
*pTransferable
= new OXFormsTransferable(desc
);
237 Reference
< XTransferable
> xEnsureDelete
= pTransferable
;
240 pTransferable
->StartDrag( this, DND_ACTION_COPY
);
244 PopupMenu
* DataTreeListBox::CreateContextMenu()
246 PopupMenu
* pMenu
= new PopupMenu( SVX_RES( RID_MENU_DATANAVIGATOR
) );
247 if ( DGTInstance
== m_eGroup
)
248 pMenu
->RemoveItem( pMenu
->GetItemPos( TBI_ITEM_ADD
) );
251 pMenu
->RemoveItem( pMenu
->GetItemPos( TBI_ITEM_ADD_ELEMENT
) );
252 pMenu
->RemoveItem( pMenu
->GetItemPos( TBI_ITEM_ADD_ATTRIBUTE
) );
254 if ( DGTSubmission
== m_eGroup
)
256 pMenu
->SetItemText( TBI_ITEM_ADD
, SVX_RESSTR( RID_STR_DATANAV_ADD_SUBMISSION
) );
257 pMenu
->SetItemText( TBI_ITEM_EDIT
, SVX_RESSTR( RID_STR_DATANAV_EDIT_SUBMISSION
) );
258 pMenu
->SetItemText( TBI_ITEM_REMOVE
, SVX_RESSTR( RID_STR_DATANAV_REMOVE_SUBMISSION
) );
262 pMenu
->SetItemText( TBI_ITEM_ADD
, SVX_RESSTR( RID_STR_DATANAV_ADD_BINDING
) );
263 pMenu
->SetItemText( TBI_ITEM_EDIT
, SVX_RESSTR( RID_STR_DATANAV_EDIT_BINDING
) );
264 pMenu
->SetItemText( TBI_ITEM_REMOVE
, SVX_RESSTR( RID_STR_DATANAV_REMOVE_BINDING
) );
267 m_pXFormsPage
->EnableMenuItems( pMenu
);
271 void DataTreeListBox::ExcecuteContextMenuAction( USHORT _nSelectedPopupEntry
)
273 m_pXFormsPage
->DoMenuAction( _nSelectedPopupEntry
);
276 void DataTreeListBox::RemoveEntry( SvLBoxEntry
* _pEntry
)
280 delete static_cast< ItemNode
* >( _pEntry
->GetUserData() );
281 SvTreeListBox::GetModel()->Remove( _pEntry
);
285 void DataTreeListBox::DeleteAndClear()
287 ULONG i
, nCount
= GetEntryCount();
288 for ( i
= 0; i
< nCount
; ++i
)
290 SvLBoxEntry
* pEntry
= GetEntry(i
);
292 delete static_cast< ItemNode
* >( pEntry
->GetUserData() );
298 //========================================================================
300 //========================================================================
301 XFormsPage::XFormsPage( Window
* pParent
, DataNavigatorWindow
* _pNaviWin
, DataGroupType _eGroup
) :
303 TabPage( pParent
, SVX_RES( RID_SVX_XFORMS_TABPAGES
) ),
305 m_aToolBox ( this, SVX_RES( TB_ITEMS
) ),
306 m_aItemList ( this, _eGroup
, SVX_RES( LB_ITEMS
) ),
307 m_pNaviWin ( _pNaviWin
),
308 m_bHasModel ( false ),
309 m_eGroup ( _eGroup
),
310 m_TbxImageList ( SVX_RES( IL_TBX_BMPS
) ),
311 m_TbxHCImageList( SVX_RES( IL_TBX_BMPS_HC
) )
316 const ImageList
& rImageList
=
317 GetBackground().GetColor().IsDark() ? m_TbxHCImageList
: m_TbxImageList
;
318 m_aToolBox
.SetItemImage( TBI_ITEM_ADD
, rImageList
.GetImage( IID_ITEM_ADD
) );
319 m_aToolBox
.SetItemImage( TBI_ITEM_ADD_ELEMENT
, rImageList
.GetImage( IID_ITEM_ADD_ELEMENT
) );
320 m_aToolBox
.SetItemImage( TBI_ITEM_ADD_ATTRIBUTE
, rImageList
.GetImage( IID_ITEM_ADD_ATTRIBUTE
) );
321 m_aToolBox
.SetItemImage( TBI_ITEM_EDIT
, rImageList
.GetImage( IID_ITEM_EDIT
) );
322 m_aToolBox
.SetItemImage( TBI_ITEM_REMOVE
, rImageList
.GetImage( IID_ITEM_REMOVE
) );
324 if ( DGTInstance
== m_eGroup
)
325 m_aToolBox
.RemoveItem( m_aToolBox
.GetItemPos( TBI_ITEM_ADD
) );
328 m_aToolBox
.RemoveItem( m_aToolBox
.GetItemPos( TBI_ITEM_ADD_ELEMENT
) );
329 m_aToolBox
.RemoveItem( m_aToolBox
.GetItemPos( TBI_ITEM_ADD_ATTRIBUTE
) );
331 if ( DGTSubmission
== m_eGroup
)
333 m_aToolBox
.SetItemText( TBI_ITEM_ADD
, SVX_RESSTR( RID_STR_DATANAV_ADD_SUBMISSION
) );
334 m_aToolBox
.SetItemText( TBI_ITEM_EDIT
, SVX_RESSTR( RID_STR_DATANAV_EDIT_SUBMISSION
) );
335 m_aToolBox
.SetItemText( TBI_ITEM_REMOVE
, SVX_RESSTR( RID_STR_DATANAV_REMOVE_SUBMISSION
) );
339 m_aToolBox
.SetItemText( TBI_ITEM_ADD
, SVX_RESSTR( RID_STR_DATANAV_ADD_BINDING
) );
340 m_aToolBox
.SetItemText( TBI_ITEM_EDIT
, SVX_RESSTR( RID_STR_DATANAV_EDIT_BINDING
) );
341 m_aToolBox
.SetItemText( TBI_ITEM_REMOVE
, SVX_RESSTR( RID_STR_DATANAV_REMOVE_BINDING
) );
345 const Size
aTbxSz( m_aToolBox
.CalcWindowSizePixel() );
346 m_aToolBox
.SetSizePixel( aTbxSz
);
347 m_aToolBox
.SetOutStyle( SvtMiscOptions().GetToolboxStyle() );
348 m_aToolBox
.SetSelectHdl( LINK( this, XFormsPage
, TbxSelectHdl
) );
349 Point aPos
= m_aItemList
.GetPosPixel();
350 aPos
.Y() = aTbxSz
.Height();
351 m_aItemList
.SetPosPixel( aPos
);
353 m_aItemList
.SetSelectHdl( LINK( this, XFormsPage
, ItemSelectHdl
) );
354 m_aItemList
.SetNodeDefaultImages();
355 WinBits nBits
= WB_BORDER
| WB_TABSTOP
| WB_HIDESELECTION
| WB_NOINITIALSELECTION
;
356 if ( DGTInstance
== m_eGroup
|| DGTSubmission
== m_eGroup
)
357 nBits
|= WB_HASBUTTONS
| WB_HASLINES
| WB_HASLINESATROOT
| WB_HASBUTTONSATROOT
;
358 m_aItemList
.SetWindowBits( m_aItemList
.GetStyle() | nBits
);
360 ItemSelectHdl( &m_aItemList
);
362 //------------------------------------------------------------------------
363 XFormsPage::~XFormsPage()
366 //------------------------------------------------------------------------
367 IMPL_LINK( XFormsPage
, TbxSelectHdl
, ToolBox
*, EMPTYARG
)
369 DoToolBoxAction( m_aToolBox
.GetCurItemId() );
372 //------------------------------------------------------------------------
373 IMPL_LINK( XFormsPage
, ItemSelectHdl
, DataTreeListBox
*, EMPTYARG
)
375 EnableMenuItems( NULL
);
378 //------------------------------------------------------------------------
379 void XFormsPage::AddChildren(
380 SvLBoxEntry
* _pParent
, const ImageList
& _rImgLst
,
381 const Reference
< css::xml::dom::XNode
>& _xNode
)
383 DBG_ASSERT( m_xUIHelper
.is(), "XFormsPage::AddChildren(): invalid UIHelper" );
387 Reference
< css::xml::dom::XNodeList
> xNodeList
= _xNode
->getChildNodes();
388 if ( xNodeList
.is() )
390 bool bShowDetails
= m_pNaviWin
->IsShowDetails();
391 sal_Int32 i
, nNodeCount
= xNodeList
->getLength();
392 for ( i
= 0; i
< nNodeCount
; ++i
)
394 Reference
< css::xml::dom::XNode
> xChild
= xNodeList
->item(i
);
395 css::xml::dom::NodeType eChildType
= xChild
->getNodeType();
396 Image aExpImg
, aCollImg
;
397 switch ( eChildType
)
399 case css::xml::dom::NodeType_ATTRIBUTE_NODE
:
400 aExpImg
= aCollImg
= _rImgLst
.GetImage( IID_ATTRIBUTE
);
402 case css::xml::dom::NodeType_ELEMENT_NODE
:
403 aExpImg
= aCollImg
= _rImgLst
.GetImage( IID_ELEMENT
);
405 case css::xml::dom::NodeType_TEXT_NODE
:
406 aExpImg
= aCollImg
= _rImgLst
.GetImage( IID_TEXT
);
409 aExpImg
= aCollImg
= _rImgLst
.GetImage( IID_OTHER
);
412 ::rtl::OUString sName
= m_xUIHelper
->getNodeDisplayName( xChild
, bShowDetails
);
413 if ( sName
.getLength() > 0 )
415 ItemNode
* pNode
= new ItemNode( xChild
);
416 SvLBoxEntry
* pEntry
= m_aItemList
.InsertEntry(
417 sName
, aExpImg
, aCollImg
, _pParent
, FALSE
, LIST_APPEND
, pNode
);
418 if ( xChild
->hasAttributes() )
420 Reference
< css::xml::dom::XNamedNodeMap
> xMap
= xChild
->getAttributes();
423 aExpImg
= aCollImg
= _rImgLst
.GetImage( IID_ATTRIBUTE
);
424 sal_Int32 j
, nMapLen
= xMap
->getLength();
425 for ( j
= 0; j
< nMapLen
; ++j
)
427 Reference
< css::xml::dom::XNode
> xAttr
= xMap
->item(j
);
428 pNode
= new ItemNode( xAttr
);
429 ::rtl::OUString sAttrName
=
430 m_xUIHelper
->getNodeDisplayName( xAttr
, bShowDetails
);
431 m_aItemList
.InsertEntry(
432 sAttrName
, aExpImg
, aCollImg
,
433 pEntry
, FALSE
, LIST_APPEND
, pNode
);
437 if ( xChild
->hasChildNodes() )
438 AddChildren( pEntry
, _rImgLst
, xChild
);
445 DBG_UNHANDLED_EXCEPTION();
448 //------------------------------------------------------------------------
449 bool XFormsPage::DoToolBoxAction( USHORT _nToolBoxID
) {
451 bool bHandled
= false;
452 bool bIsDocModified
= false;
453 m_pNaviWin
->DisableNotify( true );
455 switch ( _nToolBoxID
)
458 case TBI_ITEM_ADD_ELEMENT
:
459 case TBI_ITEM_ADD_ATTRIBUTE
:
462 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
463 DBG_ASSERT( xModel
.is(), "XFormsPage::DoToolBoxAction(): Action without model" );
464 if ( DGTSubmission
== m_eGroup
)
466 AddSubmissionDialog
aDlg( this, NULL
, m_xUIHelper
);
467 if ( aDlg
.Execute() == RET_OK
&& aDlg
.GetNewSubmission().is() )
471 Reference
< css::xforms::XSubmission
> xNewSubmission
= aDlg
.GetNewSubmission();
472 Reference
< XSet
> xSubmissions( xModel
->getSubmissions(), UNO_QUERY
);
473 xSubmissions
->insert( makeAny( xNewSubmission
) );
474 Reference
< XPropertySet
> xNewPropSet( xNewSubmission
, UNO_QUERY
);
475 SvLBoxEntry
* pEntry
= AddEntry( xNewPropSet
);
476 m_aItemList
.Select( pEntry
, TRUE
);
477 bIsDocModified
= true;
481 DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while adding submission" );
487 DataItemType eType
= DITElement
;
488 SvLBoxEntry
* pEntry
= m_aItemList
.FirstSelected();
489 ItemNode
* pNode
= NULL
;
490 Reference
< css::xml::dom::XNode
> xParentNode
;
491 Reference
< XPropertySet
> xNewBinding
;
493 bool bIsElement
= true;
494 if ( DGTInstance
== m_eGroup
)
496 if ( m_sInstanceURL
.Len() > 0 )
498 LinkedInstanceWarningBox
aMsgBox( this );
499 if ( aMsgBox
.Execute() != RET_OK
)
503 DBG_ASSERT( pEntry
, "XFormsPage::DoToolBoxAction(): no entry" );
504 ItemNode
* pParentNode
= static_cast< ItemNode
* >( pEntry
->GetUserData() );
505 DBG_ASSERT( pParentNode
, "XFormsPage::DoToolBoxAction(): no parent node" );
506 xParentNode
= pParentNode
->m_xNode
;
507 Reference
< css::xml::dom::XNode
> xNewNode
;
508 if ( TBI_ITEM_ADD_ELEMENT
== _nToolBoxID
)
512 nResId
= RID_STR_DATANAV_ADD_ELEMENT
;
513 xNewNode
= m_xUIHelper
->createElement( xParentNode
, NEW_ELEMENT
);
517 DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while create element" );
522 nResId
= RID_STR_DATANAV_ADD_ATTRIBUTE
;
524 eType
= DITAttribute
;
527 xNewNode
= m_xUIHelper
->createAttribute( xParentNode
, NEW_ATTRIBUTE
);
531 DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while create attribute" );
537 xNewNode
= xParentNode
->appendChild( xNewNode
);
539 catch ( css::xml::dom::DOMException
& e
)
541 if ( e
.Code
== css::xml::dom::DOMExceptionType_DOMSTRING_SIZE_ERR
)
543 DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): domexception: size error" );
545 DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): domexception while append child" );
549 DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while append child" );
554 Reference
< css::xml::dom::XNode
> xPNode
;
556 xPNode
= xNewNode
->getParentNode();
557 // attributes don't have parents in the DOM model
558 DBG_ASSERT( TBI_ITEM_ADD_ATTRIBUTE
== _nToolBoxID
559 || xPNode
.is(), "XFormsPage::DoToolboxAction(): node not added" );
563 DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
568 m_xUIHelper
->getBindingForNode( xNewNode
, sal_True
);
572 DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while get binding for node" );
574 pNode
= new ItemNode( xNewNode
);
580 nResId
= RID_STR_DATANAV_ADD_BINDING
;
581 xNewBinding
= xModel
->createBinding();
582 Reference
< XSet
> xBindings( xModel
->getBindings(), UNO_QUERY
);
583 xBindings
->insert( makeAny( xNewBinding
) );
584 pNode
= new ItemNode( xNewBinding
);
589 DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while adding binding" );
593 AddDataItemDialog
aDlg( this, pNode
, m_xUIHelper
);
594 aDlg
.SetText( SVX_RESSTR( nResId
) );
595 aDlg
.InitText( eType
);
596 short nReturn
= aDlg
.Execute();
597 if ( DGTInstance
== m_eGroup
)
599 if ( RET_OK
== nReturn
)
601 SvLBoxEntry
* pNewEntry
= AddEntry( pNode
, bIsElement
);
602 m_aItemList
.MakeVisible( pNewEntry
);
603 m_aItemList
.Select( pNewEntry
, TRUE
);
604 bIsDocModified
= true;
610 Reference
< css::xml::dom::XNode
> xPNode
;
611 Reference
< css::xml::dom::XNode
> xNode
=
612 xParentNode
->removeChild( pNode
->m_xNode
);
614 xPNode
= xNode
->getParentNode();
615 DBG_ASSERT( !xPNode
.is(), "XFormsPage::RemoveEntry(): node not removed" );
620 DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
626 if ( RET_OK
== nReturn
)
628 SvLBoxEntry
* pNewEntry
= AddEntry( xNewBinding
);
629 m_aItemList
.Select( pNewEntry
, TRUE
);
630 bIsDocModified
= true;
636 Reference
< XSet
> xBindings( xModel
->getBindings(), UNO_QUERY
);
637 xBindings
->remove( makeAny( xNewBinding
) );
641 DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
653 SvLBoxEntry
* pEntry
= m_aItemList
.FirstSelected();
656 if ( DGTSubmission
== m_eGroup
&& m_aItemList
.GetParent( pEntry
) )
657 pEntry
= m_aItemList
.GetParent( pEntry
);
658 ItemNode
* pNode
= static_cast< ItemNode
* >( pEntry
->GetUserData() );
659 if ( DGTInstance
== m_eGroup
|| DGTBinding
== m_eGroup
)
661 if ( DGTInstance
== m_eGroup
&& m_sInstanceURL
.Len() > 0 )
663 LinkedInstanceWarningBox
aMsgBox( this );
664 if ( aMsgBox
.Execute() != RET_OK
)
668 AddDataItemDialog
aDlg( this, pNode
, m_xUIHelper
);
669 DataItemType eType
= DITElement
;
670 USHORT nResId
= RID_STR_DATANAV_EDIT_ELEMENT
;
671 if ( pNode
&& pNode
->m_xNode
.is() )
675 css::xml::dom::NodeType eChildType
= pNode
->m_xNode
->getNodeType();
676 if ( eChildType
== css::xml::dom::NodeType_ATTRIBUTE_NODE
)
678 nResId
= RID_STR_DATANAV_EDIT_ATTRIBUTE
;
679 eType
= DITAttribute
;
684 DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
687 else if ( DGTBinding
== m_eGroup
)
689 nResId
= RID_STR_DATANAV_EDIT_BINDING
;
692 aDlg
.SetText( SVX_RESSTR( nResId
) );
693 aDlg
.InitText( eType
);
694 if ( aDlg
.Execute() == RET_OK
)
698 if ( DGTInstance
== m_eGroup
)
702 sNewName
= m_xUIHelper
->getNodeDisplayName(
703 pNode
->m_xNode
, m_pNaviWin
->IsShowDetails() );
707 DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
714 String
sDelim( RTL_CONSTASCII_STRINGPARAM( ": " ) );
715 ::rtl::OUString sTemp
;
716 pNode
->m_xPropSet
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
717 sNewName
+= String( sTemp
);
719 pNode
->m_xPropSet
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
720 sNewName
+= String( sTemp
);
724 DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
728 m_aItemList
.SetEntryText( pEntry
, sNewName
);
729 bIsDocModified
= true;
734 AddSubmissionDialog
aDlg( this, pNode
, m_xUIHelper
);
735 aDlg
.SetText( SVX_RESSTR( RID_STR_DATANAV_EDIT_SUBMISSION
) );
736 if ( aDlg
.Execute() == RET_OK
)
738 EditEntry( pNode
->m_xPropSet
);
739 bIsDocModified
= true;
746 case TBI_ITEM_REMOVE
:
749 if ( DGTInstance
== m_eGroup
&& m_sInstanceURL
.Len() > 0 )
751 LinkedInstanceWarningBox
aMsgBox( this );
752 if ( aMsgBox
.Execute() != RET_OK
)
755 bIsDocModified
= RemoveEntry();
759 case MID_INSERT_CONTROL
:
761 OSL_ENSURE( false, "XFormsPage::DoToolboxAction: MID_INSERT_CONTROL not implemented, yet!" );
766 OSL_ENSURE( false, "XFormsPage::DoToolboxAction: unknown ID!" );
770 m_pNaviWin
->DisableNotify( false );
771 EnableMenuItems( NULL
);
772 if ( bIsDocModified
)
773 m_pNaviWin
->SetDocModified();
777 //------------------------------------------------------------------------
778 SvLBoxEntry
* XFormsPage::AddEntry( ItemNode
* _pNewNode
, bool _bIsElement
)
780 SvLBoxEntry
* pParent
= m_aItemList
.FirstSelected();
781 const ImageList
& rImageList
= GetBackground().GetColor().IsDark()
782 ? m_pNaviWin
->GetItemHCImageList()
783 : m_pNaviWin
->GetItemImageList();
784 USHORT nImageID
= ( _bIsElement
) ? IID_ELEMENT
: IID_ATTRIBUTE
;
785 Image aImage
= rImageList
.GetImage( nImageID
);
786 ::rtl::OUString sName
;
789 sName
= m_xUIHelper
->getNodeDisplayName(
790 _pNewNode
->m_xNode
, m_pNaviWin
->IsShowDetails() );
794 DBG_UNHANDLED_EXCEPTION();
796 return m_aItemList
.InsertEntry(
797 sName
, aImage
, aImage
, pParent
, FALSE
, LIST_APPEND
, _pNewNode
);
799 //------------------------------------------------------------------------
800 class lcl_ResourceString
807 lcl_ResourceString( const lcl_ResourceString
& );
809 virtual ~lcl_ResourceString()
813 // load UI resources from resource file
816 // create a resource manager, for the svx resource file
818 ByteString
aResourceFile( "svx" );
819 ResMgr
* pResMgr
= ResMgr::CreateResMgr(
820 aResourceFile
.GetBuffer(),
821 Application::GetSettings().GetUILocale() );
823 // load the resources for the AddSubmission modal dialog.
824 // This will create our own resource context.
825 ResId
aRes( RID_SVXDLG_ADD_SUBMISSION
, *pResMgr
);
826 aRes
.SetRT( RSC_MODALDIALOG
);
827 pResMgr
->GetResource( aRes
);
829 // now, we can access the local resources from the dialog's
831 _initResources(pResMgr
);
833 // clean up: remove context, and delete the resource manager
834 // ( Increment(..) is needed since PopContext() requires that
835 // the file pointer is at the end. )
836 pResMgr
->Increment( pResMgr
->GetRemainSize() );
837 pResMgr
->PopContext();
841 // load resources... to be overloaded in sub-classes
842 virtual void _initResources( ResMgr
* pMgr
) = 0;
845 class lcl_ReplaceString
: public lcl_ResourceString
847 rtl::OUString m_sDoc_UI
;
848 rtl::OUString m_sInstance_UI
;
849 rtl::OUString m_sNone_UI
;
851 rtl::OUString m_sDoc_API
;
852 rtl::OUString m_sInstance_API
;
853 rtl::OUString m_sNone_API
;
855 lcl_ReplaceString() :
856 lcl_ResourceString(),
857 m_sDoc_API( RTL_CONSTASCII_USTRINGPARAM("all") ),
858 m_sInstance_API( RTL_CONSTASCII_USTRINGPARAM("instance") ),
859 m_sNone_API( RTL_CONSTASCII_USTRINGPARAM("none") )
864 lcl_ReplaceString( const lcl_ReplaceString
& );
866 virtual ~lcl_ReplaceString()
870 // load UI resources from resource file
871 virtual void _initResources( ResMgr
* pMgr
)
873 // now, we can access the local resources from the dialog's
875 m_sDoc_UI
= String( ResId( STR_REPLACE_DOC
, *pMgr
) );
876 m_sInstance_UI
= String( ResId( STR_REPLACE_INST
, *pMgr
) );
877 m_sNone_UI
= String( ResId( STR_REPLACE_NONE
, *pMgr
) );
882 /** create and obtain the singleton instance */
883 static const lcl_ReplaceString
& get()
885 // keep the singleton instance here
886 static lcl_ReplaceString
* m_pInstance
= NULL
;
888 if( m_pInstance
== NULL
)
889 m_pInstance
= new lcl_ReplaceString();
893 /** convert submission replace string from API value to UI value.
894 Use 'none' as default. */
895 rtl::OUString
toUI( const rtl::OUString
& rStr
) const
897 if( rStr
== m_sDoc_API
)
899 else if( rStr
== m_sInstance_API
)
900 return m_sInstance_UI
;
905 /** convert submission replace string from UI to API.
906 Use 'none' as default. */
907 rtl::OUString
toAPI( const rtl::OUString
& rStr
) const
909 if( rStr
== m_sDoc_UI
)
911 else if( rStr
== m_sInstance_UI
)
912 return m_sInstance_API
;
918 class lcl_MethodString
: public lcl_ResourceString
920 rtl::OUString m_sPost_UI
;
921 rtl::OUString m_sPut_UI
;
922 rtl::OUString m_sGet_UI
;
924 rtl::OUString m_sPost_API
;
925 rtl::OUString m_sPut_API
;
926 rtl::OUString m_sGet_API
;
929 lcl_ResourceString(),
930 m_sPost_API( RTL_CONSTASCII_USTRINGPARAM("post") ),
931 m_sPut_API( RTL_CONSTASCII_USTRINGPARAM("put") ),
932 m_sGet_API( RTL_CONSTASCII_USTRINGPARAM("get") )
937 lcl_MethodString( const lcl_MethodString
& );
939 virtual ~lcl_MethodString()
943 // load UI resources from resource file
944 virtual void _initResources(ResMgr
* pMgr
)
946 m_sPost_UI
= String( ResId( STR_METHOD_POST
, *pMgr
) );
947 m_sPut_UI
= String( ResId( STR_METHOD_PUT
, *pMgr
) );
948 m_sGet_UI
= String( ResId( STR_METHOD_GET
, *pMgr
) );
953 /** create and obtain the singleton instance */
954 static const lcl_MethodString
& get()
956 // keep the singleton instance here
957 static lcl_MethodString
* m_pInstance
= NULL
;
959 if( m_pInstance
== NULL
)
960 m_pInstance
= new lcl_MethodString();
964 /** convert from API to UI; put is default. */
965 rtl::OUString
toUI( const rtl::OUString
& rStr
) const
967 if( rStr
== m_sGet_API
)
969 else if( rStr
== m_sPost_API
)
975 /** convert from UI to API; put is default */
976 rtl::OUString
toAPI( const rtl::OUString
& rStr
) const
978 if( rStr
== m_sGet_UI
)
980 else if( rStr
== m_sPost_UI
)
987 //------------------------------------------------------------------------
988 SvLBoxEntry
* XFormsPage::AddEntry( const Reference
< XPropertySet
>& _rEntry
)
990 SvLBoxEntry
* pEntry
= NULL
;
991 const ImageList
& rImageList
= GetBackground().GetColor().IsDark()
992 ? m_pNaviWin
->GetItemHCImageList()
993 : m_pNaviWin
->GetItemImageList();
994 Image aImage
= rImageList
.GetImage( IID_ELEMENT
);
996 ItemNode
* pNode
= new ItemNode( _rEntry
);
999 if ( DGTSubmission
== m_eGroup
)
1004 _rEntry
->getPropertyValue( PN_SUBMISSION_ID
) >>= sTemp
;
1005 pEntry
= m_aItemList
.InsertEntry( sTemp
, aImage
, aImage
, NULL
, FALSE
, LIST_APPEND
, pNode
);
1007 _rEntry
->getPropertyValue( PN_SUBMISSION_ACTION
) >>= sTemp
;
1008 String sEntry
= SVX_RESSTR( RID_STR_DATANAV_SUBM_ACTION
);
1009 sEntry
+= String( sTemp
);
1010 m_aItemList
.InsertEntry( sEntry
, aImage
, aImage
, pEntry
);
1012 _rEntry
->getPropertyValue( PN_SUBMISSION_METHOD
) >>= sTemp
;
1013 sEntry
= SVX_RESSTR( RID_STR_DATANAV_SUBM_METHOD
);
1014 sEntry
+= String( lcl_MethodString::get().toUI( sTemp
) );
1015 m_aItemList
.InsertEntry( sEntry
, aImage
, aImage
, pEntry
);
1017 _rEntry
->getPropertyValue( PN_SUBMISSION_REF
) >>= sTemp
;
1018 sEntry
= SVX_RESSTR( RID_STR_DATANAV_SUBM_REF
);
1019 sEntry
+= String( sTemp
);
1020 m_aItemList
.InsertEntry( sEntry
, aImage
, aImage
, pEntry
);
1022 _rEntry
->getPropertyValue( PN_SUBMISSION_BIND
) >>= sTemp
;
1023 sEntry
= SVX_RESSTR( RID_STR_DATANAV_SUBM_BIND
);
1024 sEntry
+= String( sTemp
);
1025 m_aItemList
.InsertEntry( sEntry
, aImage
, aImage
, pEntry
);
1027 _rEntry
->getPropertyValue( PN_SUBMISSION_REPLACE
) >>= sTemp
;
1028 sEntry
= SVX_RESSTR( RID_STR_DATANAV_SUBM_REPLACE
);
1029 sEntry
+= String( lcl_ReplaceString::get().toUI( sTemp
) );
1030 m_aItemList
.InsertEntry( sEntry
, aImage
, aImage
, pEntry
);
1032 catch ( Exception
& )
1034 DBG_ERRORFILE( "XFormsPage::AddEntry(Ref): exception caught" );
1037 else // then Binding Page
1041 String
sDelim( RTL_CONSTASCII_STRINGPARAM( ": " ) );
1042 ::rtl::OUString sName
;
1043 _rEntry
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
1044 sName
+= String( sTemp
);
1046 _rEntry
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
1047 sName
+= String( sTemp
);
1048 pEntry
= m_aItemList
.InsertEntry(
1049 sName
, aImage
, aImage
, NULL
, FALSE
, LIST_APPEND
, pNode
);
1051 catch ( Exception
& )
1053 DBG_ERRORFILE( "XFormsPage::AddEntry(Ref): exception caught" );
1060 //------------------------------------------------------------------------
1061 void XFormsPage::EditEntry( const Reference
< XPropertySet
>& _rEntry
)
1063 SvLBoxEntry
* pEntry
= NULL
;
1064 rtl::OUString sTemp
;
1066 if ( DGTSubmission
== m_eGroup
)
1070 pEntry
= m_aItemList
.FirstSelected();
1072 // #i36262# may be called for submission entry *or* for
1073 // submission children. If we don't have any children, we
1074 // assume the latter case and use the parent
1075 if( m_aItemList
.GetEntry( pEntry
, 0 ) == NULL
)
1077 pEntry
= m_aItemList
.GetModel()->GetParent( pEntry
);
1080 _rEntry
->getPropertyValue( PN_SUBMISSION_ID
) >>= sTemp
;
1081 m_aItemList
.SetEntryText( pEntry
, sTemp
);
1083 _rEntry
->getPropertyValue( PN_SUBMISSION_BIND
) >>= sTemp
;
1084 String sEntry
= SVX_RESSTR( RID_STR_DATANAV_SUBM_BIND
);
1085 sEntry
+= String( sTemp
);
1087 SvLBoxEntry
* pChild
= m_aItemList
.GetEntry( pEntry
, nPos
++ );
1088 m_aItemList
.SetEntryText( pChild
, sEntry
);
1089 _rEntry
->getPropertyValue( PN_SUBMISSION_REF
) >>= sTemp
;
1090 sEntry
= SVX_RESSTR( RID_STR_DATANAV_SUBM_REF
);
1091 sEntry
+= String( sTemp
);
1092 pChild
= m_aItemList
.GetEntry( pEntry
, nPos
++ );
1093 m_aItemList
.SetEntryText( pChild
, sEntry
);
1094 _rEntry
->getPropertyValue( PN_SUBMISSION_ACTION
) >>= sTemp
;
1095 sEntry
= SVX_RESSTR( RID_STR_DATANAV_SUBM_ACTION
);
1096 sEntry
+= String( sTemp
);
1097 pChild
= m_aItemList
.GetEntry( pEntry
, nPos
++ );
1098 m_aItemList
.SetEntryText( pChild
, sEntry
);
1099 _rEntry
->getPropertyValue( PN_SUBMISSION_METHOD
) >>= sTemp
;
1100 sEntry
= SVX_RESSTR( RID_STR_DATANAV_SUBM_METHOD
);
1101 sEntry
+= String( lcl_MethodString::get().toUI( sTemp
) );
1102 pChild
= m_aItemList
.GetEntry( pEntry
, nPos
++ );
1103 m_aItemList
.SetEntryText( pChild
, sEntry
);
1104 _rEntry
->getPropertyValue( PN_SUBMISSION_REPLACE
) >>= sTemp
;
1105 sEntry
= SVX_RESSTR( RID_STR_DATANAV_SUBM_REPLACE
);
1106 sEntry
+= String( lcl_ReplaceString::get().toUI( sTemp
) );
1107 pChild
= m_aItemList
.GetEntry( pEntry
, nPos
++ );
1108 m_aItemList
.SetEntryText( pChild
, sEntry
);
1110 catch ( Exception
& )
1112 DBG_ERRORFILE( "XFormsPage::EditEntry(): exception caught" );
1117 //------------------------------------------------------------------------
1118 bool XFormsPage::RemoveEntry()
1121 SvLBoxEntry
* pEntry
= m_aItemList
.FirstSelected();
1123 ( DGTInstance
!= m_eGroup
|| m_aItemList
.GetParent( pEntry
) ) )
1125 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
1126 DBG_ASSERT( xModel
.is(), "XFormsPage::RemoveEntry(): no model" );
1127 ItemNode
* pNode
= static_cast< ItemNode
* >( pEntry
->GetUserData() );
1128 DBG_ASSERT( pNode
, "XFormsPage::RemoveEntry(): no node" );
1130 if ( DGTInstance
== m_eGroup
)
1134 DBG_ASSERT( pNode
->m_xNode
.is(), "XFormsPage::RemoveEntry(): no XNode" );
1135 css::xml::dom::NodeType eChildType
= pNode
->m_xNode
->getNodeType();
1136 bool bIsElement
= ( eChildType
== css::xml::dom::NodeType_ELEMENT_NODE
);
1137 USHORT nResId
= bIsElement
? RID_QRY_REMOVE_ELEMENT
: RID_QRY_REMOVE_ATTRIBUTE
;
1138 String sVar
= bIsElement
? ELEMENTNAME
: ATTRIBUTENAME
;
1139 QueryBox
aQBox( this, SVX_RES( nResId
) );
1140 String sMessText
= aQBox
.GetMessText();
1141 sMessText
.SearchAndReplace(
1142 sVar
, m_xUIHelper
->getNodeDisplayName( pNode
->m_xNode
, sal_False
) );
1143 aQBox
.SetMessText( sMessText
);
1144 if ( aQBox
.Execute() == RET_YES
)
1146 SvLBoxEntry
* pParent
= m_aItemList
.GetParent( pEntry
);
1147 DBG_ASSERT( pParent
, "XFormsPage::RemoveEntry(): no parent entry" );
1148 ItemNode
* pParentNode
= static_cast< ItemNode
* >( pParent
->GetUserData() );
1149 DBG_ASSERT( pParentNode
&& pParentNode
->m_xNode
.is(), "XFormsPage::RemoveEntry(): no parent XNode" );
1151 Reference
< css::xml::dom::XNode
> xPNode
;
1152 Reference
< css::xml::dom::XNode
> xNode
=
1153 pParentNode
->m_xNode
->removeChild( pNode
->m_xNode
);
1155 xPNode
= xNode
->getParentNode();
1156 DBG_ASSERT( !xPNode
.is(), "XFormsPage::RemoveEntry(): node not removed" );
1160 catch ( Exception
& )
1162 DBG_ERRORFILE( "XFormsPage::RemoveEntry(): exception caught" );
1167 DBG_ASSERT( pNode
->m_xPropSet
.is(), "XFormsPage::RemoveEntry(): no propset" );
1168 bool bSubmission
= ( DGTSubmission
== m_eGroup
);
1169 USHORT nResId
= bSubmission
? RID_QRY_REMOVE_SUBMISSION
: RID_QRY_REMOVE_BINDING
;
1170 rtl::OUString sProperty
= bSubmission
? PN_SUBMISSION_ID
: PN_BINDING_ID
;
1171 String sSearch
= bSubmission
? SUBMISSIONNAME
: BINDINGNAME
;
1172 rtl::OUString sName
;
1175 pNode
->m_xPropSet
->getPropertyValue( sProperty
) >>= sName
;
1177 catch ( Exception
& )
1179 DBG_ERRORFILE( "XFormsPage::RemoveEntry(): exception caught" );
1181 QueryBox
aQBox( this, SVX_RES( nResId
) );
1182 String sMessText
= aQBox
.GetMessText();
1183 sMessText
.SearchAndReplace( sSearch
, String( sName
) );
1184 aQBox
.SetMessText( sMessText
);
1185 if ( aQBox
.Execute() == RET_YES
)
1190 xModel
->getSubmissions()->remove( makeAny( pNode
->m_xPropSet
) );
1191 else // then Binding Page
1192 xModel
->getBindings()->remove( makeAny( pNode
->m_xPropSet
) );
1195 catch ( Exception
& )
1197 DBG_ERRORFILE( "XFormsPage::RemoveEntry(): exception caught" );
1203 m_aItemList
.RemoveEntry( pEntry
);
1209 //------------------------------------------------------------------------
1210 long XFormsPage::Notify( NotifyEvent
& rNEvt
)
1214 if ( rNEvt
.GetType() == EVENT_KEYINPUT
)
1216 USHORT nCode
= rNEvt
.GetKeyEvent()->GetKeyCode().GetCode();
1221 nHandled
= DoMenuAction( TBI_ITEM_REMOVE
);
1226 return nHandled
? nHandled
: Window::Notify( rNEvt
);
1228 //------------------------------------------------------------------------
1229 void XFormsPage::Resize()
1231 Size aSize
= GetOutputSizePixel();
1232 Size aTbxSize
= m_aToolBox
.GetSizePixel();
1233 aTbxSize
.Width() = aSize
.Width();
1234 m_aToolBox
.SetSizePixel( aTbxSize
);
1236 aSize
.Height() -= ( 4 + aTbxSize
.Height() );
1237 m_aItemList
.SetPosSizePixel( Point( 2, 2 + aTbxSize
.Height() ), aSize
);
1239 //------------------------------------------------------------------------
1240 String
XFormsPage::SetModel( const Reference
< css::xforms::XModel
>& _xModel
, USHORT _nPagePos
)
1242 DBG_ASSERT( _xModel
.is(), "XFormsPage::SetModel(): invalid model" );
1244 m_xUIHelper
= Reference
< css::xforms::XFormsUIHelper1
>( _xModel
, UNO_QUERY
);
1247 const ImageList
& rImageList
= GetBackground().GetColor().IsDark()
1248 ? m_pNaviWin
->GetItemHCImageList()
1249 : m_pNaviWin
->GetItemImageList();
1255 DBG_ASSERT( _nPagePos
!= TAB_PAGE_NOTFOUND
, "XFormsPage::SetModel(): invalid page position" );
1258 Reference
< XContainer
> xContainer( _xModel
->getInstances(), UNO_QUERY
);
1259 if ( xContainer
.is() )
1260 m_pNaviWin
->AddContainerBroadcaster( xContainer
);
1263 Reference
< XEnumerationAccess
> xNumAccess( _xModel
->getInstances(), UNO_QUERY
);
1264 if ( xNumAccess
.is() )
1266 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
1267 if ( xNum
.is() && xNum
->hasMoreElements() )
1269 while ( xNum
->hasMoreElements() )
1271 if ( nIter
== _nPagePos
)
1273 Sequence
< PropertyValue
> xPropSeq
;
1274 Any aAny
= xNum
->nextElement();
1275 if ( aAny
>>= xPropSeq
)
1276 sRet
= LoadInstance( xPropSeq
, rImageList
);
1279 DBG_ERRORFILE( "XFormsPage::SetModel(): invalid instance" );
1285 xNum
->nextElement();
1294 DBG_ERRORFILE( "XFormsPage::SetModel(): exception caught" );
1299 case DGTSubmission
:
1301 DBG_ASSERT( TAB_PAGE_NOTFOUND
== _nPagePos
, "XFormsPage::SetModel(): invalid page position" );
1304 Reference
< XContainer
> xContainer( _xModel
->getSubmissions(), UNO_QUERY
);
1305 if ( xContainer
.is() )
1306 m_pNaviWin
->AddContainerBroadcaster( xContainer
);
1308 Reference
< XEnumerationAccess
> xNumAccess( _xModel
->getSubmissions(), UNO_QUERY
);
1309 if ( xNumAccess
.is() )
1311 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
1312 if ( xNum
.is() && xNum
->hasMoreElements() )
1314 while ( xNum
->hasMoreElements() )
1316 Reference
< XPropertySet
> xPropSet
;
1317 Any aAny
= xNum
->nextElement();
1318 if ( aAny
>>= xPropSet
)
1319 AddEntry( xPropSet
);
1326 DBG_ERRORFILE( "XFormsPage::SetModel(): exception caught" );
1333 DBG_ASSERT( TAB_PAGE_NOTFOUND
== _nPagePos
, "XFormsPage::SetModel(): invalid page position" );
1336 Reference
< XContainer
> xContainer( _xModel
->getBindings(), UNO_QUERY
);
1337 if ( xContainer
.is() )
1338 m_pNaviWin
->AddContainerBroadcaster( xContainer
);
1340 Reference
< XEnumerationAccess
> xNumAccess( _xModel
->getBindings(), UNO_QUERY
);
1341 if ( xNumAccess
.is() )
1343 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
1344 if ( xNum
.is() && xNum
->hasMoreElements() )
1346 Image aImage1
= rImageList
.GetImage( IID_ELEMENT
);
1347 Image aImage2
= rImageList
.GetImage( IID_ELEMENT
);
1348 String
sDelim( RTL_CONSTASCII_STRINGPARAM( ": " ) );
1349 while ( xNum
->hasMoreElements() )
1351 Reference
< XPropertySet
> xPropSet
;
1352 Any aAny
= xNum
->nextElement();
1353 if ( aAny
>>= xPropSet
)
1356 rtl::OUString sTemp
;
1357 xPropSet
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
1358 sEntry
+= String( sTemp
);
1360 xPropSet
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
1361 sEntry
+= String( sTemp
);
1363 ItemNode
* pNode
= new ItemNode( xPropSet
);
1364 m_aItemList
.InsertEntry(
1365 sEntry
, aImage1
, aImage2
, NULL
, FALSE
, LIST_APPEND
, pNode
);
1373 DBG_ERRORFILE( "XFormsPage::SetModel(): exception caught" );
1378 DBG_ERROR( "XFormsPage::SetModel: unknown group!" );
1382 EnableMenuItems( NULL
);
1386 //------------------------------------------------------------------------
1387 void XFormsPage::ClearModel()
1389 m_bHasModel
= false;
1390 m_aItemList
.DeleteAndClear();
1392 //------------------------------------------------------------------------
1393 String
XFormsPage::LoadInstance(
1394 const Sequence
< PropertyValue
>& _xPropSeq
, const ImageList
& _rImgLst
)
1397 rtl::OUString sTemp
;
1398 rtl::OUString sInstModel
= PN_INSTANCE_MODEL
;
1399 rtl::OUString sInstName
= PN_INSTANCE_ID
;
1400 rtl::OUString sInstURL
= PN_INSTANCE_URL
;
1401 const PropertyValue
* pProps
= _xPropSeq
.getConstArray();
1402 const PropertyValue
* pPropsEnd
= pProps
+ _xPropSeq
.getLength();
1403 for ( ; pProps
!= pPropsEnd
; ++pProps
)
1405 if ( sInstModel
.compareTo( pProps
->Name
) == 0 )
1407 Reference
< css::xml::dom::XNode
> xRoot
;
1408 if ( pProps
->Value
>>= xRoot
)
1412 Reference
< XEventTarget
> xTarget( xRoot
, UNO_QUERY
);
1414 m_pNaviWin
->AddEventBroadcaster( xTarget
);
1416 #if OSL_DEBUG_LEVEL > 0
1417 css::xml::dom::NodeType eNodeType
= xRoot
->getNodeType(); (void)eNodeType
;
1419 ::rtl::OUString sNodeName
=
1420 m_xUIHelper
->getNodeDisplayName( xRoot
, m_pNaviWin
->IsShowDetails() );
1421 if ( sNodeName
.getLength() == 0 )
1422 sNodeName
= xRoot
->getNodeName();
1423 if ( xRoot
->hasChildNodes() )
1424 AddChildren( NULL
, _rImgLst
, xRoot
);
1426 catch ( Exception
& )
1428 DBG_ERRORFILE( "XFormsPage::LoadInstance(): exception caught" );
1432 else if ( sInstName
.compareTo( pProps
->Name
) == 0 && ( pProps
->Value
>>= sTemp
) )
1433 m_sInstanceName
= sRet
= sTemp
;
1434 else if ( sInstURL
.compareTo( pProps
->Name
) == 0 && ( pProps
->Value
>>= sTemp
) )
1435 m_sInstanceURL
= sTemp
;
1441 //------------------------------------------------------------------------
1442 bool XFormsPage::DoMenuAction( USHORT _nMenuID
)
1444 return DoToolBoxAction( _nMenuID
);
1447 //------------------------------------------------------------------------
1448 void XFormsPage::EnableMenuItems( Menu
* _pMenu
)
1450 BOOL bEnableAdd
= FALSE
;
1451 BOOL bEnableEdit
= FALSE
;
1452 BOOL bEnableRemove
= FALSE
;
1454 SvLBoxEntry
* pEntry
= m_aItemList
.FirstSelected();
1458 bool bSubmitChild
= false;
1459 if ( DGTSubmission
== m_eGroup
&& m_aItemList
.GetParent( pEntry
) )
1461 pEntry
= m_aItemList
.GetParent( pEntry
);
1462 bSubmitChild
= true;
1464 ItemNode
* pNode
= static_cast< ItemNode
* >( pEntry
->GetUserData() );
1465 if ( pNode
&& ( pNode
->m_xNode
.is() || pNode
->m_xPropSet
.is() ) )
1468 bEnableRemove
= ( bSubmitChild
!= true );
1469 if ( DGTInstance
== m_eGroup
&& !m_aItemList
.GetParent( pEntry
) )
1470 bEnableRemove
= FALSE
;
1471 if ( pNode
->m_xNode
.is() )
1475 css::xml::dom::NodeType eChildType
= pNode
->m_xNode
->getNodeType();
1476 if ( eChildType
!= css::xml::dom::NodeType_ELEMENT_NODE
1477 && eChildType
!= css::xml::dom::NodeType_DOCUMENT_NODE
)
1482 catch ( Exception
& )
1484 DBG_ERRORFILE( "XFormsPage::EnableMenuItems(): exception caught" );
1489 else if ( m_eGroup
!= DGTInstance
)
1492 m_aToolBox
.EnableItem( TBI_ITEM_ADD
, bEnableAdd
);
1493 m_aToolBox
.EnableItem( TBI_ITEM_ADD_ELEMENT
, bEnableAdd
);
1494 m_aToolBox
.EnableItem( TBI_ITEM_ADD_ATTRIBUTE
, bEnableAdd
);
1495 m_aToolBox
.EnableItem( TBI_ITEM_EDIT
, bEnableEdit
);
1496 m_aToolBox
.EnableItem( TBI_ITEM_REMOVE
, bEnableRemove
);
1500 _pMenu
->EnableItem( TBI_ITEM_ADD
, bEnableAdd
);
1501 _pMenu
->EnableItem( TBI_ITEM_ADD_ELEMENT
, bEnableAdd
);
1502 _pMenu
->EnableItem( TBI_ITEM_ADD_ATTRIBUTE
, bEnableAdd
);
1503 _pMenu
->EnableItem( TBI_ITEM_EDIT
, bEnableEdit
);
1504 _pMenu
->EnableItem( TBI_ITEM_REMOVE
, bEnableRemove
);
1506 if ( DGTInstance
== m_eGroup
)
1508 USHORT nResId1
= RID_STR_DATANAV_EDIT_ELEMENT
;
1509 USHORT nResId2
= RID_STR_DATANAV_REMOVE_ELEMENT
;
1512 ItemNode
* pNode
= static_cast< ItemNode
* >( pEntry
->GetUserData() );
1513 if ( pNode
&& pNode
->m_xNode
.is() )
1517 css::xml::dom::NodeType eChildType
= pNode
->m_xNode
->getNodeType();
1518 if ( eChildType
== css::xml::dom::NodeType_ATTRIBUTE_NODE
)
1520 nResId1
= RID_STR_DATANAV_EDIT_ATTRIBUTE
;
1521 nResId2
= RID_STR_DATANAV_REMOVE_ATTRIBUTE
;
1524 catch ( Exception
& )
1526 DBG_ERRORFILE( "XFormsPage::EnableMenuItems(): exception caught" );
1530 m_aToolBox
.SetItemText( TBI_ITEM_EDIT
, SVX_RESSTR( nResId1
) );
1531 m_aToolBox
.SetItemText( TBI_ITEM_REMOVE
, SVX_RESSTR( nResId2
) );
1534 _pMenu
->SetItemText( TBI_ITEM_EDIT
, SVX_RESSTR( nResId1
) );
1535 _pMenu
->SetItemText( TBI_ITEM_REMOVE
, SVX_RESSTR( nResId2
) );
1541 //========================================================================
1542 // class DataNavigatorWindow
1543 //========================================================================
1544 DataNavigatorWindow::DataNavigatorWindow( Window
* pParent
, SfxBindings
* pBindings
) :
1546 Window( pParent
, SVX_RES( RID_SVXWIN_DATANAVIGATOR
) ),
1548 m_aModelsBox ( this, SVX_RES( LB_MODELS
) ),
1549 m_aModelBtn ( this, SVX_RES( MB_MODELS
) ),
1550 m_aTabCtrl ( this, SVX_RES( TC_ITEMS
) ),
1551 m_aInstanceBtn ( this, SVX_RES( MB_INSTANCES
) ),
1553 m_pInstPage ( NULL
),
1554 m_pSubmissionPage ( NULL
),
1555 m_pBindingPage ( NULL
),
1559 m_nBorderHeight ( 0 ),
1560 m_nLastSelectedPos ( LISTBOX_ENTRY_NOTFOUND
),
1561 m_bShowDetails ( false ),
1562 m_bIsNotifyDisabled ( false ),
1564 m_aItemImageList ( SVX_RES( IL_ITEM_BMPS
) ),
1565 m_aItemHCImageList ( SVX_RES( IL_ITEM_BMPS_HC
) ),
1566 m_xDataListener ( new DataListener( this ) )
1571 // init minimal metric
1572 m_a2Size
= LogicToPixel( Size( 2, 2 ), MAP_APPFONT
);
1573 m_a3Size
= LogicToPixel( Size( 3, 3 ), MAP_APPFONT
);
1574 Size aOutSz
= GetOutputSizePixel();
1575 Size aLogSize
= PixelToLogic( aOutSz
, MAP_APPFONT
);
1576 m_nMinWidth
= aLogSize
.Width();
1577 m_nMinHeight
= aLogSize
.Height();
1578 m_nBorderHeight
= 4*m_a3Size
.Height() +
1579 m_aModelBtn
.GetSizePixel().Height() + m_aInstanceBtn
.GetSizePixel().Height();
1582 m_aModelsBox
.SetSelectHdl( LINK( this, DataNavigatorWindow
, ModelSelectHdl
) );
1583 Link aLink
= LINK( this, DataNavigatorWindow
, MenuSelectHdl
);
1584 m_aModelBtn
.SetSelectHdl( aLink
);
1585 m_aInstanceBtn
.SetSelectHdl( aLink
);
1586 aLink
= LINK( this, DataNavigatorWindow
, MenuActivateHdl
);
1587 m_aModelBtn
.SetActivateHdl( aLink
);
1588 m_aInstanceBtn
.SetActivateHdl( aLink
);
1589 m_aTabCtrl
.SetActivatePageHdl( LINK( this, DataNavigatorWindow
, ActivatePageHdl
) );
1590 m_aUpdateTimer
.SetTimeout( 2000 );
1591 m_aUpdateTimer
.SetTimeoutHdl( LINK( this, DataNavigatorWindow
, UpdateHdl
) );
1595 sal_Int32 nPageId
= TID_INSTANCE
;
1596 SvtViewOptions
aViewOpt( E_TABDIALOG
, CFGNAME_DATANAVIGATOR
);
1597 if ( aViewOpt
.Exists() )
1599 nPageId
= aViewOpt
.GetPageID();
1600 aViewOpt
.GetUserItem(CFGNAME_SHOWDETAILS
) >>= m_bShowDetails
;
1603 Menu
* pMenu
= m_aInstanceBtn
.GetPopupMenu();
1604 pMenu
->SetItemBits( MID_SHOW_DETAILS
, MIB_CHECKABLE
);
1605 pMenu
->CheckItem( MID_SHOW_DETAILS
, m_bShowDetails
);
1607 m_aTabCtrl
.SetCurPageId( static_cast< USHORT
>( nPageId
) );
1608 ActivatePageHdl( &m_aTabCtrl
);
1611 DBG_ASSERT( pBindings
!= NULL
,
1612 "DataNavigatorWindow::LoadModels(): no SfxBindings; can't get frame" );
1613 m_xFrame
= Reference
<XFrame
>(
1614 pBindings
->GetDispatcher()->GetFrame()->GetFrame()->GetFrameInterface(),
1616 DBG_ASSERT( m_xFrame
.is(), "DataNavigatorWindow::LoadModels(): no frame" );
1617 // add frameaction listener
1618 Reference
< XFrameActionListener
> xListener(
1619 static_cast< XFrameActionListener
* >( m_xDataListener
.get() ), UNO_QUERY
);
1620 m_xFrame
->addFrameActionListener( xListener
);
1622 // load xforms models of the current document
1625 //------------------------------------------------------------------------
1626 DataNavigatorWindow::~DataNavigatorWindow()
1628 SvtViewOptions
aViewOpt( E_TABDIALOG
, CFGNAME_DATANAVIGATOR
);
1629 aViewOpt
.SetPageID( static_cast< sal_Int32
>( m_aTabCtrl
.GetCurPageId() ) );
1631 aAny
<<= m_bShowDetails
;
1632 aViewOpt
.SetUserItem(CFGNAME_SHOWDETAILS
,aAny
);
1635 delete m_pSubmissionPage
;
1636 delete m_pBindingPage
;
1638 sal_Int32 i
, nCount
= m_aPageList
.size();
1639 for ( i
= 0; i
< nCount
; ++i
)
1640 delete m_aPageList
[i
];
1641 Reference
< XFrameActionListener
> xListener(
1642 static_cast< XFrameActionListener
* >( m_xDataListener
.get() ), UNO_QUERY
);
1643 m_xFrame
->removeFrameActionListener( xListener
);
1644 RemoveBroadcaster();
1645 m_xDataListener
.clear();
1648 // -----------------------------------------------------------------------
1649 IMPL_LINK( DataNavigatorWindow
, ModelSelectHdl
, ListBox
*, pBox
)
1651 USHORT nPos
= m_aModelsBox
.GetSelectEntryPos();
1652 // pBox == NULL, if you want to force a new fill.
1653 if ( nPos
!= m_nLastSelectedPos
|| !pBox
)
1655 m_nLastSelectedPos
= nPos
;
1656 ClearAllPageModels( pBox
!= NULL
);
1663 // -----------------------------------------------------------------------
1664 IMPL_LINK( DataNavigatorWindow
, MenuSelectHdl
, MenuButton
*, pBtn
)
1666 bool bIsDocModified
= false;
1667 Reference
< css::xforms::XFormsUIHelper1
> xUIHelper
;
1668 USHORT nSelectedPos
= m_aModelsBox
.GetSelectEntryPos();
1669 ::rtl::OUString
sSelectedModel( m_aModelsBox
.GetEntry( nSelectedPos
) );
1670 Reference
< css::xforms::XModel
> xModel
;
1673 Any aAny
= m_xDataContainer
->getByName( sSelectedModel
);
1674 if ( aAny
>>= xModel
)
1675 xUIHelper
= Reference
< css::xforms::XFormsUIHelper1
>( xModel
, UNO_QUERY
);
1677 catch ( Exception
& )
1679 DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1681 DBG_ASSERT( xUIHelper
.is(), "DataNavigatorWindow::MenuSelectHdl(): no UIHelper" );
1683 m_bIsNotifyDisabled
= true;
1685 if ( &m_aModelBtn
== pBtn
)
1687 switch ( pBtn
->GetCurItemId() )
1689 case MID_MODELS_ADD
:
1691 AddModelDialog
aDlg( this, false );
1692 bool bShowDialog
= true;
1693 while ( bShowDialog
)
1695 bShowDialog
= false;
1696 if ( aDlg
.Execute() == RET_OK
)
1698 String sNewName
= aDlg
.GetName();
1699 sal_Bool bDocumentData
= aDlg
.GetModifyDoc();
1701 if ( m_aModelsBox
.GetEntryPos( sNewName
) != LISTBOX_ENTRY_NOTFOUND
)
1703 // error: model name already exists
1704 ErrorBox
aErrBox( this, SVX_RES( RID_ERR_DOUBLE_MODELNAME
) );
1705 String sMessText
= aErrBox
.GetMessText();
1706 sMessText
.SearchAndReplace( MSG_VARIABLE
, sNewName
);
1707 aErrBox
.SetMessText( sMessText
);
1715 // add new model to frame model
1716 Reference
< css::xforms::XModel
> xNewModel(
1717 xUIHelper
->newModel( m_xFrameModel
, sNewName
), UNO_SET_THROW
);
1719 Reference
< XPropertySet
> xModelProps( xNewModel
, UNO_QUERY_THROW
);
1720 xModelProps
->setPropertyValue(
1721 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExternalData" ) ),
1722 makeAny( sal_Bool( !bDocumentData
) ) );
1724 USHORT nNewPos
= m_aModelsBox
.InsertEntry( sNewName
);
1725 m_aModelsBox
.SelectEntryPos( nNewPos
);
1726 ModelSelectHdl( &m_aModelsBox
);
1727 bIsDocModified
= true;
1729 catch ( Exception
& )
1731 DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1738 case MID_MODELS_EDIT
:
1740 AddModelDialog
aDlg( this, true );
1741 aDlg
.SetName( sSelectedModel
);
1743 bool bDocumentData( false );
1746 Reference
< css::xforms::XFormsSupplier
> xFormsSupp( m_xFrameModel
, UNO_QUERY_THROW
);
1747 Reference
< XNameContainer
> xXForms( xFormsSupp
->getXForms(), UNO_SET_THROW
);
1748 Reference
< XPropertySet
> xModelProps( xXForms
->getByName( sSelectedModel
), UNO_QUERY_THROW
);
1749 sal_Bool bExternalData
= sal_False
;
1750 OSL_VERIFY( xModelProps
->getPropertyValue(
1751 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExternalData" ) ) ) >>= bExternalData
);
1752 bDocumentData
= ( bExternalData
== sal_False
);
1754 catch( const Exception
& )
1756 DBG_UNHANDLED_EXCEPTION();
1758 aDlg
.SetModifyDoc( bDocumentData
);
1760 if ( aDlg
.Execute() == RET_OK
)
1762 if ( aDlg
.GetModifyDoc() != bool( bDocumentData
) )
1764 bDocumentData
= aDlg
.GetModifyDoc();
1767 Reference
< css::xforms::XFormsSupplier
> xFormsSupp( m_xFrameModel
, UNO_QUERY_THROW
);
1768 Reference
< XNameContainer
> xXForms( xFormsSupp
->getXForms(), UNO_SET_THROW
);
1769 Reference
< XPropertySet
> xModelProps( xXForms
->getByName( sSelectedModel
), UNO_QUERY_THROW
);
1770 xModelProps
->setPropertyValue(
1771 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExternalData" ) ),
1772 makeAny( sal_Bool( !bDocumentData
) ) );
1773 bIsDocModified
= true;
1775 catch( const Exception
& )
1777 DBG_UNHANDLED_EXCEPTION();
1781 String sNewName
= aDlg
.GetName();
1782 if ( sNewName
.Len() > 0 && ( sNewName
!= String( sSelectedModel
) ) )
1786 xUIHelper
->renameModel( m_xFrameModel
, sSelectedModel
, sNewName
);
1788 m_aModelsBox
.RemoveEntry( nSelectedPos
);
1789 nSelectedPos
= m_aModelsBox
.InsertEntry( sNewName
);
1790 m_aModelsBox
.SelectEntryPos( nSelectedPos
);
1791 bIsDocModified
= true;
1793 catch ( Exception
& )
1795 DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1801 case MID_MODELS_REMOVE
:
1803 QueryBox
aQBox( this, SVX_RES( RID_QRY_REMOVE_MODEL
) );
1804 String sText
= aQBox
.GetMessText();
1805 sText
.SearchAndReplace( MODELNAME
, sSelectedModel
);
1806 aQBox
.SetMessText( sText
);
1807 if ( aQBox
.Execute() == RET_YES
)
1811 xUIHelper
->removeModel( m_xFrameModel
, sSelectedModel
);
1813 catch ( Exception
& )
1815 DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1817 m_aModelsBox
.RemoveEntry( nSelectedPos
);
1818 if ( m_aModelsBox
.GetEntryCount() <= nSelectedPos
)
1819 nSelectedPos
= m_aModelsBox
.GetEntryCount() - 1;
1820 m_aModelsBox
.SelectEntryPos( nSelectedPos
);
1821 ModelSelectHdl( &m_aModelsBox
);
1822 bIsDocModified
= true;
1828 DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" );
1832 else if ( &m_aInstanceBtn
== pBtn
)
1834 switch ( pBtn
->GetCurItemId() )
1836 case MID_INSTANCES_ADD
:
1838 AddInstanceDialog
aDlg( this, false );
1839 if ( aDlg
.Execute() == RET_OK
)
1841 USHORT nInst
= GetNewPageId();
1842 ::rtl::OUString sName
= aDlg
.GetName();
1843 ::rtl::OUString sURL
= aDlg
.GetURL();
1844 bool bLinkOnce
= aDlg
.IsLinkInstance();
1847 Reference
< css::xml::dom::XDocument
> xNewInst
=
1848 xUIHelper
->newInstance( sName
, sURL
, !bLinkOnce
);
1850 catch ( Exception
& )
1852 DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1854 ModelSelectHdl( NULL
);
1855 m_aTabCtrl
.SetCurPageId( nInst
);
1856 XFormsPage
* pPage
= GetCurrentPage( nInst
);
1857 pPage
->SetInstanceName(sName
);
1858 pPage
->SetInstanceURL(sURL
);
1859 pPage
->SetLinkOnce(bLinkOnce
);
1860 ActivatePageHdl( &m_aTabCtrl
);
1861 bIsDocModified
= true;
1865 case MID_INSTANCES_EDIT
:
1868 XFormsPage
* pPage
= GetCurrentPage( nId
);
1871 AddInstanceDialog
aDlg( this, true );
1872 aDlg
.SetName( pPage
->GetInstanceName() );
1873 aDlg
.SetURL( pPage
->GetInstanceURL() );
1874 aDlg
.SetLinkInstance( pPage
->GetLinkOnce() );
1875 String sOldName
= aDlg
.GetName();
1876 if ( aDlg
.Execute() == RET_OK
)
1878 String sNewName
= aDlg
.GetName();
1879 ::rtl::OUString sURL
= aDlg
.GetURL();
1880 bool bLinkOnce
= aDlg
.IsLinkInstance();
1883 xUIHelper
->renameInstance( sOldName
,
1888 catch ( Exception
& )
1890 DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1892 pPage
->SetInstanceName(sNewName
);
1893 pPage
->SetInstanceURL(sURL
);
1894 pPage
->SetLinkOnce(bLinkOnce
);
1895 m_aTabCtrl
.SetPageText( nId
, sNewName
);
1896 bIsDocModified
= true;
1901 case MID_INSTANCES_REMOVE
:
1904 XFormsPage
* pPage
= GetCurrentPage( nId
);
1907 String sInstName
= pPage
->GetInstanceName();
1908 QueryBox
aQBox( this, SVX_RES( RID_QRY_REMOVE_INSTANCE
) );
1909 String sMessText
= aQBox
.GetMessText();
1910 sMessText
.SearchAndReplace( INSTANCENAME
, sInstName
);
1911 aQBox
.SetMessText( sMessText
);
1912 if ( aQBox
.Execute() == RET_YES
)
1914 bool bDoRemove
= false;
1915 if ( nId
> TID_INSTANCE
)
1917 PageList::iterator aPageListEnd
= m_aPageList
.end();
1918 PageList::iterator aFoundPage
=
1919 std::find( m_aPageList
.begin(), aPageListEnd
, pPage
);
1920 if ( aFoundPage
!= aPageListEnd
)
1922 m_aPageList
.erase( aFoundPage
);
1929 DELETEZ( m_pInstPage
);
1937 xUIHelper
->removeInstance( sInstName
);
1939 catch ( Exception
& )
1941 DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
1943 m_aTabCtrl
.RemovePage( nId
);
1944 m_aTabCtrl
.SetCurPageId( TID_INSTANCE
);
1945 ModelSelectHdl( NULL
);
1946 bIsDocModified
= true;
1952 case MID_SHOW_DETAILS
:
1954 m_bShowDetails
= !m_bShowDetails
;
1955 m_aInstanceBtn
.GetPopupMenu()->CheckItem( MID_SHOW_DETAILS
, m_bShowDetails
);
1956 ModelSelectHdl( &m_aModelsBox
);
1961 DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" );
1967 DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): wrong button" );
1970 m_bIsNotifyDisabled
= false;
1972 if ( bIsDocModified
)
1976 // -----------------------------------------------------------------------
1977 IMPL_LINK( DataNavigatorWindow
, MenuActivateHdl
, MenuButton
*, pBtn
)
1979 Menu
* pMenu
= pBtn
->GetPopupMenu();
1981 if ( &m_aInstanceBtn
== pBtn
)
1983 bool bIsInstPage
= ( m_aTabCtrl
.GetCurPageId() >= TID_INSTANCE
);
1984 pMenu
->EnableItem( MID_INSTANCES_EDIT
, bIsInstPage
);
1985 pMenu
->EnableItem( MID_INSTANCES_REMOVE
,
1986 bIsInstPage
&& m_aTabCtrl
.GetPageCount() > MIN_PAGE_COUNT
);
1987 pMenu
->EnableItem( MID_SHOW_DETAILS
, bIsInstPage
);
1989 else if ( &m_aModelBtn
== pBtn
)
1991 // we need at least one model!
1992 pMenu
->EnableItem( MID_MODELS_REMOVE
, m_aModelsBox
.GetEntryCount() > 1 );
1996 DBG_ERRORFILE( "DataNavigatorWindow::MenuActivateHdl(): wrong button" );
2000 // -----------------------------------------------------------------------
2001 IMPL_LINK( DataNavigatorWindow
, ActivatePageHdl
, TabControl
*, EMPTYARG
)
2004 XFormsPage
* pPage
= GetCurrentPage( nId
);
2007 m_aTabCtrl
.SetTabPage( nId
, pPage
);
2008 if ( m_xDataContainer
.is() && !pPage
->HasModel() )
2014 // -----------------------------------------------------------------------
2015 IMPL_LINK( DataNavigatorWindow
, UpdateHdl
, Timer
*, EMPTYARG
)
2017 ModelSelectHdl( NULL
);
2020 // -----------------------------------------------------------------------
2021 XFormsPage
* DataNavigatorWindow::GetCurrentPage( USHORT
& rCurId
)
2023 rCurId
= m_aTabCtrl
.GetCurPageId();
2024 XFormsPage
* pPage
= NULL
;
2027 case TID_SUBMISSION
:
2029 if ( !m_pSubmissionPage
)
2030 m_pSubmissionPage
= new XFormsPage( &m_aTabCtrl
, this, DGTSubmission
);
2031 pPage
= m_pSubmissionPage
;
2037 if ( !m_pBindingPage
)
2038 m_pBindingPage
= new XFormsPage( &m_aTabCtrl
, this, DGTBinding
);
2039 pPage
= m_pBindingPage
;
2046 m_pInstPage
= new XFormsPage( &m_aTabCtrl
, this, DGTInstance
);
2047 pPage
= m_pInstPage
;
2052 if ( rCurId
> TID_INSTANCE
)
2054 USHORT nPos
= m_aTabCtrl
.GetPagePos( rCurId
);
2055 if ( HasFirstInstancePage() && nPos
> 0 )
2057 if ( m_aPageList
.size() > nPos
)
2058 pPage
= m_aPageList
[nPos
];
2061 pPage
= new XFormsPage( &m_aTabCtrl
, this, DGTInstance
);
2062 m_aPageList
.push_back( pPage
);
2068 // -----------------------------------------------------------------------
2069 void DataNavigatorWindow::LoadModels()
2071 if ( !m_xFrameModel
.is() )
2073 // get model of active frame
2074 Reference
< XController
> xCtrl
= m_xFrame
->getController();
2079 m_xFrameModel
= xCtrl
->getModel();
2081 catch ( Exception
& )
2083 DBG_ERRORFILE( "DataNavigatorWindow::LoadModels(): exception caught" );
2088 if ( m_xFrameModel
.is() )
2092 ::rtl::OUString sURL
= m_xFrameModel
->getURL();
2093 Reference
< css::xforms::XFormsSupplier
> xFormsSupp( m_xFrameModel
, UNO_QUERY
);
2094 if ( xFormsSupp
.is() )
2096 Reference
< XNameContainer
> xContainer
= xFormsSupp
->getXForms();
2097 if ( xContainer
.is() )
2099 m_xDataContainer
= xContainer
;
2100 Sequence
< ::rtl::OUString
> aNameList
= m_xDataContainer
->getElementNames();
2101 sal_Int32 i
, nCount
= aNameList
.getLength();
2102 ::rtl::OUString
* pNames
= aNameList
.getArray();
2103 for ( i
= 0; i
< nCount
; ++i
)
2105 Any aAny
= m_xDataContainer
->getByName( pNames
[i
] );
2106 Reference
< css::xforms::XModel
> xFormsModel
;
2107 if ( aAny
>>= xFormsModel
)
2108 m_aModelsBox
.InsertEntry( xFormsModel
->getID() );
2115 DBG_ERRORFILE( "DataNavigatorWindow::LoadModels(): exception caught" );
2119 if ( m_aModelsBox
.GetEntryCount() > 0 )
2121 m_aModelsBox
.SelectEntryPos(0);
2122 ModelSelectHdl( &m_aModelsBox
);
2125 // -----------------------------------------------------------------------
2126 void DataNavigatorWindow::SetPageModel()
2128 rtl::OUString
sModel( m_aModelsBox
.GetSelectEntry() );
2131 Any aAny
= m_xDataContainer
->getByName( sModel
);
2132 Reference
< css::xforms::XModel
> xFormsModel
;
2133 if ( aAny
>>= xFormsModel
)
2135 USHORT nPagePos
= TAB_PAGE_NOTFOUND
;
2137 XFormsPage
* pPage
= GetCurrentPage( nId
);
2138 DBG_ASSERT( pPage
, "DataNavigatorWindow::SetPageModel(): no page" );
2139 if ( nId
>= TID_INSTANCE
)
2141 nPagePos
= m_aTabCtrl
.GetPagePos( nId
);
2142 m_bIsNotifyDisabled
= true;
2143 String sText
= pPage
->SetModel( xFormsModel
, nPagePos
);
2144 m_bIsNotifyDisabled
= false;
2145 if ( sText
.Len() > 0 )
2146 m_aTabCtrl
.SetPageText( nId
, sText
);
2149 catch ( NoSuchElementException
& )
2151 DBG_ERRORFILE( "DataNavigatorWindow::SetPageModel(): no such element" );
2155 DBG_ERRORFILE( "DataNavigatorWindow::SetPageModel(): unexpected exception" );
2158 // -----------------------------------------------------------------------
2159 void DataNavigatorWindow::InitPages()
2161 rtl::OUString
sModel( m_aModelsBox
.GetSelectEntry() );
2164 Any aAny
= m_xDataContainer
->getByName( sModel
);
2165 Reference
< css::xforms::XModel
> xModel
;
2166 if ( aAny
>>= xModel
)
2168 Reference
< XEnumerationAccess
> xNumAccess( xModel
->getInstances(), UNO_QUERY
);
2169 if ( xNumAccess
.is() )
2171 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
2172 if ( xNum
.is() && xNum
->hasMoreElements() )
2174 sal_Int32 nAlreadyLoadedCount
= m_aPageList
.size();
2175 if ( !HasFirstInstancePage() && nAlreadyLoadedCount
> 0 )
2176 nAlreadyLoadedCount
--;
2178 while ( xNum
->hasMoreElements() )
2180 if ( nIdx
> nAlreadyLoadedCount
)
2182 Sequence
< PropertyValue
> xPropSeq
;
2183 if ( xNum
->nextElement() >>= xPropSeq
)
2184 CreateInstancePage( xPropSeq
);
2187 DBG_ERRORFILE( "DataNavigator::InitPages(): invalid instance" );
2191 xNum
->nextElement();
2198 catch ( NoSuchElementException
& )
2200 DBG_ERRORFILE( "DataNavigatorWindow::SetPageModel(): no such element" );
2204 DBG_ERRORFILE( "DataNavigatorWindow::SetPageModel(): unexpected exception" );
2207 // -----------------------------------------------------------------------
2208 void DataNavigatorWindow::ClearAllPageModels( bool bClearPages
)
2211 m_pInstPage
->ClearModel();
2212 if ( m_pSubmissionPage
)
2213 m_pSubmissionPage
->ClearModel();
2214 if ( m_pBindingPage
)
2215 m_pBindingPage
->ClearModel();
2217 sal_Int32 i
, nCount
= m_aPageList
.size();
2218 for ( i
= 0; i
< nCount
; ++i
)
2220 XFormsPage
* pPage
= m_aPageList
[i
];
2221 pPage
->ClearModel();
2228 m_aPageList
.clear();
2229 while ( m_aTabCtrl
.GetPageCount() > MIN_PAGE_COUNT
)
2230 m_aTabCtrl
.RemovePage( m_aTabCtrl
.GetPageId( 1 ) );
2233 // -----------------------------------------------------------------------
2234 void DataNavigatorWindow::CreateInstancePage( const Sequence
< PropertyValue
>& _xPropSeq
)
2236 rtl::OUString sInstName
;
2237 rtl::OUString
sID( PN_INSTANCE_ID
);
2238 const PropertyValue
* pProps
= _xPropSeq
.getConstArray();
2239 const PropertyValue
* pPropsEnd
= pProps
+ _xPropSeq
.getLength();
2240 for ( ; pProps
!= pPropsEnd
; ++pProps
)
2242 if ( sID
.compareTo( pProps
->Name
) == 0 )
2244 pProps
->Value
>>= sInstName
;
2249 USHORT nPageId
= GetNewPageId();
2250 if ( sInstName
.getLength() == 0 )
2252 DBG_ERRORFILE( "DataNavigatorWindow::CreateInstancePage(): instance without name" );
2253 String sTemp
= String::CreateFromAscii( "untitled" );
2254 sTemp
+= String::CreateFromInt32( nPageId
);
2257 m_aTabCtrl
.InsertPage( nPageId
, sInstName
, m_aTabCtrl
.GetPageCount() - 2 );
2260 //------------------------------------------------------------------------
2261 bool DataNavigatorWindow::HasFirstInstancePage() const
2263 return ( m_aTabCtrl
.GetPageId( 0 ) == TID_INSTANCE
);
2266 //------------------------------------------------------------------------
2267 USHORT
DataNavigatorWindow::GetNewPageId() const
2269 USHORT i
, nMax
= 0, nCount
= m_aTabCtrl
.GetPageCount();
2270 for ( i
= 0; i
< nCount
; ++i
)
2272 if ( nMax
< m_aTabCtrl
.GetPageId(i
) )
2273 nMax
= m_aTabCtrl
.GetPageId(i
);
2275 return ( nMax
+ 1 );
2278 //------------------------------------------------------------------------
2279 void DataNavigatorWindow::Resize()
2283 Size aOutSz
= GetOutputSizePixel();
2284 long nWidth
= Max( aOutSz
.Width(), m_nMinWidth
);
2285 long nHeight
= Max( aOutSz
.Height(), m_nMinHeight
);
2287 Size aSz
= m_aModelsBox
.GetSizePixel();
2288 aSz
.Width() = nWidth
- 3*m_a3Size
.Width() - m_aModelBtn
.GetSizePixel().Width();
2289 m_aModelsBox
.SetSizePixel( aSz
);
2290 Point aPos
= m_aModelBtn
.GetPosPixel();
2291 aPos
.X() = m_aModelsBox
.GetPosPixel().X() + aSz
.Width() + m_a3Size
.Width();
2292 m_aModelBtn
.SetPosPixel( aPos
);
2294 aSz
= m_aTabCtrl
.GetSizePixel();
2295 aSz
.Width() = nWidth
- 2*m_a3Size
.Width();
2296 aSz
.Height() = nHeight
- m_nBorderHeight
;
2297 m_aTabCtrl
.SetSizePixel( aSz
);
2298 // Instance button positioning
2299 aPos
= m_aInstanceBtn
.GetPosPixel();
2301 aPos
.X() = nWidth
- m_aInstanceBtn
.GetSizePixel().Width() - m_a3Size
.Width();
2302 // under the tabcontrol
2303 aPos
.Y() = m_aTabCtrl
.GetPosPixel().Y() + aSz
.Height() + m_a3Size
.Height();
2304 m_aInstanceBtn
.SetPosPixel( aPos
);
2307 //------------------------------------------------------------------------
2308 void DataNavigatorWindow::SetDocModified()
2310 SfxObjectShell
* pCurrentDoc
= SfxObjectShell::Current();
2311 DBG_ASSERT( pCurrentDoc
, "DataNavigatorWindow::SetDocModified(): no objectshell" );
2312 if ( !pCurrentDoc
->IsModified() && pCurrentDoc
->IsEnableSetModified() )
2313 pCurrentDoc
->SetModified();
2316 //------------------------------------------------------------------------
2317 void DataNavigatorWindow::NotifyChanges( bool _bLoadAll
)
2319 if ( !m_bIsNotifyDisabled
)
2323 // reset all members
2324 RemoveBroadcaster();
2325 m_xDataContainer
.clear();
2326 m_xFrameModel
.clear();
2327 m_aModelsBox
.Clear();
2328 m_nLastSelectedPos
= LISTBOX_ENTRY_NOTFOUND
;
2333 m_aUpdateTimer
.Start();
2337 //------------------------------------------------------------------------
2338 void DataNavigatorWindow::AddContainerBroadcaster( const XContainer_ref
& xContainer
)
2340 Reference
< XContainerListener
> xListener(
2341 static_cast< XContainerListener
* >( m_xDataListener
.get() ), UNO_QUERY
);
2342 xContainer
->addContainerListener( xListener
);
2343 m_aContainerList
.push_back( xContainer
);
2346 //------------------------------------------------------------------------
2347 void DataNavigatorWindow::AddEventBroadcaster( const XEventTarget_ref
& xTarget
)
2349 Reference
< XEventListener
> xListener(
2350 static_cast< XEventListener
* >( m_xDataListener
.get() ), UNO_QUERY
);
2351 xTarget
->addEventListener( EVENTTYPE_CHARDATA
, xListener
, true );
2352 xTarget
->addEventListener( EVENTTYPE_CHARDATA
, xListener
, false );
2353 xTarget
->addEventListener( EVENTTYPE_ATTR
, xListener
, true );
2354 xTarget
->addEventListener( EVENTTYPE_ATTR
, xListener
, false );
2355 m_aEventTargetList
.push_back( xTarget
);
2358 //------------------------------------------------------------------------
2359 void DataNavigatorWindow::RemoveBroadcaster()
2361 Reference
< XContainerListener
> xContainerListener(
2362 static_cast< XContainerListener
* >( m_xDataListener
.get() ), UNO_QUERY
);
2363 sal_Int32 i
, nCount
= m_aContainerList
.size();
2364 for ( i
= 0; i
< nCount
; ++i
)
2365 m_aContainerList
[i
]->removeContainerListener( xContainerListener
);
2366 Reference
< XEventListener
> xEventListener(
2367 static_cast< XEventListener
* >( m_xDataListener
.get() ), UNO_QUERY
);
2368 nCount
= m_aEventTargetList
.size();
2369 for ( i
= 0; i
< nCount
; ++i
)
2371 m_aEventTargetList
[i
]->removeEventListener( EVENTTYPE_CHARDATA
, xEventListener
, true );
2372 m_aEventTargetList
[i
]->removeEventListener( EVENTTYPE_CHARDATA
, xEventListener
, false );
2373 m_aEventTargetList
[i
]->removeEventListener( EVENTTYPE_ATTR
, xEventListener
, true );
2374 m_aEventTargetList
[i
]->removeEventListener( EVENTTYPE_ATTR
, xEventListener
, false );
2378 //========================================================================
2379 // class DataNavigator
2380 //========================================================================
2381 DBG_NAME(DataNavigator
)
2382 //------------------------------------------------------------------------
2383 DataNavigator::DataNavigator( SfxBindings
* _pBindings
, SfxChildWindow
* _pMgr
, Window
* _pParent
) :
2385 SfxDockingWindow( _pBindings
, _pMgr
, _pParent
,
2386 WinBits(WB_STDMODELESS
|WB_SIZEABLE
|WB_ROLLABLE
|WB_3DLOOK
|WB_DOCKABLE
) ),
2387 SfxControllerItem( SID_FM_DATANAVIGATOR_CONTROL
, *_pBindings
),
2389 m_aDataWin( this, _pBindings
)
2392 DBG_CTOR(DataNavigator
,NULL
);
2394 SetHelpId( HID_DATA_NAVIGATOR_WIN
);
2395 SetText( SVX_RES( RID_STR_DATANAVIGATOR
) );
2397 Size aSize
= m_aDataWin
.GetOutputSizePixel();
2398 Size aLogSize
= PixelToLogic( aSize
, MAP_APPFONT
);
2399 SfxDockingWindow::SetFloatingSize( aLogSize
);
2404 //------------------------------------------------------------------------
2405 DataNavigator::~DataNavigator()
2407 DBG_DTOR(DataNavigator
,NULL
);
2410 //-----------------------------------------------------------------------
2411 void DataNavigator::Update( FmFormShell
* /*pFormShell*/ )
2414 //-----------------------------------------------------------------------
2415 void DataNavigator::StateChanged( sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
)
2417 if ( !pState
|| SID_FM_DATANAVIGATOR_CONTROL
!= nSID
)
2420 if ( eState
>= SFX_ITEM_AVAILABLE
)
2422 FmFormShell
* pShell
= PTR_CAST( FmFormShell
,((SfxObjectItem
*)pState
)->GetShell() );
2429 //-----------------------------------------------------------------------
2430 void DataNavigator::GetFocus()
2432 SfxDockingWindow::GetFocus();
2435 //-----------------------------------------------------------------------
2436 sal_Bool
DataNavigator::Close()
2439 return SfxDockingWindow::Close();
2442 //-----------------------------------------------------------------------
2443 Size
DataNavigator::CalcDockingSize( SfxChildAlignment eAlign
)
2445 if ( ( eAlign
== SFX_ALIGN_TOP
) || ( eAlign
== SFX_ALIGN_BOTTOM
) )
2448 return SfxDockingWindow::CalcDockingSize( eAlign
);
2451 //-----------------------------------------------------------------------
2452 SfxChildAlignment
DataNavigator::CheckAlignment( SfxChildAlignment eActAlign
, SfxChildAlignment eAlign
)
2456 case SFX_ALIGN_LEFT
:
2457 case SFX_ALIGN_RIGHT
:
2458 case SFX_ALIGN_NOALIGNMENT
:
2466 //------------------------------------------------------------------------
2467 void DataNavigator::Resize()
2469 SfxDockingWindow::Resize();
2471 Size aLogOutputSize
= PixelToLogic( GetOutputSizePixel(), MAP_APPFONT
);
2472 Size aLogExplSize
= aLogOutputSize
;
2473 aLogExplSize
.Width() -= 2;
2474 aLogExplSize
.Height() -= 2;
2476 Point aExplPos
= LogicToPixel( Point(1,1), MAP_APPFONT
);
2477 Size aExplSize
= LogicToPixel( aLogExplSize
, MAP_APPFONT
);
2479 m_aDataWin
.SetPosSizePixel( aExplPos
, aExplSize
);
2483 //========================================================================
2484 // class NavigatorFrameManager
2485 //========================================================================
2487 //-----------------------------------------------------------------------
2488 SFX_IMPL_DOCKINGWINDOW( DataNavigatorManager
, SID_FM_SHOW_DATANAVIGATOR
)
2490 //-----------------------------------------------------------------------
2491 DataNavigatorManager::DataNavigatorManager(
2492 Window
* _pParent
, sal_uInt16 _nId
, SfxBindings
* _pBindings
, SfxChildWinInfo
* _pInfo
) :
2494 SfxChildWindow( _pParent
, _nId
)
2497 pWindow
= new DataNavigator( _pBindings
, this, _pParent
);
2498 eChildAlignment
= SFX_ALIGN_RIGHT
;
2499 pWindow
->SetSizePixel( Size( 250, 400 ) );
2500 ( (SfxDockingWindow
*)pWindow
)->Initialize( _pInfo
);
2503 //========================================================================
2504 // class AddDataItemDialog
2505 //========================================================================
2507 AddDataItemDialog::AddDataItemDialog(
2508 Window
* pParent
, ItemNode
* _pNode
,
2509 const Reference
< css::xforms::XFormsUIHelper1
>& _rUIHelper
) :
2511 ModalDialog( pParent
, SVX_RES( RID_SVXDLG_ADD_DATAITEM
) ),
2513 m_aItemFL ( this, SVX_RES( FL_ITEM
) ),
2514 m_aNameFT ( this, SVX_RES( FT_NAME
) ),
2515 m_aNameED ( this, SVX_RES( ED_NAME
) ),
2516 m_aDefaultFT ( this, SVX_RES( FT_DEFAULT
) ),
2517 m_aDefaultED ( this, SVX_RES( ED_DEFAULT
) ),
2518 m_aDefaultBtn ( this, SVX_RES( PB_DEFAULT
) ),
2519 m_aSettingsFL ( this, SVX_RES( FL_SETTINGS
) ),
2520 m_aDataTypeFT ( this, SVX_RES( FT_DATATYPE
) ),
2521 m_aDataTypeLB ( this, SVX_RES( LB_DATATYPE
) ),
2522 m_aRequiredCB ( this, SVX_RES( CB_REQUIRED
) ),
2523 m_aRequiredBtn ( this, SVX_RES( PB_REQUIRED
) ),
2524 m_aRelevantCB ( this, SVX_RES( CB_RELEVANT
) ),
2525 m_aRelevantBtn ( this, SVX_RES( PB_RELEVANT
) ),
2526 m_aConstraintCB ( this, SVX_RES( CB_CONSTRAINT
) ),
2527 m_aConstraintBtn( this, SVX_RES( PB_CONSTRAINT
) ),
2528 m_aReadonlyCB ( this, SVX_RES( CB_READONLY
) ),
2529 m_aReadonlyBtn ( this, SVX_RES( PB_READONLY
) ),
2530 m_aCalculateCB ( this, SVX_RES( CB_CALCULATE
) ),
2531 m_aCalculateBtn ( this, SVX_RES( PB_CALCULATE
) ),
2532 m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN
) ),
2533 m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK
) ),
2534 m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC
) ),
2535 m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP
) ),
2537 m_xUIHelper ( _rUIHelper
),
2538 m_pItemNode ( _pNode
),
2539 m_eItemType ( DITNone
),
2540 m_sFL_Element ( SVX_RES( STR_FIXEDLINE_ELEMENT
) ),
2541 m_sFL_Attribute ( SVX_RES( STR_FIXEDLINE_ATTRIBUTE
) ),
2542 m_sFL_Binding ( SVX_RES( STR_FIXEDLINE_BINDING
) ),
2543 m_sFT_BindingExp( SVX_RES( STR_FIXEDTEXT_BINDING
) )
2547 m_aDataTypeLB
.SetDropDownLineCount( 10 );
2555 //------------------------------------------------------------------------
2556 AddDataItemDialog::~AddDataItemDialog()
2558 if ( m_xTempBinding
.is() )
2560 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2565 Reference
< XSet
> xBindings
= xModel
->getBindings();
2566 if ( xBindings
.is() )
2567 xBindings
->remove( makeAny( m_xTempBinding
) );
2569 catch ( Exception
& )
2571 DBG_ERRORFILE( "AddDataItemDialog::Dtor(): exception caught" );
2575 if( m_xUIHelper
.is() && m_xBinding
.is() )
2577 // remove binding, if it does not convey 'useful' information
2578 m_xUIHelper
->removeBindingIfUseless( m_xBinding
);
2582 //------------------------------------------------------------------------
2583 IMPL_LINK( AddDataItemDialog
, CheckHdl
, CheckBox
*, pBox
)
2585 // Condition buttons are only enable if their check box is checked
2586 m_aReadonlyBtn
.Enable( m_aReadonlyCB
.IsChecked() );
2587 m_aRequiredBtn
.Enable( m_aRequiredCB
.IsChecked() );
2588 m_aRelevantBtn
.Enable( m_aRelevantCB
.IsChecked() );
2589 m_aConstraintBtn
.Enable( m_aConstraintCB
.IsChecked() );
2590 m_aCalculateBtn
.Enable( m_aCalculateCB
.IsChecked() );
2592 if ( pBox
&& m_xTempBinding
.is() )
2594 ::rtl::OUString sTemp
, sPropName
;
2595 if ( &m_aRequiredCB
== pBox
)
2596 sPropName
= PN_REQUIRED_EXPR
;
2597 else if ( &m_aRelevantCB
== pBox
)
2598 sPropName
= PN_RELEVANT_EXPR
;
2599 else if ( &m_aConstraintCB
== pBox
)
2600 sPropName
= PN_CONSTRAINT_EXPR
;
2601 else if ( &m_aReadonlyCB
== pBox
)
2602 sPropName
= PN_READONLY_EXPR
;
2603 else if ( &m_aCalculateCB
== pBox
)
2604 sPropName
= PN_CALCULATE_EXPR
;
2605 bool bIsChecked
= ( pBox
->IsChecked() != FALSE
);
2606 m_xTempBinding
->getPropertyValue( sPropName
) >>= sTemp
;
2607 if ( bIsChecked
&& sTemp
.getLength() == 0 )
2609 else if ( !bIsChecked
&& sTemp
.getLength() > 0 )
2610 sTemp
= ::rtl::OUString();
2611 m_xTempBinding
->setPropertyValue( sPropName
, makeAny( sTemp
) );
2617 //------------------------------------------------------------------------
2618 IMPL_LINK( AddDataItemDialog
, ConditionHdl
, PushButton
*, pBtn
)
2620 ::rtl::OUString sTemp
, sPropName
;
2621 if ( &m_aDefaultBtn
== pBtn
)
2622 sPropName
= PN_BINDING_EXPR
;
2623 else if ( &m_aRequiredBtn
== pBtn
)
2624 sPropName
= PN_REQUIRED_EXPR
;
2625 else if ( &m_aRelevantBtn
== pBtn
)
2626 sPropName
= PN_RELEVANT_EXPR
;
2627 else if ( &m_aConstraintBtn
== pBtn
)
2628 sPropName
= PN_CONSTRAINT_EXPR
;
2629 else if ( &m_aReadonlyBtn
== pBtn
)
2630 sPropName
= PN_READONLY_EXPR
;
2631 else if ( &m_aCalculateBtn
== pBtn
)
2632 sPropName
= PN_CALCULATE_EXPR
;
2633 AddConditionDialog
aDlg( this, sPropName
, m_xTempBinding
);
2634 bool bIsDefBtn
= ( &m_aDefaultBtn
== pBtn
);
2637 sCondition
= m_aDefaultED
.GetText();
2640 m_xTempBinding
->getPropertyValue( sPropName
) >>= sTemp
;
2641 if ( sTemp
.getLength() == 0 )
2645 aDlg
.SetCondition( sCondition
);
2647 if ( aDlg
.Execute() == RET_OK
)
2649 String sNewCondition
= aDlg
.GetCondition();
2651 m_aDefaultED
.SetText( sNewCondition
);
2655 m_xTempBinding
->setPropertyValue(
2656 sPropName
, makeAny( ::rtl::OUString( sNewCondition
) ) );
2662 void copyPropSet( const Reference
< XPropertySet
>& xFrom
, Reference
< XPropertySet
>& xTo
)
2664 DBG_ASSERT( xFrom
.is(), "copyPropSet(): no source" );
2665 DBG_ASSERT( xTo
.is(), "copyPropSet(): no target" );
2669 // get property names & infos, and iterate over target properties
2670 Sequence
< Property
> aProperties
= xTo
->getPropertySetInfo()->getProperties();
2671 sal_Int32 nProperties
= aProperties
.getLength();
2672 const Property
* pProperties
= aProperties
.getConstArray();
2673 Reference
< XPropertySetInfo
> xFromInfo
= xFrom
->getPropertySetInfo();
2674 for ( sal_Int32 i
= 0; i
< nProperties
; ++i
)
2676 const ::rtl::OUString
& rName
= pProperties
[i
].Name
;
2678 // if both set have the property, copy the value
2679 // (catch and ignore exceptions, if any)
2680 if ( xFromInfo
->hasPropertyByName( rName
) )
2682 // don't set readonly properties
2683 Property aProperty
= xFromInfo
->getPropertyByName( rName
);
2684 if ( ( aProperty
.Attributes
& PropertyAttribute::READONLY
) == 0 )
2685 xTo
->setPropertyValue(rName
, xFrom
->getPropertyValue( rName
));
2687 // else: no property? then ignore.
2690 catch ( Exception
& )
2692 DBG_ERRORFILE( "copyPropSet(): exception caught" );
2696 //------------------------------------------------------------------------
2697 IMPL_LINK( AddDataItemDialog
, OKHdl
, OKButton
*, EMPTYARG
)
2699 bool bIsHandleBinding
= ( DITBinding
== m_eItemType
);
2700 bool bIsHandleText
= ( DITText
== m_eItemType
);
2701 ::rtl::OUString
sNewName( m_aNameED
.GetText() );
2703 if ( ( !bIsHandleBinding
&& !bIsHandleText
&& !m_xUIHelper
->isValidXMLName( sNewName
) ) ||
2704 ( bIsHandleBinding
&& sNewName
.getLength() == 0 ) )
2706 // Error and don't close the dialog
2707 ErrorBox
aErrBox( this, SVX_RES( RID_ERR_INVALID_XMLNAME
) );
2708 String sMessText
= aErrBox
.GetMessText();
2709 sMessText
.SearchAndReplace( MSG_VARIABLE
, sNewName
);
2710 aErrBox
.SetMessText( sMessText
);
2715 ::rtl::OUString
sDataType( m_aDataTypeLB
.GetSelectEntry() );
2716 m_xTempBinding
->setPropertyValue( PN_BINDING_TYPE
, makeAny( sDataType
) );
2718 if ( bIsHandleBinding
)
2720 // copy properties from temp binding to original binding
2721 copyPropSet( m_xTempBinding
, m_pItemNode
->m_xPropSet
);
2724 ::rtl::OUString sValue
= m_aNameED
.GetText();
2725 m_pItemNode
->m_xPropSet
->setPropertyValue( PN_BINDING_ID
, makeAny( sValue
) );
2726 sValue
= m_aDefaultED
.GetText();
2727 m_pItemNode
->m_xPropSet
->setPropertyValue( PN_BINDING_EXPR
, makeAny( sValue
) );
2729 catch ( Exception
& )
2731 DBG_ERRORFILE( "AddDataDialog::OKHdl(): exception caught" );
2736 // copy properties from temp binding to original binding
2737 copyPropSet( m_xTempBinding
, m_xBinding
);
2740 if ( bIsHandleText
)
2741 m_xUIHelper
->setNodeValue( m_pItemNode
->m_xNode
, m_aDefaultED
.GetText() );
2744 Reference
< css::xml::dom::XNode
> xNewNode
=
2745 m_xUIHelper
->renameNode( m_pItemNode
->m_xNode
, m_aNameED
.GetText() );
2746 m_xUIHelper
->setNodeValue( xNewNode
, m_aDefaultED
.GetText() );
2747 m_pItemNode
->m_xNode
= xNewNode
;
2750 catch ( Exception
& )
2752 DBG_ERRORFILE( "AddDataDialog::OKHdl(): exception caught" );
2755 // then close the dialog
2756 EndDialog( RET_OK
);
2760 //------------------------------------------------------------------------
2761 void AddDataItemDialog::InitDialog()
2764 Link aLink
= LINK( this, AddDataItemDialog
, CheckHdl
);
2765 m_aRequiredCB
.SetClickHdl( aLink
);
2766 m_aRelevantCB
.SetClickHdl( aLink
);
2767 m_aConstraintCB
.SetClickHdl( aLink
);
2768 m_aReadonlyCB
.SetClickHdl( aLink
);
2769 m_aCalculateCB
.SetClickHdl( aLink
);
2771 aLink
= LINK( this, AddDataItemDialog
, ConditionHdl
);
2772 m_aDefaultBtn
.SetClickHdl( aLink
);
2773 m_aRequiredBtn
.SetClickHdl( aLink
);
2774 m_aRelevantBtn
.SetClickHdl( aLink
);
2775 m_aConstraintBtn
.SetClickHdl( aLink
);
2776 m_aReadonlyBtn
.SetClickHdl( aLink
);
2777 m_aCalculateBtn
.SetClickHdl( aLink
);
2779 m_aOKBtn
.SetClickHdl( LINK( this, AddDataItemDialog
, OKHdl
) );
2782 //------------------------------------------------------------------------
2783 void AddDataItemDialog::InitFromNode()
2787 if ( m_pItemNode
->m_xNode
.is() )
2791 // detect type of the node
2792 css::xml::dom::NodeType eChildType
= m_pItemNode
->m_xNode
->getNodeType();
2793 switch ( eChildType
)
2795 case css::xml::dom::NodeType_ATTRIBUTE_NODE
:
2796 m_eItemType
= DITAttribute
;
2798 case css::xml::dom::NodeType_ELEMENT_NODE
:
2799 m_eItemType
= DITElement
;
2801 case css::xml::dom::NodeType_TEXT_NODE
:
2802 m_eItemType
= DITText
;
2805 DBG_ERROR( "AddDataItemDialog::InitFronNode: cannot handle this node type!" );
2809 /** Get binding of the node and clone it
2810 Then use this temporary binding in the dialog.
2811 When the user click OK the temporary binding will be copied
2812 into the original binding.
2815 Reference
< css::xml::dom::XNode
> xNode
= m_pItemNode
->m_xNode
;
2816 m_xBinding
= m_xUIHelper
->getBindingForNode( xNode
, sal_True
);
2817 if ( m_xBinding
.is() )
2819 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2822 m_xTempBinding
= m_xUIHelper
->cloneBindingAsGhost( m_xBinding
);
2823 Reference
< XSet
> xBindings
= xModel
->getBindings();
2824 if ( xBindings
.is() )
2825 xBindings
->insert( makeAny( m_xTempBinding
) );
2829 if ( m_eItemType
!= DITText
)
2831 ::rtl::OUString
sName( m_xUIHelper
->getNodeName( m_pItemNode
->m_xNode
) );
2832 m_aNameED
.SetText( sName
);
2834 m_aDefaultED
.SetText( m_pItemNode
->m_xNode
->getNodeValue() );
2838 DBG_ERRORFILE( "AddDataItemDialog::InitFromNode(): exception caught" );
2841 else if ( m_pItemNode
->m_xPropSet
.is() )
2843 m_eItemType
= DITBinding
;
2844 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2849 m_xTempBinding
= m_xUIHelper
->cloneBindingAsGhost( m_pItemNode
->m_xPropSet
);
2850 Reference
< XSet
> xBindings
= xModel
->getBindings();
2851 if ( xBindings
.is() )
2852 xBindings
->insert( makeAny( m_xTempBinding
) );
2854 catch ( Exception
& )
2856 DBG_ERRORFILE( "AddDataItemDialog::InitFromNode(): exception caught" );
2859 rtl::OUString sTemp
;
2862 Reference
< XPropertySetInfo
> xInfo
= m_pItemNode
->m_xPropSet
->getPropertySetInfo();
2863 if ( xInfo
->hasPropertyByName( PN_BINDING_ID
) )
2865 m_pItemNode
->m_xPropSet
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
2866 m_aNameED
.SetText( sTemp
);
2867 m_pItemNode
->m_xPropSet
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
2868 m_aDefaultED
.SetText( sTemp
);
2870 else if ( xInfo
->hasPropertyByName( PN_SUBMISSION_BIND
) )
2872 m_pItemNode
->m_xPropSet
->getPropertyValue( PN_SUBMISSION_ID
) >>= sTemp
;
2873 m_aNameED
.SetText( sTemp
);
2878 DBG_ERRORFILE( "AddDataItemDialog::InitFromNode(): exception caught" );
2881 Size a3and1Sz
= LogicToPixel( Size( 3, 1 ), MAP_APPFONT
);
2882 Size aNewSz
= m_aDefaultED
.GetSizePixel();
2883 Point aNewPnt
= m_aDefaultED
.GetPosPixel();
2884 aNewPnt
.Y() += a3and1Sz
.Height();
2885 aNewSz
.Width() -= ( m_aDefaultBtn
.GetSizePixel().Width() + a3and1Sz
.Width() );
2886 m_aDefaultED
.SetPosSizePixel( aNewPnt
, aNewSz
);
2887 m_aDefaultBtn
.Show();
2890 if ( m_xTempBinding
.is() )
2892 ::rtl::OUString sTemp
;
2895 if ( ( m_xTempBinding
->getPropertyValue( PN_REQUIRED_EXPR
) >>= sTemp
)
2896 && sTemp
.getLength() > 0 )
2897 m_aRequiredCB
.Check( TRUE
);
2898 if ( ( m_xTempBinding
->getPropertyValue( PN_RELEVANT_EXPR
) >>= sTemp
)
2899 && sTemp
.getLength() > 0 )
2900 m_aRelevantCB
.Check( TRUE
);
2901 if ( ( m_xTempBinding
->getPropertyValue( PN_CONSTRAINT_EXPR
) >>= sTemp
)
2902 && sTemp
.getLength() > 0 )
2903 m_aConstraintCB
.Check( TRUE
);
2904 if ( ( m_xTempBinding
->getPropertyValue( PN_READONLY_EXPR
) >>= sTemp
)
2905 && sTemp
.getLength() > 0 )
2906 m_aReadonlyCB
.Check( TRUE
);
2907 if ( ( m_xTempBinding
->getPropertyValue( PN_CALCULATE_EXPR
) >>= sTemp
)
2908 && sTemp
.getLength() > 0 )
2909 m_aCalculateCB
.Check( TRUE
);
2911 catch ( Exception
& )
2913 DBG_ERRORFILE( "AddDataItemDialog::InitFromNode(): exception caught" );
2918 if ( DITText
== m_eItemType
)
2920 long nDelta
= m_aButtonsFL
.GetPosPixel().Y() - m_aSettingsFL
.GetPosPixel().Y();
2922 Window
* pWinsForHide
[] =
2924 &m_aSettingsFL
, &m_aDataTypeFT
, &m_aDataTypeLB
, &m_aRequiredCB
,
2925 &m_aRequiredBtn
, &m_aRelevantCB
, &m_aRelevantBtn
, &m_aConstraintCB
,
2926 &m_aConstraintBtn
, &m_aReadonlyCB
, &m_aReadonlyBtn
, &m_aCalculateCB
,
2929 Window
** pCurrent
= pWinsForHide
;
2930 for ( ; i
< sizeof( pWinsForHide
) / sizeof( pWinsForHide
[ 0 ] ); ++i
, ++pCurrent
)
2931 (*pCurrent
)->Hide();
2933 Window
* pWinsForMove
[] =
2935 &m_aButtonsFL
, &m_aOKBtn
, &m_aEscBtn
, &m_aHelpBtn
2937 pCurrent
= pWinsForMove
;
2938 for ( i
= 0; i
< sizeof( pWinsForMove
) / sizeof( pWinsForMove
[ 0 ] ); ++i
, ++pCurrent
)
2940 Point aNewPos
= (*pCurrent
)->GetPosPixel();
2941 aNewPos
.Y() -= nDelta
;
2942 (*pCurrent
)->SetPosPixel( aNewPos
);
2944 Size aNewWinSz
= GetSizePixel();
2945 aNewWinSz
.Height() -= nDelta
;
2946 SetSizePixel( aNewWinSz
);
2948 m_aNameFT
.Disable();
2949 m_aNameED
.Disable();
2953 //------------------------------------------------------------------------
2954 void AddDataItemDialog::InitDataTypeBox()
2956 if ( m_eItemType
!= DITText
)
2958 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
2963 Reference
< css::xforms::XDataTypeRepository
> xDataTypes
=
2964 xModel
->getDataTypeRepository();
2965 if ( xDataTypes
.is() )
2967 Sequence
< ::rtl::OUString
> aNameList
= xDataTypes
->getElementNames();
2968 sal_Int32 i
, nCount
= aNameList
.getLength();
2969 ::rtl::OUString
* pNames
= aNameList
.getArray();
2970 for ( i
= 0; i
< nCount
; ++i
)
2971 m_aDataTypeLB
.InsertEntry( pNames
[i
] );
2974 if ( m_xTempBinding
.is() )
2976 rtl::OUString sTemp
;
2977 if ( m_xTempBinding
->getPropertyValue( PN_BINDING_TYPE
) >>= sTemp
)
2979 USHORT nPos
= m_aDataTypeLB
.GetEntryPos( String( sTemp
) );
2980 if ( LISTBOX_ENTRY_NOTFOUND
== nPos
)
2981 nPos
= m_aDataTypeLB
.InsertEntry( sTemp
);
2982 m_aDataTypeLB
.SelectEntryPos( nPos
);
2986 catch ( Exception
& )
2988 DBG_ERRORFILE( "AddDataItemDialog::InitDataTypeBox(): exception caught" );
2994 void AddDataItemDialog::InitText( DataItemType _eType
)
3002 sText
= m_sFL_Attribute
;
3008 sText
= m_sFL_Binding
;
3009 m_aDefaultFT
.SetText( m_sFT_BindingExp
);
3015 sText
= m_sFL_Element
;
3019 m_aItemFL
.SetText( sText
);
3022 //========================================================================
3023 // class AddConditionDialog
3024 //========================================================================
3026 AddConditionDialog::AddConditionDialog(
3027 Window
* pParent
, const ::rtl::OUString
& _rPropertyName
,
3028 const Reference
< XPropertySet
>& _rPropSet
) :
3030 ModalDialog( pParent
, SVX_RES( RID_SVXDLG_ADD_CONDITION
) ),
3032 m_aConditionFT ( this, SVX_RES( FT_CONDITION
) ),
3033 m_aConditionED ( this, SVX_RES( ED_CONDITION
) ),
3034 m_aResultFT ( this, SVX_RES( FT_RESULT
) ),
3035 m_aResultWin ( this, SVX_RES( FT_RESULT_PREVIEW
) ),
3036 m_aEditNamespacesBtn( this, SVX_RES( PB_EDIT_NAMESPACES
) ),
3037 m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN
) ),
3038 m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK
) ),
3039 m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC
) ),
3040 m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP
) ),
3042 m_sPropertyName ( _rPropertyName
),
3043 m_xBinding ( _rPropSet
)
3048 DBG_ASSERT( m_xBinding
.is(), "AddConditionDialog::Ctor(): no Binding" );
3050 m_aResultWin
.SetBackground( m_aConditionED
.GetBackground() );
3051 m_aConditionED
.SetModifyHdl( LINK( this, AddConditionDialog
, ModifyHdl
) );
3052 m_aEditNamespacesBtn
.SetClickHdl( LINK( this, AddConditionDialog
, EditHdl
) );
3053 m_aOKBtn
.SetClickHdl( LINK( this, AddConditionDialog
, OKHdl
) );
3054 m_aResultTimer
.SetTimeout( 500 );
3055 m_aResultTimer
.SetTimeoutHdl( LINK( this, AddConditionDialog
, ResultHdl
) );
3057 if ( m_sPropertyName
.getLength() > 0 )
3061 rtl::OUString sTemp
;
3062 if ( ( m_xBinding
->getPropertyValue( m_sPropertyName
) >>= sTemp
)
3063 && sTemp
.getLength() > 0 )
3065 m_aConditionED
.SetText( sTemp
);
3069 //! m_xBinding->setPropertyValue( m_sPropertyName, makeAny( TRUE_VALUE ) );
3070 m_aConditionED
.SetText( TRUE_VALUE
);
3073 Reference
< css::xforms::XModel
> xModel
;
3074 if ( ( m_xBinding
->getPropertyValue( PN_BINDING_MODEL
) >>= xModel
) && xModel
.is() )
3075 m_xUIHelper
= Reference
< css::xforms::XFormsUIHelper1
>( xModel
, UNO_QUERY
);
3077 catch ( Exception
& )
3079 DBG_ERRORFILE( "AddConditionDialog::Ctor(): exception caught" );
3083 DBG_ASSERT( m_xUIHelper
.is(), "AddConditionDialog::Ctor(): no UIHelper" );
3084 ResultHdl( &m_aResultTimer
);
3087 //------------------------------------------------------------------------
3088 AddConditionDialog::~AddConditionDialog()
3092 //------------------------------------------------------------------------
3093 IMPL_LINK( AddConditionDialog
, EditHdl
, PushButton
*, EMPTYARG
)
3095 Reference
< XNameContainer
> xNameContnr
;
3098 m_xBinding
->getPropertyValue( PN_BINDING_NAMESPACES
) >>= xNameContnr
;
3100 catch ( Exception
& )
3102 DBG_ERRORFILE( "AddDataItemDialog::EditHdl(): exception caught" );
3104 NamespaceItemDialog
aDlg( this, xNameContnr
);
3108 m_xBinding
->setPropertyValue( PN_BINDING_NAMESPACES
, makeAny( xNameContnr
) );
3110 catch ( Exception
& )
3112 DBG_ERRORFILE( "AddDataItemDialog::EditHdl(): exception caught" );
3117 //------------------------------------------------------------------------
3118 IMPL_LINK( AddConditionDialog
, OKHdl
, OKButton
*, EMPTYARG
)
3123 if ( m_xBinding.is() )
3124 m_xBinding->setPropertyValue( m_sPropertyName, makeAny( ::rtl::OUString( m_aConditionED.GetText() ) ) );
3126 catch( const Exception& )
3128 DBG_ERRORFILE( "AddConditionDialog, OKHdl: caught an exception!" );
3131 EndDialog( RET_OK
);
3135 //------------------------------------------------------------------------
3136 IMPL_LINK( AddConditionDialog
, ModifyHdl
, MultiLineEdit
*, EMPTYARG
)
3138 m_aResultTimer
.Start();
3142 //------------------------------------------------------------------------
3143 IMPL_LINK( AddConditionDialog
, ResultHdl
, Timer
*, EMPTYARG
)
3145 String sCondition
= m_aConditionED
.GetText().EraseLeadingChars().EraseTrailingChars();
3147 if ( sCondition
.Len() > 0 )
3151 sResult
= m_xUIHelper
->getResultForExpression( m_xBinding
, ( m_sPropertyName
== PN_BINDING_EXPR
), sCondition
);
3153 catch ( Exception
& )
3155 DBG_ERRORFILE( "AddConditionDialog::ResultHdl(): exception caught" );
3158 m_aResultWin
.SetText( sResult
);
3162 //========================================================================
3163 // class NamespaceItemDialog
3164 //========================================================================
3166 NamespaceItemDialog::NamespaceItemDialog(
3167 AddConditionDialog
* _pCondDlg
, Reference
< XNameContainer
>& _rContainer
) :
3169 ModalDialog( _pCondDlg
, SVX_RES( RID_SVXDLG_NAMESPACE_ITEM
) ),
3171 m_aNamespacesFT ( this, SVX_RES( FT_NAMESPACES
) ),
3172 m_aNamespacesList ( this, SVX_RES( LB_NAMESPACES
) ),
3173 m_aAddNamespaceBtn ( this, SVX_RES( PB_ADD_NAMESPACE
) ),
3174 m_aEditNamespaceBtn ( this, SVX_RES( PB_EDIT_NAMESPACE
) ),
3175 m_aDeleteNamespaceBtn ( this, SVX_RES( PB_DELETE_NAMESPACE
) ),
3176 m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN
) ),
3177 m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK
) ),
3178 m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC
) ),
3179 m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP
) ),
3181 m_pConditionDlg ( _pCondDlg
),
3182 m_rNamespaces ( _rContainer
)
3185 static long aStaticTabs
[]= { 3, 0, 35, 200 };
3186 m_aNamespacesList
.SvxSimpleTable::SetTabs( aStaticTabs
);
3187 String sHeader
= String( SVX_RES( STR_HEADER_PREFIX
) );
3189 sHeader
+= String( SVX_RES( STR_HEADER_URL
) );
3190 m_aNamespacesList
.InsertHeaderEntry(
3191 sHeader
, HEADERBAR_APPEND
, HIB_LEFT
/*| HIB_FIXEDPOS | HIB_FIXED*/ );
3195 m_aNamespacesList
.SetSelectHdl( LINK( this, NamespaceItemDialog
, SelectHdl
) );
3196 Link aLink
= LINK( this, NamespaceItemDialog
, ClickHdl
);
3197 m_aAddNamespaceBtn
.SetClickHdl( aLink
);
3198 m_aEditNamespaceBtn
.SetClickHdl( aLink
);
3199 m_aDeleteNamespaceBtn
.SetClickHdl( aLink
);
3200 m_aOKBtn
.SetClickHdl( LINK( this, NamespaceItemDialog
, OKHdl
) );
3203 SelectHdl( &m_aNamespacesList
);
3206 //------------------------------------------------------------------------
3207 NamespaceItemDialog::~NamespaceItemDialog()
3211 //------------------------------------------------------------------------
3212 IMPL_LINK( NamespaceItemDialog
, SelectHdl
, SvxSimpleTable
*, EMPTYARG
)
3214 BOOL bEnable
= ( m_aNamespacesList
.FirstSelected() != NULL
);
3215 m_aEditNamespaceBtn
.Enable( bEnable
);
3216 m_aDeleteNamespaceBtn
.Enable( bEnable
);
3221 //------------------------------------------------------------------------
3222 IMPL_LINK( NamespaceItemDialog
, ClickHdl
, PushButton
*, pBtn
)
3224 if ( &m_aAddNamespaceBtn
== pBtn
)
3226 ManageNamespaceDialog
aDlg( this, m_pConditionDlg
, false );
3227 if ( aDlg
.Execute() == RET_OK
)
3229 String sEntry
= aDlg
.GetPrefix();
3231 sEntry
+= aDlg
.GetURL();
3232 m_aNamespacesList
.InsertEntry( sEntry
);
3235 else if ( &m_aEditNamespaceBtn
== pBtn
)
3237 ManageNamespaceDialog
aDlg( this, m_pConditionDlg
, true );
3238 SvLBoxEntry
* pEntry
= m_aNamespacesList
.FirstSelected();
3239 DBG_ASSERT( pEntry
, "NamespaceItemDialog::ClickHdl(): no entry" );
3240 String
sPrefix( m_aNamespacesList
.GetEntryText( pEntry
, 0 ) );
3243 m_aNamespacesList
.GetEntryText( pEntry
, 1 ) );
3244 if ( aDlg
.Execute() == RET_OK
)
3246 // if a prefix was changed, mark the old prefix as 'removed'
3247 if( sPrefix
!= aDlg
.GetPrefix() )
3248 m_aRemovedList
.push_back( sPrefix
);
3250 m_aNamespacesList
.SetEntryText( aDlg
.GetPrefix(), pEntry
, 0 );
3251 m_aNamespacesList
.SetEntryText( aDlg
.GetURL(), pEntry
, 1 );
3254 else if ( &m_aDeleteNamespaceBtn
== pBtn
)
3256 SvLBoxEntry
* pEntry
= m_aNamespacesList
.FirstSelected();
3257 DBG_ASSERT( pEntry
, "NamespaceItemDialog::ClickHdl(): no entry" );
3258 ::rtl::OUString
sPrefix( m_aNamespacesList
.GetEntryText( pEntry
, 0 ) );
3259 m_aRemovedList
.push_back( sPrefix
);
3260 m_aNamespacesList
.GetModel()->Remove( pEntry
);
3264 DBG_ERRORFILE( "NamespaceItemDialog::ClickHdl(): invalid button" );
3267 SelectHdl( &m_aNamespacesList
);
3271 //------------------------------------------------------------------------
3272 IMPL_LINK( NamespaceItemDialog
, OKHdl
, OKButton
*, EMPTYARG
)
3276 // update namespace container
3277 sal_Int32 i
, nRemovedCount
= m_aRemovedList
.size();
3278 for( i
= 0; i
< nRemovedCount
; ++i
)
3279 m_rNamespaces
->removeByName( m_aRemovedList
[i
] );
3281 sal_Int32 nEntryCount
= m_aNamespacesList
.GetEntryCount();
3282 for( i
= 0; i
< nEntryCount
; ++i
)
3284 SvLBoxEntry
* pEntry
= m_aNamespacesList
.GetEntry(i
);
3285 ::rtl::OUString
sPrefix( m_aNamespacesList
.GetEntryText( pEntry
, 0 ) );
3286 ::rtl::OUString
sURL( m_aNamespacesList
.GetEntryText( pEntry
, 1 ) );
3288 if ( m_rNamespaces
->hasByName( sPrefix
) )
3289 m_rNamespaces
->replaceByName( sPrefix
, makeAny( sURL
) );
3291 m_rNamespaces
->insertByName( sPrefix
, makeAny( sURL
) );
3294 catch ( Exception
& )
3296 DBG_ERRORFILE( "NamespaceItemDialog::OKHdl(): exception caught" );
3298 // and close the dialog
3299 EndDialog( RET_OK
);
3303 //------------------------------------------------------------------------
3304 void NamespaceItemDialog::LoadNamespaces()
3308 Sequence
< ::rtl::OUString
> aAllNames
= m_rNamespaces
->getElementNames();
3309 const ::rtl::OUString
* pAllNames
= aAllNames
.getConstArray();
3310 const ::rtl::OUString
* pAllNamesEnd
= pAllNames
+ aAllNames
.getLength();
3311 for ( ; pAllNames
!= pAllNamesEnd
; ++pAllNames
)
3313 ::rtl::OUString sURL
;
3314 ::rtl::OUString sPrefix
= *pAllNames
;
3315 if ( m_rNamespaces
->hasByName( sPrefix
) )
3317 Any aAny
= m_rNamespaces
->getByName( sPrefix
);
3318 if ( aAny
>>= sURL
)
3320 String
sEntry( sPrefix
);
3322 sEntry
+= String( sURL
);
3324 m_aNamespacesList
.InsertEntry( sEntry
);
3329 catch ( Exception
& )
3331 DBG_ERRORFILE( "NamespaceItemDialog::LoadNamespaces(): exception caught" );
3335 //========================================================================
3336 // class ManageNamespaceDialog
3337 //========================================================================
3339 ManageNamespaceDialog::ManageNamespaceDialog(
3340 Window
* pParent
, AddConditionDialog
* _pCondDlg
, bool _bIsEdit
) :
3342 ModalDialog( pParent
, SVX_RES( RID_SVXDLG_MANAGE_NAMESPACE
) ),
3344 m_aPrefixFT ( this, SVX_RES( FT_PREFIX
) ),
3345 m_aPrefixED ( this, SVX_RES( ED_PREFIX
) ),
3346 m_aUrlFT ( this, SVX_RES( FT_URL
) ),
3347 m_aUrlED ( this, SVX_RES( ED_URL
) ),
3348 m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN
) ),
3349 m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK
) ),
3350 m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC
) ),
3351 m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP
) ),
3353 m_pConditionDlg ( _pCondDlg
)
3357 SetText( String( SVX_RES( STR_EDIT_TEXT
) ) );
3361 m_aOKBtn
.SetClickHdl( LINK( this, ManageNamespaceDialog
, OKHdl
) );
3364 //------------------------------------------------------------------------
3365 ManageNamespaceDialog::~ManageNamespaceDialog()
3369 //------------------------------------------------------------------------
3370 IMPL_LINK( ManageNamespaceDialog
, OKHdl
, OKButton
*, EMPTYARG
)
3372 String sPrefix
= m_aPrefixED
.GetText();
3376 if ( !m_pConditionDlg
->GetUIHelper()->isValidPrefixName( sPrefix
) )
3378 ErrorBox
aErrBox( this, SVX_RES( RID_ERR_INVALID_XMLPREFIX
) );
3379 String sMessText
= aErrBox
.GetMessText();
3380 sMessText
.SearchAndReplace( MSG_VARIABLE
, sPrefix
);
3381 aErrBox
.SetMessText( sMessText
);
3386 catch ( Exception
& )
3388 DBG_ERRORFILE( "ManageNamespacesDialog::OKHdl(): exception caught" );
3391 // no error so close the dialog
3392 EndDialog( RET_OK
);
3396 //========================================================================
3397 // class AddSubmissionDialog
3398 //========================================================================
3400 AddSubmissionDialog::AddSubmissionDialog(
3401 Window
* pParent
, ItemNode
* _pNode
,
3402 const Reference
< css::xforms::XFormsUIHelper1
>& _rUIHelper
) :
3404 ModalDialog( pParent
, SVX_RES( RID_SVXDLG_ADD_SUBMISSION
) ),
3406 m_aSubmissionFL ( this, SVX_RES( FL_SUBMISSION
) ),
3407 m_aNameFT ( this, SVX_RES( FT_SUBMIT_NAME
) ),
3408 m_aNameED ( this, SVX_RES( ED_SUBMIT_NAME
) ),
3409 m_aActionFT ( this, SVX_RES( FT_SUBMIT_ACTION
) ),
3410 m_aActionED ( this, SVX_RES( ED_SUBMIT_ACTION
) ),
3411 m_aMethodFT ( this, SVX_RES( FT_SUBMIT_METHOD
) ),
3412 m_aMethodLB ( this, SVX_RES( LB_SUBMIT_METHOD
) ),
3413 m_aRefFT ( this, SVX_RES( FT_SUBMIT_REF
) ),
3414 m_aRefED ( this, SVX_RES( ED_SUBMIT_REF
) ),
3415 m_aRefBtn ( this, SVX_RES( PB_SUBMIT_REF
) ),
3416 m_aBindFT ( this, SVX_RES( FT_SUBMIT_BIND
) ),
3417 m_aBindLB ( this, SVX_RES( LB_SUBMIT_BIND
) ),
3418 m_aReplaceFT ( this, SVX_RES( FT_SUBMIT_REPLACE
) ),
3419 m_aReplaceLB ( this, SVX_RES( LB_SUBMIT_REPLACE
) ),
3421 m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN
) ),
3422 m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK
) ),
3423 m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC
) ),
3424 m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP
) ),
3426 m_pItemNode ( _pNode
),
3427 m_xUIHelper ( _rUIHelper
)
3430 FillAllBoxes(); // we need local resources here, so call before FreeResource!!!
3434 m_aRefBtn
.SetClickHdl( LINK( this, AddSubmissionDialog
, RefHdl
) );
3435 m_aOKBtn
.SetClickHdl( LINK( this, AddSubmissionDialog
, OKHdl
) );
3438 //------------------------------------------------------------------------
3439 AddSubmissionDialog::~AddSubmissionDialog()
3441 // #i38991# if we have added a binding, we need to remove it as well.
3442 if( m_xCreatedBinding
.is() && m_xUIHelper
.is() )
3443 m_xUIHelper
->removeBindingIfUseless( m_xCreatedBinding
);
3446 //------------------------------------------------------------------------
3447 IMPL_LINK( AddSubmissionDialog
, RefHdl
, PushButton
*, EMPTYARG
)
3449 AddConditionDialog
aDlg( this, PN_BINDING_EXPR
, m_xTempBinding
);
3450 aDlg
.SetCondition( m_aRefED
.GetText() );
3451 if ( aDlg
.Execute() == RET_OK
)
3452 m_aRefED
.SetText( aDlg
.GetCondition() );
3457 //------------------------------------------------------------------------
3458 IMPL_LINK( AddSubmissionDialog
, OKHdl
, OKButton
*, EMPTYARG
)
3460 rtl::OUString
sName(m_aNameED
.GetText());
3461 if(!sName
.getLength()) {
3463 ErrorBox
aErrorBox(this,SVX_RES(RID_ERR_EMPTY_SUBMISSIONNAME
));
3464 aErrorBox
.SetText( Application::GetDisplayName() );
3465 aErrorBox
.Execute();
3469 if ( !m_xSubmission
.is() )
3471 DBG_ASSERT( !m_xNewSubmission
.is(),
3472 "AddSubmissionDialog::OKHdl(): new submission already exists" );
3474 // add a new submission
3475 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
3480 m_xNewSubmission
= xModel
->createSubmission();
3481 m_xSubmission
= Reference
< XPropertySet
>( m_xNewSubmission
, UNO_QUERY
);
3483 catch ( Exception
& )
3485 DBG_ERRORFILE( "AddSubmissionDialog::OKHdl(): exception caught" );
3490 if ( m_xSubmission
.is() )
3492 rtl::OUString sTemp
= m_aNameED
.GetText();
3495 m_xSubmission
->setPropertyValue( PN_SUBMISSION_ID
, makeAny( sTemp
) );
3496 sTemp
= m_aActionED
.GetText();
3497 m_xSubmission
->setPropertyValue( PN_SUBMISSION_ACTION
, makeAny( sTemp
) );
3498 sTemp
= lcl_MethodString::get().toAPI( m_aMethodLB
.GetSelectEntry() );
3499 m_xSubmission
->setPropertyValue( PN_SUBMISSION_METHOD
, makeAny( sTemp
) );
3500 sTemp
= m_aRefED
.GetText();
3501 m_xSubmission
->setPropertyValue( PN_SUBMISSION_REF
, makeAny( sTemp
) );
3502 String sEntry
= m_aBindLB
.GetSelectEntry();
3503 sEntry
.Erase( sEntry
.Search( ':' ) );
3505 m_xSubmission
->setPropertyValue( PN_SUBMISSION_BIND
, makeAny( sTemp
) );
3506 sTemp
= lcl_ReplaceString::get().toAPI( m_aReplaceLB
.GetSelectEntry() );
3507 m_xSubmission
->setPropertyValue( PN_SUBMISSION_REPLACE
, makeAny( sTemp
) );
3509 catch ( Exception
& )
3511 DBG_ERRORFILE( "AddSubmissionDialog::OKHdl(): exception caught" );
3515 EndDialog( RET_OK
);
3519 //------------------------------------------------------------------------
3520 void AddSubmissionDialog::FillAllBoxes()
3523 m_aMethodLB
.InsertEntry( String( SVX_RES( STR_METHOD_POST
) ) );
3524 m_aMethodLB
.InsertEntry( String( SVX_RES( STR_METHOD_PUT
) ) );
3525 m_aMethodLB
.InsertEntry( String( SVX_RES( STR_METHOD_GET
) ) );
3526 m_aMethodLB
.SelectEntryPos(0);
3529 Reference
< css::xforms::XModel
> xModel( m_xUIHelper
, UNO_QUERY
);
3534 Reference
< XEnumerationAccess
> xNumAccess( xModel
->getBindings(), UNO_QUERY
);
3535 if ( xNumAccess
.is() )
3537 Reference
< XEnumeration
> xNum
= xNumAccess
->createEnumeration();
3538 if ( xNum
.is() && xNum
->hasMoreElements() )
3540 String
sDelim( RTL_CONSTASCII_STRINGPARAM( ": " ) );
3541 while ( xNum
->hasMoreElements() )
3543 Reference
< XPropertySet
> xPropSet
;
3544 Any aAny
= xNum
->nextElement();
3545 if ( aAny
>>= xPropSet
)
3548 rtl::OUString sTemp
;
3549 xPropSet
->getPropertyValue( PN_BINDING_ID
) >>= sTemp
;
3550 sEntry
+= String( sTemp
);
3552 xPropSet
->getPropertyValue( PN_BINDING_EXPR
) >>= sTemp
;
3553 sEntry
+= String( sTemp
);
3554 m_aBindLB
.InsertEntry( sEntry
);
3556 if ( !m_xTempBinding
.is() )
3557 m_xTempBinding
= xPropSet
;
3563 catch ( Exception
& )
3565 DBG_ERRORFILE( "AddSubmissionDialog::FillAllBoxes(): exception caught" );
3569 // #i36342# we need a temporary binding; create one if no existing binding
3571 if( !m_xTempBinding
.is() )
3573 m_xCreatedBinding
= m_xUIHelper
->getBindingForNode(
3574 Reference
<css::xml::dom::XNode
>(
3575 xModel
->getDefaultInstance()->getDocumentElement(),
3578 m_xTempBinding
= m_xCreatedBinding
;
3582 m_aReplaceLB
.InsertEntry( String( SVX_RES( STR_REPLACE_NONE
) ) );
3583 m_aReplaceLB
.InsertEntry( String( SVX_RES( STR_REPLACE_INST
) ) );
3584 m_aReplaceLB
.InsertEntry( String( SVX_RES( STR_REPLACE_DOC
) ) );
3587 // init the controls with the values of the submission
3588 if ( m_pItemNode
&& m_pItemNode
->m_xPropSet
.is() )
3590 m_xSubmission
= m_pItemNode
->m_xPropSet
;
3591 rtl::OUString sTemp
;
3594 m_xSubmission
->getPropertyValue( PN_SUBMISSION_ID
) >>= sTemp
;
3595 m_aNameED
.SetText( sTemp
);
3596 m_xSubmission
->getPropertyValue( PN_SUBMISSION_ACTION
) >>= sTemp
;
3597 m_aActionED
.SetText( sTemp
);
3598 m_xSubmission
->getPropertyValue( PN_SUBMISSION_REF
) >>= sTemp
;
3599 m_aRefED
.SetText( sTemp
);
3601 m_xSubmission
->getPropertyValue( PN_SUBMISSION_METHOD
) >>= sTemp
;
3602 sTemp
= lcl_MethodString::get().toUI( sTemp
);
3603 USHORT nPos
= m_aMethodLB
.GetEntryPos( String( sTemp
) );
3604 if ( LISTBOX_ENTRY_NOTFOUND
== nPos
)
3605 nPos
= m_aMethodLB
.InsertEntry( sTemp
);
3606 m_aMethodLB
.SelectEntryPos( nPos
);
3608 m_xSubmission
->getPropertyValue( PN_SUBMISSION_BIND
) >>= sTemp
;
3609 nPos
= m_aBindLB
.GetEntryPos( String( sTemp
) );
3610 if ( LISTBOX_ENTRY_NOTFOUND
== nPos
)
3611 nPos
= m_aBindLB
.InsertEntry( sTemp
);
3612 m_aBindLB
.SelectEntryPos( nPos
);
3614 m_xSubmission
->getPropertyValue( PN_SUBMISSION_REPLACE
) >>= sTemp
;
3615 sTemp
= lcl_ReplaceString::get().toUI( sTemp
);
3616 if ( sTemp
.getLength() == 0 )
3617 sTemp
= m_aReplaceLB
.GetEntry(0); // first entry == "none"
3618 nPos
= m_aReplaceLB
.GetEntryPos( String( sTemp
) );
3619 if ( LISTBOX_ENTRY_NOTFOUND
== nPos
)
3620 nPos
= m_aReplaceLB
.InsertEntry( sTemp
);
3621 m_aReplaceLB
.SelectEntryPos( nPos
);
3623 catch ( Exception
& )
3625 DBG_ERRORFILE( "AddSubmissionDialog::FillAllBoxes(): exception caught" );
3629 m_aRefBtn
.Enable( m_xTempBinding
.is() );
3632 //========================================================================
3633 // class AddModelDialog
3634 //========================================================================
3636 AddModelDialog::AddModelDialog( Window
* pParent
, bool _bEdit
) :
3638 ModalDialog( pParent
, SVX_RES( RID_SVXDLG_ADD_MODEL
) ),
3640 m_aModelFL ( this, SVX_RES( FL_MODEL
) ),
3641 m_aNameFT ( this, SVX_RES( FT_MODEL_NAME
) ),
3642 m_aNameED ( this, SVX_RES( ED_MODEL_NAME
) ),
3643 m_aModifyCB ( this, SVX_RES( CB_MODIFIES_DOCUMENT
) ),
3644 m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN
) ),
3645 m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK
) ),
3646 m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC
) ),
3647 m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP
) )
3651 SetText( String( SVX_RES( STR_EDIT_TEXT
) ) );
3656 AddModelDialog::~AddModelDialog()
3660 //========================================================================
3661 // class AddInstanceDialog
3662 //========================================================================
3664 AddInstanceDialog::AddInstanceDialog( Window
* pParent
, bool _bEdit
) :
3666 ModalDialog( pParent
, SVX_RES( RID_SVXDLG_ADD_INSTANCE
) ),
3668 m_aInstanceFL ( this, SVX_RES( FL_INSTANCE
) ),
3669 m_aNameFT ( this, SVX_RES( FT_INST_NAME
) ),
3670 m_aNameED ( this, SVX_RES( ED_INST_NAME
) ),
3671 m_aURLFT ( this, SVX_RES( FT_INST_URL
) ),
3672 m_aURLED ( this, SVX_RES( ED_INST_URL
) ),
3673 m_aFilePickerBtn ( this, SVX_RES( PB_FILEPICKER
) ),
3674 m_aLinkInstanceCB ( this, SVX_RES( CB_INST_LINKINST
) ),
3675 m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN
) ),
3676 m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK
) ),
3677 m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC
) ),
3678 m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP
) )
3682 SetText( String( SVX_RES( STR_EDIT_TEXT
) ) );
3686 m_aURLED
.DisableHistory();
3687 m_aFilePickerBtn
.SetClickHdl( LINK( this, AddInstanceDialog
, FilePickerHdl
) );
3689 // load the filter name from svtools resource
3690 ByteString
aResMgrName( "svt" );
3691 ResMgr
* pSvtResMgr
= ResMgr::CreateResMgr(
3692 aResMgrName
.GetBuffer(), Application::GetSettings().GetUILocale() );
3693 m_sAllFilterName
= String( ResId( STR_FILTERNAME_ALL
, *pSvtResMgr
) );
3696 AddInstanceDialog::~AddInstanceDialog()
3700 //------------------------------------------------------------------------
3701 IMPL_LINK( AddInstanceDialog
, FilePickerHdl
, PushButton
*, EMPTYARG
)
3703 ::sfx2::FileDialogHelper
aDlg(
3704 css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
, 0 );
3705 INetURLObject
aFile( SvtPathOptions().GetWorkPath() );
3707 aDlg
.AddFilter( m_sAllFilterName
, DEFINE_CONST_UNICODE(FILEDIALOG_FILTER_ALL
) );
3708 String
sFilterName( DEFINE_CONST_UNICODE("XML") );
3709 aDlg
.AddFilter( sFilterName
, DEFINE_CONST_UNICODE("*.xml") );
3710 aDlg
.SetCurrentFilter( sFilterName
);
3711 aDlg
.SetDisplayDirectory( aFile
.GetMainURL( INetURLObject::NO_DECODE
) );
3713 if( aDlg
.Execute() == ERRCODE_NONE
)
3714 m_aURLED
.SetText( aDlg
.GetPath() );
3719 //========================================================================
3720 // class LinkedInstanceWarningBox
3721 //========================================================================
3723 LinkedInstanceWarningBox::LinkedInstanceWarningBox( Window
* pParent
) :
3725 MessBox( pParent
, SVX_RES( RID_QRY_LINK_WARNING
) )
3728 SetText( Application::GetDisplayName() );
3729 SetImage( QueryBox::GetStandardImage() );
3730 AddButton( SVX_RESSTR( RID_STR_DATANAV_LINKWARN_BUTTON
), BUTTONID_OK
, BUTTONDIALOG_DEFBUTTON
);
3731 AddButton( BUTTON_CANCEL
, BUTTONID_CANCEL
, BUTTONDIALOG_CANCELBUTTON
);
3734 //............................................................................
3735 } // namespace svxform
3736 //............................................................................