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

Generated by: LCOV version 1.10