LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/form - datanavi.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 1884 0.1 %
Date: 2013-07-09 Functions: 3 151 2.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10