Files
libreoffice/basctl/source/basicide/baside3.cxx

1532 lines
52 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-06-12 17:02:47 +01:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-29 10:02:42 +00:00
2011-11-21 23:33:54 -05:00
#include "basidesh.hrc"
#include "helpid.hrc"
2000-09-29 10:02:42 +00:00
2011-11-21 23:33:54 -05:00
#include "accessibledialogwindow.hxx"
#include "baside3.hxx"
#include "basidesh.hxx"
#include "bastype2.hxx"
#include "dlged.hxx"
#include "dlgeddef.hxx"
#include "dlgedmod.hxx"
#include "dlgedview.hxx"
#include "iderdll.hxx"
#include "idetemp.hxx"
#include "localizationmgr.hxx"
#include "propbrw.hxx"
#include "objdlg.hxx"
2001-07-27 17:06:15 +00:00
#include <basic/basmgr.hxx>
2011-11-21 23:33:54 -05:00
#include <com/sun/star/resource/StringResourceWithLocation.hpp>
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
2011-11-21 23:33:54 -05:00
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/ui/dialogs/FilePicker.hpp>
2011-11-21 23:33:54 -05:00
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
#include <comphelper/processfactory.hxx>
#include <sfx2/dinfdlg.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/request.hxx>
#include <svl/aeitem.hxx>
#include <svl/visitem.hxx>
#include <svl/whiter.hxx>
#include <tools/diagnose_ex.h>
#include <tools/urlobj.hxx>
2011-11-21 23:33:54 -05:00
#include <vcl/msgbox.hxx>
#include <xmlscript/xmldlg_imexp.hxx>
namespace basctl
{
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::ucb;
2001-03-19 11:42:53 +00:00
using namespace ::com::sun::star::io;
using namespace ::com::sun::star::resource;
using namespace ::com::sun::star::ui::dialogs;
#if defined(UNX)
char const FilterMask_All[] = "*";
#else
char const FilterMask_All[] = "*.*";
#endif
DBG_NAME( DialogWindow )
TYPEINIT1( DialogWindow, BaseWindow );
2000-09-29 10:02:42 +00:00
DialogWindow::DialogWindow (
DialogWindowLayout* pParent,
ScriptDocument const& rDocument,
OUString aLibName, OUString aName,
com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> const& xDialogModel
) :
BaseWindow(pParent, rDocument, aLibName, aName),
rLayout(*pParent),
pEditor(new DlgEditor(*this, rLayout, rDocument.isDocument() ? rDocument.getDocument() : Reference<frame::XModel>(), xDialogModel)),
pUndoMgr(new SfxUndoManager)
{
InitSettings( true, true, true );
aOldNotifyUndoActionHdl = pEditor->GetModel().GetNotifyUndoActionHdl();
pEditor->GetModel().SetNotifyUndoActionHdl(
LINK(this, DialogWindow, NotifyUndoActionHdl)
);
SetHelpId( HID_BASICIDE_DIALOGWINDOW );
// set readonly mode for readonly libraries
Reference< script::XLibraryContainer2 > xDlgLibContainer( GetDocument().getLibraryContainer( E_DIALOGS ), UNO_QUERY );
2011-12-09 01:58:49 -05:00
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) )
SetReadOnly(true);
if ( rDocument.isDocument() && rDocument.isReadOnly() )
SetReadOnly(true);
}
2000-09-29 10:02:42 +00:00
DialogWindow::~DialogWindow()
{ }
2000-09-29 10:02:42 +00:00
void DialogWindow::LoseFocus()
{
2001-09-25 08:14:46 +00:00
if ( IsModified() )
2001-06-15 07:45:19 +00:00
StoreData();
2001-09-25 08:14:46 +00:00
2000-09-29 10:02:42 +00:00
Window::LoseFocus();
}
void DialogWindow::Paint( const Rectangle& rRect )
{
pEditor->Paint( rRect );
}
void DialogWindow::Resize()
{
2001-02-26 10:14:44 +00:00
if ( GetHScrollBar() && GetVScrollBar() ) {
pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
}
2000-09-29 10:02:42 +00:00
}
void DialogWindow::MouseButtonDown( const MouseEvent& rMEvt )
{
pEditor->MouseButtonDown( rMEvt );
if (SfxBindings* pBindings = GetBindingsPtr())
pBindings->Invalidate( SID_SHOW_PROPERTYBROWSER );
2000-09-29 10:02:42 +00:00
}
void DialogWindow::MouseButtonUp( const MouseEvent& rMEvt )
{
pEditor->MouseButtonUp( rMEvt );
if( (pEditor->GetMode() == DlgEditor::INSERT) && !pEditor->IsCreateOK() )
2000-09-29 10:02:42 +00:00
{
pEditor->SetMode( DlgEditor::SELECT );
if (SfxBindings* pBindings = GetBindingsPtr())
pBindings->Invalidate( SID_CHOOSE_CONTROLS );
}
if (SfxBindings* pBindings = GetBindingsPtr())
{
pBindings->Invalidate( SID_SHOW_PROPERTYBROWSER );
pBindings->Invalidate( SID_DOC_MODIFIED );
pBindings->Invalidate( SID_SAVEDOC );
pBindings->Invalidate( SID_COPY );
pBindings->Invalidate( SID_CUT );
2000-09-29 10:02:42 +00:00
}
}
void DialogWindow::MouseMove( const MouseEvent& rMEvt )
{
pEditor->MouseMove( rMEvt );
}
void DialogWindow::KeyInput( const KeyEvent& rKEvt )
{
SfxBindings* pBindings = GetBindingsPtr();
2000-09-29 10:02:42 +00:00
if( rKEvt.GetKeyCode() == KEY_BACKSPACE )
{
if (SfxDispatcher* pDispatcher = GetDispatcher())
2000-09-29 10:02:42 +00:00
pDispatcher->Execute( SID_BACKSPACE );
}
else
{
if( pBindings && rKEvt.GetKeyCode() == KEY_TAB )
pBindings->Invalidate( SID_SHOW_PROPERTYBROWSER );
2000-09-29 10:02:42 +00:00
if( !pEditor->KeyInput( rKEvt ) )
{
if( !SfxViewShell::Current()->KeyInput( rKEvt ) )
Window::KeyInput( rKEvt );
}
}
// may be KEY_TAB, KEY_BACKSPACE, KEY_ESCAPE
if( pBindings )
{
pBindings->Invalidate( SID_COPY );
pBindings->Invalidate( SID_CUT );
}
2000-09-29 10:02:42 +00:00
}
void DialogWindow::Command( const CommandEvent& rCEvt )
{
if ( ( rCEvt.GetCommand() == COMMAND_WHEEL ) ||
( rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL ) ||
( rCEvt.GetCommand() == COMMAND_AUTOSCROLL ) )
2000-09-29 10:02:42 +00:00
{
HandleScrollCommand( rCEvt, GetHScrollBar(), GetVScrollBar() );
}
else if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
{
if (SfxDispatcher* pDispatcher = GetDispatcher())
{
SdrView& rView = GetView();
if( !rCEvt.IsMouseEvent() && rView.AreObjectsMarked() )
{
Rectangle aMarkedRect( rView.GetMarkedRect() );
Point MarkedCenter( aMarkedRect.Center() );
Point PosPixel( LogicToPixel( MarkedCenter ) );
pDispatcher->ExecutePopup( IDEResId(RID_POPUP_DLGED), this, &PosPixel );
}
else
{
pDispatcher->ExecutePopup( IDEResId(RID_POPUP_DLGED) );
}
}
}
2000-09-29 10:02:42 +00:00
else
BaseWindow::Command( rCEvt );
2000-09-29 10:02:42 +00:00
}
IMPL_LINK( DialogWindow, NotifyUndoActionHdl, SfxUndoAction *, pUndoAction )
{
// #i120515# pUndoAction needs to be deleted, this hand over is an ownership
// change. As long as it does not get added to the undo manager, it needs at
// least to be deleted.
delete pUndoAction;
2000-09-29 10:02:42 +00:00
return 0;
}
2010-12-11 22:45:31 +01:00
void DialogWindow::DoInit()
2000-09-29 10:02:42 +00:00
{
GetHScrollBar()->Show();
GetVScrollBar()->Show();
pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
}
2010-12-11 22:45:31 +01:00
void DialogWindow::DoScroll( ScrollBar* pCurScrollBar )
2000-09-29 10:02:42 +00:00
{
pEditor->DoScroll( pCurScrollBar );
}
2010-12-11 22:45:31 +01:00
void DialogWindow::GetState( SfxItemSet& rSet )
2000-09-29 10:02:42 +00:00
{
SfxWhichIter aIter(rSet);
bool bIsCalc = false;
if ( GetDocument().isDocument() )
{
Reference< frame::XModel > xModel= GetDocument().getDocument();
if ( xModel.is() )
{
Reference< lang::XServiceInfo > xServiceInfo ( xModel, UNO_QUERY );
if ( xServiceInfo.is() && xServiceInfo->supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
bIsCalc = true;
}
}
for ( sal_uInt16 nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich() )
2000-09-29 10:02:42 +00:00
{
switch ( nWh )
{
case SID_PASTE:
{
if ( !IsPasteAllowed() )
rSet.DisableItem( nWh );
if ( IsReadOnly() )
rSet.DisableItem( nWh );
}
2000-09-29 10:02:42 +00:00
break;
case SID_COPY:
{
// any object selected?
if ( !pEditor->GetView().AreObjectsMarked() )
rSet.DisableItem( nWh );
}
break;
case SID_CUT:
2000-09-29 10:02:42 +00:00
case SID_DELETE:
case SID_BACKSPACE:
{
// any object selected?
if ( !pEditor->GetView().AreObjectsMarked() )
rSet.DisableItem( nWh );
if ( IsReadOnly() )
rSet.DisableItem( nWh );
2000-09-29 10:02:42 +00:00
}
break;
case SID_REDO:
{
if ( !pUndoMgr->GetUndoActionCount() )
rSet.DisableItem( nWh );
}
break;
case SID_DIALOG_TESTMODE:
{
// is the IDE still active?
bool const bBool = GetShell()->GetFrame() &&
pEditor->GetMode() == DlgEditor::TEST;
rSet.Put(SfxBoolItem(SID_DIALOG_TESTMODE, bBool));
2000-09-29 10:02:42 +00:00
}
break;
case SID_CHOOSE_CONTROLS:
{
if ( IsReadOnly() )
{
rSet.DisableItem( nWh );
}
2000-09-29 10:02:42 +00:00
else
{
SfxAllEnumItem aItem( SID_CHOOSE_CONTROLS );
if ( GetEditor().GetMode() == DlgEditor::SELECT )
aItem.SetValue( SVX_SNAP_SELECT );
else
2000-09-29 10:02:42 +00:00
{
sal_uInt16 nObj;
switch( pEditor->GetInsertObj() )
{
case OBJ_DLG_PUSHBUTTON: nObj = SVX_SNAP_PUSHBUTTON; break;
case OBJ_DLG_RADIOBUTTON: nObj = SVX_SNAP_RADIOBUTTON; break;
case OBJ_DLG_CHECKBOX: nObj = SVX_SNAP_CHECKBOX; break;
case OBJ_DLG_LISTBOX: nObj = SVX_SNAP_LISTBOX; break;
case OBJ_DLG_COMBOBOX: nObj = SVX_SNAP_COMBOBOX; break;
case OBJ_DLG_GROUPBOX: nObj = SVX_SNAP_GROUPBOX; break;
case OBJ_DLG_EDIT: nObj = SVX_SNAP_EDIT; break;
case OBJ_DLG_FIXEDTEXT: nObj = SVX_SNAP_FIXEDTEXT; break;
case OBJ_DLG_IMAGECONTROL: nObj = SVX_SNAP_IMAGECONTROL; break;
case OBJ_DLG_PROGRESSBAR: nObj = SVX_SNAP_PROGRESSBAR; break;
case OBJ_DLG_HSCROLLBAR: nObj = SVX_SNAP_HSCROLLBAR; break;
case OBJ_DLG_VSCROLLBAR: nObj = SVX_SNAP_VSCROLLBAR; break;
case OBJ_DLG_HFIXEDLINE: nObj = SVX_SNAP_HFIXEDLINE; break;
case OBJ_DLG_VFIXEDLINE: nObj = SVX_SNAP_VFIXEDLINE; break;
case OBJ_DLG_DATEFIELD: nObj = SVX_SNAP_DATEFIELD; break;
case OBJ_DLG_TIMEFIELD: nObj = SVX_SNAP_TIMEFIELD; break;
case OBJ_DLG_NUMERICFIELD: nObj = SVX_SNAP_NUMERICFIELD; break;
case OBJ_DLG_CURRENCYFIELD: nObj = SVX_SNAP_CURRENCYFIELD; break;
case OBJ_DLG_FORMATTEDFIELD: nObj = SVX_SNAP_FORMATTEDFIELD; break;
case OBJ_DLG_PATTERNFIELD: nObj = SVX_SNAP_PATTERNFIELD; break;
case OBJ_DLG_FILECONTROL: nObj = SVX_SNAP_FILECONTROL; break;
case OBJ_DLG_SPINBUTTON: nObj = SVX_SNAP_SPINBUTTON; break;
case OBJ_DLG_TREECONTROL: nObj = SVX_SNAP_TREECONTROL; break;
default: nObj = 0;
}
2000-09-29 10:02:42 +00:00
#ifdef DBG_UTIL
if( !nObj )
{
DBG_WARNING( "SID_CHOOSE_CONTROLS: Unbekannt!" );
}
2000-09-29 10:02:42 +00:00
#endif
aItem.SetValue( nObj );
}
2000-09-29 10:02:42 +00:00
rSet.Put( aItem );
}
2000-09-29 10:02:42 +00:00
}
break;
case SID_SHOW_PROPERTYBROWSER:
{
Shell* pShell = GetShell();
SfxViewFrame* pViewFrame = pShell ? pShell->GetViewFrame() : NULL;
if ( pViewFrame && !pViewFrame->HasChildWindow( SID_SHOW_PROPERTYBROWSER ) && !pEditor->GetView().AreObjectsMarked() )
rSet.DisableItem( nWh );
if ( IsReadOnly() )
rSet.DisableItem( nWh );
}
break;
case SID_INSERT_FORM_RADIO:
case SID_INSERT_FORM_CHECK:
case SID_INSERT_FORM_LIST:
case SID_INSERT_FORM_COMBO:
case SID_INSERT_FORM_VSCROLL:
case SID_INSERT_FORM_HSCROLL:
case SID_INSERT_FORM_SPIN:
{
if ( !bIsCalc || IsReadOnly() )
rSet.DisableItem( nWh );
}
break;
case SID_SHOWLINES:
{
// if this is not a module window hide the
// setting, doesn't make sense for example if the
// dialog editor is open
rSet.DisableItem(nWh);
rSet.Put(SfxVisibilityItem(nWh, false));
break;
}
2000-09-29 10:02:42 +00:00
}
}
}
2010-12-11 22:45:31 +01:00
void DialogWindow::ExecuteCommand( SfxRequest& rReq )
2000-09-29 10:02:42 +00:00
{
switch ( rReq.GetSlot() )
{
case SID_CUT:
if ( !IsReadOnly() )
{
GetEditor().Cut();
if (SfxBindings* pBindings = GetBindingsPtr())
pBindings->Invalidate( SID_DOC_MODIFIED );
}
2000-09-29 10:02:42 +00:00
break;
case SID_DELETE:
if ( !IsReadOnly() )
{
GetEditor().Delete();
if (SfxBindings* pBindings = GetBindingsPtr())
pBindings->Invalidate( SID_DOC_MODIFIED );
}
2000-09-29 10:02:42 +00:00
break;
case SID_COPY:
GetEditor().Copy();
2000-09-29 10:02:42 +00:00
break;
case SID_PASTE:
if ( !IsReadOnly() )
{
GetEditor().Paste();
if (SfxBindings* pBindings = GetBindingsPtr())
pBindings->Invalidate( SID_DOC_MODIFIED );
}
2000-09-29 10:02:42 +00:00
break;
case SID_INSERT_FORM_RADIO:
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_FORMRADIO );
break;
case SID_INSERT_FORM_CHECK:
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_FORMCHECK );
break;
case SID_INSERT_FORM_LIST:
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_FORMLIST );
break;
case SID_INSERT_FORM_COMBO:
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_FORMCOMBO );
break;
case SID_INSERT_FORM_SPIN:
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_FORMSPIN );
break;
case SID_INSERT_FORM_VSCROLL:
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_FORMVSCROLL );
break;
case SID_INSERT_FORM_HSCROLL:
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_FORMHSCROLL );
break;
2000-09-29 10:02:42 +00:00
case SID_CHOOSE_CONTROLS:
{
const SfxItemSet* pArgs = rReq.GetArgs();
DBG_ASSERT( pArgs, "Nix Args" );
const SfxAllEnumItem& rItem = (SfxAllEnumItem&)pArgs->Get( SID_CHOOSE_CONTROLS );
switch( rItem.GetValue() )
{
case SVX_SNAP_PUSHBUTTON:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_PUSHBUTTON );
2000-09-29 10:02:42 +00:00
}
break;
case SVX_SNAP_RADIOBUTTON:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_RADIOBUTTON );
2000-09-29 10:02:42 +00:00
}
break;
case SVX_SNAP_CHECKBOX:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_CHECKBOX);
2000-09-29 10:02:42 +00:00
}
break;
case SVX_SNAP_LISTBOX:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_LISTBOX );
2000-09-29 10:02:42 +00:00
}
break;
case SVX_SNAP_COMBOBOX:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_COMBOBOX );
2000-09-29 10:02:42 +00:00
}
break;
case SVX_SNAP_GROUPBOX:
2000-09-29 10:02:42 +00:00
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_GROUPBOX );
2000-09-29 10:02:42 +00:00
}
break;
case SVX_SNAP_EDIT:
2000-09-29 10:02:42 +00:00
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_EDIT );
2000-09-29 10:02:42 +00:00
}
break;
case SVX_SNAP_FIXEDTEXT:
2000-09-29 10:02:42 +00:00
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_FIXEDTEXT );
2000-09-29 10:02:42 +00:00
}
break;
case SVX_SNAP_IMAGECONTROL:
2000-09-29 10:02:42 +00:00
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_IMAGECONTROL );
2000-09-29 10:02:42 +00:00
}
break;
case SVX_SNAP_PROGRESSBAR:
2000-09-29 10:02:42 +00:00
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_PROGRESSBAR );
2000-09-29 10:02:42 +00:00
}
break;
case SVX_SNAP_HSCROLLBAR:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_HSCROLLBAR );
}
break;
case SVX_SNAP_VSCROLLBAR:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_VSCROLLBAR );
}
break;
case SVX_SNAP_HFIXEDLINE:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_HFIXEDLINE );
}
break;
case SVX_SNAP_VFIXEDLINE:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_VFIXEDLINE );
}
break;
case SVX_SNAP_DATEFIELD:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_DATEFIELD );
}
break;
case SVX_SNAP_TIMEFIELD:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_TIMEFIELD );
}
break;
case SVX_SNAP_NUMERICFIELD:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_NUMERICFIELD );
}
break;
case SVX_SNAP_CURRENCYFIELD:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_CURRENCYFIELD );
}
break;
case SVX_SNAP_FORMATTEDFIELD:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_FORMATTEDFIELD );
}
break;
case SVX_SNAP_PATTERNFIELD:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_PATTERNFIELD );
}
break;
case SVX_SNAP_FILECONTROL:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_FILECONTROL );
}
break;
case SVX_SNAP_SPINBUTTON:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_SPINBUTTON );
}
break;
case SVX_SNAP_TREECONTROL:
{
GetEditor().SetMode( DlgEditor::INSERT );
GetEditor().SetInsertObj( OBJ_DLG_TREECONTROL );
}
break;
case SVX_SNAP_SELECT:
{
GetEditor().SetMode( DlgEditor::SELECT );
}
break;
2000-09-29 10:02:42 +00:00
}
if ( rReq.GetModifier() & KEY_MOD1 )
{
if ( GetEditor().GetMode() == DlgEditor::INSERT )
GetEditor().CreateDefaultObject();
}
if (SfxBindings* pBindings = GetBindingsPtr())
pBindings->Invalidate( SID_DOC_MODIFIED );
2000-09-29 10:02:42 +00:00
}
break;
case SID_DIALOG_TESTMODE:
{
DlgEditor::Mode eOldMode = GetEditor().GetMode();
GetEditor().SetMode( DlgEditor::TEST );
GetEditor().SetMode( eOldMode );
2000-09-29 10:02:42 +00:00
rReq.Done();
if (SfxBindings* pBindings = GetBindingsPtr())
pBindings->Invalidate( SID_DIALOG_TESTMODE );
2000-09-29 10:02:42 +00:00
return;
}
case SID_EXPORT_DIALOG:
SaveDialog();
break;
case SID_IMPORT_DIALOG:
ImportDialog();
break;
case SID_BASICIDE_DELETECURRENT:
if (QueryDelDialog(m_aName, this))
{
if (RemoveDialog(m_aDocument, m_aLibName, m_aName))
{
MarkDocumentModified(m_aDocument);
GetShell()->RemoveWindow(this, true);
}
}
break;
2000-09-29 10:02:42 +00:00
}
rReq.Done();
}
2001-06-15 07:45:19 +00:00
Reference< container::XNameContainer > DialogWindow::GetDialog() const
2000-09-29 10:02:42 +00:00
{
2001-06-15 07:45:19 +00:00
return pEditor->GetDialog();
2000-09-29 10:02:42 +00:00
}
bool DialogWindow::RenameDialog( const OUString& rNewName )
2001-06-15 07:45:19 +00:00
{
if ( !basctl::RenameDialog( this, GetDocument(), GetLibName(), GetName(), rNewName ) )
return false;
2000-09-29 10:02:42 +00:00
if (SfxBindings* pBindings = GetBindingsPtr())
pBindings->Invalidate( SID_DOC_MODIFIED );
2000-09-29 10:02:42 +00:00
return true;
2001-06-15 07:45:19 +00:00
}
2000-09-29 10:02:42 +00:00
void DialogWindow::DisableBrowser()
{
rLayout.DisablePropertyBrowser();
2000-09-29 10:02:42 +00:00
}
void DialogWindow::UpdateBrowser()
{
rLayout.UpdatePropertyBrowser();
2000-09-29 10:02:42 +00:00
}
static OUString aResourceResolverPropName( "ResourceResolver" );
bool DialogWindow::SaveDialog()
{
DBG_CHKTHIS( DialogWindow, 0 );
bool bDone = false;
Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD);
Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false);
Any aValue;
aValue <<= sal_True;
xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
2011-12-09 01:58:49 -05:00
if ( !aCurPath.isEmpty() )
xFP->setDisplayDirectory ( aCurPath );
xFP->setDefaultName( OUString( GetName() ) );
OUString aDialogStr(IDE_RESSTR(RID_STR_STDDIALOGNAME));
xFP->appendFilter( aDialogStr, String( "*.xdl" ) );
xFP->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), String( FilterMask_All ) );
xFP->setCurrentFilter( aDialogStr );
if( xFP->execute() == RET_OK )
{
Sequence< OUString > aPaths = xFP->getFiles();
aCurPath = aPaths[0];
// export dialog model to xml
Reference< container::XNameContainer > xDialogModel = GetDialog();
Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() );
Reference< XInputStream > xInput( xISP->createInputStream() );
Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) );
Reference< XOutputStream > xOutput;
try
{
if( xSFI->exists( aCurPath ) )
xSFI->kill( aCurPath );
xOutput = xSFI->openFileWrite( aCurPath );
}
catch(const Exception& )
{}
if( xOutput.is() )
{
Sequence< sal_Int8 > bytes;
sal_Int32 nRead = xInput->readBytes( bytes, xInput->available() );
for (;;)
{
if( nRead )
xOutput->writeBytes( bytes );
nRead = xInput->readBytes( bytes, 1024 );
if (! nRead)
break;
}
bDone = true;
// With resource?
Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY );
Reference< resource::XStringResourceResolver > xStringResourceResolver;
if( xDialogModelPropSet.is() )
{
try
{
Any aResourceResolver = xDialogModelPropSet->getPropertyValue( aResourceResolverPropName );
aResourceResolver >>= xStringResourceResolver;
}
catch(const beans::UnknownPropertyException& )
{}
}
bool bResource = false;
if( xStringResourceResolver.is() )
{
Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales();
sal_Int32 nLocaleCount = aLocaleSeq.getLength();
if( nLocaleCount > 0 )
bResource = true;
}
if( bResource )
{
INetURLObject aURLObj( aCurPath );
aURLObj.removeExtension();
OUString aDialogName( aURLObj.getName() );
aURLObj.removeSegment();
OUString aURL( aURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
bool bReadOnly = false;
OUString aComment( "# " );
aComment += aDialogName;
aComment += " strings" ;
Reference< task::XInteractionHandler > xDummyHandler;
// Remove old properties files in case of overwriting Dialog files
if( xSFI->isFolder( aURL ) )
{
Sequence< OUString > aContentSeq = xSFI->getFolderContents( aURL, false );
OUString aDialogName_( aDialogName );
aDialogName_ += "_" ;
sal_Int32 nCount = aContentSeq.getLength();
const OUString* pFiles = aContentSeq.getConstArray();
for( int i = 0 ; i < nCount ; i++ )
{
OUString aCompleteName = pFiles[i];
OUString aPureName;
OUString aExtension;
sal_Int32 iDot = aCompleteName.lastIndexOf( '.' );
sal_Int32 iSlash = aCompleteName.lastIndexOf( '/' );
if( iDot != -1 )
{
sal_Int32 iCopyFrom = (iSlash != -1) ? iSlash + 1 : 0;
aPureName = aCompleteName.copy( iCopyFrom, iDot-iCopyFrom );
aExtension = aCompleteName.copy( iDot + 1 );
}
if( aExtension == "properties" || aExtension == "default" )
{
if( aPureName.indexOf( aDialogName_ ) == 0 )
{
try
{
xSFI->kill( aCompleteName );
}
catch(const uno::Exception& )
{}
}
}
}
}
Reference< XStringResourceWithLocation > xStringResourceWithLocation =
StringResourceWithLocation::create( xContext, aURL, bReadOnly,
xStringResourceResolver->getDefaultLocale(), aDialogName, aComment, xDummyHandler );
// Add locales
Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales();
const lang::Locale* pLocales = aLocaleSeq.getConstArray();
sal_Int32 nLocaleCount = aLocaleSeq.getLength();
for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
{
const lang::Locale& rLocale = pLocales[ iLocale ];
xStringResourceWithLocation->newLocale( rLocale );
}
LocalizationMgr::copyResourceForDialog( xDialogModel,
xStringResourceResolver, xStringResourceWithLocation );
xStringResourceWithLocation->store();
}
}
else
ErrorBox( this, WB_OK | WB_DEF_OK, IDE_RESSTR(RID_STR_COULDNTWRITE)).Execute();
}
return bDone;
}
extern bool localesAreEqual( const ::com::sun::star::lang::Locale& rLocaleLeft,
const ::com::sun::star::lang::Locale& rLocaleRight );
std::vector< lang::Locale > implGetLanguagesOnlyContainedInFirstSeq
( Sequence< lang::Locale > aFirstSeq, Sequence< lang::Locale > aSecondSeq )
{
std::vector< lang::Locale > avRet;
const lang::Locale* pFirst = aFirstSeq.getConstArray();
const lang::Locale* pSecond = aSecondSeq.getConstArray();
sal_Int32 nFirstCount = aFirstSeq.getLength();
sal_Int32 nSecondCount = aSecondSeq.getLength();
for( sal_Int32 iFirst = 0 ; iFirst < nFirstCount ; iFirst++ )
{
const lang::Locale& rFirstLocale = pFirst[ iFirst ];
bool bAlsoContainedInSecondSeq = false;
for( sal_Int32 iSecond = 0 ; iSecond < nSecondCount ; iSecond++ )
{
const lang::Locale& rSecondLocale = pSecond[ iSecond ];
bool bMatch = localesAreEqual( rFirstLocale, rSecondLocale );
if( bMatch )
{
bAlsoContainedInSecondSeq = true;
break;
}
}
if( !bAlsoContainedInSecondSeq )
avRet.push_back( rFirstLocale );
}
return avRet;
}
class NameClashQueryBox : public MessBox
{
public:
NameClashQueryBox( Window* pParent,
const OUString& rTitle, const OUString& rMessage );
};
NameClashQueryBox::NameClashQueryBox( Window* pParent,
const OUString& rTitle, const OUString& rMessage )
: MessBox( pParent, 0, rTitle, rMessage )
{
if ( !rTitle.isEmpty() )
SetText( rTitle );
maMessText = rMessage;
AddButton( IDE_RESSTR(RID_STR_DLGIMP_CLASH_RENAME), RET_YES,
BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_OKBUTTON | BUTTONDIALOG_FOCUSBUTTON );
AddButton( IDE_RESSTR(RID_STR_DLGIMP_CLASH_REPLACE), RET_NO, 0 );
AddButton( BUTTON_CANCEL, RET_CANCEL, BUTTONDIALOG_CANCELBUTTON );
SetImage( QueryBox::GetStandardImage() );
}
class LanguageMismatchQueryBox : public MessBox
{
public:
LanguageMismatchQueryBox( Window* pParent,
const OUString& rTitle, const OUString& rMessage );
};
LanguageMismatchQueryBox::LanguageMismatchQueryBox( Window* pParent,
const OUString& rTitle, const OUString& rMessage )
: MessBox( pParent, 0, rTitle, rMessage )
{
if ( !rTitle.isEmpty() )
SetText( rTitle );
maMessText = rMessage;
AddButton( IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_ADD), RET_YES,
BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_OKBUTTON | BUTTONDIALOG_FOCUSBUTTON );
AddButton( IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_OMIT), RET_NO, 0 );
AddButton( BUTTON_CANCEL, RET_CANCEL, BUTTONDIALOG_CANCELBUTTON );
AddButton( BUTTON_HELP, RET_HELP, BUTTONDIALOG_HELPBUTTON, 4 );
SetImage( QueryBox::GetStandardImage() );
}
bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocument& rDocument, const OUString& aLibName )
{
bool bDone = false;
Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_SIMPLE);
Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false);
Any aValue;
aValue <<= sal_True;
xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
OUString aCurPath( rCurPath );
2011-12-09 01:58:49 -05:00
if ( !aCurPath.isEmpty() )
xFP->setDisplayDirectory ( aCurPath );
OUString aDialogStr(IDE_RESSTR(RID_STR_STDDIALOGNAME));
xFP->appendFilter( aDialogStr, String( "*.xdl" ) );
xFP->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), String( FilterMask_All ) );
xFP->setCurrentFilter( aDialogStr );
if( xFP->execute() == RET_OK )
{
Sequence< OUString > aPaths = xFP->getFiles();
aCurPath = aPaths[0];
OUString aBasePath;
OUString aOUCurPath( aCurPath );
sal_Int32 iSlash = aOUCurPath.lastIndexOf( '/' );
if( iSlash != -1 )
aBasePath = aOUCurPath.copy( 0, iSlash + 1 );
try
{
// create dialog model
Reference< container::XNameContainer > xDialogModel(
xContext->getServiceManager()->createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", xContext),
UNO_QUERY_THROW );
Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) );
Reference< XInputStream > xInput;
if( xSFI->exists( aCurPath ) )
xInput = xSFI->openFileRead( aCurPath );
::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() );
Revert "fdo#46808, Convert awt::UnoControlDialogModel to new style" This reverts commit 6c61b20a8d4a6dcac28801cde82a211fb7e30654. As discussed at <http://lists.freedesktop.org/archives/libreoffice/2013-May/052449.html> "Re: fdo#46808, Convert awt::UnoControlDialogModel to new style problem" why the odd change in 2e2a4827ce6708f0e8677dba9cc92e1479a44086 "scripting: get CreateUnoDialog() work again" appears to fix things again: The problem is that the implementation of the css.awt.UnoControlDialogModel involves UNO aggregation (IMPL_CREATE_INSTANCE_WITH_GEOMETRY(UnoControlDialogModel) in toolkit/soruce/helper/registerservices.cxx creating a OGeometryControlModel<UnoControlDialogModel> instance that aggregates a UnoControlDialogModel instance). That means that queryInterface can return a reference to something that is technically a different object, and that's what's happening here, and explains why calling setPropertyValue in two different ways on what logically appears to be a single object can end up calling two different implementations (of two different physical objects). (UNO aggregation is known to be broken and should not be used. Nevertheless, there's still code that does---code that is a horrible mess and hard to clean up.) That all this worked as intended in the past is just sheer luck, but any way of substantially touching it is asking for trouble. I'm going to revert 6c61b20a8d4a6dcac28801cde82a211fb7e30654 again. I wasn't able to revert without also reverting be50ad28f5bbdaeff527f646481ce263843c2401 "fdo#46808, Convert awt::XUnoControlDialog to new style," as the two were tightly dependant. Also reverts all the follow-up fixes cb4b6dde8fda2a5848e11063028bf44d72f85431 "-Werror,-Wuninitialized" (sans the const-ness fix in UpdateHandler::insertControlModel), 697a007c61b9cabceb9767fad87cd5822b300452 "Fix exception specifications," 2ce6828bbbf6ba181bb2276adeec279e74151ef6 "fix awt::UnoControlModelDialog crash," and 2e2a4827ce6708f0e8677dba9cc92e1479a44086 "scripting: get CreateUnoDialog() work again." Conflicts: basctl/source/dlged/dlged.cxx filter/source/t602/t602filter.cxx xmlscript/test/imexp.cxx Change-Id: I5d133468062f3ca36300db52fbd699be1ac72998
2013-05-24 22:44:30 +02:00
OUString aXmlDlgName;
Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY );
if( xDialogModelPropSet.is() )
{
try
{
Any aXmlDialogNameAny = xDialogModelPropSet->getPropertyValue( DLGED_PROP_NAME );
OUString aOUXmlDialogName;
aXmlDialogNameAny >>= aOUXmlDialogName;
aXmlDlgName = aOUXmlDialogName;
}
catch(const beans::UnknownPropertyException& )
{}
}
2011-12-09 01:58:49 -05:00
bool bValidName = !aXmlDlgName.isEmpty();
OSL_ASSERT( bValidName );
if( !bValidName )
return bDone;
bool bDialogAlreadyExists = rDocument.hasDialog( aLibName, aXmlDlgName );
OUString aNewDlgName = aXmlDlgName;
enum NameClashMode
{
NO_CLASH,
CLASH_OVERWRITE_DIALOG,
CLASH_RENAME_DIALOG,
};
NameClashMode eNameClashMode = NO_CLASH;
if( bDialogAlreadyExists )
{
OUString aQueryBoxTitle(IDE_RESSTR(RID_STR_DLGIMP_CLASH_TITLE));
OUString aQueryBoxText(IDE_RESSTR(RID_STR_DLGIMP_CLASH_TEXT));
aQueryBoxText = aQueryBoxText.replaceAll("$(ARG1)", aXmlDlgName);
NameClashQueryBox aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText );
sal_uInt16 nRet = aQueryBox.Execute();
if( RET_YES == nRet )
{
// RET_YES == Rename, see NameClashQueryBox::NameClashQueryBox
eNameClashMode = CLASH_RENAME_DIALOG;
aNewDlgName = rDocument.createObjectName( E_DIALOGS, aLibName );
}
else if( RET_NO == nRet )
{
// RET_NO == Replace, see NameClashQueryBox::NameClashQueryBox
eNameClashMode = CLASH_OVERWRITE_DIALOG;
}
else if( RET_CANCEL == nRet )
{
return bDone;
}
}
Shell* pShell = GetShell();
if (!pShell)
{
OSL_ASSERT(pShell);
return bDone;
}
// Resource?
::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILanguageTag().getLocale();
Reference< task::XInteractionHandler > xDummyHandler;
bool bReadOnly = true;
Reference< XStringResourceWithLocation > xImportStringResource =
StringResourceWithLocation::create( xContext, aBasePath, bReadOnly,
aLocale, aXmlDlgName, OUString(), xDummyHandler );
Sequence< lang::Locale > aImportLocaleSeq = xImportStringResource->getLocales();
sal_Int32 nImportLocaleCount = aImportLocaleSeq.getLength();
Reference< container::XNameContainer > xDialogLib( rDocument.getLibrary( E_DIALOGS, aLibName, true ) );
Reference< resource::XStringResourceManager > xLibStringResourceManager = LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
sal_Int32 nLibLocaleCount = 0;
Sequence< lang::Locale > aLibLocaleSeq;
if( xLibStringResourceManager.is() )
{
aLibLocaleSeq = xLibStringResourceManager->getLocales();
nLibLocaleCount = aLibLocaleSeq.getLength();
}
// Check language matches
std::vector< lang::Locale > aOnlyInImportLanguages =
implGetLanguagesOnlyContainedInFirstSeq( aImportLocaleSeq, aLibLocaleSeq );
int nOnlyInImportLanguageCount = aOnlyInImportLanguages.size();
// For now: Keep languages from lib
bool bLibLocalized = (nLibLocaleCount > 0);
bool bImportLocalized = (nImportLocaleCount > 0);
bool bAddDialogLanguagesToLib = false;
if( nOnlyInImportLanguageCount > 0 )
{
OUString aQueryBoxTitle(IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_TITLE));
OUString aQueryBoxText(IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_TEXT));
LanguageMismatchQueryBox aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText );
sal_uInt16 nRet = aQueryBox.Execute();
if( RET_YES == nRet )
{
// RET_YES == Add, see LanguageMismatchQueryBox::LanguageMismatchQueryBox
bAddDialogLanguagesToLib = true;
}
// RET_NO == Omit, see LanguageMismatchQueryBox::LanguageMismatchQueryBox
// -> nothing to do here
//else if( RET_NO == nRet )
//{
//}
else if( RET_CANCEL == nRet )
{
return bDone;
}
}
if( bImportLocalized )
{
bool bCopyResourcesForDialog = true;
if( bAddDialogLanguagesToLib )
{
boost::shared_ptr<LocalizationMgr> pCurMgr = pShell->GetCurLocalizationMgr();
lang::Locale aFirstLocale;
aFirstLocale = aOnlyInImportLanguages[0];
if( nOnlyInImportLanguageCount > 1 )
{
// Check if import default belongs to only import languages and use it then
lang::Locale aImportDefaultLocale = xImportStringResource->getDefaultLocale();
lang::Locale aTmpLocale;
for( int i = 0 ; i < nOnlyInImportLanguageCount ; ++i )
{
aTmpLocale = aOnlyInImportLanguages[i];
if( localesAreEqual( aImportDefaultLocale, aTmpLocale ) )
{
aFirstLocale = aImportDefaultLocale;
break;
}
}
}
Sequence< lang::Locale > aFirstLocaleSeq( 1 );
aFirstLocaleSeq[0] = aFirstLocale;
pCurMgr->handleAddLocales( aFirstLocaleSeq );
if( nOnlyInImportLanguageCount > 1 )
{
Sequence< lang::Locale > aRemainingLocaleSeq( nOnlyInImportLanguageCount - 1 );
lang::Locale aTmpLocale;
int iSeq = 0;
for( int i = 0 ; i < nOnlyInImportLanguageCount ; ++i )
{
aTmpLocale = aOnlyInImportLanguages[i];
if( !localesAreEqual( aFirstLocale, aTmpLocale ) )
aRemainingLocaleSeq[iSeq++] = aTmpLocale;
}
pCurMgr->handleAddLocales( aRemainingLocaleSeq );
}
}
else if( !bLibLocalized )
{
Reference< resource::XStringResourceManager > xImportStringResourceManager( xImportStringResource, UNO_QUERY );
LocalizationMgr::resetResourceForDialog( xDialogModel, xImportStringResourceManager );
bCopyResourcesForDialog = false;
}
if( bCopyResourcesForDialog )
{
Reference< resource::XStringResourceResolver > xImportStringResourceResolver( xImportStringResource, UNO_QUERY );
LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, aXmlDlgName,
xLibStringResourceManager, xImportStringResourceResolver );
}
}
else if( bLibLocalized )
{
LocalizationMgr::setResourceIDsForDialog( xDialogModel, xLibStringResourceManager );
}
LocalizationMgr::setStringResourceAtDialog( rDocument, aLibName, aNewDlgName, xDialogModel );
if( eNameClashMode == CLASH_OVERWRITE_DIALOG )
{
if (basctl::RemoveDialog( rDocument, aLibName, aNewDlgName ) )
{
BaseWindow* pDlgWin = pShell->FindDlgWin( rDocument, aLibName, aNewDlgName, false, true );
if( pDlgWin != NULL )
pShell->RemoveWindow( pDlgWin, true );
MarkDocumentModified( rDocument );
}
else
{
// TODO: Assertion?
return bDone;
}
}
if( eNameClashMode == CLASH_RENAME_DIALOG )
{
Revert "fdo#46808, Convert awt::UnoControlDialogModel to new style" This reverts commit 6c61b20a8d4a6dcac28801cde82a211fb7e30654. As discussed at <http://lists.freedesktop.org/archives/libreoffice/2013-May/052449.html> "Re: fdo#46808, Convert awt::UnoControlDialogModel to new style problem" why the odd change in 2e2a4827ce6708f0e8677dba9cc92e1479a44086 "scripting: get CreateUnoDialog() work again" appears to fix things again: The problem is that the implementation of the css.awt.UnoControlDialogModel involves UNO aggregation (IMPL_CREATE_INSTANCE_WITH_GEOMETRY(UnoControlDialogModel) in toolkit/soruce/helper/registerservices.cxx creating a OGeometryControlModel<UnoControlDialogModel> instance that aggregates a UnoControlDialogModel instance). That means that queryInterface can return a reference to something that is technically a different object, and that's what's happening here, and explains why calling setPropertyValue in two different ways on what logically appears to be a single object can end up calling two different implementations (of two different physical objects). (UNO aggregation is known to be broken and should not be used. Nevertheless, there's still code that does---code that is a horrible mess and hard to clean up.) That all this worked as intended in the past is just sheer luck, but any way of substantially touching it is asking for trouble. I'm going to revert 6c61b20a8d4a6dcac28801cde82a211fb7e30654 again. I wasn't able to revert without also reverting be50ad28f5bbdaeff527f646481ce263843c2401 "fdo#46808, Convert awt::XUnoControlDialog to new style," as the two were tightly dependant. Also reverts all the follow-up fixes cb4b6dde8fda2a5848e11063028bf44d72f85431 "-Werror,-Wuninitialized" (sans the const-ness fix in UpdateHandler::insertControlModel), 697a007c61b9cabceb9767fad87cd5822b300452 "Fix exception specifications," 2ce6828bbbf6ba181bb2276adeec279e74151ef6 "fix awt::UnoControlModelDialog crash," and 2e2a4827ce6708f0e8677dba9cc92e1479a44086 "scripting: get CreateUnoDialog() work again." Conflicts: basctl/source/dlged/dlged.cxx filter/source/t602/t602filter.cxx xmlscript/test/imexp.cxx Change-Id: I5d133468062f3ca36300db52fbd699be1ac72998
2013-05-24 22:44:30 +02:00
bool bRenamed = false;
if( xDialogModelPropSet.is() )
{
try
{
Any aXmlDialogNameAny;
aXmlDialogNameAny <<= OUString( aNewDlgName );
xDialogModelPropSet->setPropertyValue( DLGED_PROP_NAME, aXmlDialogNameAny );
bRenamed = true;
}
catch(const beans::UnknownPropertyException& )
{}
}
if( bRenamed )
{
LocalizationMgr::renameStringResourceIDs( rDocument, aLibName, aNewDlgName, xDialogModel );
}
else
{
// TODO: Assertion?
return bDone;
}
}
Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() );
bool bSuccess = rDocument.insertDialog( aLibName, aNewDlgName, xISP );
if( bSuccess )
{
DialogWindow* pNewDlgWin = pShell->CreateDlgWin( rDocument, aLibName, aNewDlgName );
pShell->SetCurWindow( pNewDlgWin, true );
}
bDone = true;
}
catch(const Exception& )
{}
}
return bDone;
}
bool DialogWindow::ImportDialog()
{
DBG_CHKTHIS( DialogWindow, 0 );
const ScriptDocument& rDocument = GetDocument();
OUString aLibName = GetLibName();
return implImportDialog( this, aCurPath, rDocument, aLibName );
}
DlgEdModel& DialogWindow::GetModel() const
2000-09-29 10:02:42 +00:00
{
return pEditor->GetModel();
}
DlgEdPage& DialogWindow::GetPage() const
{
return pEditor->GetPage();
}
DlgEdView& DialogWindow::GetView() const
{
return pEditor->GetView();
2000-09-29 10:02:42 +00:00
}
bool DialogWindow::IsModified()
2000-09-29 10:02:42 +00:00
{
2001-06-15 07:45:19 +00:00
return pEditor->IsModified();
2000-09-29 10:02:42 +00:00
}
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101 * commit 'ooo/DEV300_m101': (185 commits) masterfix DEV300: #i10000# usage of L10N build_type masterfix: #i10000# INT16 -> sal_Int16 fixed compile errors after resync to m100, part2 gridsort: post-rebase fixes CWS gnumake3: found another tools integer type removetooltypes01: Fix build problems after rebase to DEV300m99 in basctl, cui, reportdesign, sw native359: #i114398# changing mac langpack icon native359: #i115669# fixing package description for solaris packages gnumake3: remove comphelper version; fix including extract.hxx locales34: #i106785# add Haitian_Haiti [ht-HT] to language list and locale data; locale data contributed by <jcpoulard> sb138: #i116659# timely termination of OnLogRotateThread accfixes: removed include of obsolete header file accfixes: removed obsolete file removetooltypes01: #i112600# Fix build problems on non-pro accfixes: moved some shared strings to svx part2 accfixes: moved some shared strings to svx accfixes: added more accessibility information and fixed tab orders in multiple dialogs (cui module) removetooltypes01: #i112600# Remove tools types for Mac specific parts fixed tab order in BasicIDE, Library dialog tab page added some accessible names in BasicIDE ... Conflicts: UnoControls/source/base/registercontrols.cxx accessibility/inc/accessibility/standard/vclxaccessiblelistboxlist.hxx automation/inc/automation/communi.hxx automation/inc/automation/simplecm.hxx automation/source/communi/communi.cxx automation/source/inc/rcontrol.hxx automation/source/miniapp/servuid.hxx automation/source/server/XMLParser.cxx automation/source/server/cmdbasestream.cxx automation/source/server/profiler.hxx automation/source/server/recorder.cxx automation/source/server/retstrm.hxx automation/source/server/server.cxx automation/source/server/sta_list.cxx automation/source/server/statemnt.cxx automation/source/server/statemnt.hxx automation/source/simplecm/packethandler.cxx automation/source/simplecm/simplecm.cxx automation/source/simplecm/tcpio.cxx automation/source/simplecm/tcpio.hxx automation/source/testtool/comm_bas.hxx automation/source/testtool/cretstrm.hxx automation/source/testtool/httprequest.cxx automation/source/testtool/httprequest.hxx automation/source/testtool/objtest.cxx automation/source/testtool/objtest.hxx basctl/source/basicide/baside2.cxx basctl/source/basicide/baside2.hxx basctl/source/basicide/baside2b.cxx basctl/source/basicide/baside3.cxx basctl/source/basicide/basides1.cxx basctl/source/basicide/basides2.cxx basctl/source/basicide/basidesh.cxx basctl/source/basicide/basidesh.src basctl/source/basicide/basobj3.cxx basctl/source/basicide/bastype2.cxx basctl/source/basicide/bastype3.cxx basctl/source/basicide/bastypes.cxx basctl/source/basicide/brkdlg.cxx basctl/source/basicide/iderdll.cxx basctl/source/basicide/macrodlg.cxx basctl/source/basicide/moduldl2.cxx basctl/source/basicide/moduldlg.cxx basctl/source/basicide/objdlg.cxx basctl/source/basicide/scriptdocument.cxx basctl/source/basicide/tbxctl.cxx basctl/source/basicide/tbxctl.hxx basctl/source/basicide/tbxctl.src basctl/source/dlged/dlged.cxx basctl/source/dlged/dlgedfunc.cxx basctl/source/dlged/dlgedobj.cxx basctl/source/inc/basidesh.hxx basctl/source/inc/bastypes.hxx basctl/source/inc/dlgedmod.hxx basctl/source/inc/dlgedpage.hxx crashrep/prj/build.lst cui/inc/pch/precompiled_cui.hxx cui/source/customize/acccfg.cxx cui/source/customize/acccfg.hrc cui/source/customize/acccfg.src cui/source/customize/cfg.cxx cui/source/customize/cfgutil.cxx cui/source/customize/macropg.cxx cui/source/customize/macropg.src cui/source/customize/selector.cxx cui/source/dialogs/SpellDialog.cxx cui/source/dialogs/commonlingui.cxx cui/source/dialogs/cuicharmap.cxx cui/source/dialogs/cuifmsearch.cxx cui/source/dialogs/cuigaldlg.cxx cui/source/dialogs/cuigrfflt.cxx cui/source/dialogs/hldocntp.cxx cui/source/dialogs/hldoctp.cxx cui/source/dialogs/hlinettp.cxx cui/source/dialogs/hlmailtp.cxx cui/source/dialogs/hlmarkwn.cxx cui/source/dialogs/hlmarkwn.src cui/source/dialogs/hltpbase.cxx cui/source/dialogs/iconcdlg.cxx cui/source/dialogs/passwdomdlg.cxx cui/source/dialogs/pastedlg.cxx cui/source/dialogs/scriptdlg.cxx cui/source/dialogs/thesdlg.cxx cui/source/dialogs/zoom.cxx cui/source/factory/dlgfact.hxx cui/source/inc/SpellDialog.hxx cui/source/inc/autocdlg.hxx cui/source/inc/backgrnd.hxx cui/source/inc/bbdlg.hxx cui/source/inc/cfg.hxx cui/source/inc/cfgutil.hxx cui/source/inc/cuigaldlg.hxx cui/source/inc/cuigrfflt.hxx cui/source/inc/cuitabarea.hxx cui/source/inc/cuitabline.hxx cui/source/inc/hldocntp.hxx cui/source/inc/hltpbase.hxx cui/source/inc/iconcdlg.hxx cui/source/inc/numpages.hxx cui/source/inc/page.hxx cui/source/inc/postdlg.hxx cui/source/inc/scriptdlg.hxx cui/source/inc/transfrm.hxx cui/source/inc/zoom.hxx cui/source/options/cfgchart.cxx cui/source/options/cuisrchdlg.cxx cui/source/options/dbregister.cxx cui/source/options/dbregister.src cui/source/options/fontsubs.cxx cui/source/options/internationaloptions.cxx cui/source/options/optasian.cxx cui/source/options/optchart.cxx cui/source/options/optcolor.cxx cui/source/options/optcolor.src cui/source/options/optfltr.cxx cui/source/options/optfltr.src cui/source/options/optgdlg.cxx cui/source/options/optgdlg.src cui/source/options/optgenrl.cxx cui/source/options/opthtml.cxx cui/source/options/optimprove.cxx cui/source/options/optinet2.cxx cui/source/options/optinet2.hxx cui/source/options/optjava.cxx cui/source/options/optlingu.cxx cui/source/options/optsave.cxx cui/source/options/optsave.hxx cui/source/options/treeopt.cxx cui/source/options/webconninfo.cxx cui/source/tabpages/autocdlg.cxx cui/source/tabpages/backgrnd.cxx cui/source/tabpages/border.cxx cui/source/tabpages/chardlg.cxx cui/source/tabpages/dstribut.cxx cui/source/tabpages/grfpage.cxx cui/source/tabpages/macroass.cxx cui/source/tabpages/measure.cxx cui/source/tabpages/numfmt.cxx cui/source/tabpages/numpages.cxx cui/source/tabpages/page.cxx cui/source/tabpages/paragrph.cxx cui/source/tabpages/swpossizetabpage.cxx cui/source/tabpages/tabarea.src cui/source/tabpages/textanim.cxx cui/source/tabpages/textattr.cxx cui/source/tabpages/tparea.cxx cui/source/tabpages/tpbitmap.cxx cui/source/tabpages/tpcolor.cxx cui/source/tabpages/tpgradnt.cxx cui/source/tabpages/tphatch.cxx cui/source/tabpages/tpline.cxx cui/source/tabpages/tplnedef.cxx cui/source/tabpages/tplneend.cxx cui/source/tabpages/tpshadow.cxx cui/source/tabpages/transfrm.cxx embedserv/source/embed/register.cxx extensions/inc/pch/precompiled_extensions.hxx extensions/inc/propctrlr.hrc extensions/source/abpilot/abpservices.cxx extensions/source/bibliography/bibload.cxx extensions/source/bibliography/datman.cxx extensions/source/bibliography/general.cxx extensions/source/dbpilots/dbpservices.cxx extensions/source/inc/componentmodule.cxx extensions/source/nsplugin/source/so_env.cxx extensions/source/ole/oleobjw.cxx extensions/source/ole/oleobjw.hxx extensions/source/oooimprovement/invite_job.cxx extensions/source/oooimprovement/onlogrotate_job.cxx extensions/source/plugin/base/service.cxx extensions/source/plugin/inc/plugin/unx/mediator.hxx extensions/source/plugin/inc/plugin/unx/plugcon.hxx extensions/source/plugin/unx/mediator.cxx extensions/source/plugin/unx/nppapi.cxx extensions/source/plugin/unx/plugcon.cxx extensions/source/preload/services.cxx extensions/source/propctrlr/formmetadata.cxx extensions/source/propctrlr/pcrservices.cxx extensions/source/resource/resource.cxx extensions/source/scanner/sane.hxx extensions/source/scanner/sanedlg.cxx extensions/source/scanner/scanunx.cxx extensions/source/scanner/scanwin.cxx extensions/source/scanner/twain.cxx extensions/source/scanner/twain.hxx extensions/source/update/check/updatecheckconfig.cxx extensions/test/stm/datatest.cxx extensions/test/stm/marktest.cxx extensions/test/stm/pipetest.cxx extensions/test/stm/testfactreg.cxx extensions/workben/testpgp.cxx forms/qa/complex/forms/CheckOGroupBoxModel.java forms/qa/makefile.mk forms/source/component/Button.cxx forms/source/component/Button.hxx forms/source/component/ListBox.cxx forms/source/inc/forms_module_impl.hxx forms/source/misc/services.cxx forms/source/solar/control/navtoolbar.cxx javainstaller2/prj/build.lst javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java lingucomponent/prj/build.lst lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx lingucomponent/source/spellcheck/spell/sreg.cxx lingucomponent/source/spellcheck/spell/sspellimp.cxx package/source/manifest/ManifestExport.cxx package/source/manifest/UnoRegister.cxx package/source/xstor/owriteablestream.cxx package/source/xstor/owriteablestream.hxx package/source/xstor/xstorage.hxx package/source/zippackage/ZipPackageFolder.cxx package/source/zippackage/ZipPackageStream.cxx setup_native/source/mac/ooo/DS_Store setup_native/source/win32/customactions/shellextensions/registerextensions.cxx xmlsecurity/prj/build.lst xmlsecurity/source/component/registerservices.cxx xmlsecurity/source/dialogs/stbcontrl.cxx xmlsecurity/source/framework/xsec_framework.cxx xmlsecurity/source/xmlsec/xsec_xmlsec.cxx xmlsecurity/tools/demo/util.hxx xmlsecurity/workben/signaturetest.cxx
2011-03-09 16:20:50 -06:00
::svl::IUndoManager* DialogWindow::GetUndoManager()
2000-09-29 10:02:42 +00:00
{
return pUndoMgr.get();
2000-09-29 10:02:42 +00:00
}
OUString DialogWindow::GetTitle()
2000-09-29 10:02:42 +00:00
{
2001-09-25 08:14:46 +00:00
return GetName();
2000-09-29 10:02:42 +00:00
}
EntryDescriptor DialogWindow::CreateEntryDescriptor()
{
ScriptDocument aDocument( GetDocument() );
OUString aLibName( GetLibName() );
OUString aLibSubName;
LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
return EntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, GetName(), OBJ_TYPE_DIALOG );
}
void DialogWindow::SetReadOnly (bool bReadOnly)
{
pEditor->SetMode(bReadOnly ? DlgEditor::READONLY : DlgEditor::SELECT);
}
bool DialogWindow::IsReadOnly ()
{
return pEditor->GetMode() == DlgEditor::READONLY;
}
bool DialogWindow::IsPasteAllowed()
{
return pEditor->IsPasteAllowed();
}
2000-09-29 10:02:42 +00:00
void DialogWindow::StoreData()
{
2001-09-25 08:14:46 +00:00
if ( IsModified() )
{
2001-06-15 07:45:19 +00:00
try
{
Reference< container::XNameContainer > xLib = GetDocument().getLibrary( E_DIALOGS, GetLibName(), true );
2001-06-15 07:45:19 +00:00
if( xLib.is() )
{
Reference< container::XNameContainer > xDialogModel = pEditor->GetDialog();
2001-06-15 07:45:19 +00:00
if( xDialogModel.is() )
{
Reference< XComponentContext > xContext(
comphelper::getProcessComponentContext() );
Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() );
xLib->replaceByName( OUString( GetName() ), makeAny( xISP ) );
2001-06-15 07:45:19 +00:00
}
}
}
catch (const uno::Exception& )
2001-06-15 07:45:19 +00:00
{
DBG_UNHANDLED_EXCEPTION();
}
MarkDocumentModified( GetDocument() );
pEditor->ClearModifyFlag();
}
2000-09-29 10:02:42 +00:00
}
void DialogWindow::Activating ()
{
UpdateBrowser();
Show();
}
2000-09-29 10:02:42 +00:00
void DialogWindow::Deactivating()
{
Hide();
2001-09-25 08:14:46 +00:00
if ( IsModified() )
MarkDocumentModified( GetDocument() );
DisableBrowser();
2000-09-29 10:02:42 +00:00
}
2009-05-19 11:32:44 +00:00
sal_Int32 DialogWindow::countPages( Printer* pPrinter )
2000-09-29 10:02:42 +00:00
{
2009-05-19 11:32:44 +00:00
return pEditor->countPages( pPrinter );
}
void DialogWindow::printPage( sal_Int32 nPage, Printer* pPrinter )
{
pEditor->printPage( nPage, pPrinter, CreateQualifiedName() );
2000-09-29 10:02:42 +00:00
}
void DialogWindow::DataChanged( const DataChangedEvent& rDCEvt )
{
if( (rDCEvt.GetType()==DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
{
InitSettings( true, true, true );
2000-09-29 10:02:42 +00:00
Invalidate();
}
else
BaseWindow::DataChanged( rDCEvt );
2000-09-29 10:02:42 +00:00
}
void DialogWindow::InitSettings(bool bFont, bool bForeground, bool bBackground)
2000-09-29 10:02:42 +00:00
{
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
if( bFont )
{
Font aFont;
aFont = rStyleSettings.GetFieldFont();
SetPointFont( aFont );
}
if( bForeground || bFont )
{
SetTextColor( rStyleSettings.GetFieldTextColor() );
SetTextFillColor();
}
if( bBackground )
SetBackground( rStyleSettings.GetFieldColor() );
}
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > DialogWindow::CreateAccessible()
{
return (::com::sun::star::accessibility::XAccessible*) new AccessibleDialogWindow( this );
}
char const* DialogWindow::GetHid () const
{
return HID_BASICIDE_DIALOGWINDOW;
}
ItemType DialogWindow::GetType () const
{
return TYPE_DIALOG;
}
//
// DialogWindowLayout
// ==================
//
DialogWindowLayout::DialogWindowLayout (Window* pParent, ObjectCatalog& rObjectCatalog_) :
Layout(pParent),
pChild(0),
rObjectCatalog(rObjectCatalog_),
pPropertyBrowser(0)
{
ShowPropertyBrowser();
}
Prevent basctl::PropBrw using basctl::Layout from within ~Layout ...as is reproducible when creating a new dialog via "Tools - Macros - Organize Dialogs", adding e.g. some date/time controls to it, then closing LO. Invalid read of size 8 at 0x23DD58DB: basctl::Layout::SplittedSide::Remove(basctl::DockingWindow*) (/basctl/source/basicide/layout.cxx:205) by 0x23DD4F65: basctl::Layout::Remove(basctl::DockingWindow*) (/basctl/source/basicide/layout.cxx:62) by 0x23D847B7: basctl::DialogWindowLayout::RemovePropertyBrowser() (/basctl/source/basicide/baside3.cxx:1459) by 0x23E45AB3: basctl::PropBrw::~PropBrw() (/basctl/source/dlged/propbrw.cxx:202) by 0x23E45BA5: basctl::PropBrw::~PropBrw() (/basctl/source/dlged/propbrw.cxx:205) by 0x7E03A49: VCLXDevice::DestroyOutputDevice() (/toolkit/source/awt/vclxdevice.cxx:56) by 0x7E4655D: VCLXWindow::dispose() (/toolkit/source/awt/vclxwindow.cxx:956) by 0x7FD451C: UnoWrapper::WindowDestroyed(Window*) (/toolkit/source/helper/unowrapper.cxx:263) by 0x95EA632: Window::~Window() (/vcl/source/window/window.cxx:4365) by 0x23DD4EFD: basctl::Layout::~Layout() (/basctl/source/basicide/layout.cxx:56) by 0x23D89E39: basctl::DialogWindowLayout::~DialogWindowLayout() (in /data/lo/core/solver/unxlngx6/installation/opt/program/libbasctllo.so) by 0x23D89E69: basctl::DialogWindowLayout::~DialogWindowLayout() (/basctl/source/inc/baside3.hxx:125) ... Address 0x19d17da0 is 0 bytes inside a block of size 80 free'd at 0x4A078DE: operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x23DD92D5: __gnu_cxx::new_allocator<basctl::Layout::SplittedSide::Item>::deallocate(basctl::Layout::SplittedSide::Item*, unsigned long) (/usr/include/c++/4.8.1/ext/new_allocator.h:110) by 0x23DD8C77: std::__cxx1998::_Vector_base<basctl::Layout::SplittedSide::Item, std::allocator<basctl::Layout::SplittedSide::Item> >::_M_deallocate(basctl::Layout::SplittedSide::Item*, unsigned long) (/usr/include/c++/4.8.1/bits/stl_vector.h:174) by 0x23DD7F89: std::__cxx1998::_Vector_base<basctl::Layout::SplittedSide::Item, std::allocator<basctl::Layout::SplittedSide::Item> >::~_Vector_base() (/usr/include/c++/4.8.1/bits/stl_vector.h:160) by 0x23DD73DC: std::__cxx1998::vector<basctl::Layout::SplittedSide::Item, std::allocator<basctl::Layout::SplittedSide::Item> >::~vector() (/usr/include/c++/4.8.1/bits/stl_vector.h:416) by 0x23DD6A05: std::__debug::vector<basctl::Layout::SplittedSide::Item, std::allocator<basctl::Layout::SplittedSide::Item> >::~vector() (/usr/include/c++/4.8.1/debug/vector:144) by 0x23DD6889: basctl::Layout::SplittedSide::~SplittedSide() (/basctl/source/basicide/layout.hxx:80) by 0x23DD4EF1: basctl::Layout::~Layout() (/basctl/source/basicide/layout.cxx:56) by 0x23D89E39: basctl::DialogWindowLayout::~DialogWindowLayout() (in /data/lo/core/solver/unxlngx6/installation/opt/program/libbasctllo.so) by 0x23D89E69: basctl::DialogWindowLayout::~DialogWindowLayout() (/basctl/source/inc/baside3.hxx:125) by 0x23D997F3: void boost::checked_delete<basctl::DialogWindowLayout>(basctl::DialogWindowLayout*) (/workdir/unxlngx6/UnpackedTarball/boost/boost/checked_delete.hpp:34) by 0x23D99694: boost::scoped_ptr<basctl::DialogWindowLayout>::~scoped_ptr() (/workdir/unxlngx6/UnpackedTarball/boost/boost/smart_ptr/scoped_ptr.hpp:82) by 0x23D9A5E7: basctl::Shell::~Shell() (/basctl/source/basicide/basidesh.cxx:223) by 0x23D9A717: basctl::Shell::~Shell() (/basctl/source/basicide/basidesh.cxx:248) by 0x6942297: SfxViewFrame::ReleaseObjectShell_Impl() (/sfx2/source/view/viewfrm.cxx:1089) by 0x6943BAB: SfxViewFrame::~SfxViewFrame() (/sfx2/source/view/viewfrm.cxx:1484) by 0x6943E09: SfxViewFrame::~SfxViewFrame() (/sfx2/source/view/viewfrm.cxx:1505) by 0x69427EC: SfxViewFrame::Close() (/sfx2/source/view/viewfrm.cxx:1144) by 0x6919441: SfxFrame::DoClose_Impl() (/sfx2/source/view/frame.cxx:175) by 0x6934542: SfxBaseController::dispose() (/sfx2/source/view/sfxbasecontroller.cxx:1035) by 0x1BC8C5B3: framework::Frame::setComponent(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&, com::sun::star::uno::Reference<com::sun::star::frame::XController> const&) (/framework/source/services/frame.cxx:1357) by 0x1BBAF54B: framework::CloseDispatcher::implts_establishBackingMode() (/framework/source/dispatch/closedispatcher.cxx:540) by 0x1BBAEB15: framework::CloseDispatcher::impl_asyncCallback(void*) (/framework/source/dispatch/closedispatcher.cxx:391) by 0x1BBAE6AF: framework::CloseDispatcher::dispatchWithNotification(com::sun::star::util::URL const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XDispatchResultListener> const&) (/framework/source/dispatch/closedispatcher.cxx:228) by 0x23A2A71D: framework::DispatchHelper::executeDispatch(com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/framework/source/services/dispatchhelper.cxx:142) by 0x1BC06442: framework::LayoutManager::MenuBarClose(void*) (/framework/source/layoutmanager/layoutmanager.cxx:2638) by 0x1BC062F6: framework::LayoutManager::LinkStubMenuBarClose(void*, void*) (/framework/source/layoutmanager/layoutmanager.cxx:2621) by 0x9053555: Link::Call(void*) const (/include/tools/link.hxx:123) by 0x9610263: ImplHandleUserEvent(ImplSVEvent*) (/vcl/source/window/winproc.cxx:1975) by 0x961173A: ImplWindowFrameProc(Window*, SalFrame*, unsigned short, void const*) (/vcl/source/window/winproc.cxx:2590) by 0x961FCAE: SalFrame::CallCallback(unsigned short, void const*) const (in /data/lo/core/solver/unxlngx6/installation/opt/program/libvcllo.so) by 0x961F74D: SalGenericDisplay::DispatchInternalEvent() (/vcl/generic/app/gendisp.cxx:91) by 0x171A5821: GtkData::userEventFn(void*) (/vcl/unx/gtk/app/gtkdata.cxx:933) by 0x171A587C: call_userEventFn (/vcl/unx/gtk/app/gtkdata.cxx:943) by 0x3B78E47E05: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3) by 0x3B78E48157: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3) by 0x3B78E481FB: g_main_context_iteration (in /usr/lib64/libglib-2.0.so.0.3600.3) by 0x171A47B0: GtkData::Yield(bool, bool) (/vcl/unx/gtk/app/gtkdata.cxx:574) by 0x171A82BD: GtkInstance::Yield(bool, bool) (/vcl/unx/gtk/app/gtkinst.cxx:405) by 0x906C838: ImplYield(bool, bool) (/vcl/source/app/svapp.cxx:417) by 0x9068F00: Application::Yield() (/vcl/source/app/svapp.cxx:451) by 0x9068EB0: Application::Execute() (/vcl/source/app/svapp.cxx:396) by 0x4EC6117: desktop::Desktop::Main() (/desktop/source/app/app.cxx:1720) by 0x9075192: ImplSVMain() (/vcl/source/app/svmain.cxx:162) by 0x907529C: SVMain() (/vcl/source/app/svmain.cxx:198) by 0x4F0A9C0: soffice_main (/desktop/source/app/sofficemain.cxx:81) by 0x40096B: sal_main (/desktop/source/app/main.c:48) by 0x40094C: main (/desktop/source/app/main.c:47) Change-Id: If7ec0fceec6da1731df8ac389406327fbd95b382
2013-08-06 11:58:59 +02:00
DialogWindowLayout::~DialogWindowLayout()
{
if (pPropertyBrowser != 0)
{
Remove(pPropertyBrowser);
delete pPropertyBrowser;
}
}
// shows the property browser (and creates if necessary)
void DialogWindowLayout::ShowPropertyBrowser ()
{
// not exists?
if (!pPropertyBrowser)
{
// creating
pPropertyBrowser = new PropBrw(*this);
pPropertyBrowser->Show();
// after OnFirstSize():
if (HasSize())
AddPropertyBrowser();
// updating if necessary
UpdatePropertyBrowser();
}
else
pPropertyBrowser->Show();
// refreshing the button state
if (SfxBindings* pBindings = GetBindingsPtr())
pBindings->Invalidate(SID_SHOW_PROPERTYBROWSER);
}
// disables the property browser
void DialogWindowLayout::DisablePropertyBrowser ()
{
if (pPropertyBrowser)
pPropertyBrowser->Update(0);
}
// updates the property browser
void DialogWindowLayout::UpdatePropertyBrowser ()
{
if (pPropertyBrowser)
pPropertyBrowser->Update(GetShell());
}
void DialogWindowLayout::Activating (BaseWindow& rChild)
{
assert(dynamic_cast<DialogWindow*>(&rChild));
pChild = &static_cast<DialogWindow&>(rChild);
rObjectCatalog.SetLayoutWindow(this);
rObjectCatalog.UpdateEntries();
rObjectCatalog.Show();
if (pPropertyBrowser)
pPropertyBrowser->Show();
Layout::Activating(rChild);
}
void DialogWindowLayout::Deactivating ()
{
Layout::Deactivating();
rObjectCatalog.Hide();
if (pPropertyBrowser)
pPropertyBrowser->Hide();
pChild = 0;
}
void DialogWindowLayout::ExecuteGlobal (SfxRequest& rReq)
{
switch (rReq.GetSlot())
{
case SID_SHOW_PROPERTYBROWSER:
// toggling property browser
if (pPropertyBrowser && pPropertyBrowser->IsVisible())
pPropertyBrowser->Hide();
else
ShowPropertyBrowser();
ArrangeWindows();
// refreshing the button state
if (SfxBindings* pBindings = GetBindingsPtr())
pBindings->Invalidate(SID_SHOW_PROPERTYBROWSER);
break;
}
}
void DialogWindowLayout::GetState (SfxItemSet& rSet, unsigned nWhich)
{
switch (nWhich)
{
case SID_SHOW_PROPERTYBROWSER:
rSet.Put(SfxBoolItem(nWhich, pPropertyBrowser && pPropertyBrowser->IsVisible()));
break;
case SID_BASICIDE_CHOOSEMACRO:
rSet.Put(SfxVisibilityItem(nWhich, false));
break;
}
}
void DialogWindowLayout::OnFirstSize (long const nWidth, long const nHeight)
{
AddToLeft(&rObjectCatalog, Size(nWidth * 0.25, nHeight * 0.35));
if (pPropertyBrowser)
AddPropertyBrowser();
}
void DialogWindowLayout::AddPropertyBrowser () {
Size const aSize = GetOutputSizePixel();
AddToLeft(pPropertyBrowser, Size(aSize.Width() * 0.25, aSize.Height() * 0.65));
}
} // namespace basctl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */