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