1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "basidesh.hrc"
23 #include "accessibledialogwindow.hxx"
24 #include "baside3.hxx"
25 #include "basidesh.hxx"
26 #include "bastype2.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 "managelang.hxx"
36 #include <basic/basmgr.hxx>
37 #include <com/sun/star/resource/StringResourceWithLocation.hpp>
38 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
39 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
40 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
41 #include <com/sun/star/ui/dialogs/FilePicker.hpp>
42 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
43 #include <comphelper/processfactory.hxx>
44 #include <sfx2/dispatch.hxx>
45 #include <sfx2/request.hxx>
46 #include <svl/aeitem.hxx>
47 #include <svl/visitem.hxx>
48 #include <svl/whiter.hxx>
49 #include <tools/diagnose_ex.h>
50 #include <tools/urlobj.hxx>
51 #include <vcl/layout.hxx>
52 #include <vcl/msgbox.hxx>
53 #include <vcl/settings.hxx>
54 #include <xmlscript/xmldlg_imexp.hxx>
59 using namespace ::com::sun::star
;
60 using namespace ::com::sun::star::uno
;
61 using namespace ::com::sun::star::ucb
;
62 using namespace ::com::sun::star::io
;
63 using namespace ::com::sun::star::resource
;
64 using namespace ::com::sun::star::ui::dialogs
;
67 char const FilterMask_All
[] = "*.*";
69 char const FilterMask_All
[] = "*";
72 TYPEINIT1( DialogWindow
, BaseWindow
);
74 DialogWindow::DialogWindow(DialogWindowLayout
* pParent
, ScriptDocument
const& rDocument
,
75 const OUString
& aLibName
, const OUString
& aName
,
76 css::uno::Reference
<css::container::XNameContainer
> const& xDialogModel
)
77 : BaseWindow(pParent
, rDocument
, aLibName
, aName
)
79 ,pEditor(new DlgEditor(*this, rLayout
, rDocument
.isDocument()
80 ? rDocument
.getDocument()
81 : Reference
<frame::XModel
>(), xDialogModel
))
82 ,pUndoMgr(new SfxUndoManager
)
84 InitSettings( true, true, true );
86 pEditor
->GetModel().SetNotifyUndoActionHdl(
87 LINK(this, DialogWindow
, NotifyUndoActionHdl
)
90 SetHelpId( HID_BASICIDE_DIALOGWINDOW
);
92 // set readonly mode for readonly libraries
93 Reference
< script::XLibraryContainer2
> xDlgLibContainer( GetDocument().getLibraryContainer( E_DIALOGS
), UNO_QUERY
);
94 if ( xDlgLibContainer
.is() && xDlgLibContainer
->hasByName( aLibName
) && xDlgLibContainer
->isLibraryReadOnly( aLibName
) )
97 if ( rDocument
.isDocument() && rDocument
.isReadOnly() )
101 void DialogWindow::LoseFocus()
109 void DialogWindow::Paint(vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
)
111 pEditor
->Paint(rRenderContext
, rRect
);
114 void DialogWindow::Resize()
116 if (GetHScrollBar() && GetVScrollBar())
118 pEditor
->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
122 void DialogWindow::MouseButtonDown( const MouseEvent
& rMEvt
)
124 pEditor
->MouseButtonDown( rMEvt
);
126 if (SfxBindings
* pBindings
= GetBindingsPtr())
127 pBindings
->Invalidate( SID_SHOW_PROPERTYBROWSER
);
130 void DialogWindow::MouseButtonUp( const MouseEvent
& rMEvt
)
132 pEditor
->MouseButtonUp( rMEvt
);
133 if( (pEditor
->GetMode() == DlgEditor::INSERT
) && !pEditor
->IsCreateOK() )
135 pEditor
->SetMode( DlgEditor::SELECT
);
136 if (SfxBindings
* pBindings
= GetBindingsPtr())
137 pBindings
->Invalidate( SID_CHOOSE_CONTROLS
);
139 if (SfxBindings
* pBindings
= GetBindingsPtr())
141 pBindings
->Invalidate( SID_SHOW_PROPERTYBROWSER
);
142 pBindings
->Invalidate( SID_DOC_MODIFIED
);
143 pBindings
->Invalidate( SID_SAVEDOC
);
144 pBindings
->Invalidate( SID_COPY
);
145 pBindings
->Invalidate( SID_CUT
);
149 void DialogWindow::MouseMove( const MouseEvent
& rMEvt
)
151 pEditor
->MouseMove( rMEvt
);
154 void DialogWindow::KeyInput( const KeyEvent
& rKEvt
)
156 SfxBindings
* pBindings
= GetBindingsPtr();
158 if( rKEvt
.GetKeyCode() == KEY_BACKSPACE
)
160 if (SfxDispatcher
* pDispatcher
= GetDispatcher())
161 pDispatcher
->Execute( SID_BACKSPACE
);
165 if( pBindings
&& rKEvt
.GetKeyCode() == KEY_TAB
)
166 pBindings
->Invalidate( SID_SHOW_PROPERTYBROWSER
);
168 if( !pEditor
->KeyInput( rKEvt
) )
170 if( !SfxViewShell::Current()->KeyInput( rKEvt
) )
171 Window::KeyInput( rKEvt
);
175 // may be KEY_TAB, KEY_BACKSPACE, KEY_ESCAPE
178 pBindings
->Invalidate( SID_COPY
);
179 pBindings
->Invalidate( SID_CUT
);
183 void DialogWindow::Command( const CommandEvent
& rCEvt
)
185 if ( ( rCEvt
.GetCommand() == CommandEventId::Wheel
) ||
186 ( rCEvt
.GetCommand() == CommandEventId::StartAutoScroll
) ||
187 ( rCEvt
.GetCommand() == CommandEventId::AutoScroll
) )
189 HandleScrollCommand( rCEvt
, GetHScrollBar(), GetVScrollBar() );
191 else if ( rCEvt
.GetCommand() == CommandEventId::ContextMenu
)
193 if (SfxDispatcher
* pDispatcher
= GetDispatcher())
195 SdrView
& rView
= GetView();
196 if( !rCEvt
.IsMouseEvent() && rView
.AreObjectsMarked() )
198 Rectangle
aMarkedRect( rView
.GetMarkedRect() );
199 Point
MarkedCenter( aMarkedRect
.Center() );
200 Point
PosPixel( LogicToPixel( MarkedCenter
) );
201 pDispatcher
->ExecutePopup( IDEResId(RID_POPUP_DLGED
), this, &PosPixel
);
205 pDispatcher
->ExecutePopup( IDEResId(RID_POPUP_DLGED
) );
211 BaseWindow::Command( rCEvt
);
218 DialogWindow
, NotifyUndoActionHdl
, SfxUndoAction
*, pUndoAction
)
220 // #i120515# pUndoAction needs to be deleted, this hand over is an ownership
221 // change. As long as it does not get added to the undo manager, it needs at
222 // least to be deleted.
228 void DialogWindow::DoInit()
230 GetHScrollBar()->Show();
231 GetVScrollBar()->Show();
232 pEditor
->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
235 void DialogWindow::DoScroll( ScrollBar
* pCurScrollBar
)
237 pEditor
->DoScroll( pCurScrollBar
);
240 void DialogWindow::GetState( SfxItemSet
& rSet
)
242 SfxWhichIter
aIter(rSet
);
243 bool bIsCalc
= false;
244 if ( GetDocument().isDocument() )
246 Reference
< frame::XModel
> xModel
= GetDocument().getDocument();
249 Reference
< lang::XServiceInfo
> xServiceInfo ( xModel
, UNO_QUERY
);
250 if ( xServiceInfo
.is() && xServiceInfo
->supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
255 for ( sal_uInt16 nWh
= aIter
.FirstWhich(); 0 != nWh
; nWh
= aIter
.NextWhich() )
261 if ( !IsPasteAllowed() )
262 rSet
.DisableItem( nWh
);
265 rSet
.DisableItem( nWh
);
270 // any object selected?
271 if ( !pEditor
->GetView().AreObjectsMarked() )
272 rSet
.DisableItem( nWh
);
279 // any object selected?
280 if ( !pEditor
->GetView().AreObjectsMarked() )
281 rSet
.DisableItem( nWh
);
284 rSet
.DisableItem( nWh
);
289 if ( !pUndoMgr
->GetUndoActionCount() )
290 rSet
.DisableItem( nWh
);
294 case SID_DIALOG_TESTMODE
:
296 // is the IDE still active?
297 bool const bBool
= GetShell()->GetFrame() &&
298 pEditor
->GetMode() == DlgEditor::TEST
;
299 rSet
.Put(SfxBoolItem(SID_DIALOG_TESTMODE
, bBool
));
303 case SID_CHOOSE_CONTROLS
:
307 rSet
.DisableItem( nWh
);
311 SfxAllEnumItem
aItem( SID_CHOOSE_CONTROLS
);
312 if ( GetEditor().GetMode() == DlgEditor::SELECT
)
313 aItem
.SetValue( SVX_SNAP_SELECT
);
317 switch( pEditor
->GetInsertObj() )
319 case OBJ_DLG_PUSHBUTTON
: nObj
= SVX_SNAP_PUSHBUTTON
; break;
320 case OBJ_DLG_RADIOBUTTON
: nObj
= SVX_SNAP_RADIOBUTTON
; break;
321 case OBJ_DLG_CHECKBOX
: nObj
= SVX_SNAP_CHECKBOX
; break;
322 case OBJ_DLG_LISTBOX
: nObj
= SVX_SNAP_LISTBOX
; break;
323 case OBJ_DLG_COMBOBOX
: nObj
= SVX_SNAP_COMBOBOX
; break;
324 case OBJ_DLG_GROUPBOX
: nObj
= SVX_SNAP_GROUPBOX
; break;
325 case OBJ_DLG_EDIT
: nObj
= SVX_SNAP_EDIT
; break;
326 case OBJ_DLG_FIXEDTEXT
: nObj
= SVX_SNAP_FIXEDTEXT
; break;
327 case OBJ_DLG_IMAGECONTROL
: nObj
= SVX_SNAP_IMAGECONTROL
; break;
328 case OBJ_DLG_PROGRESSBAR
: nObj
= SVX_SNAP_PROGRESSBAR
; break;
329 case OBJ_DLG_HSCROLLBAR
: nObj
= SVX_SNAP_HSCROLLBAR
; break;
330 case OBJ_DLG_VSCROLLBAR
: nObj
= SVX_SNAP_VSCROLLBAR
; break;
331 case OBJ_DLG_HFIXEDLINE
: nObj
= SVX_SNAP_HFIXEDLINE
; break;
332 case OBJ_DLG_VFIXEDLINE
: nObj
= SVX_SNAP_VFIXEDLINE
; break;
333 case OBJ_DLG_DATEFIELD
: nObj
= SVX_SNAP_DATEFIELD
; break;
334 case OBJ_DLG_TIMEFIELD
: nObj
= SVX_SNAP_TIMEFIELD
; break;
335 case OBJ_DLG_NUMERICFIELD
: nObj
= SVX_SNAP_NUMERICFIELD
; break;
336 case OBJ_DLG_CURRENCYFIELD
: nObj
= SVX_SNAP_CURRENCYFIELD
; break;
337 case OBJ_DLG_FORMATTEDFIELD
: nObj
= SVX_SNAP_FORMATTEDFIELD
; break;
338 case OBJ_DLG_PATTERNFIELD
: nObj
= SVX_SNAP_PATTERNFIELD
; break;
339 case OBJ_DLG_FILECONTROL
: nObj
= SVX_SNAP_FILECONTROL
; break;
340 case OBJ_DLG_SPINBUTTON
: nObj
= SVX_SNAP_SPINBUTTON
; break;
341 case OBJ_DLG_TREECONTROL
: nObj
= SVX_SNAP_TREECONTROL
; break;
347 DBG_WARNING( "SID_CHOOSE_CONTROLS: Unbekannt!" );
350 aItem
.SetValue( nObj
);
358 case SID_SHOW_PROPERTYBROWSER
:
360 Shell
* pShell
= GetShell();
361 SfxViewFrame
* pViewFrame
= pShell
? pShell
->GetViewFrame() : NULL
;
362 if ( pViewFrame
&& !pViewFrame
->HasChildWindow( SID_SHOW_PROPERTYBROWSER
) && !pEditor
->GetView().AreObjectsMarked() )
363 rSet
.DisableItem( nWh
);
366 rSet
.DisableItem( nWh
);
369 case SID_INSERT_FORM_RADIO
:
370 case SID_INSERT_FORM_CHECK
:
371 case SID_INSERT_FORM_LIST
:
372 case SID_INSERT_FORM_COMBO
:
373 case SID_INSERT_FORM_VSCROLL
:
374 case SID_INSERT_FORM_HSCROLL
:
375 case SID_INSERT_FORM_SPIN
:
377 if ( !bIsCalc
|| IsReadOnly() )
378 rSet
.DisableItem( nWh
);
383 // if this is not a module window hide the
384 // setting, doesn't make sense for example if the
385 // dialog editor is open
386 rSet
.DisableItem(nWh
);
387 rSet
.Put(SfxVisibilityItem(nWh
, false));
392 rSet
.DisableItem( nWh
);
399 void DialogWindow::ExecuteCommand( SfxRequest
& rReq
)
401 switch ( rReq
.GetSlot() )
407 if (SfxBindings
* pBindings
= GetBindingsPtr())
408 pBindings
->Invalidate( SID_DOC_MODIFIED
);
414 GetEditor().Delete();
415 if (SfxBindings
* pBindings
= GetBindingsPtr())
416 pBindings
->Invalidate( SID_DOC_MODIFIED
);
426 if (SfxBindings
* pBindings
= GetBindingsPtr())
427 pBindings
->Invalidate( SID_DOC_MODIFIED
);
430 case SID_INSERT_FORM_RADIO
:
431 GetEditor().SetMode( DlgEditor::INSERT
);
432 GetEditor().SetInsertObj( OBJ_DLG_FORMRADIO
);
434 case SID_INSERT_FORM_CHECK
:
435 GetEditor().SetMode( DlgEditor::INSERT
);
436 GetEditor().SetInsertObj( OBJ_DLG_FORMCHECK
);
438 case SID_INSERT_FORM_LIST
:
439 GetEditor().SetMode( DlgEditor::INSERT
);
440 GetEditor().SetInsertObj( OBJ_DLG_FORMLIST
);
442 case SID_INSERT_FORM_COMBO
:
443 GetEditor().SetMode( DlgEditor::INSERT
);
444 GetEditor().SetInsertObj( OBJ_DLG_FORMCOMBO
);
446 case SID_INSERT_FORM_SPIN
:
447 GetEditor().SetMode( DlgEditor::INSERT
);
448 GetEditor().SetInsertObj( OBJ_DLG_FORMSPIN
);
450 case SID_INSERT_FORM_VSCROLL
:
451 GetEditor().SetMode( DlgEditor::INSERT
);
452 GetEditor().SetInsertObj( OBJ_DLG_FORMVSCROLL
);
454 case SID_INSERT_FORM_HSCROLL
:
455 GetEditor().SetMode( DlgEditor::INSERT
);
456 GetEditor().SetInsertObj( OBJ_DLG_FORMHSCROLL
);
458 case SID_CHOOSE_CONTROLS
:
460 const SfxItemSet
* pArgs
= rReq
.GetArgs();
461 DBG_ASSERT( pArgs
, "Nix Args" );
463 const SfxAllEnumItem
& rItem
= static_cast<const SfxAllEnumItem
&>(pArgs
->Get( SID_CHOOSE_CONTROLS
));
464 switch( rItem
.GetValue() )
466 case SVX_SNAP_PUSHBUTTON
:
468 GetEditor().SetMode( DlgEditor::INSERT
);
469 GetEditor().SetInsertObj( OBJ_DLG_PUSHBUTTON
);
472 case SVX_SNAP_RADIOBUTTON
:
474 GetEditor().SetMode( DlgEditor::INSERT
);
475 GetEditor().SetInsertObj( OBJ_DLG_RADIOBUTTON
);
478 case SVX_SNAP_CHECKBOX
:
480 GetEditor().SetMode( DlgEditor::INSERT
);
481 GetEditor().SetInsertObj( OBJ_DLG_CHECKBOX
);
484 case SVX_SNAP_LISTBOX
:
486 GetEditor().SetMode( DlgEditor::INSERT
);
487 GetEditor().SetInsertObj( OBJ_DLG_LISTBOX
);
490 case SVX_SNAP_COMBOBOX
:
492 GetEditor().SetMode( DlgEditor::INSERT
);
493 GetEditor().SetInsertObj( OBJ_DLG_COMBOBOX
);
496 case SVX_SNAP_GROUPBOX
:
498 GetEditor().SetMode( DlgEditor::INSERT
);
499 GetEditor().SetInsertObj( OBJ_DLG_GROUPBOX
);
504 GetEditor().SetMode( DlgEditor::INSERT
);
505 GetEditor().SetInsertObj( OBJ_DLG_EDIT
);
508 case SVX_SNAP_FIXEDTEXT
:
510 GetEditor().SetMode( DlgEditor::INSERT
);
511 GetEditor().SetInsertObj( OBJ_DLG_FIXEDTEXT
);
514 case SVX_SNAP_IMAGECONTROL
:
516 GetEditor().SetMode( DlgEditor::INSERT
);
517 GetEditor().SetInsertObj( OBJ_DLG_IMAGECONTROL
);
520 case SVX_SNAP_PROGRESSBAR
:
522 GetEditor().SetMode( DlgEditor::INSERT
);
523 GetEditor().SetInsertObj( OBJ_DLG_PROGRESSBAR
);
526 case SVX_SNAP_HSCROLLBAR
:
528 GetEditor().SetMode( DlgEditor::INSERT
);
529 GetEditor().SetInsertObj( OBJ_DLG_HSCROLLBAR
);
532 case SVX_SNAP_VSCROLLBAR
:
534 GetEditor().SetMode( DlgEditor::INSERT
);
535 GetEditor().SetInsertObj( OBJ_DLG_VSCROLLBAR
);
538 case SVX_SNAP_HFIXEDLINE
:
540 GetEditor().SetMode( DlgEditor::INSERT
);
541 GetEditor().SetInsertObj( OBJ_DLG_HFIXEDLINE
);
544 case SVX_SNAP_VFIXEDLINE
:
546 GetEditor().SetMode( DlgEditor::INSERT
);
547 GetEditor().SetInsertObj( OBJ_DLG_VFIXEDLINE
);
550 case SVX_SNAP_DATEFIELD
:
552 GetEditor().SetMode( DlgEditor::INSERT
);
553 GetEditor().SetInsertObj( OBJ_DLG_DATEFIELD
);
556 case SVX_SNAP_TIMEFIELD
:
558 GetEditor().SetMode( DlgEditor::INSERT
);
559 GetEditor().SetInsertObj( OBJ_DLG_TIMEFIELD
);
562 case SVX_SNAP_NUMERICFIELD
:
564 GetEditor().SetMode( DlgEditor::INSERT
);
565 GetEditor().SetInsertObj( OBJ_DLG_NUMERICFIELD
);
568 case SVX_SNAP_CURRENCYFIELD
:
570 GetEditor().SetMode( DlgEditor::INSERT
);
571 GetEditor().SetInsertObj( OBJ_DLG_CURRENCYFIELD
);
574 case SVX_SNAP_FORMATTEDFIELD
:
576 GetEditor().SetMode( DlgEditor::INSERT
);
577 GetEditor().SetInsertObj( OBJ_DLG_FORMATTEDFIELD
);
580 case SVX_SNAP_PATTERNFIELD
:
582 GetEditor().SetMode( DlgEditor::INSERT
);
583 GetEditor().SetInsertObj( OBJ_DLG_PATTERNFIELD
);
586 case SVX_SNAP_FILECONTROL
:
588 GetEditor().SetMode( DlgEditor::INSERT
);
589 GetEditor().SetInsertObj( OBJ_DLG_FILECONTROL
);
592 case SVX_SNAP_SPINBUTTON
:
594 GetEditor().SetMode( DlgEditor::INSERT
);
595 GetEditor().SetInsertObj( OBJ_DLG_SPINBUTTON
);
598 case SVX_SNAP_TREECONTROL
:
600 GetEditor().SetMode( DlgEditor::INSERT
);
601 GetEditor().SetInsertObj( OBJ_DLG_TREECONTROL
);
605 case SVX_SNAP_SELECT
:
607 GetEditor().SetMode( DlgEditor::SELECT
);
612 if ( rReq
.GetModifier() & KEY_MOD1
)
614 if ( GetEditor().GetMode() == DlgEditor::INSERT
)
615 GetEditor().CreateDefaultObject();
618 if (SfxBindings
* pBindings
= GetBindingsPtr())
619 pBindings
->Invalidate( SID_DOC_MODIFIED
);
623 case SID_DIALOG_TESTMODE
:
625 DlgEditor::Mode eOldMode
= GetEditor().GetMode();
626 GetEditor().SetMode( DlgEditor::TEST
);
627 GetEditor().SetMode( eOldMode
);
629 if (SfxBindings
* pBindings
= GetBindingsPtr())
630 pBindings
->Invalidate( SID_DIALOG_TESTMODE
);
633 case SID_EXPORT_DIALOG
:
637 case SID_IMPORT_DIALOG
:
641 case SID_BASICIDE_DELETECURRENT
:
642 if (QueryDelDialog(m_aName
, this))
644 if (RemoveDialog(m_aDocument
, m_aLibName
, m_aName
))
646 MarkDocumentModified(m_aDocument
);
647 GetShell()->RemoveWindow(this, true);
656 Reference
< container::XNameContainer
> DialogWindow::GetDialog() const
658 return pEditor
->GetDialog();
661 bool DialogWindow::RenameDialog( const OUString
& rNewName
)
663 if ( !basctl::RenameDialog( this, GetDocument(), GetLibName(), GetName(), rNewName
) )
666 if (SfxBindings
* pBindings
= GetBindingsPtr())
667 pBindings
->Invalidate( SID_DOC_MODIFIED
);
672 void DialogWindow::DisableBrowser()
674 rLayout
.DisablePropertyBrowser();
677 void DialogWindow::UpdateBrowser()
679 rLayout
.UpdatePropertyBrowser();
682 bool DialogWindow::SaveDialog()
686 Reference
< XComponentContext
> xContext( comphelper::getProcessComponentContext() );
687 Reference
< XFilePicker3
> xFP
= FilePicker::createWithMode(xContext
, TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD
);
689 Reference
< XFilePickerControlAccess
> xFPControl(xFP
, UNO_QUERY
);
690 xFPControl
->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
, false);
693 xFPControl
->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
, 0, aValue
);
695 if ( !aCurPath
.isEmpty() )
696 xFP
->setDisplayDirectory ( aCurPath
);
698 xFP
->setDefaultName( OUString( GetName() ) );
700 OUString
aDialogStr(IDE_RESSTR(RID_STR_STDDIALOGNAME
));
701 xFP
->appendFilter( aDialogStr
, OUString( "*.xdl" ) );
702 xFP
->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES
), OUString( FilterMask_All
) );
703 xFP
->setCurrentFilter( aDialogStr
);
705 if( xFP
->execute() == RET_OK
)
707 Sequence
< OUString
> aPaths
= xFP
->getFiles();
708 aCurPath
= aPaths
[0];
710 // export dialog model to xml
711 Reference
< container::XNameContainer
> xDialogModel
= GetDialog();
712 Reference
< XInputStreamProvider
> xISP
= ::xmlscript::exportDialogModel( xDialogModel
, xContext
, GetDocument().isDocument() ? GetDocument().getDocument() : Reference
< frame::XModel
>() );
713 Reference
< XInputStream
> xInput( xISP
->createInputStream() );
715 Reference
< XSimpleFileAccess3
> xSFI( SimpleFileAccess::create(xContext
) );
717 Reference
< XOutputStream
> xOutput
;
720 if( xSFI
->exists( aCurPath
) )
721 xSFI
->kill( aCurPath
);
722 xOutput
= xSFI
->openFileWrite( aCurPath
);
724 catch(const Exception
& )
729 Sequence
< sal_Int8
> bytes
;
730 sal_Int32 nRead
= xInput
->readBytes( bytes
, xInput
->available() );
734 xOutput
->writeBytes( bytes
);
736 nRead
= xInput
->readBytes( bytes
, 1024 );
743 Reference
< beans::XPropertySet
> xDialogModelPropSet( xDialogModel
, UNO_QUERY
);
744 Reference
< resource::XStringResourceResolver
> xStringResourceResolver
;
745 if( xDialogModelPropSet
.is() )
749 Any aResourceResolver
= xDialogModelPropSet
->getPropertyValue( "ResourceResolver" );
750 aResourceResolver
>>= xStringResourceResolver
;
752 catch(const beans::UnknownPropertyException
& )
756 bool bResource
= false;
757 if( xStringResourceResolver
.is() )
759 Sequence
< lang::Locale
> aLocaleSeq
= xStringResourceResolver
->getLocales();
760 sal_Int32 nLocaleCount
= aLocaleSeq
.getLength();
761 if( nLocaleCount
> 0 )
767 INetURLObject
aURLObj( aCurPath
);
768 aURLObj
.removeExtension();
769 OUString
aDialogName( aURLObj
.getName() );
770 aURLObj
.removeSegment();
771 OUString
aURL( aURLObj
.GetMainURL( INetURLObject::NO_DECODE
) );
772 bool bReadOnly
= false;
773 OUString
aComment( "# " );
774 aComment
+= aDialogName
;
775 aComment
+= " strings" ;
776 Reference
< task::XInteractionHandler
> xDummyHandler
;
778 // Remove old properties files in case of overwriting Dialog files
779 if( xSFI
->isFolder( aURL
) )
781 Sequence
< OUString
> aContentSeq
= xSFI
->getFolderContents( aURL
, false );
783 OUString
aDialogName_( aDialogName
);
784 aDialogName_
+= "_" ;
785 sal_Int32 nCount
= aContentSeq
.getLength();
786 const OUString
* pFiles
= aContentSeq
.getConstArray();
787 for( int i
= 0 ; i
< nCount
; i
++ )
789 OUString aCompleteName
= pFiles
[i
];
792 sal_Int32 iDot
= aCompleteName
.lastIndexOf( '.' );
793 sal_Int32 iSlash
= aCompleteName
.lastIndexOf( '/' );
796 sal_Int32 iCopyFrom
= (iSlash
!= -1) ? iSlash
+ 1 : 0;
797 aPureName
= aCompleteName
.copy( iCopyFrom
, iDot
-iCopyFrom
);
798 aExtension
= aCompleteName
.copy( iDot
+ 1 );
801 if( aExtension
== "properties" || aExtension
== "default" )
803 if( aPureName
.startsWith( aDialogName_
) )
807 xSFI
->kill( aCompleteName
);
809 catch(const uno::Exception
& )
816 Reference
< XStringResourceWithLocation
> xStringResourceWithLocation
=
817 StringResourceWithLocation::create( xContext
, aURL
, bReadOnly
,
818 xStringResourceResolver
->getDefaultLocale(), aDialogName
, aComment
, xDummyHandler
);
821 Sequence
< lang::Locale
> aLocaleSeq
= xStringResourceResolver
->getLocales();
822 const lang::Locale
* pLocales
= aLocaleSeq
.getConstArray();
823 sal_Int32 nLocaleCount
= aLocaleSeq
.getLength();
824 for( sal_Int32 iLocale
= 0 ; iLocale
< nLocaleCount
; iLocale
++ )
826 const lang::Locale
& rLocale
= pLocales
[ iLocale
];
827 xStringResourceWithLocation
->newLocale( rLocale
);
830 LocalizationMgr::copyResourceForDialog( xDialogModel
,
831 xStringResourceResolver
, xStringResourceWithLocation
);
833 xStringResourceWithLocation
->store();
837 ScopedVclPtrInstance
<MessageDialog
>::Create(this, IDE_RESSTR(RID_STR_COULDNTWRITE
))->Execute();
843 std::vector
< lang::Locale
> implGetLanguagesOnlyContainedInFirstSeq
844 ( const Sequence
< lang::Locale
>& aFirstSeq
, const Sequence
< lang::Locale
>& aSecondSeq
)
846 std::vector
< lang::Locale
> avRet
;
848 const lang::Locale
* pFirst
= aFirstSeq
.getConstArray();
849 const lang::Locale
* pSecond
= aSecondSeq
.getConstArray();
850 sal_Int32 nFirstCount
= aFirstSeq
.getLength();
851 sal_Int32 nSecondCount
= aSecondSeq
.getLength();
853 for( sal_Int32 iFirst
= 0 ; iFirst
< nFirstCount
; iFirst
++ )
855 const lang::Locale
& rFirstLocale
= pFirst
[ iFirst
];
857 bool bAlsoContainedInSecondSeq
= false;
858 for( sal_Int32 iSecond
= 0 ; iSecond
< nSecondCount
; iSecond
++ )
860 const lang::Locale
& rSecondLocale
= pSecond
[ iSecond
];
862 bool bMatch
= localesAreEqual( rFirstLocale
, rSecondLocale
);
865 bAlsoContainedInSecondSeq
= true;
870 if( !bAlsoContainedInSecondSeq
)
871 avRet
.push_back( rFirstLocale
);
878 class NameClashQueryBox
: public MessBox
881 NameClashQueryBox( vcl::Window
* pParent
,
882 const OUString
& rTitle
, const OUString
& rMessage
);
885 NameClashQueryBox::NameClashQueryBox( vcl::Window
* pParent
,
886 const OUString
& rTitle
, const OUString
& rMessage
)
887 : MessBox( pParent
, 0, rTitle
, rMessage
)
889 if ( !rTitle
.isEmpty() )
892 maMessText
= rMessage
;
894 AddButton( IDE_RESSTR(RID_STR_DLGIMP_CLASH_RENAME
), RET_YES
,
895 ButtonDialogFlags::Default
| ButtonDialogFlags::OK
| ButtonDialogFlags::Focus
);
896 AddButton( IDE_RESSTR(RID_STR_DLGIMP_CLASH_REPLACE
), RET_NO
);
897 AddButton( StandardButtonType::Cancel
, RET_CANCEL
, ButtonDialogFlags::Cancel
);
899 SetImage( QueryBox::GetStandardImage() );
903 class LanguageMismatchQueryBox
: public MessBox
906 LanguageMismatchQueryBox( vcl::Window
* pParent
,
907 const OUString
& rTitle
, const OUString
& rMessage
);
910 LanguageMismatchQueryBox::LanguageMismatchQueryBox( vcl::Window
* pParent
,
911 const OUString
& rTitle
, const OUString
& rMessage
)
912 : MessBox( pParent
, 0, rTitle
, rMessage
)
914 if ( !rTitle
.isEmpty() )
917 maMessText
= rMessage
;
918 AddButton( IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_ADD
), RET_YES
,
919 ButtonDialogFlags::Default
| ButtonDialogFlags::OK
| ButtonDialogFlags::Focus
);
920 AddButton( IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_OMIT
), RET_NO
);
921 AddButton( StandardButtonType::Cancel
, RET_CANCEL
, ButtonDialogFlags::Cancel
);
922 AddButton( StandardButtonType::Help
, RET_HELP
, ButtonDialogFlags::Help
, 4 );
924 SetImage( QueryBox::GetStandardImage() );
928 bool implImportDialog( vcl::Window
* pWin
, const OUString
& rCurPath
, const ScriptDocument
& rDocument
, const OUString
& aLibName
)
932 Reference
< XComponentContext
> xContext( comphelper::getProcessComponentContext() );
933 Reference
< XFilePicker3
> xFP
= FilePicker::createWithMode(xContext
, TemplateDescription::FILEOPEN_SIMPLE
);
935 Reference
< XFilePickerControlAccess
> xFPControl(xFP
, UNO_QUERY
);
936 xFPControl
->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
, false);
939 xFPControl
->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
, 0, aValue
);
941 OUString
aCurPath( rCurPath
);
942 if ( !aCurPath
.isEmpty() )
943 xFP
->setDisplayDirectory ( aCurPath
);
945 OUString
aDialogStr(IDE_RESSTR(RID_STR_STDDIALOGNAME
));
946 xFP
->appendFilter( aDialogStr
, OUString( "*.xdl" ) );
947 xFP
->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES
), OUString( FilterMask_All
) );
948 xFP
->setCurrentFilter( aDialogStr
);
950 if( xFP
->execute() == RET_OK
)
952 Sequence
< OUString
> aPaths
= xFP
->getFiles();
953 aCurPath
= aPaths
[0];
956 OUString
aOUCurPath( aCurPath
);
957 sal_Int32 iSlash
= aOUCurPath
.lastIndexOf( '/' );
959 aBasePath
= aOUCurPath
.copy( 0, iSlash
+ 1 );
963 // create dialog model
964 Reference
< container::XNameContainer
> xDialogModel(
965 xContext
->getServiceManager()->createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", xContext
),
968 Reference
< XSimpleFileAccess3
> xSFI( SimpleFileAccess::create(xContext
) );
970 Reference
< XInputStream
> xInput
;
971 if( xSFI
->exists( aCurPath
) )
972 xInput
= xSFI
->openFileRead( aCurPath
);
974 ::xmlscript::importDialogModel( xInput
, xDialogModel
, xContext
, rDocument
.isDocument() ? rDocument
.getDocument() : Reference
< frame::XModel
>() );
976 OUString aXmlDlgName
;
977 Reference
< beans::XPropertySet
> xDialogModelPropSet( xDialogModel
, UNO_QUERY
);
978 if( xDialogModelPropSet
.is() )
982 Any aXmlDialogNameAny
= xDialogModelPropSet
->getPropertyValue( DLGED_PROP_NAME
);
983 OUString aOUXmlDialogName
;
984 aXmlDialogNameAny
>>= aOUXmlDialogName
;
985 aXmlDlgName
= aOUXmlDialogName
;
987 catch(const beans::UnknownPropertyException
& )
990 bool bValidName
= !aXmlDlgName
.isEmpty();
991 OSL_ASSERT( bValidName
);
995 bool bDialogAlreadyExists
= rDocument
.hasDialog( aLibName
, aXmlDlgName
);
997 OUString aNewDlgName
= aXmlDlgName
;
1001 CLASH_OVERWRITE_DIALOG
,
1002 CLASH_RENAME_DIALOG
,
1004 NameClashMode eNameClashMode
= NO_CLASH
;
1005 if( bDialogAlreadyExists
)
1007 OUString
aQueryBoxTitle(IDE_RESSTR(RID_STR_DLGIMP_CLASH_TITLE
));
1008 OUString
aQueryBoxText(IDE_RESSTR(RID_STR_DLGIMP_CLASH_TEXT
));
1009 aQueryBoxText
= aQueryBoxText
.replaceAll("$(ARG1)", aXmlDlgName
);
1011 ScopedVclPtrInstance
< NameClashQueryBox
> aQueryBox( pWin
, aQueryBoxTitle
, aQueryBoxText
);
1012 sal_uInt16 nRet
= aQueryBox
->Execute();
1013 if( RET_YES
== nRet
)
1015 // RET_YES == Rename, see NameClashQueryBox::NameClashQueryBox
1016 eNameClashMode
= CLASH_RENAME_DIALOG
;
1018 aNewDlgName
= rDocument
.createObjectName( E_DIALOGS
, aLibName
);
1020 else if( RET_NO
== nRet
)
1022 // RET_NO == Replace, see NameClashQueryBox::NameClashQueryBox
1023 eNameClashMode
= CLASH_OVERWRITE_DIALOG
;
1025 else if( RET_CANCEL
== nRet
)
1031 Shell
* pShell
= GetShell();
1039 ::com::sun::star::lang::Locale aLocale
= Application::GetSettings().GetUILanguageTag().getLocale();
1040 Reference
< task::XInteractionHandler
> xDummyHandler
;
1041 bool bReadOnly
= true;
1042 Reference
< XStringResourceWithLocation
> xImportStringResource
=
1043 StringResourceWithLocation::create( xContext
, aBasePath
, bReadOnly
,
1044 aLocale
, aXmlDlgName
, OUString(), xDummyHandler
);
1046 Sequence
< lang::Locale
> aImportLocaleSeq
= xImportStringResource
->getLocales();
1047 sal_Int32 nImportLocaleCount
= aImportLocaleSeq
.getLength();
1049 Reference
< container::XNameContainer
> xDialogLib( rDocument
.getLibrary( E_DIALOGS
, aLibName
, true ) );
1050 Reference
< resource::XStringResourceManager
> xLibStringResourceManager
= LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib
);
1051 sal_Int32 nLibLocaleCount
= 0;
1052 Sequence
< lang::Locale
> aLibLocaleSeq
;
1053 if( xLibStringResourceManager
.is() )
1055 aLibLocaleSeq
= xLibStringResourceManager
->getLocales();
1056 nLibLocaleCount
= aLibLocaleSeq
.getLength();
1059 // Check language matches
1060 std::vector
< lang::Locale
> aOnlyInImportLanguages
=
1061 implGetLanguagesOnlyContainedInFirstSeq( aImportLocaleSeq
, aLibLocaleSeq
);
1062 int nOnlyInImportLanguageCount
= aOnlyInImportLanguages
.size();
1064 // For now: Keep languages from lib
1065 bool bLibLocalized
= (nLibLocaleCount
> 0);
1066 bool bImportLocalized
= (nImportLocaleCount
> 0);
1068 bool bAddDialogLanguagesToLib
= false;
1069 if( nOnlyInImportLanguageCount
> 0 )
1071 OUString
aQueryBoxTitle(IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_TITLE
));
1072 OUString
aQueryBoxText(IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_TEXT
));
1073 ScopedVclPtrInstance
< LanguageMismatchQueryBox
> aQueryBox( pWin
, aQueryBoxTitle
, aQueryBoxText
);
1074 sal_uInt16 nRet
= aQueryBox
->Execute();
1075 if( RET_YES
== nRet
)
1077 // RET_YES == Add, see LanguageMismatchQueryBox::LanguageMismatchQueryBox
1078 bAddDialogLanguagesToLib
= true;
1080 // RET_NO == Omit, see LanguageMismatchQueryBox::LanguageMismatchQueryBox
1081 // -> nothing to do here
1082 //else if( RET_NO == nRet )
1085 else if( RET_CANCEL
== nRet
)
1091 if( bImportLocalized
)
1093 bool bCopyResourcesForDialog
= true;
1094 if( bAddDialogLanguagesToLib
)
1096 boost::shared_ptr
<LocalizationMgr
> pCurMgr
= pShell
->GetCurLocalizationMgr();
1098 lang::Locale aFirstLocale
;
1099 aFirstLocale
= aOnlyInImportLanguages
[0];
1100 if( nOnlyInImportLanguageCount
> 1 )
1102 // Check if import default belongs to only import languages and use it then
1103 lang::Locale aImportDefaultLocale
= xImportStringResource
->getDefaultLocale();
1104 lang::Locale aTmpLocale
;
1105 for( int i
= 0 ; i
< nOnlyInImportLanguageCount
; ++i
)
1107 aTmpLocale
= aOnlyInImportLanguages
[i
];
1108 if( localesAreEqual( aImportDefaultLocale
, aTmpLocale
) )
1110 aFirstLocale
= aImportDefaultLocale
;
1116 Sequence
< lang::Locale
> aFirstLocaleSeq( 1 );
1117 aFirstLocaleSeq
[0] = aFirstLocale
;
1118 pCurMgr
->handleAddLocales( aFirstLocaleSeq
);
1120 if( nOnlyInImportLanguageCount
> 1 )
1122 Sequence
< lang::Locale
> aRemainingLocaleSeq( nOnlyInImportLanguageCount
- 1 );
1123 lang::Locale aTmpLocale
;
1125 for( int i
= 0 ; i
< nOnlyInImportLanguageCount
; ++i
)
1127 aTmpLocale
= aOnlyInImportLanguages
[i
];
1128 if( !localesAreEqual( aFirstLocale
, aTmpLocale
) )
1129 aRemainingLocaleSeq
[iSeq
++] = aTmpLocale
;
1131 pCurMgr
->handleAddLocales( aRemainingLocaleSeq
);
1134 else if( !bLibLocalized
)
1136 Reference
< resource::XStringResourceManager
> xImportStringResourceManager( xImportStringResource
, UNO_QUERY
);
1137 LocalizationMgr::resetResourceForDialog( xDialogModel
, xImportStringResourceManager
);
1138 bCopyResourcesForDialog
= false;
1141 if( bCopyResourcesForDialog
)
1143 Reference
< resource::XStringResourceResolver
> xImportStringResourceResolver( xImportStringResource
, UNO_QUERY
);
1144 LocalizationMgr::copyResourceForDroppedDialog( xDialogModel
, aXmlDlgName
,
1145 xLibStringResourceManager
, xImportStringResourceResolver
);
1148 else if( bLibLocalized
)
1150 LocalizationMgr::setResourceIDsForDialog( xDialogModel
, xLibStringResourceManager
);
1154 LocalizationMgr::setStringResourceAtDialog( rDocument
, aLibName
, aNewDlgName
, xDialogModel
);
1156 if( eNameClashMode
== CLASH_OVERWRITE_DIALOG
)
1158 if (basctl::RemoveDialog( rDocument
, aLibName
, aNewDlgName
) )
1160 BaseWindow
* pDlgWin
= pShell
->FindDlgWin( rDocument
, aLibName
, aNewDlgName
, false, true );
1161 if( pDlgWin
!= NULL
)
1162 pShell
->RemoveWindow( pDlgWin
, true );
1163 MarkDocumentModified( rDocument
);
1172 if( eNameClashMode
== CLASH_RENAME_DIALOG
)
1174 bool bRenamed
= false;
1175 if( xDialogModelPropSet
.is() )
1179 Any aXmlDialogNameAny
;
1180 aXmlDialogNameAny
<<= OUString( aNewDlgName
);
1181 xDialogModelPropSet
->setPropertyValue( DLGED_PROP_NAME
, aXmlDialogNameAny
);
1184 catch(const beans::UnknownPropertyException
& )
1191 LocalizationMgr::renameStringResourceIDs( rDocument
, aLibName
, aNewDlgName
, xDialogModel
);
1200 Reference
< XInputStreamProvider
> xISP
= ::xmlscript::exportDialogModel( xDialogModel
, xContext
, rDocument
.isDocument() ? rDocument
.getDocument() : Reference
< frame::XModel
>() );
1201 bool bSuccess
= rDocument
.insertDialog( aLibName
, aNewDlgName
, xISP
);
1204 VclPtr
<DialogWindow
> pNewDlgWin
= pShell
->CreateDlgWin( rDocument
, aLibName
, aNewDlgName
);
1205 pShell
->SetCurWindow( pNewDlgWin
, true );
1210 catch(const Exception
& )
1218 bool DialogWindow::ImportDialog()
1220 const ScriptDocument
& rDocument
= GetDocument();
1221 OUString aLibName
= GetLibName();
1222 return implImportDialog( this, aCurPath
, rDocument
, aLibName
);
1225 DlgEdModel
& DialogWindow::GetModel() const
1227 return pEditor
->GetModel();
1230 DlgEdPage
& DialogWindow::GetPage() const
1232 return pEditor
->GetPage();
1235 DlgEdView
& DialogWindow::GetView() const
1237 return pEditor
->GetView();
1240 bool DialogWindow::IsModified()
1242 return pEditor
->IsModified();
1245 ::svl::IUndoManager
* DialogWindow::GetUndoManager()
1247 return pUndoMgr
.get();
1250 OUString
DialogWindow::GetTitle()
1255 EntryDescriptor
DialogWindow::CreateEntryDescriptor()
1257 ScriptDocument
aDocument( GetDocument() );
1258 OUString
aLibName( GetLibName() );
1259 OUString aLibSubName
;
1260 LibraryLocation eLocation
= aDocument
.getLibraryLocation( aLibName
);
1261 return EntryDescriptor( aDocument
, eLocation
, aLibName
, aLibSubName
, GetName(), OBJ_TYPE_DIALOG
);
1264 void DialogWindow::SetReadOnly (bool bReadOnly
)
1266 pEditor
->SetMode(bReadOnly
? DlgEditor::READONLY
: DlgEditor::SELECT
);
1269 bool DialogWindow::IsReadOnly ()
1271 return pEditor
->GetMode() == DlgEditor::READONLY
;
1274 bool DialogWindow::IsPasteAllowed()
1276 return pEditor
->IsPasteAllowed();
1279 void DialogWindow::StoreData()
1285 Reference
< container::XNameContainer
> xLib
= GetDocument().getLibrary( E_DIALOGS
, GetLibName(), true );
1289 Reference
< container::XNameContainer
> xDialogModel
= pEditor
->GetDialog();
1291 if( xDialogModel
.is() )
1293 Reference
< XComponentContext
> xContext(
1294 comphelper::getProcessComponentContext() );
1295 Reference
< XInputStreamProvider
> xISP
= ::xmlscript::exportDialogModel( xDialogModel
, xContext
, GetDocument().isDocument() ? GetDocument().getDocument() : Reference
< frame::XModel
>() );
1296 xLib
->replaceByName( OUString( GetName() ), makeAny( xISP
) );
1300 catch (const uno::Exception
& )
1302 DBG_UNHANDLED_EXCEPTION();
1304 MarkDocumentModified( GetDocument() );
1305 pEditor
->ClearModifyFlag();
1309 void DialogWindow::Activating ()
1315 void DialogWindow::Deactivating()
1319 MarkDocumentModified( GetDocument() );
1323 sal_Int32
DialogWindow::countPages( Printer
* )
1328 void DialogWindow::printPage( sal_Int32 nPage
, Printer
* pPrinter
)
1330 DlgEditor::printPage( nPage
, pPrinter
, CreateQualifiedName() );
1333 void DialogWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
1335 if( (rDCEvt
.GetType()==DataChangedEventType::SETTINGS
) && (rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
) )
1337 InitSettings( true, true, true );
1341 BaseWindow::DataChanged( rDCEvt
);
1344 void DialogWindow::InitSettings(bool bFont
, bool bForeground
, bool bBackground
)
1346 // FIXME RenderContext
1347 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
1351 aFont
= rStyleSettings
.GetFieldFont();
1352 SetPointFont(*this, aFont
);
1355 if( bForeground
|| bFont
)
1357 SetTextColor( rStyleSettings
.GetFieldTextColor() );
1362 SetBackground( rStyleSettings
.GetFieldColor() );
1365 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> DialogWindow::CreateAccessible()
1367 return (::com::sun::star::accessibility::XAccessible
*) new AccessibleDialogWindow( this );
1370 char const* DialogWindow::GetHid () const
1372 return HID_BASICIDE_DIALOGWINDOW
;
1374 ItemType
DialogWindow::GetType () const
1381 // DialogWindowLayout
1385 DialogWindowLayout::DialogWindowLayout (vcl::Window
* pParent
, ObjectCatalog
& rObjectCatalog_
) :
1388 rObjectCatalog(rObjectCatalog_
),
1391 ShowPropertyBrowser();
1394 DialogWindowLayout::~DialogWindowLayout()
1399 void DialogWindowLayout::dispose()
1401 if (pPropertyBrowser
)
1402 Remove(pPropertyBrowser
);
1403 pPropertyBrowser
.disposeAndClear();
1408 // shows the property browser (and creates if necessary)
1409 void DialogWindowLayout::ShowPropertyBrowser ()
1412 if (!pPropertyBrowser
)
1415 pPropertyBrowser
= VclPtr
<PropBrw
>::Create(*this);
1416 pPropertyBrowser
->Show();
1417 // after OnFirstSize():
1419 AddPropertyBrowser();
1420 // updating if necessary
1421 UpdatePropertyBrowser();
1424 pPropertyBrowser
->Show();
1425 // refreshing the button state
1426 if (SfxBindings
* pBindings
= GetBindingsPtr())
1427 pBindings
->Invalidate(SID_SHOW_PROPERTYBROWSER
);
1430 // disables the property browser
1431 void DialogWindowLayout::DisablePropertyBrowser ()
1433 if (pPropertyBrowser
)
1434 pPropertyBrowser
->Update(0);
1437 // updates the property browser
1438 void DialogWindowLayout::UpdatePropertyBrowser ()
1440 if (pPropertyBrowser
)
1441 pPropertyBrowser
->Update(GetShell());
1444 void DialogWindowLayout::Activating (BaseWindow
& rChild
)
1446 assert(dynamic_cast<DialogWindow
*>(&rChild
));
1447 pChild
= &static_cast<DialogWindow
&>(rChild
);
1448 rObjectCatalog
.SetLayoutWindow(this);
1449 rObjectCatalog
.UpdateEntries();
1450 rObjectCatalog
.Show();
1451 if (pPropertyBrowser
)
1452 pPropertyBrowser
->Show();
1453 Layout::Activating(rChild
);
1456 void DialogWindowLayout::Deactivating ()
1458 Layout::Deactivating();
1459 rObjectCatalog
.Hide();
1460 if (pPropertyBrowser
)
1461 pPropertyBrowser
->Hide();
1465 void DialogWindowLayout::ExecuteGlobal (SfxRequest
& rReq
)
1467 switch (rReq
.GetSlot())
1469 case SID_SHOW_PROPERTYBROWSER
:
1470 // toggling property browser
1471 if (pPropertyBrowser
&& pPropertyBrowser
->IsVisible())
1472 pPropertyBrowser
->Hide();
1474 ShowPropertyBrowser();
1476 // refreshing the button state
1477 if (SfxBindings
* pBindings
= GetBindingsPtr())
1478 pBindings
->Invalidate(SID_SHOW_PROPERTYBROWSER
);
1483 void DialogWindowLayout::GetState (SfxItemSet
& rSet
, unsigned nWhich
)
1487 case SID_SHOW_PROPERTYBROWSER
:
1488 rSet
.Put(SfxBoolItem(nWhich
, pPropertyBrowser
&& pPropertyBrowser
->IsVisible()));
1491 case SID_BASICIDE_CHOOSEMACRO
:
1492 rSet
.Put(SfxVisibilityItem(nWhich
, false));
1497 void DialogWindowLayout::OnFirstSize (long const nWidth
, long const nHeight
)
1499 AddToLeft(&rObjectCatalog
, Size(nWidth
* 0.25, nHeight
* 0.35));
1500 if (pPropertyBrowser
)
1501 AddPropertyBrowser();
1504 void DialogWindowLayout::AddPropertyBrowser () {
1505 Size
const aSize
= GetOutputSizePixel();
1506 AddToLeft(pPropertyBrowser
, Size(aSize
.Width() * 0.25, aSize
.Height() * 0.65));
1510 } // namespace basctl
1512 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */