LCOV - code coverage report
Current view: top level - basctl/source/basicide - baside3.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 764 0.0 %
Date: 2012-08-25 Functions: 0 63 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10