LCOV - code coverage report
Current view: top level - libreoffice/basctl/source/basicide - baside3.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 778 0.0 %
Date: 2012-12-17 Functions: 0 69 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "basidesh.hrc"
      21             : #include "helpid.hrc"
      22             : 
      23             : #include "accessibledialogwindow.hxx"
      24             : #include "baside3.hxx"
      25             : #include "basidesh.hxx"
      26             : #include "bastype2.hxx"
      27             : #include "dlged.hxx"
      28             : #include "dlgeddef.hxx"
      29             : #include "dlgedmod.hxx"
      30             : #include "dlgedview.hxx"
      31             : #include "iderdll.hxx"
      32             : #include "idetemp.hxx"
      33             : #include "localizationmgr.hxx"
      34             : #include "propbrw.hxx"
      35             : #include "objdlg.hxx"
      36             : 
      37             : #include <basic/basmgr.hxx>
      38             : #include <com/sun/star/resource/StringResourceWithLocation.hpp>
      39             : #include <com/sun/star/ucb/SimpleFileAccess.hpp>
      40             : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
      41             : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
      42             : #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
      43             : #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
      44             : #include <comphelper/processfactory.hxx>
      45             : #include <sfx2/dinfdlg.hxx>
      46             : #include <sfx2/dispatch.hxx>
      47             : #include <sfx2/request.hxx>
      48             : #include <svl/aeitem.hxx>
      49             : #include <svl/visitem.hxx>
      50             : #include <svl/whiter.hxx>
      51             : #include <tools/diagnose_ex.h>
      52             : #include <tools/urlobj.hxx>
      53             : #include <vcl/msgbox.hxx>
      54             : #include <xmlscript/xmldlg_imexp.hxx>
      55             : 
      56             : namespace basctl
      57             : {
      58             : 
      59             : using namespace ::com::sun::star;
      60             : using namespace ::com::sun::star::uno;
      61             : using namespace ::com::sun::star::ucb;
      62             : using namespace ::com::sun::star::io;
      63             : using namespace ::com::sun::star::resource;
      64             : using namespace ::com::sun::star::ui::dialogs;
      65             : 
      66             : #if defined(UNX)
      67             : char const FilterMask_All[] = "*";
      68             : #else
      69             : char const FilterMask_All[] = "*.*";
      70             : #endif
      71             : 
      72             : DBG_NAME( DialogWindow )
      73             : 
      74           0 : TYPEINIT1( DialogWindow, BaseWindow );
      75             : 
      76           0 : DialogWindow::DialogWindow (
      77             :     DialogWindowLayout* pParent,
      78             :     ScriptDocument const& rDocument,
      79             :     OUString aLibName, OUString aName,
      80             :     com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> const& xDialogModel
      81             : ) :
      82             :     BaseWindow(pParent, rDocument, aLibName, aName),
      83             :     rLayout(*pParent),
      84           0 :     pEditor(new DlgEditor(*this, rLayout, rDocument.isDocument() ? rDocument.getDocument() : Reference<frame::XModel>(), xDialogModel)),
      85           0 :     pUndoMgr(new SfxUndoManager)
      86             : {
      87           0 :     InitSettings( true, true, true );
      88             : 
      89           0 :     aOldNotifyUndoActionHdl = pEditor->GetModel().GetNotifyUndoActionHdl();
      90           0 :     pEditor->GetModel().SetNotifyUndoActionHdl(
      91             :         LINK(this, DialogWindow, NotifyUndoActionHdl)
      92           0 :     );
      93             : 
      94           0 :     SetHelpId( HID_BASICIDE_DIALOGWINDOW );
      95             : 
      96             :     // set readonly mode for readonly libraries
      97           0 :     Reference< script::XLibraryContainer2 > xDlgLibContainer( GetDocument().getLibraryContainer( E_DIALOGS ), UNO_QUERY );
      98           0 :     if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) )
      99           0 :         SetReadOnly(true);
     100             : 
     101           0 :     if ( rDocument.isDocument() && rDocument.isReadOnly() )
     102           0 :         SetReadOnly(true);
     103           0 : }
     104             : 
     105           0 : DialogWindow::~DialogWindow()
     106           0 : { }
     107             : 
     108           0 : void DialogWindow::LoseFocus()
     109             : {
     110           0 :     if ( IsModified() )
     111           0 :         StoreData();
     112             : 
     113           0 :     Window::LoseFocus();
     114           0 : }
     115             : 
     116             : 
     117             : 
     118           0 : void DialogWindow::Paint( const Rectangle& rRect )
     119             : {
     120           0 :     pEditor->Paint( rRect );
     121           0 : }
     122             : 
     123             : 
     124             : 
     125           0 : void DialogWindow::Resize()
     126             : {
     127           0 :     if ( GetHScrollBar() && GetVScrollBar() ) {
     128           0 :         pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
     129             :     }
     130           0 : }
     131             : 
     132             : 
     133             : 
     134           0 : void DialogWindow::MouseButtonDown( const MouseEvent& rMEvt )
     135             : {
     136           0 :     pEditor->MouseButtonDown( rMEvt );
     137             : 
     138           0 :     if (SfxBindings* pBindings = GetBindingsPtr())
     139           0 :         pBindings->Invalidate( SID_SHOW_PROPERTYBROWSER );
     140           0 : }
     141             : 
     142             : 
     143             : 
     144           0 : void DialogWindow::MouseButtonUp( const MouseEvent& rMEvt )
     145             : {
     146           0 :     pEditor->MouseButtonUp( rMEvt );
     147           0 :     if( (pEditor->GetMode() == DlgEditor::INSERT) && !pEditor->IsCreateOK() )
     148             :     {
     149           0 :         pEditor->SetMode( DlgEditor::SELECT );
     150           0 :         if (SfxBindings* pBindings = GetBindingsPtr())
     151           0 :             pBindings->Invalidate( SID_CHOOSE_CONTROLS );
     152             :     }
     153           0 :     if (SfxBindings* pBindings = GetBindingsPtr())
     154             :     {
     155           0 :         pBindings->Invalidate( SID_SHOW_PROPERTYBROWSER );
     156           0 :         pBindings->Invalidate( SID_DOC_MODIFIED );
     157           0 :         pBindings->Invalidate( SID_SAVEDOC );
     158             :     }
     159           0 : }
     160             : 
     161             : 
     162             : 
     163           0 : void DialogWindow::MouseMove( const MouseEvent& rMEvt )
     164             : {
     165           0 :     pEditor->MouseMove( rMEvt );
     166           0 : }
     167             : 
     168             : 
     169             : 
     170           0 : void DialogWindow::KeyInput( const KeyEvent& rKEvt )
     171             : {
     172           0 :     if( rKEvt.GetKeyCode() == KEY_BACKSPACE )
     173             :     {
     174           0 :         if (SfxDispatcher* pDispatcher = GetDispatcher())
     175           0 :             pDispatcher->Execute( SID_BACKSPACE );
     176             :     }
     177             :     else
     178             :     {
     179           0 :         if (rKEvt.GetKeyCode() == KEY_TAB)
     180           0 :             if (SfxBindings* pBindings = GetBindingsPtr())
     181           0 :                 pBindings->Invalidate( SID_SHOW_PROPERTYBROWSER );
     182             : 
     183           0 :         if( !pEditor->KeyInput( rKEvt ) )
     184             :         {
     185           0 :             if( !SfxViewShell::Current()->KeyInput( rKEvt ) )
     186           0 :                 Window::KeyInput( rKEvt );
     187             :         }
     188             :     }
     189           0 : }
     190             : 
     191           0 : void DialogWindow::Command( const CommandEvent& rCEvt )
     192             : {
     193           0 :     if ( ( rCEvt.GetCommand() == COMMAND_WHEEL           ) ||
     194           0 :          ( rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL ) ||
     195           0 :          ( rCEvt.GetCommand() == COMMAND_AUTOSCROLL      ) )
     196             :     {
     197           0 :         HandleScrollCommand( rCEvt, GetHScrollBar(), GetVScrollBar() );
     198             :     }
     199           0 :     else if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
     200             :     {
     201           0 :         if (SfxDispatcher* pDispatcher = GetDispatcher())
     202             :         {
     203           0 :             SdrView& rView = GetView();
     204           0 :             if( !rCEvt.IsMouseEvent() && rView.AreObjectsMarked() )
     205             :             {
     206           0 :                 Rectangle aMarkedRect( rView.GetMarkedRect() );
     207           0 :                 Point MarkedCenter( aMarkedRect.Center() );
     208           0 :                 Point PosPixel( LogicToPixel( MarkedCenter ) );
     209           0 :                 pDispatcher->ExecutePopup( IDEResId(RID_POPUP_DLGED), this, &PosPixel );
     210             :             }
     211             :             else
     212             :             {
     213           0 :                 pDispatcher->ExecutePopup( IDEResId(RID_POPUP_DLGED) );
     214             :             }
     215             : 
     216             :         }
     217             :     }
     218             :     else
     219           0 :         BaseWindow::Command( rCEvt );
     220           0 : }
     221             : 
     222             : 
     223             : 
     224             : 
     225           0 : IMPL_LINK( DialogWindow, NotifyUndoActionHdl, SfxUndoAction *, pUndoAction )
     226             : {
     227             :     (void)pUndoAction;
     228             : 
     229           0 :     return 0;
     230             : }
     231             : 
     232             : 
     233             : 
     234           0 : void DialogWindow::DoInit()
     235             : {
     236           0 :     GetHScrollBar()->Show();
     237           0 :     GetVScrollBar()->Show();
     238           0 :     pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
     239           0 : }
     240             : 
     241             : 
     242             : 
     243           0 : void DialogWindow::DoScroll( ScrollBar* pCurScrollBar )
     244             : {
     245           0 :     pEditor->DoScroll( pCurScrollBar );
     246           0 : }
     247             : 
     248           0 : void DialogWindow::GetState( SfxItemSet& rSet )
     249             : {
     250           0 :     SfxWhichIter aIter(rSet);
     251           0 :     bool bIsCalc = false;
     252           0 :     if ( GetDocument().isDocument() )
     253             :     {
     254           0 :         Reference< frame::XModel > xModel= GetDocument().getDocument();
     255           0 :         if ( xModel.is() )
     256             :         {
     257           0 :             Reference< lang::XServiceInfo > xServiceInfo ( xModel, UNO_QUERY );
     258           0 :             if ( xServiceInfo.is() && xServiceInfo->supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
     259           0 :                 bIsCalc = true;
     260           0 :         }
     261             :     }
     262             : 
     263           0 :     for ( sal_uInt16 nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich() )
     264             :     {
     265           0 :         switch ( nWh )
     266             :         {
     267             :             case SID_PASTE:
     268             :             {
     269           0 :                 if ( !IsPasteAllowed() )
     270           0 :                     rSet.DisableItem( nWh );
     271             : 
     272           0 :                 if ( IsReadOnly() )
     273           0 :                     rSet.DisableItem( nWh );
     274             :             }
     275           0 :             break;
     276             :             case SID_COPY:
     277             :             {
     278             :                 // any object selected?
     279           0 :                 if ( !pEditor->GetView().AreObjectsMarked() )
     280           0 :                     rSet.DisableItem( nWh );
     281             :             }
     282           0 :             break;
     283             :             case SID_CUT:
     284             :             case SID_DELETE:
     285             :             case SID_BACKSPACE:
     286             :             {
     287             :                 // any object selected?
     288           0 :                 if ( !pEditor->GetView().AreObjectsMarked() )
     289           0 :                     rSet.DisableItem( nWh );
     290             : 
     291           0 :                 if ( IsReadOnly() )
     292           0 :                     rSet.DisableItem( nWh );
     293             :             }
     294           0 :             break;
     295             :             case SID_REDO:
     296             :             {
     297           0 :                 if ( !pUndoMgr->GetUndoActionCount() )
     298           0 :                     rSet.DisableItem( nWh );
     299             :             }
     300           0 :             break;
     301             : 
     302             :             case SID_DIALOG_TESTMODE:
     303             :             {
     304             :                 // is the IDE still active?
     305           0 :                 bool const bBool = GetShell()->GetFrame() &&
     306           0 :                     pEditor->GetMode() == DlgEditor::TEST;
     307           0 :                 rSet.Put(SfxBoolItem(SID_DIALOG_TESTMODE, bBool));
     308             :             }
     309           0 :             break;
     310             : 
     311             :             case SID_CHOOSE_CONTROLS:
     312             :             {
     313           0 :                 if ( IsReadOnly() )
     314             :                 {
     315           0 :                     rSet.DisableItem( nWh );
     316             :                 }
     317             :                 else
     318             :                 {
     319           0 :                     SfxAllEnumItem aItem( SID_CHOOSE_CONTROLS );
     320           0 :                     if ( GetEditor().GetMode() == DlgEditor::SELECT )
     321           0 :                         aItem.SetValue( SVX_SNAP_SELECT );
     322             :                     else
     323             :                     {
     324             :                         sal_uInt16 nObj;
     325           0 :                         switch( pEditor->GetInsertObj() )
     326             :                         {
     327           0 :                             case OBJ_DLG_PUSHBUTTON:        nObj = SVX_SNAP_PUSHBUTTON; break;
     328           0 :                             case OBJ_DLG_RADIOBUTTON:       nObj = SVX_SNAP_RADIOBUTTON; break;
     329           0 :                             case OBJ_DLG_CHECKBOX:          nObj = SVX_SNAP_CHECKBOX; break;
     330           0 :                             case OBJ_DLG_LISTBOX:           nObj = SVX_SNAP_LISTBOX; break;
     331           0 :                             case OBJ_DLG_COMBOBOX:          nObj = SVX_SNAP_COMBOBOX; break;
     332           0 :                             case OBJ_DLG_GROUPBOX:          nObj = SVX_SNAP_GROUPBOX; break;
     333           0 :                             case OBJ_DLG_EDIT:              nObj = SVX_SNAP_EDIT; break;
     334           0 :                             case OBJ_DLG_FIXEDTEXT:         nObj = SVX_SNAP_FIXEDTEXT; break;
     335           0 :                             case OBJ_DLG_IMAGECONTROL:      nObj = SVX_SNAP_IMAGECONTROL; break;
     336           0 :                             case OBJ_DLG_PROGRESSBAR:       nObj = SVX_SNAP_PROGRESSBAR; break;
     337           0 :                             case OBJ_DLG_HSCROLLBAR:        nObj = SVX_SNAP_HSCROLLBAR; break;
     338           0 :                             case OBJ_DLG_VSCROLLBAR:        nObj = SVX_SNAP_VSCROLLBAR; break;
     339           0 :                             case OBJ_DLG_HFIXEDLINE:        nObj = SVX_SNAP_HFIXEDLINE; break;
     340           0 :                             case OBJ_DLG_VFIXEDLINE:        nObj = SVX_SNAP_VFIXEDLINE; break;
     341           0 :                             case OBJ_DLG_DATEFIELD:         nObj = SVX_SNAP_DATEFIELD; break;
     342           0 :                             case OBJ_DLG_TIMEFIELD:         nObj = SVX_SNAP_TIMEFIELD; break;
     343           0 :                             case OBJ_DLG_NUMERICFIELD:      nObj = SVX_SNAP_NUMERICFIELD; break;
     344           0 :                             case OBJ_DLG_CURRENCYFIELD:     nObj = SVX_SNAP_CURRENCYFIELD; break;
     345           0 :                             case OBJ_DLG_FORMATTEDFIELD:    nObj = SVX_SNAP_FORMATTEDFIELD; break;
     346           0 :                             case OBJ_DLG_PATTERNFIELD:      nObj = SVX_SNAP_PATTERNFIELD; break;
     347           0 :                             case OBJ_DLG_FILECONTROL:       nObj = SVX_SNAP_FILECONTROL; break;
     348           0 :                             case OBJ_DLG_SPINBUTTON:        nObj = SVX_SNAP_SPINBUTTON; break;
     349           0 :                             case OBJ_DLG_TREECONTROL:       nObj = SVX_SNAP_TREECONTROL; break;
     350           0 :                             default:                        nObj = 0;
     351             :                         }
     352             : #ifdef DBG_UTIL
     353             :                         if( !nObj )
     354             :                         {
     355             :                             DBG_WARNING( "SID_CHOOSE_CONTROLS: Unbekannt!" );
     356             :                         }
     357             : #endif
     358           0 :                         aItem.SetValue( nObj );
     359             :                     }
     360             : 
     361           0 :                     rSet.Put( aItem );
     362             :                 }
     363             :             }
     364           0 :             break;
     365             : 
     366             :             case SID_SHOW_PROPERTYBROWSER:
     367             :             {
     368           0 :                 Shell* pShell = GetShell();
     369           0 :                 SfxViewFrame* pViewFrame = pShell ? pShell->GetViewFrame() : NULL;
     370           0 :                 if ( pViewFrame && !pViewFrame->HasChildWindow( SID_SHOW_PROPERTYBROWSER ) && !pEditor->GetView().AreObjectsMarked() )
     371           0 :                     rSet.DisableItem( nWh );
     372             : 
     373           0 :                 if ( IsReadOnly() )
     374           0 :                     rSet.DisableItem( nWh );
     375             :             }
     376           0 :             break;
     377             :             case SID_INSERT_FORM_RADIO:
     378             :             case SID_INSERT_FORM_CHECK:
     379             :             case SID_INSERT_FORM_LIST:
     380             :             case SID_INSERT_FORM_COMBO:
     381             :             case SID_INSERT_FORM_VSCROLL:
     382             :             case SID_INSERT_FORM_HSCROLL:
     383             :             case SID_INSERT_FORM_SPIN:
     384             :             {
     385           0 :                 if ( !bIsCalc || IsReadOnly() )
     386           0 :                     rSet.DisableItem( nWh );
     387             :             }
     388           0 :             break;
     389             :             case SID_SHOWLINES:
     390             :             {
     391             :                 // if this is not a module window hide the
     392             :                 // setting, doesn't make sense for example if the
     393             :                 // dialog editor is open
     394           0 :                 rSet.DisableItem(nWh);
     395           0 :                 rSet.Put(SfxVisibilityItem(nWh, false));
     396           0 :                 break;
     397             :             }
     398             :         }
     399           0 :     }
     400           0 : }
     401             : 
     402           0 : void DialogWindow::ExecuteCommand( SfxRequest& rReq )
     403             : {
     404           0 :     switch ( rReq.GetSlot() )
     405             :     {
     406             :         case SID_CUT:
     407           0 :             if ( !IsReadOnly() )
     408             :             {
     409           0 :                 GetEditor().Cut();
     410           0 :                 if (SfxBindings* pBindings = GetBindingsPtr())
     411           0 :                     pBindings->Invalidate( SID_DOC_MODIFIED );
     412             :             }
     413           0 :             break;
     414             :         case SID_DELETE:
     415           0 :             if ( !IsReadOnly() )
     416             :             {
     417           0 :                 GetEditor().Delete();
     418           0 :                 if (SfxBindings* pBindings = GetBindingsPtr())
     419           0 :                     pBindings->Invalidate( SID_DOC_MODIFIED );
     420             :             }
     421           0 :             break;
     422             :         case SID_COPY:
     423           0 :             GetEditor().Copy();
     424           0 :             break;
     425             :         case SID_PASTE:
     426           0 :             if ( !IsReadOnly() )
     427             :             {
     428           0 :                 GetEditor().Paste();
     429           0 :                 if (SfxBindings* pBindings = GetBindingsPtr())
     430           0 :                     pBindings->Invalidate( SID_DOC_MODIFIED );
     431             :             }
     432           0 :             break;
     433             :         case SID_INSERT_FORM_RADIO:
     434           0 :             GetEditor().SetMode( DlgEditor::INSERT );
     435           0 :             GetEditor().SetInsertObj( OBJ_DLG_FORMRADIO );
     436           0 :             break;
     437             :         case SID_INSERT_FORM_CHECK:
     438           0 :             GetEditor().SetMode( DlgEditor::INSERT );
     439           0 :             GetEditor().SetInsertObj( OBJ_DLG_FORMCHECK );
     440           0 :             break;
     441             :         case SID_INSERT_FORM_LIST:
     442           0 :             GetEditor().SetMode( DlgEditor::INSERT );
     443           0 :             GetEditor().SetInsertObj( OBJ_DLG_FORMLIST );
     444           0 :             break;
     445             :         case SID_INSERT_FORM_COMBO:
     446           0 :             GetEditor().SetMode( DlgEditor::INSERT );
     447           0 :             GetEditor().SetInsertObj( OBJ_DLG_FORMCOMBO );
     448           0 :             break;
     449             :         case SID_INSERT_FORM_SPIN:
     450           0 :             GetEditor().SetMode( DlgEditor::INSERT );
     451           0 :             GetEditor().SetInsertObj( OBJ_DLG_FORMSPIN );
     452           0 :             break;
     453             :         case SID_INSERT_FORM_VSCROLL:
     454           0 :             GetEditor().SetMode( DlgEditor::INSERT );
     455           0 :             GetEditor().SetInsertObj( OBJ_DLG_FORMVSCROLL );
     456           0 :             break;
     457             :         case SID_INSERT_FORM_HSCROLL:
     458           0 :             GetEditor().SetMode( DlgEditor::INSERT );
     459           0 :             GetEditor().SetInsertObj( OBJ_DLG_FORMHSCROLL );
     460           0 :             break;
     461             :         case SID_CHOOSE_CONTROLS:
     462             :         {
     463           0 :             const SfxItemSet* pArgs = rReq.GetArgs();
     464             :             DBG_ASSERT( pArgs, "Nix Args" );
     465             : 
     466           0 :             const SfxAllEnumItem& rItem = (SfxAllEnumItem&)pArgs->Get( SID_CHOOSE_CONTROLS );
     467           0 :             switch( rItem.GetValue() )
     468             :             {
     469             :                 case SVX_SNAP_PUSHBUTTON:
     470             :                 {
     471           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     472           0 :                     GetEditor().SetInsertObj( OBJ_DLG_PUSHBUTTON );
     473             :                 }
     474           0 :                 break;
     475             :                 case SVX_SNAP_RADIOBUTTON:
     476             :                 {
     477           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     478           0 :                     GetEditor().SetInsertObj( OBJ_DLG_RADIOBUTTON );
     479             :                 }
     480           0 :                 break;
     481             :                 case SVX_SNAP_CHECKBOX:
     482             :                 {
     483           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     484           0 :                     GetEditor().SetInsertObj( OBJ_DLG_CHECKBOX);
     485             :                 }
     486           0 :                 break;
     487             :                 case SVX_SNAP_LISTBOX:
     488             :                 {
     489           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     490           0 :                     GetEditor().SetInsertObj( OBJ_DLG_LISTBOX );
     491             :                 }
     492           0 :                 break;
     493             :                 case SVX_SNAP_COMBOBOX:
     494             :                 {
     495           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     496           0 :                     GetEditor().SetInsertObj( OBJ_DLG_COMBOBOX );
     497             :                 }
     498           0 :                 break;
     499             :                 case SVX_SNAP_GROUPBOX:
     500             :                 {
     501           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     502           0 :                     GetEditor().SetInsertObj( OBJ_DLG_GROUPBOX );
     503             :                 }
     504           0 :                 break;
     505             :                 case SVX_SNAP_EDIT:
     506             :                 {
     507           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     508           0 :                     GetEditor().SetInsertObj( OBJ_DLG_EDIT );
     509             :                 }
     510           0 :                 break;
     511             :                 case SVX_SNAP_FIXEDTEXT:
     512             :                 {
     513           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     514           0 :                     GetEditor().SetInsertObj( OBJ_DLG_FIXEDTEXT );
     515             :                 }
     516           0 :                 break;
     517             :                 case SVX_SNAP_IMAGECONTROL:
     518             :                 {
     519           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     520           0 :                     GetEditor().SetInsertObj( OBJ_DLG_IMAGECONTROL );
     521             :                 }
     522           0 :                 break;
     523             :                 case SVX_SNAP_PROGRESSBAR:
     524             :                 {
     525           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     526           0 :                     GetEditor().SetInsertObj( OBJ_DLG_PROGRESSBAR );
     527             :                 }
     528           0 :                 break;
     529             :                 case SVX_SNAP_HSCROLLBAR:
     530             :                 {
     531           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     532           0 :                     GetEditor().SetInsertObj( OBJ_DLG_HSCROLLBAR );
     533             :                 }
     534           0 :                 break;
     535             :                 case SVX_SNAP_VSCROLLBAR:
     536             :                 {
     537           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     538           0 :                     GetEditor().SetInsertObj( OBJ_DLG_VSCROLLBAR );
     539             :                 }
     540           0 :                 break;
     541             :                 case SVX_SNAP_HFIXEDLINE:
     542             :                 {
     543           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     544           0 :                     GetEditor().SetInsertObj( OBJ_DLG_HFIXEDLINE );
     545             :                 }
     546           0 :                 break;
     547             :                 case SVX_SNAP_VFIXEDLINE:
     548             :                 {
     549           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     550           0 :                     GetEditor().SetInsertObj( OBJ_DLG_VFIXEDLINE );
     551             :                 }
     552           0 :                 break;
     553             :                 case SVX_SNAP_DATEFIELD:
     554             :                 {
     555           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     556           0 :                     GetEditor().SetInsertObj( OBJ_DLG_DATEFIELD );
     557             :                 }
     558           0 :                 break;
     559             :                 case SVX_SNAP_TIMEFIELD:
     560             :                 {
     561           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     562           0 :                     GetEditor().SetInsertObj( OBJ_DLG_TIMEFIELD );
     563             :                 }
     564           0 :                 break;
     565             :                 case SVX_SNAP_NUMERICFIELD:
     566             :                 {
     567           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     568           0 :                     GetEditor().SetInsertObj( OBJ_DLG_NUMERICFIELD );
     569             :                 }
     570           0 :                 break;
     571             :                 case SVX_SNAP_CURRENCYFIELD:
     572             :                 {
     573           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     574           0 :                     GetEditor().SetInsertObj( OBJ_DLG_CURRENCYFIELD );
     575             :                 }
     576           0 :                 break;
     577             :                 case SVX_SNAP_FORMATTEDFIELD:
     578             :                 {
     579           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     580           0 :                     GetEditor().SetInsertObj( OBJ_DLG_FORMATTEDFIELD );
     581             :                 }
     582           0 :                 break;
     583             :                 case SVX_SNAP_PATTERNFIELD:
     584             :                 {
     585           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     586           0 :                     GetEditor().SetInsertObj( OBJ_DLG_PATTERNFIELD );
     587             :                 }
     588           0 :                 break;
     589             :                 case SVX_SNAP_FILECONTROL:
     590             :                 {
     591           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     592           0 :                     GetEditor().SetInsertObj( OBJ_DLG_FILECONTROL );
     593             :                 }
     594           0 :                 break;
     595             :                 case SVX_SNAP_SPINBUTTON:
     596             :                 {
     597           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     598           0 :                     GetEditor().SetInsertObj( OBJ_DLG_SPINBUTTON );
     599             :                 }
     600           0 :                 break;
     601             :                 case SVX_SNAP_TREECONTROL:
     602             :                 {
     603           0 :                     GetEditor().SetMode( DlgEditor::INSERT );
     604           0 :                     GetEditor().SetInsertObj( OBJ_DLG_TREECONTROL );
     605             :                 }
     606           0 :                 break;
     607             : 
     608             :                 case SVX_SNAP_SELECT:
     609             :                 {
     610           0 :                     GetEditor().SetMode( DlgEditor::SELECT );
     611             :                 }
     612           0 :                 break;
     613             :             }
     614             : 
     615           0 :             if ( rReq.GetModifier() & KEY_MOD1 )
     616             :             {
     617           0 :                 if ( GetEditor().GetMode() == DlgEditor::INSERT )
     618           0 :                     GetEditor().CreateDefaultObject();
     619             :             }
     620             : 
     621           0 :             if (SfxBindings* pBindings = GetBindingsPtr())
     622           0 :                 pBindings->Invalidate( SID_DOC_MODIFIED );
     623             :         }
     624           0 :         break;
     625             : 
     626             :         case SID_DIALOG_TESTMODE:
     627             :         {
     628           0 :             DlgEditor::Mode eOldMode = GetEditor().GetMode();
     629           0 :             GetEditor().SetMode( DlgEditor::TEST );
     630           0 :             GetEditor().SetMode( eOldMode );
     631           0 :             rReq.Done();
     632           0 :             if (SfxBindings* pBindings = GetBindingsPtr())
     633           0 :                 pBindings->Invalidate( SID_DIALOG_TESTMODE );
     634           0 :             return;
     635             :         }
     636             :         case SID_EXPORT_DIALOG:
     637           0 :             SaveDialog();
     638           0 :             break;
     639             : 
     640             :         case SID_IMPORT_DIALOG:
     641           0 :             ImportDialog();
     642           0 :             break;
     643             : 
     644             :         case SID_BASICIDE_DELETECURRENT:
     645           0 :             if (QueryDelDialog(m_aName, this))
     646             :             {
     647           0 :                 if (RemoveDialog(m_aDocument, m_aLibName, m_aName))
     648             :                 {
     649           0 :                     MarkDocumentModified(m_aDocument);
     650           0 :                     GetShell()->RemoveWindow(this, true);
     651             :                 }
     652             :             }
     653           0 :             break;
     654             :     }
     655             : 
     656           0 :     rReq.Done();
     657             : }
     658             : 
     659           0 : Reference< container::XNameContainer > DialogWindow::GetDialog() const
     660             : {
     661           0 :     return pEditor->GetDialog();
     662             : }
     663             : 
     664           0 : bool DialogWindow::RenameDialog( const OUString& rNewName )
     665             : {
     666           0 :     if ( !basctl::RenameDialog( this, GetDocument(), GetLibName(), GetName(), rNewName ) )
     667           0 :         return false;
     668             : 
     669           0 :     if (SfxBindings* pBindings = GetBindingsPtr())
     670           0 :         pBindings->Invalidate( SID_DOC_MODIFIED );
     671             : 
     672           0 :     return true;
     673             : }
     674             : 
     675           0 : void DialogWindow::DisableBrowser()
     676             : {
     677           0 :     rLayout.DisablePropertyBrowser();
     678           0 : }
     679             : 
     680           0 : void DialogWindow::UpdateBrowser()
     681             : {
     682           0 :     rLayout.UpdatePropertyBrowser();
     683           0 : }
     684             : 
     685           0 : static OUString aResourceResolverPropName( "ResourceResolver" );
     686             : 
     687           0 : bool DialogWindow::SaveDialog()
     688             : {
     689             :     DBG_CHKTHIS( DialogWindow, 0 );
     690           0 :     bool bDone = false;
     691             : 
     692           0 :     Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
     693           0 :     Reference < XFilePicker > xFP;
     694           0 :     if( xMSF.is() )
     695             :     {
     696           0 :         Sequence <Any> aServiceType(1);
     697           0 :         aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD;
     698           0 :         xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
     699           0 :             "com.sun.star.ui.dialogs.FilePicker", aServiceType ), UNO_QUERY );
     700             :     }
     701             : 
     702           0 :     Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
     703           0 :     xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false);
     704           0 :     Any aValue;
     705           0 :     aValue <<= sal_True;
     706           0 :     xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
     707             : 
     708           0 :     if ( !aCurPath.isEmpty() )
     709           0 :         xFP->setDisplayDirectory ( aCurPath );
     710             : 
     711           0 :     xFP->setDefaultName( OUString( GetName() ) );
     712             : 
     713           0 :     OUString aDialogStr(IDE_RESSTR(RID_STR_STDDIALOGNAME));
     714           0 :     Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
     715           0 :     xFltMgr->appendFilter( aDialogStr, String( "*.xdl" ) );
     716           0 :     xFltMgr->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), String( FilterMask_All ) );
     717           0 :     xFltMgr->setCurrentFilter( aDialogStr );
     718             : 
     719           0 :     if( xFP->execute() == RET_OK )
     720             :     {
     721           0 :         Sequence< OUString > aPaths = xFP->getFiles();
     722           0 :         aCurPath = aPaths[0];
     723             : 
     724             :         // export dialog model to xml
     725           0 :         Reference< container::XNameContainer > xDialogModel = GetDialog();
     726           0 :         Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
     727           0 :         Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() );
     728           0 :         Reference< XInputStream > xInput( xISP->createInputStream() );
     729             : 
     730           0 :         Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(comphelper::getProcessComponentContext()) );
     731             : 
     732           0 :         Reference< XOutputStream > xOutput;
     733             :         try
     734             :         {
     735           0 :             if( xSFI->exists( aCurPath ) )
     736           0 :                 xSFI->kill( aCurPath );
     737           0 :             xOutput = xSFI->openFileWrite( aCurPath );
     738             :         }
     739           0 :         catch(const Exception& )
     740             :         {}
     741             : 
     742           0 :         if( xOutput.is() )
     743             :         {
     744           0 :             Sequence< sal_Int8 > bytes;
     745           0 :             sal_Int32 nRead = xInput->readBytes( bytes, xInput->available() );
     746           0 :             for (;;)
     747             :             {
     748           0 :                 if( nRead )
     749           0 :                     xOutput->writeBytes( bytes );
     750             : 
     751           0 :                 nRead = xInput->readBytes( bytes, 1024 );
     752           0 :                 if (! nRead)
     753           0 :                     break;
     754             :             }
     755           0 :             bDone = true;
     756             : 
     757             :             // With resource?
     758           0 :             Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY );
     759           0 :             Reference< resource::XStringResourceResolver > xStringResourceResolver;
     760           0 :             if( xDialogModelPropSet.is() )
     761             :             {
     762             :                 try
     763             :                 {
     764           0 :                     Any aResourceResolver = xDialogModelPropSet->getPropertyValue( aResourceResolverPropName );
     765           0 :                     aResourceResolver >>= xStringResourceResolver;
     766             :                 }
     767           0 :                 catch(const beans::UnknownPropertyException& )
     768             :                 {}
     769             :             }
     770             : 
     771           0 :             bool bResource = false;
     772           0 :             if( xStringResourceResolver.is() )
     773             :             {
     774           0 :                 Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales();
     775           0 :                 sal_Int32 nLocaleCount = aLocaleSeq.getLength();
     776           0 :                 if( nLocaleCount > 0 )
     777           0 :                     bResource = true;
     778             :             }
     779             : 
     780           0 :             if( bResource )
     781             :             {
     782           0 :                 INetURLObject aURLObj( aCurPath );
     783           0 :                 aURLObj.removeExtension();
     784           0 :                 OUString aDialogName( aURLObj.getName() );
     785           0 :                 aURLObj.removeSegment();
     786           0 :                 OUString aURL( aURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
     787           0 :                 bool bReadOnly = false;
     788           0 :                 OUString aComment( "# " );
     789           0 :                 aComment += aDialogName;
     790           0 :                 aComment += " strings" ;
     791           0 :                 Reference< task::XInteractionHandler > xDummyHandler;
     792             : 
     793             :                 // Remove old properties files in case of overwriting Dialog files
     794           0 :                 if( xSFI->isFolder( aURL ) )
     795             :                 {
     796           0 :                     Sequence< OUString > aContentSeq = xSFI->getFolderContents( aURL, false );
     797             : 
     798           0 :                     OUString aDialogName_( aDialogName );
     799           0 :                     aDialogName_ += "_" ;
     800           0 :                     sal_Int32 nCount = aContentSeq.getLength();
     801           0 :                     const OUString* pFiles = aContentSeq.getConstArray();
     802           0 :                     for( int i = 0 ; i < nCount ; i++ )
     803             :                     {
     804           0 :                         OUString aCompleteName = pFiles[i];
     805           0 :                         OUString aPureName;
     806           0 :                         OUString aExtension;
     807           0 :                         sal_Int32 iDot = aCompleteName.lastIndexOf( '.' );
     808           0 :                         sal_Int32 iSlash = aCompleteName.lastIndexOf( '/' );
     809           0 :                         if( iDot != -1 )
     810             :                         {
     811           0 :                             sal_Int32 iCopyFrom = (iSlash != -1) ? iSlash + 1 : 0;
     812           0 :                             aPureName = aCompleteName.copy( iCopyFrom, iDot-iCopyFrom );
     813           0 :                             aExtension = aCompleteName.copy( iDot + 1 );
     814             :                         }
     815             : 
     816           0 :                         if( aExtension == "properties" || aExtension == "default" )
     817             :                         {
     818           0 :                             if( aPureName.indexOf( aDialogName_ ) == 0 )
     819             :                             {
     820             :                                 try
     821             :                                 {
     822           0 :                                     xSFI->kill( aCompleteName );
     823             :                                 }
     824           0 :                                 catch(const uno::Exception& )
     825             :                                 {}
     826             :                             }
     827             :                         }
     828           0 :                     }
     829             :                 }
     830             : 
     831             :                 Reference< XStringResourceWithLocation > xStringResourceWithLocation =
     832             :                     StringResourceWithLocation::create( xContext, aURL, bReadOnly,
     833           0 :                         xStringResourceResolver->getDefaultLocale(), aDialogName, aComment, xDummyHandler );
     834             : 
     835             :                 // Add locales
     836           0 :                 Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales();
     837           0 :                 const lang::Locale* pLocales = aLocaleSeq.getConstArray();
     838           0 :                 sal_Int32 nLocaleCount = aLocaleSeq.getLength();
     839           0 :                 for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
     840             :                 {
     841           0 :                     const lang::Locale& rLocale = pLocales[ iLocale ];
     842           0 :                     xStringResourceWithLocation->newLocale( rLocale );
     843             :                 }
     844             : 
     845           0 :                 Reference< XStringResourceManager > xTargetStringResourceManager( xStringResourceWithLocation, uno::UNO_QUERY );
     846             : 
     847             :                 LocalizationMgr::copyResourceForDialog( xDialogModel,
     848           0 :                     xStringResourceResolver, xTargetStringResourceManager );
     849             : 
     850           0 :                 xStringResourceWithLocation->store();
     851           0 :             }
     852             :         }
     853             :         else
     854           0 :             ErrorBox( this, WB_OK | WB_DEF_OK, IDE_RESSTR(RID_STR_COULDNTWRITE)).Execute();
     855             :     }
     856             : 
     857           0 :     return bDone;
     858             : }
     859             : 
     860             : extern bool localesAreEqual( const ::com::sun::star::lang::Locale& rLocaleLeft,
     861             :                              const ::com::sun::star::lang::Locale& rLocaleRight );
     862             : 
     863           0 : std::vector< lang::Locale > implGetLanguagesOnlyContainedInFirstSeq
     864             :     ( Sequence< lang::Locale > aFirstSeq, Sequence< lang::Locale > aSecondSeq )
     865             : {
     866           0 :     std::vector< lang::Locale > avRet;
     867             : 
     868           0 :     const lang::Locale* pFirst = aFirstSeq.getConstArray();
     869           0 :     const lang::Locale* pSecond = aSecondSeq.getConstArray();
     870           0 :     sal_Int32 nFirstCount = aFirstSeq.getLength();
     871           0 :     sal_Int32 nSecondCount = aSecondSeq.getLength();
     872             : 
     873           0 :     for( sal_Int32 iFirst = 0 ; iFirst < nFirstCount ; iFirst++ )
     874             :     {
     875           0 :         const lang::Locale& rFirstLocale = pFirst[ iFirst ];
     876             : 
     877           0 :         bool bAlsoContainedInSecondSeq = false;
     878           0 :         for( sal_Int32 iSecond = 0 ; iSecond < nSecondCount ; iSecond++ )
     879             :         {
     880           0 :             const lang::Locale& rSecondLocale = pSecond[ iSecond ];
     881             : 
     882           0 :             bool bMatch = localesAreEqual( rFirstLocale, rSecondLocale );
     883           0 :             if( bMatch )
     884             :             {
     885           0 :                 bAlsoContainedInSecondSeq = true;
     886           0 :                 break;
     887             :             }
     888             :         }
     889             : 
     890           0 :         if( !bAlsoContainedInSecondSeq )
     891           0 :             avRet.push_back( rFirstLocale );
     892             :     }
     893             : 
     894           0 :     return avRet;
     895             : }
     896             : 
     897             : 
     898           0 : class NameClashQueryBox : public MessBox
     899             : {
     900             : public:
     901             :     NameClashQueryBox( Window* pParent,
     902             :         const XubString& rTitle, const XubString& rMessage );
     903             : };
     904             : 
     905           0 : NameClashQueryBox::NameClashQueryBox( Window* pParent,
     906             :     const XubString& rTitle, const XubString& rMessage )
     907           0 :         : MessBox( pParent, 0, rTitle, rMessage )
     908             : {
     909           0 :     if ( rTitle.Len() )
     910           0 :         SetText( rTitle );
     911             : 
     912           0 :     maMessText = rMessage;
     913             : 
     914             :     AddButton( IDE_RESSTR(RID_STR_DLGIMP_CLASH_RENAME), RET_YES,
     915           0 :         BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_OKBUTTON | BUTTONDIALOG_FOCUSBUTTON );
     916           0 :     AddButton( IDE_RESSTR(RID_STR_DLGIMP_CLASH_REPLACE), RET_NO, 0 );
     917           0 :     AddButton( BUTTON_CANCEL, RET_CANCEL, BUTTONDIALOG_CANCELBUTTON );
     918             : 
     919           0 :     SetImage( QueryBox::GetStandardImage() );
     920           0 : }
     921             : 
     922             : 
     923           0 : class LanguageMismatchQueryBox : public MessBox
     924             : {
     925             : public:
     926             :     LanguageMismatchQueryBox( Window* pParent,
     927             :         const XubString& rTitle, const XubString& rMessage );
     928             : };
     929             : 
     930           0 : LanguageMismatchQueryBox::LanguageMismatchQueryBox( Window* pParent,
     931             :     const XubString& rTitle, const XubString& rMessage )
     932           0 :         : MessBox( pParent, 0, rTitle, rMessage )
     933             : {
     934           0 :     if ( rTitle.Len() )
     935           0 :         SetText( rTitle );
     936             : 
     937           0 :     maMessText = rMessage;
     938             :     AddButton( IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_ADD), RET_YES,
     939           0 :         BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_OKBUTTON | BUTTONDIALOG_FOCUSBUTTON );
     940           0 :     AddButton( IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_OMIT), RET_NO, 0 );
     941           0 :     AddButton( BUTTON_CANCEL, RET_CANCEL, BUTTONDIALOG_CANCELBUTTON );
     942           0 :     AddButton( BUTTON_HELP, BUTTONID_HELP, BUTTONDIALOG_HELPBUTTON, 4 );
     943             : 
     944           0 :     SetImage( QueryBox::GetStandardImage() );
     945           0 : }
     946             : 
     947             : 
     948           0 : bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocument& rDocument, const OUString& aLibName )
     949             : {
     950           0 :     bool bDone = false;
     951             : 
     952           0 :     Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
     953           0 :     Reference < XFilePicker > xFP;
     954           0 :     if( xMSF.is() )
     955             :     {
     956           0 :         Sequence <Any> aServiceType(1);
     957           0 :         aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
     958           0 :         xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
     959           0 :             "com.sun.star.ui.dialogs.FilePicker", aServiceType ), UNO_QUERY );
     960             :     }
     961             : 
     962           0 :     Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
     963           0 :     xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false);
     964           0 :     Any aValue;
     965           0 :     aValue <<= sal_True;
     966           0 :     xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
     967             : 
     968           0 :     OUString aCurPath( rCurPath );
     969           0 :     if ( !aCurPath.isEmpty() )
     970           0 :         xFP->setDisplayDirectory ( aCurPath );
     971             : 
     972           0 :     OUString aDialogStr(IDE_RESSTR(RID_STR_STDDIALOGNAME));
     973           0 :     Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
     974           0 :     xFltMgr->appendFilter( aDialogStr, String( "*.xdl" ) );
     975           0 :     xFltMgr->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), String( FilterMask_All ) );
     976           0 :     xFltMgr->setCurrentFilter( aDialogStr );
     977             : 
     978           0 :     if( xFP->execute() == RET_OK )
     979             :     {
     980           0 :         Sequence< OUString > aPaths = xFP->getFiles();
     981           0 :         aCurPath = aPaths[0];
     982             : 
     983           0 :         OUString aBasePath;
     984           0 :         OUString aOUCurPath( aCurPath );
     985           0 :         sal_Int32 iSlash = aOUCurPath.lastIndexOf( '/' );
     986           0 :         if( iSlash != -1 )
     987           0 :             aBasePath = aOUCurPath.copy( 0, iSlash + 1 );
     988             : 
     989             :         try
     990             :         {
     991             :             // create dialog model
     992           0 :             Reference< container::XNameContainer > xDialogModel( xMSF->createInstance
     993           0 :                 ( "com.sun.star.awt.UnoControlDialogModel" ), UNO_QUERY_THROW );
     994             : 
     995           0 :             Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(comphelper::getProcessComponentContext()) );
     996             : 
     997           0 :             Reference< XInputStream > xInput;
     998           0 :             if( xSFI->exists( aCurPath ) )
     999           0 :                 xInput = xSFI->openFileRead( aCurPath );
    1000             : 
    1001             :             Reference< XComponentContext > xContext(
    1002           0 :                 comphelper::getComponentContext( xMSF ) );
    1003           0 :             ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() );
    1004             : 
    1005           0 :             OUString aXmlDlgName;
    1006           0 :             Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY );
    1007           0 :             if( xDialogModelPropSet.is() )
    1008             :             {
    1009             :                 try
    1010             :                 {
    1011           0 :                     Any aXmlDialogNameAny = xDialogModelPropSet->getPropertyValue( DLGED_PROP_NAME );
    1012           0 :                     OUString aOUXmlDialogName;
    1013           0 :                     aXmlDialogNameAny >>= aOUXmlDialogName;
    1014           0 :                     aXmlDlgName = aOUXmlDialogName;
    1015             :                 }
    1016           0 :                 catch(const beans::UnknownPropertyException& )
    1017             :                 {}
    1018             :             }
    1019           0 :             bool bValidName = !aXmlDlgName.isEmpty();
    1020             :             OSL_ASSERT( bValidName );
    1021           0 :             if( !bValidName )
    1022           0 :                 return bDone;
    1023             : 
    1024           0 :             bool bDialogAlreadyExists = rDocument.hasDialog( aLibName, aXmlDlgName );
    1025             : 
    1026           0 :             OUString aNewDlgName = aXmlDlgName;
    1027             :             enum NameClashMode
    1028             :             {
    1029             :                 NO_CLASH,
    1030             :                 CLASH_OVERWRITE_DIALOG,
    1031             :                 CLASH_RENAME_DIALOG,
    1032             :             };
    1033           0 :             NameClashMode eNameClashMode = NO_CLASH;
    1034           0 :             if( bDialogAlreadyExists )
    1035             :             {
    1036           0 :                 OUString aQueryBoxTitle(IDE_RESSTR(RID_STR_DLGIMP_CLASH_TITLE));
    1037           0 :                 OUString aQueryBoxText(IDE_RESSTR(RID_STR_DLGIMP_CLASH_TEXT));
    1038           0 :                 aQueryBoxText = aQueryBoxText.replaceAll("$(ARG1)", aXmlDlgName);
    1039             : 
    1040           0 :                 NameClashQueryBox aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText );
    1041           0 :                 sal_uInt16 nRet = aQueryBox.Execute();
    1042           0 :                 if( RET_YES == nRet )
    1043             :                 {
    1044             :                     // RET_YES == Rename, see NameClashQueryBox::NameClashQueryBox
    1045           0 :                     eNameClashMode = CLASH_RENAME_DIALOG;
    1046             : 
    1047           0 :                     aNewDlgName = rDocument.createObjectName( E_DIALOGS, aLibName );
    1048             :                 }
    1049           0 :                 else if( RET_NO == nRet )
    1050             :                 {
    1051             :                     // RET_NO == Replace, see NameClashQueryBox::NameClashQueryBox
    1052           0 :                     eNameClashMode = CLASH_OVERWRITE_DIALOG;
    1053             :                 }
    1054           0 :                 else if( RET_CANCEL == nRet )
    1055             :                 {
    1056           0 :                     return bDone;
    1057           0 :                 }
    1058             :             }
    1059             : 
    1060           0 :             Shell* pShell = GetShell();
    1061           0 :             if (!pShell)
    1062             :             {
    1063             :                 OSL_ASSERT(pShell);
    1064           0 :                 return bDone;
    1065             :             }
    1066             : 
    1067             :             // Resource?
    1068           0 :             ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILanguageTag().getLocale();
    1069           0 :             Reference< task::XInteractionHandler > xDummyHandler;
    1070           0 :             bool bReadOnly = true;
    1071             :             Reference< XStringResourceWithLocation > xImportStringResource =
    1072             :                 StringResourceWithLocation::create( xContext, aBasePath, bReadOnly,
    1073           0 :                 aLocale, aXmlDlgName, OUString(), xDummyHandler );
    1074             : 
    1075           0 :             Sequence< lang::Locale > aImportLocaleSeq = xImportStringResource->getLocales();
    1076           0 :             sal_Int32 nImportLocaleCount = aImportLocaleSeq.getLength();
    1077             : 
    1078           0 :             Reference< container::XNameContainer > xDialogLib( rDocument.getLibrary( E_DIALOGS, aLibName, true ) );
    1079           0 :             Reference< resource::XStringResourceManager > xLibStringResourceManager = LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
    1080           0 :             sal_Int32 nLibLocaleCount = 0;
    1081           0 :             Sequence< lang::Locale > aLibLocaleSeq;
    1082           0 :             if( xLibStringResourceManager.is() )
    1083             :             {
    1084           0 :                 aLibLocaleSeq = xLibStringResourceManager->getLocales();
    1085           0 :                 nLibLocaleCount = aLibLocaleSeq.getLength();
    1086             :             }
    1087             : 
    1088             :             // Check language matches
    1089             :             std::vector< lang::Locale > aOnlyInImportLanguages =
    1090           0 :                 implGetLanguagesOnlyContainedInFirstSeq( aImportLocaleSeq, aLibLocaleSeq );
    1091           0 :             int nOnlyInImportLanguageCount = aOnlyInImportLanguages.size();
    1092             : 
    1093             :             // For now: Keep languages from lib
    1094           0 :             bool bLibLocalized = (nLibLocaleCount > 0);
    1095           0 :             bool bImportLocalized = (nImportLocaleCount > 0);
    1096             : 
    1097           0 :             bool bAddDialogLanguagesToLib = false;
    1098           0 :             if( nOnlyInImportLanguageCount > 0 )
    1099             :             {
    1100           0 :                 OUString aQueryBoxTitle(IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_TITLE));
    1101           0 :                 OUString aQueryBoxText(IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_TEXT));
    1102           0 :                 LanguageMismatchQueryBox aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText );
    1103           0 :                 sal_uInt16 nRet = aQueryBox.Execute();
    1104           0 :                 if( RET_YES == nRet )
    1105             :                 {
    1106             :                     // RET_YES == Add, see LanguageMismatchQueryBox::LanguageMismatchQueryBox
    1107           0 :                     bAddDialogLanguagesToLib = true;
    1108             :                 }
    1109             :                 // RET_NO == Omit, see LanguageMismatchQueryBox::LanguageMismatchQueryBox
    1110             :                 // -> nothing to do here
    1111             :                 //else if( RET_NO == nRet )
    1112             :                 //{
    1113             :                 //}
    1114           0 :                 else if( RET_CANCEL == nRet )
    1115             :                 {
    1116           0 :                     return bDone;
    1117           0 :                 }
    1118             :             }
    1119             : 
    1120           0 :             if( bImportLocalized )
    1121             :             {
    1122           0 :                 bool bCopyResourcesForDialog = true;
    1123           0 :                 if( bAddDialogLanguagesToLib )
    1124             :                 {
    1125           0 :                     boost::shared_ptr<LocalizationMgr> pCurMgr = pShell->GetCurLocalizationMgr();
    1126             : 
    1127           0 :                     lang::Locale aFirstLocale;
    1128           0 :                     aFirstLocale = aOnlyInImportLanguages[0];
    1129           0 :                     if( nOnlyInImportLanguageCount > 1 )
    1130             :                     {
    1131             :                         // Check if import default belongs to only import languages and use it then
    1132           0 :                         lang::Locale aImportDefaultLocale = xImportStringResource->getDefaultLocale();
    1133           0 :                         lang::Locale aTmpLocale;
    1134           0 :                         for( int i = 0 ; i < nOnlyInImportLanguageCount ; ++i )
    1135             :                         {
    1136           0 :                             aTmpLocale = aOnlyInImportLanguages[i];
    1137           0 :                             if( localesAreEqual( aImportDefaultLocale, aTmpLocale ) )
    1138             :                             {
    1139           0 :                                 aFirstLocale = aImportDefaultLocale;
    1140           0 :                                 break;
    1141             :                             }
    1142           0 :                         }
    1143             :                     }
    1144             : 
    1145           0 :                     Sequence< lang::Locale > aFirstLocaleSeq( 1 );
    1146           0 :                     aFirstLocaleSeq[0] = aFirstLocale;
    1147           0 :                     pCurMgr->handleAddLocales( aFirstLocaleSeq );
    1148             : 
    1149           0 :                     if( nOnlyInImportLanguageCount > 1 )
    1150             :                     {
    1151           0 :                         Sequence< lang::Locale > aRemainingLocaleSeq( nOnlyInImportLanguageCount - 1 );
    1152           0 :                         lang::Locale aTmpLocale;
    1153           0 :                         int iSeq = 0;
    1154           0 :                         for( int i = 0 ; i < nOnlyInImportLanguageCount ; ++i )
    1155             :                         {
    1156           0 :                             aTmpLocale = aOnlyInImportLanguages[i];
    1157           0 :                             if( !localesAreEqual( aFirstLocale, aTmpLocale ) )
    1158           0 :                                 aRemainingLocaleSeq[iSeq++] = aTmpLocale;
    1159             :                         }
    1160           0 :                         pCurMgr->handleAddLocales( aRemainingLocaleSeq );
    1161           0 :                     }
    1162             :                 }
    1163           0 :                 else if( !bLibLocalized )
    1164             :                 {
    1165           0 :                     Reference< resource::XStringResourceManager > xImportStringResourceManager( xImportStringResource, UNO_QUERY );
    1166           0 :                     LocalizationMgr::resetResourceForDialog( xDialogModel, xImportStringResourceManager );
    1167           0 :                     bCopyResourcesForDialog = false;
    1168             :                 }
    1169             : 
    1170           0 :                 if( bCopyResourcesForDialog )
    1171             :                 {
    1172           0 :                     Reference< resource::XStringResourceResolver > xImportStringResourceResolver( xImportStringResource, UNO_QUERY );
    1173             :                     LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, aXmlDlgName,
    1174           0 :                         xLibStringResourceManager, xImportStringResourceResolver );
    1175             :                 }
    1176             :             }
    1177           0 :             else if( bLibLocalized )
    1178             :             {
    1179           0 :                 LocalizationMgr::setResourceIDsForDialog( xDialogModel, xLibStringResourceManager );
    1180             :             }
    1181             : 
    1182             : 
    1183           0 :             LocalizationMgr::setStringResourceAtDialog( rDocument, aLibName, aNewDlgName, xDialogModel );
    1184             : 
    1185           0 :             if( eNameClashMode == CLASH_OVERWRITE_DIALOG )
    1186             :             {
    1187           0 :                 if (basctl::RemoveDialog( rDocument, aLibName, aNewDlgName ) )
    1188             :                 {
    1189           0 :                     BaseWindow* pDlgWin = pShell->FindDlgWin( rDocument, aLibName, aNewDlgName, false, true );
    1190           0 :                     if( pDlgWin != NULL )
    1191           0 :                         pShell->RemoveWindow( pDlgWin, true );
    1192           0 :                     MarkDocumentModified( rDocument );
    1193             :                 }
    1194             :                 else
    1195             :                 {
    1196             :                     // TODO: Assertion?
    1197           0 :                     return bDone;
    1198             :                 }
    1199             :             }
    1200             : 
    1201           0 :             if( eNameClashMode == CLASH_RENAME_DIALOG )
    1202             :             {
    1203           0 :                 bool bRenamed = false;
    1204           0 :                 if( xDialogModelPropSet.is() )
    1205             :                 {
    1206             :                     try
    1207             :                     {
    1208           0 :                         Any aXmlDialogNameAny;
    1209           0 :                         aXmlDialogNameAny <<= OUString( aNewDlgName );
    1210           0 :                         xDialogModelPropSet->setPropertyValue( DLGED_PROP_NAME, aXmlDialogNameAny );
    1211           0 :                         bRenamed = true;
    1212             :                     }
    1213           0 :                     catch(const beans::UnknownPropertyException& )
    1214             :                     {}
    1215             :                 }
    1216             : 
    1217             : 
    1218           0 :                 if( bRenamed )
    1219             :                 {
    1220           0 :                     LocalizationMgr::renameStringResourceIDs( rDocument, aLibName, aNewDlgName, xDialogModel );
    1221             :                 }
    1222             :                 else
    1223             :                 {
    1224             :                     // TODO: Assertion?
    1225           0 :                     return bDone;
    1226             :                 }
    1227             :             }
    1228             : 
    1229           0 :             Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() );
    1230           0 :             bool bSuccess = rDocument.insertDialog( aLibName, aNewDlgName, xISP );
    1231           0 :             if( bSuccess )
    1232             :             {
    1233           0 :                 DialogWindow* pNewDlgWin = pShell->CreateDlgWin( rDocument, aLibName, aNewDlgName );
    1234           0 :                 pShell->SetCurWindow( pNewDlgWin, true );
    1235             :             }
    1236             : 
    1237           0 :             bDone = true;
    1238             :         }
    1239           0 :         catch(const Exception& )
    1240           0 :         {}
    1241             :     }
    1242             : 
    1243           0 :     return bDone;
    1244             : }
    1245             : 
    1246             : 
    1247           0 : bool DialogWindow::ImportDialog()
    1248             : {
    1249             :     DBG_CHKTHIS( DialogWindow, 0 );
    1250             : 
    1251           0 :     const ScriptDocument& rDocument = GetDocument();
    1252           0 :     OUString aLibName = GetLibName();
    1253           0 :     return implImportDialog( this, aCurPath, rDocument, aLibName );
    1254             : }
    1255             : 
    1256           0 : DlgEdModel& DialogWindow::GetModel() const
    1257             : {
    1258           0 :     return pEditor->GetModel();
    1259             : }
    1260             : 
    1261           0 : DlgEdPage& DialogWindow::GetPage() const
    1262             : {
    1263           0 :     return pEditor->GetPage();
    1264             : }
    1265             : 
    1266           0 : DlgEdView& DialogWindow::GetView() const
    1267             : {
    1268           0 :     return pEditor->GetView();
    1269             : }
    1270             : 
    1271           0 : bool DialogWindow::IsModified()
    1272             : {
    1273           0 :     return pEditor->IsModified();
    1274             : }
    1275             : 
    1276           0 : ::svl::IUndoManager* DialogWindow::GetUndoManager()
    1277             : {
    1278           0 :     return pUndoMgr.get();
    1279             : }
    1280             : 
    1281           0 : OUString DialogWindow::GetTitle()
    1282             : {
    1283           0 :     return GetName();
    1284             : }
    1285             : 
    1286           0 : EntryDescriptor DialogWindow::CreateEntryDescriptor()
    1287             : {
    1288           0 :     ScriptDocument aDocument( GetDocument() );
    1289           0 :     OUString aLibName( GetLibName() );
    1290           0 :     OUString aLibSubName;
    1291           0 :     LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
    1292           0 :     return EntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, GetName(), OBJ_TYPE_DIALOG );
    1293             : }
    1294             : 
    1295           0 : void DialogWindow::SetReadOnly (bool bReadOnly)
    1296             : {
    1297           0 :     pEditor->SetMode(bReadOnly ? DlgEditor::READONLY : DlgEditor::SELECT);
    1298           0 : }
    1299             : 
    1300           0 : bool DialogWindow::IsReadOnly ()
    1301             : {
    1302           0 :     return pEditor->GetMode() == DlgEditor::READONLY;
    1303             : }
    1304             : 
    1305           0 : bool DialogWindow::IsPasteAllowed()
    1306             : {
    1307           0 :     return pEditor->IsPasteAllowed();
    1308             : }
    1309             : 
    1310           0 : void DialogWindow::StoreData()
    1311             : {
    1312           0 :     if ( IsModified() )
    1313             :     {
    1314             :         try
    1315             :         {
    1316           0 :             Reference< container::XNameContainer > xLib = GetDocument().getLibrary( E_DIALOGS, GetLibName(), true );
    1317             : 
    1318           0 :             if( xLib.is() )
    1319             :             {
    1320           0 :                 Reference< container::XNameContainer > xDialogModel = pEditor->GetDialog();
    1321             : 
    1322           0 :                 if( xDialogModel.is() )
    1323             :                 {
    1324             :                     Reference< XComponentContext > xContext(
    1325           0 :                         comphelper::getProcessComponentContext() );
    1326           0 :                     Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() );
    1327           0 :                     xLib->replaceByName( OUString( GetName() ), makeAny( xISP ) );
    1328           0 :                 }
    1329           0 :             }
    1330             :         }
    1331           0 :         catch (const uno::Exception& )
    1332             :         {
    1333             :             DBG_UNHANDLED_EXCEPTION();
    1334             :         }
    1335           0 :         MarkDocumentModified( GetDocument() );
    1336           0 :         pEditor->ClearModifyFlag();
    1337             :     }
    1338           0 : }
    1339             : 
    1340           0 : void DialogWindow::Activating ()
    1341             : {
    1342           0 :     UpdateBrowser();
    1343           0 :     Show();
    1344           0 : }
    1345             : 
    1346           0 : void DialogWindow::Deactivating()
    1347             : {
    1348           0 :     Hide();
    1349           0 :     if ( IsModified() )
    1350           0 :         MarkDocumentModified( GetDocument() );
    1351           0 :     DisableBrowser();
    1352           0 : }
    1353             : 
    1354           0 : sal_Int32 DialogWindow::countPages( Printer* pPrinter )
    1355             : {
    1356           0 :     return pEditor->countPages( pPrinter );
    1357             : }
    1358             : 
    1359           0 : void DialogWindow::printPage( sal_Int32 nPage, Printer* pPrinter )
    1360             : {
    1361           0 :     pEditor->printPage( nPage, pPrinter, CreateQualifiedName() );
    1362           0 : }
    1363             : 
    1364           0 : void DialogWindow::DataChanged( const DataChangedEvent& rDCEvt )
    1365             : {
    1366           0 :     if( (rDCEvt.GetType()==DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
    1367             :     {
    1368           0 :         InitSettings( true, true, true );
    1369           0 :         Invalidate();
    1370             :     }
    1371             :     else
    1372           0 :         BaseWindow::DataChanged( rDCEvt );
    1373           0 : }
    1374             : 
    1375           0 : void DialogWindow::InitSettings(bool bFont, bool bForeground, bool bBackground)
    1376             : {
    1377           0 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
    1378           0 :     if( bFont )
    1379             :     {
    1380           0 :         Font aFont;
    1381           0 :         aFont = rStyleSettings.GetFieldFont();
    1382           0 :         SetPointFont( aFont );
    1383             :     }
    1384             : 
    1385           0 :     if( bForeground || bFont )
    1386             :     {
    1387           0 :         SetTextColor( rStyleSettings.GetFieldTextColor() );
    1388           0 :         SetTextFillColor();
    1389             :     }
    1390             : 
    1391           0 :     if( bBackground )
    1392           0 :         SetBackground( rStyleSettings.GetFieldColor() );
    1393           0 : }
    1394             : 
    1395           0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > DialogWindow::CreateAccessible()
    1396             : {
    1397           0 :     return (::com::sun::star::accessibility::XAccessible*) new AccessibleDialogWindow( this );
    1398             : }
    1399             : 
    1400           0 : char const* DialogWindow::GetHid () const
    1401             : {
    1402           0 :     return HID_BASICIDE_DIALOGWINDOW;
    1403             : }
    1404           0 : ItemType DialogWindow::GetType () const
    1405             : {
    1406           0 :     return TYPE_DIALOG;
    1407             : }
    1408             : 
    1409             : 
    1410             : //
    1411             : // DialogWindowLayout
    1412             : // ==================
    1413             : //
    1414             : 
    1415           0 : DialogWindowLayout::DialogWindowLayout (Window* pParent, ObjectCatalog& rObjectCatalog_) :
    1416             :     Layout(pParent),
    1417             :     pChild(0),
    1418             :     rObjectCatalog(rObjectCatalog_),
    1419           0 :     pPropertyBrowser(0)
    1420             : {
    1421           0 :     ShowPropertyBrowser();
    1422           0 : }
    1423             : 
    1424             : // shows the property browser (and creates if neccessary)
    1425           0 : void DialogWindowLayout::ShowPropertyBrowser ()
    1426             : {
    1427             :     // not exists?
    1428           0 :     if (!pPropertyBrowser)
    1429             :     {
    1430             :         // creating
    1431           0 :         pPropertyBrowser = new PropBrw(*this);
    1432           0 :         pPropertyBrowser->Show();
    1433             :         // after OnFirstSize():
    1434           0 :         if (HasSize())
    1435           0 :             AddPropertyBrowser();
    1436             :         // updating if neccessary
    1437           0 :         UpdatePropertyBrowser();
    1438             :     }
    1439             :     else
    1440           0 :         pPropertyBrowser->Show();
    1441             :     // refreshing the button state
    1442           0 :     if (SfxBindings* pBindings = GetBindingsPtr())
    1443           0 :         pBindings->Invalidate(SID_SHOW_PROPERTYBROWSER);
    1444           0 : }
    1445             : 
    1446             : // disables the property browser
    1447           0 : void DialogWindowLayout::DisablePropertyBrowser ()
    1448             : {
    1449           0 :     if (pPropertyBrowser)
    1450           0 :         pPropertyBrowser->Update(0);
    1451           0 : }
    1452             : 
    1453             : // updates the property browser
    1454           0 : void DialogWindowLayout::UpdatePropertyBrowser ()
    1455             : {
    1456           0 :     if (pPropertyBrowser)
    1457           0 :         pPropertyBrowser->Update(GetShell());
    1458           0 : }
    1459             : 
    1460             : // Removes the property browser from the layout.
    1461             : // Called by PropBrw when closed. It'll destroy itself.
    1462           0 : void DialogWindowLayout::RemovePropertyBrowser ()
    1463             : {
    1464           0 :     if (pPropertyBrowser)
    1465           0 :         Remove(pPropertyBrowser);
    1466           0 :     pPropertyBrowser = 0;
    1467             :     // refreshing the button state
    1468           0 :     if (SfxBindings* pBindings = GetBindingsPtr())
    1469           0 :         pBindings->Invalidate(SID_SHOW_PROPERTYBROWSER);
    1470           0 : }
    1471             : 
    1472           0 : void DialogWindowLayout::Activating (BaseWindow& rChild)
    1473             : {
    1474             :     assert(dynamic_cast<DialogWindow*>(&rChild));
    1475           0 :     pChild = &static_cast<DialogWindow&>(rChild);
    1476           0 :     rObjectCatalog.SetLayoutWindow(this);
    1477           0 :     rObjectCatalog.UpdateEntries();
    1478           0 :     rObjectCatalog.Show();
    1479           0 :     if (pPropertyBrowser)
    1480           0 :         pPropertyBrowser->Show();
    1481           0 :     Layout::Activating(rChild);
    1482           0 : }
    1483             : 
    1484           0 : void DialogWindowLayout::Deactivating ()
    1485             : {
    1486           0 :     Layout::Deactivating();
    1487           0 :     rObjectCatalog.Hide();
    1488           0 :     if (pPropertyBrowser)
    1489           0 :         pPropertyBrowser->Hide();
    1490           0 :     pChild = 0;
    1491           0 : }
    1492             : 
    1493           0 : void DialogWindowLayout::ExecuteGlobal (SfxRequest& rReq)
    1494             : {
    1495           0 :     switch (rReq.GetSlot())
    1496             :     {
    1497             :         case SID_SHOW_PROPERTYBROWSER:
    1498             :             // toggling property browser
    1499           0 :             if (pPropertyBrowser && pPropertyBrowser->IsVisible())
    1500           0 :                 pPropertyBrowser->Hide();
    1501             :             else
    1502           0 :                 ShowPropertyBrowser();
    1503           0 :             ArrangeWindows();
    1504             :             // refreshing the button state
    1505           0 :             if (SfxBindings* pBindings = GetBindingsPtr())
    1506           0 :                 pBindings->Invalidate(SID_SHOW_PROPERTYBROWSER);
    1507           0 :             break;
    1508             :     }
    1509           0 : }
    1510             : 
    1511           0 : void DialogWindowLayout::GetState (SfxItemSet& rSet, unsigned nWhich)
    1512             : {
    1513           0 :     switch (nWhich)
    1514             :     {
    1515             :         case SID_SHOW_PROPERTYBROWSER:
    1516           0 :             rSet.Put(SfxBoolItem(nWhich, pPropertyBrowser && pPropertyBrowser->IsVisible()));
    1517           0 :             break;
    1518             : 
    1519             :         case SID_BASICIDE_CHOOSEMACRO:
    1520           0 :             rSet.Put(SfxVisibilityItem(nWhich, false));
    1521           0 :             break;
    1522             :     }
    1523           0 : }
    1524             : 
    1525           0 : void DialogWindowLayout::OnFirstSize (long const nWidth, long const nHeight)
    1526             : {
    1527           0 :     AddToLeft(&rObjectCatalog, Size(nWidth * 0.25, nHeight * 0.35));
    1528           0 :     if (pPropertyBrowser)
    1529           0 :         AddPropertyBrowser();
    1530           0 : }
    1531             : 
    1532           0 : void DialogWindowLayout::AddPropertyBrowser () {
    1533           0 :     Size const aSize = GetOutputSizePixel();
    1534           0 :     AddToLeft(pPropertyBrowser, Size(aSize.Width() * 0.25, aSize.Height() * 0.65));
    1535           0 : }
    1536             : 
    1537             : 
    1538           0 : } // namespace basctl
    1539             : 
    1540             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10