summaryrefslogtreecommitdiff
path: root/basctl/source
diff options
context:
space:
mode:
Diffstat (limited to 'basctl/source')
-rw-r--r--basctl/source/accessibility/accessibledialogcontrolshape.cxx621
-rw-r--r--basctl/source/accessibility/accessibledialogwindow.cxx1126
-rw-r--r--basctl/source/accessibility/makefile.mk48
-rw-r--r--basctl/source/basicide/basdoc.cxx137
-rw-r--r--basctl/source/basicide/basdoc.hxx69
-rw-r--r--basctl/source/basicide/basicbox.cxx548
-rw-r--r--basctl/source/basicide/basicbox.hxx154
-rw-r--r--basctl/source/basicide/basicmod.hxx49
-rw-r--r--basctl/source/basicide/basicprint.src40
-rw-r--r--basctl/source/basicide/basicrenderable.cxx196
-rw-r--r--basctl/source/basicide/basicrenderable.hxx76
-rw-r--r--basctl/source/basicide/baside2.cxx1759
-rw-r--r--basctl/source/basicide/baside2.hrc50
-rw-r--r--basctl/source/basicide/baside2.hxx507
-rw-r--r--basctl/source/basicide/baside2b.cxx2317
-rw-r--r--basctl/source/basicide/baside3.cxx1415
-rw-r--r--basctl/source/basicide/basidectrlr.cxx153
-rw-r--r--basctl/source/basicide/basides1.cxx1443
-rw-r--r--basctl/source/basicide/basides2.cxx353
-rw-r--r--basctl/source/basicide/basides3.cxx179
-rw-r--r--basctl/source/basicide/basidesh.cxx1065
-rw-r--r--basctl/source/basicide/basidesh.src747
-rw-r--r--basctl/source/basicide/basobj2.cxx416
-rw-r--r--basctl/source/basicide/basobj3.cxx529
-rw-r--r--basctl/source/basicide/bastype2.cxx903
-rw-r--r--basctl/source/basicide/bastype2.hxx222
-rw-r--r--basctl/source/basicide/bastype3.cxx509
-rw-r--r--basctl/source/basicide/bastype3.hxx67
-rw-r--r--basctl/source/basicide/bastype4.hxx69
-rw-r--r--basctl/source/basicide/bastypes.cxx1022
-rw-r--r--basctl/source/basicide/brkdlg.cxx282
-rw-r--r--basctl/source/basicide/brkdlg.hrc45
-rw-r--r--basctl/source/basicide/brkdlg.hxx75
-rw-r--r--basctl/source/basicide/brkdlg.src130
-rw-r--r--basctl/source/basicide/doceventnotifier.cxx280
-rw-r--r--basctl/source/basicide/docsignature.cxx118
-rw-r--r--basctl/source/basicide/documentenumeration.cxx206
-rw-r--r--basctl/source/basicide/documentenumeration.hxx109
-rw-r--r--basctl/source/basicide/ide_pch.cxx33
-rw-r--r--basctl/source/basicide/ide_pch.hxx72
-rw-r--r--basctl/source/basicide/iderdll.cxx232
-rw-r--r--basctl/source/basicide/iderdll2.hxx111
-rw-r--r--basctl/source/basicide/idetemp.hxx67
-rw-r--r--basctl/source/basicide/localizationmgr.cxx1228
-rw-r--r--basctl/source/basicide/macrodlg.cxx923
-rw-r--r--basctl/source/basicide/macrodlg.hrc59
-rw-r--r--basctl/source/basicide/macrodlg.hxx114
-rw-r--r--basctl/source/basicide/macrodlg.src231
-rw-r--r--basctl/source/basicide/makefile.mk100
-rw-r--r--basctl/source/basicide/moduldl2.cxx1728
-rw-r--r--basctl/source/basicide/moduldlg.cxx1068
-rw-r--r--basctl/source/basicide/moduldlg.hrc68
-rw-r--r--basctl/source/basicide/moduldlg.hxx277
-rw-r--r--basctl/source/basicide/moduldlg.src411
-rw-r--r--basctl/source/basicide/moptions.hrc47
-rw-r--r--basctl/source/basicide/moptions.src147
-rw-r--r--basctl/source/basicide/objdlg.cxx303
-rw-r--r--basctl/source/basicide/objdlg.hrc40
-rw-r--r--basctl/source/basicide/objdlg.hxx99
-rw-r--r--basctl/source/basicide/objdlg.src93
-rw-r--r--basctl/source/basicide/register.cxx120
-rw-r--r--basctl/source/basicide/scriptdocument.cxx1631
-rw-r--r--basctl/source/basicide/tbxctl.cxx243
-rw-r--r--basctl/source/basicide/tbxctl.hrc30
-rw-r--r--basctl/source/basicide/tbxctl.hxx95
-rw-r--r--basctl/source/basicide/tbxctl.src273
-rw-r--r--basctl/source/basicide/unomodel.cxx129
-rw-r--r--basctl/source/basicide/unomodel.hxx69
-rw-r--r--basctl/source/dlged/dlged.cxx1425
-rw-r--r--basctl/source/dlged/dlgedclip.cxx151
-rw-r--r--basctl/source/dlged/dlgedfac.cxx270
-rw-r--r--basctl/source/dlged/dlgedfunc.cxx640
-rw-r--r--basctl/source/dlged/dlgedlist.cxx130
-rw-r--r--basctl/source/dlged/dlgedmod.cxx81
-rw-r--r--basctl/source/dlged/dlgedobj.cxx1896
-rw-r--r--basctl/source/dlged/dlgedpage.cxx89
-rw-r--r--basctl/source/dlged/dlgedview.cxx217
-rw-r--r--basctl/source/dlged/dlgresid.src175
-rw-r--r--basctl/source/dlged/makefile.mk63
-rw-r--r--basctl/source/dlged/managelang.cxx427
-rw-r--r--basctl/source/dlged/managelang.hrc106
-rw-r--r--basctl/source/dlged/managelang.src232
-rw-r--r--basctl/source/dlged/propbrw.cxx624
-rw-r--r--basctl/source/inc/accessibledialogcontrolshape.hxx150
-rw-r--r--basctl/source/inc/accessibledialogwindow.hxx177
-rw-r--r--basctl/source/inc/baside3.hxx116
-rw-r--r--basctl/source/inc/basidectrlr.hxx76
-rw-r--r--basctl/source/inc/basidesh.hxx239
-rw-r--r--basctl/source/inc/basobj.hxx128
-rw-r--r--basctl/source/inc/bastypes.hxx343
-rw-r--r--basctl/source/inc/dlged.hxx215
-rw-r--r--basctl/source/inc/dlgedclip.hxx68
-rw-r--r--basctl/source/inc/dlgeddef.hxx86
-rw-r--r--basctl/source/inc/dlgedfac.hxx51
-rw-r--r--basctl/source/inc/dlgedfunc.hxx98
-rw-r--r--basctl/source/inc/dlgedlist.hxx87
-rw-r--r--basctl/source/inc/dlgedmod.hxx67
-rw-r--r--basctl/source/inc/dlgedobj.hxx198
-rw-r--r--basctl/source/inc/dlgedpage.hxx64
-rw-r--r--basctl/source/inc/dlgedview.hxx63
-rw-r--r--basctl/source/inc/dlgresid.hrc77
-rw-r--r--basctl/source/inc/doceventnotifier.hxx99
-rw-r--r--basctl/source/inc/docsignature.hxx92
-rw-r--r--basctl/source/inc/iderid.hxx43
-rw-r--r--basctl/source/inc/localizationmgr.hxx158
-rw-r--r--basctl/source/inc/managelang.hxx121
-rw-r--r--basctl/source/inc/propbrw.hxx118
-rw-r--r--basctl/source/inc/sbxitem.hxx79
-rw-r--r--basctl/source/inc/scriptdocument.hxx540
-rw-r--r--basctl/source/inc/svheader.hxx91
110 files changed, 38245 insertions, 0 deletions
diff --git a/basctl/source/accessibility/accessibledialogcontrolshape.cxx b/basctl/source/accessibility/accessibledialogcontrolshape.cxx
new file mode 100644
index 000000000000..b2b20e105b4e
--- /dev/null
+++ b/basctl/source/accessibility/accessibledialogcontrolshape.cxx
@@ -0,0 +1,621 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+#include <accessibledialogcontrolshape.hxx>
+#include <baside3.hxx>
+#include <dlgeddef.hxx>
+#include <dlgedview.hxx>
+#include <dlgedobj.hxx>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <toolkit/awt/vclxfont.hxx>
+#include <toolkit/helper/externallock.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::accessibility;
+using namespace ::comphelper;
+
+
+// -----------------------------------------------------------------------------
+// class AccessibleDialogControlShape
+// -----------------------------------------------------------------------------
+
+AccessibleDialogControlShape::AccessibleDialogControlShape( DialogWindow* pDialogWindow, DlgEdObj* pDlgEdObj )
+ :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
+ ,m_pDialogWindow( pDialogWindow )
+ ,m_pDlgEdObj( pDlgEdObj )
+{
+ m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
+
+ if ( m_pDlgEdObj )
+ m_xControlModel = Reference< XPropertySet >( m_pDlgEdObj->GetUnoControlModel(), UNO_QUERY );
+
+ if ( m_xControlModel.is() )
+ m_xControlModel->addPropertyChangeListener( ::rtl::OUString(), static_cast< beans::XPropertyChangeListener* >( this ) );
+
+ m_bFocused = IsFocused();
+ m_bSelected = IsSelected();
+ m_aBounds = GetBounds();
+}
+
+// -----------------------------------------------------------------------------
+
+AccessibleDialogControlShape::~AccessibleDialogControlShape()
+{
+ if ( m_xControlModel.is() )
+ m_xControlModel->removePropertyChangeListener( ::rtl::OUString(), static_cast< beans::XPropertyChangeListener* >( this ) );
+
+ delete m_pExternalLock;
+ m_pExternalLock = NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool AccessibleDialogControlShape::IsFocused()
+{
+ sal_Bool bFocused = sal_False;
+ if ( m_pDialogWindow )
+ {
+ SdrView* pSdrView = m_pDialogWindow->GetView();
+ if ( pSdrView && pSdrView->IsObjMarked( m_pDlgEdObj ) && pSdrView->GetMarkedObjectList().GetMarkCount() == 1 )
+ bFocused = sal_True;
+ }
+
+ return bFocused;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool AccessibleDialogControlShape::IsSelected()
+{
+ sal_Bool bSelected = sal_False;
+ if ( m_pDialogWindow )
+ {
+ SdrView* pSdrView = m_pDialogWindow->GetView();
+ if ( pSdrView )
+ bSelected = pSdrView->IsObjMarked( m_pDlgEdObj );
+ }
+
+ return bSelected;
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogControlShape::SetFocused( sal_Bool bFocused )
+{
+ if ( m_bFocused != bFocused )
+ {
+ Any aOldValue, aNewValue;
+ if ( m_bFocused )
+ aOldValue <<= AccessibleStateType::FOCUSED;
+ else
+ aNewValue <<= AccessibleStateType::FOCUSED;
+ m_bFocused = bFocused;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogControlShape::SetSelected( sal_Bool bSelected )
+{
+ if ( m_bSelected != bSelected )
+ {
+ Any aOldValue, aNewValue;
+ if ( m_bSelected )
+ aOldValue <<= AccessibleStateType::SELECTED;
+ else
+ aNewValue <<= AccessibleStateType::SELECTED;
+ m_bSelected = bSelected;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Rectangle AccessibleDialogControlShape::GetBounds()
+{
+ awt::Rectangle aBounds( 0, 0, 0, 0 );
+ if ( m_pDlgEdObj )
+ {
+ // get the bounding box of the shape in logic units
+ Rectangle aRect = m_pDlgEdObj->GetSnapRect();
+
+ if ( m_pDialogWindow )
+ {
+ // transform coordinates relative to the parent
+ MapMode aMap = m_pDialogWindow->GetMapMode();
+ Point aOrg = aMap.GetOrigin();
+ aRect.Move( aOrg.X(), aOrg.Y() );
+
+ // convert logic units to pixel
+ aRect = m_pDialogWindow->LogicToPixel( aRect, MapMode(MAP_100TH_MM) );
+
+ // clip the shape's bounding box with the bounding box of its parent
+ Rectangle aParentRect( Point( 0, 0 ), m_pDialogWindow->GetSizePixel() );
+ aRect = aRect.GetIntersection( aParentRect );
+ aBounds = AWTRectangle( aRect );
+ }
+ }
+
+ return aBounds;
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogControlShape::SetBounds( const awt::Rectangle& aBounds )
+{
+ if ( m_aBounds.X != aBounds.X || m_aBounds.Y != aBounds.Y || m_aBounds.Width != aBounds.Width || m_aBounds.Height != aBounds.Height )
+ {
+ m_aBounds = aBounds;
+ NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED, Any(), Any() );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+Window* AccessibleDialogControlShape::GetWindow() const
+{
+ Window* pWindow = NULL;
+ if ( m_pDlgEdObj )
+ {
+ Reference< awt::XControl > xControl( m_pDlgEdObj->GetControl(), UNO_QUERY );
+ if ( xControl.is() )
+ pWindow = VCLUnoHelper::GetWindow( xControl->getPeer() );
+ }
+
+ return pWindow;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString AccessibleDialogControlShape::GetModelStringProperty( const sal_Char* pPropertyName )
+{
+ ::rtl::OUString sReturn;
+
+ try
+ {
+ if ( m_xControlModel.is() )
+ {
+ ::rtl::OUString sPropertyName( ::rtl::OUString::createFromAscii( pPropertyName ) );
+ Reference< XPropertySetInfo > xInfo = m_xControlModel->getPropertySetInfo();
+ if ( xInfo.is() && xInfo->hasPropertyByName( sPropertyName ) )
+ m_xControlModel->getPropertyValue( sPropertyName ) >>= sReturn;
+ }
+ }
+ catch ( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "AccessibleDialogControlShape::GetModelStringProperty: caught an exception!" );
+ }
+
+ return sReturn;
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogControlShape::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ rStateSet.AddState( AccessibleStateType::ENABLED );
+
+ rStateSet.AddState( AccessibleStateType::VISIBLE );
+
+ rStateSet.AddState( AccessibleStateType::SHOWING );
+
+ rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+
+ if ( IsFocused() )
+ rStateSet.AddState( AccessibleStateType::FOCUSED );
+
+ rStateSet.AddState( AccessibleStateType::SELECTABLE );
+
+ if ( IsSelected() )
+ rStateSet.AddState( AccessibleStateType::SELECTED );
+
+ rStateSet.AddState( AccessibleStateType::RESIZABLE );
+}
+
+// -----------------------------------------------------------------------------
+// OCommonAccessibleComponent
+// -----------------------------------------------------------------------------
+
+awt::Rectangle AccessibleDialogControlShape::implGetBounds() throw (RuntimeException)
+{
+ return GetBounds();
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogControlShape, AccessibleExtendedComponentHelper_BASE, AccessibleDialogControlShape_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogControlShape, AccessibleExtendedComponentHelper_BASE, AccessibleDialogControlShape_BASE )
+
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogControlShape::disposing()
+{
+ AccessibleExtendedComponentHelper_BASE::disposing();
+
+ m_pDialogWindow = NULL;
+ m_pDlgEdObj = NULL;
+
+ if ( m_xControlModel.is() )
+ m_xControlModel->removePropertyChangeListener( ::rtl::OUString(), static_cast< beans::XPropertyChangeListener* >( this ) );
+ m_xControlModel.clear();
+}
+
+// -----------------------------------------------------------------------------
+// XEventListener
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogControlShape::disposing( const lang::EventObject& ) throw (RuntimeException)
+{
+ if ( m_xControlModel.is() )
+ m_xControlModel->removePropertyChangeListener( ::rtl::OUString(), static_cast< beans::XPropertyChangeListener* >( this ) );
+ m_xControlModel.clear();
+}
+
+// -----------------------------------------------------------------------------
+// XPropertyChangeListener
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogControlShape::propertyChange( const beans::PropertyChangeEvent& rEvent ) throw (RuntimeException)
+{
+ if ( rEvent.PropertyName == DLGED_PROP_NAME )
+ {
+ NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, rEvent.OldValue, rEvent.NewValue );
+ }
+ else if ( rEvent.PropertyName == DLGED_PROP_POSITIONX ||
+ rEvent.PropertyName == DLGED_PROP_POSITIONY ||
+ rEvent.PropertyName == DLGED_PROP_WIDTH ||
+ rEvent.PropertyName == DLGED_PROP_HEIGHT )
+ {
+ SetBounds( GetBounds() );
+ }
+ else if ( rEvent.PropertyName == DLGED_PROP_BACKGROUNDCOLOR ||
+ rEvent.PropertyName == DLGED_PROP_TEXTCOLOR ||
+ rEvent.PropertyName == DLGED_PROP_TEXTLINECOLOR )
+ {
+ NotifyAccessibleEvent( AccessibleEventId::VISIBLE_DATA_CHANGED, Any(), Any() );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString AccessibleDialogControlShape::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.basctl.AccessibleShape" );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool AccessibleDialogControlShape::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pNames + aNames.getLength();
+ for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
+ ;
+
+ return pNames != pEnd;
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > AccessibleDialogControlShape::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.drawing.AccessibleShape" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessible
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleContext > AccessibleDialogControlShape::getAccessibleContext( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return this;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int32 AccessibleDialogControlShape::getAccessibleChildCount() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > AccessibleDialogControlShape::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( i < 0 || i >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ return Reference< XAccessible >();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > AccessibleDialogControlShape::getAccessibleParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< XAccessible > xParent;
+ if ( m_pDialogWindow )
+ xParent = m_pDialogWindow->GetAccessible();
+
+ return xParent;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 AccessibleDialogControlShape::getAccessibleIndexInParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nIndexInParent = -1;
+ Reference< XAccessible > xParent( getAccessibleParent() );
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
+ if ( xParentContext.is() )
+ {
+ for ( sal_Int32 i = 0, nCount = xParentContext->getAccessibleChildCount(); i < nCount; ++i )
+ {
+ Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) );
+ if ( xChild.is() )
+ {
+ Reference< XAccessibleContext > xChildContext = xChild->getAccessibleContext();
+ if ( xChildContext == (XAccessibleContext*)this )
+ {
+ nIndexInParent = i;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return nIndexInParent;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 AccessibleDialogControlShape::getAccessibleRole( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return AccessibleRole::SHAPE;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString AccessibleDialogControlShape::getAccessibleDescription( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return GetModelStringProperty( "HelpText" );
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString AccessibleDialogControlShape::getAccessibleName( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return GetModelStringProperty( "Name" );
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleRelationSet > AccessibleDialogControlShape::getAccessibleRelationSet( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
+ Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
+ return xSet;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleStateSet > AccessibleDialogControlShape::getAccessibleStateSet( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
+ Reference< XAccessibleStateSet > xSet = pStateSetHelper;
+
+ if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
+ {
+ FillAccessibleStateSet( *pStateSetHelper );
+ }
+ else
+ {
+ pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
+ }
+
+ return xSet;
+}
+
+// -----------------------------------------------------------------------------
+
+Locale AccessibleDialogControlShape::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return Application::GetSettings().GetLocale();
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleComponent
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > AccessibleDialogControlShape::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return Reference< XAccessible >();
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogControlShape::grabFocus( ) throw (RuntimeException)
+{
+ // no focus for shapes
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 AccessibleDialogControlShape::getForeground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ Window* pWindow = GetWindow();
+ if ( pWindow )
+ {
+ if ( pWindow->IsControlForeground() )
+ nColor = pWindow->GetControlForeground().GetColor();
+ else
+ {
+ Font aFont;
+ if ( pWindow->IsControlFont() )
+ aFont = pWindow->GetControlFont();
+ else
+ aFont = pWindow->GetFont();
+ nColor = aFont.GetColor().GetColor();
+ }
+ }
+
+ return nColor;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 AccessibleDialogControlShape::getBackground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ Window* pWindow = GetWindow();
+ if ( pWindow )
+ {
+ if ( pWindow->IsControlBackground() )
+ nColor = pWindow->GetControlBackground().GetColor();
+ else
+ nColor = pWindow->GetBackground().GetColor().GetColor();
+ }
+
+ return nColor;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleExtendedComponent
+// -----------------------------------------------------------------------------
+
+Reference< awt::XFont > AccessibleDialogControlShape::getFont( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< awt::XFont > xFont;
+ Window* pWindow = GetWindow();
+ if ( pWindow )
+ {
+ Reference< awt::XDevice > xDev( pWindow->GetComponentInterface(), UNO_QUERY );
+ if ( xDev.is() )
+ {
+ Font aFont;
+ if ( pWindow->IsControlFont() )
+ aFont = pWindow->GetControlFont();
+ else
+ aFont = pWindow->GetFont();
+ VCLXFont* pVCLXFont = new VCLXFont;
+ pVCLXFont->Init( *xDev.get(), aFont );
+ xFont = pVCLXFont;
+ }
+ }
+
+ return xFont;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString AccessibleDialogControlShape::getTitledBorderText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString AccessibleDialogControlShape::getToolTipText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sText;
+ Window* pWindow = GetWindow();
+ if ( pWindow )
+ sText = pWindow->GetQuickHelpText();
+
+ return sText;
+}
+
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/accessibility/accessibledialogwindow.cxx b/basctl/source/accessibility/accessibledialogwindow.cxx
new file mode 100644
index 000000000000..b8c43e4daa37
--- /dev/null
+++ b/basctl/source/accessibility/accessibledialogwindow.cxx
@@ -0,0 +1,1126 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+#include <accessibledialogwindow.hxx>
+#include <accessibledialogcontrolshape.hxx>
+#include <baside3.hxx>
+#include <dlged.hxx>
+#include <dlgedmod.hxx>
+#include <dlgedpage.hxx>
+#include <dlgedview.hxx>
+#include <dlgedobj.hxx>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <toolkit/awt/vclxfont.hxx>
+#include <toolkit/helper/externallock.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <vcl/svapp.hxx>
+
+#include <vector>
+#include <algorithm>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::accessibility;
+using namespace ::comphelper;
+
+DBG_NAME( AccessibleDialogWindow )
+
+
+// -----------------------------------------------------------------------------
+// class ChildDescriptor
+// -----------------------------------------------------------------------------
+
+AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( DlgEdObj* _pDlgEdObj )
+ :pDlgEdObj( _pDlgEdObj )
+ ,rxAccessible( 0 )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+AccessibleDialogWindow::ChildDescriptor::~ChildDescriptor()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( const ChildDescriptor& rDesc )
+ :pDlgEdObj( rDesc.pDlgEdObj )
+ ,rxAccessible( rDesc.rxAccessible )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+AccessibleDialogWindow::ChildDescriptor& AccessibleDialogWindow::ChildDescriptor::operator=( const ChildDescriptor& rDesc )
+{
+ pDlgEdObj = rDesc.pDlgEdObj;
+ rxAccessible = rDesc.rxAccessible;
+
+ return *this;
+}
+
+// -----------------------------------------------------------------------------
+
+bool AccessibleDialogWindow::ChildDescriptor::operator==( const ChildDescriptor& rDesc )
+{
+ bool bRet = false;
+ if ( pDlgEdObj == rDesc.pDlgEdObj )
+ bRet = true;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+bool AccessibleDialogWindow::ChildDescriptor::operator<( const ChildDescriptor& rDesc ) const
+{
+ bool bRet = false;
+ if ( pDlgEdObj && rDesc.pDlgEdObj && pDlgEdObj->GetOrdNum() < rDesc.pDlgEdObj->GetOrdNum() )
+ bRet = true;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+// class AccessibleDialogWindow
+// -----------------------------------------------------------------------------
+
+AccessibleDialogWindow::AccessibleDialogWindow( DialogWindow* pDialogWindow )
+ :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
+ ,m_pDialogWindow( pDialogWindow )
+{
+ DBG_CTOR( AccessibleDialogWindow, NULL );
+ m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
+
+ if ( m_pDialogWindow )
+ {
+ SdrPage* pSdrPage = m_pDialogWindow->GetPage();
+ if ( pSdrPage )
+ {
+ ULONG nCount = pSdrPage->GetObjCount();
+
+ for ( ULONG i = 0; i < nCount; ++i )
+ {
+ SdrObject* pObj = pSdrPage->GetObj( i );
+ DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
+ if ( pDlgEdObj )
+ {
+ ChildDescriptor aDesc( pDlgEdObj );
+ if ( IsChildVisible( aDesc ) )
+ m_aAccessibleChildren.push_back( aDesc );
+ }
+ }
+ }
+
+ m_pDialogWindow->AddEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
+
+ m_pDlgEditor = m_pDialogWindow->GetEditor();
+ if ( m_pDlgEditor )
+ StartListening( *m_pDlgEditor );
+
+ m_pDlgEdModel = m_pDialogWindow->GetModel();
+ if ( m_pDlgEdModel )
+ StartListening( *m_pDlgEdModel );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+AccessibleDialogWindow::~AccessibleDialogWindow()
+{
+ DBG_DTOR( AccessibleDialogWindow, NULL );
+ if ( m_pDialogWindow )
+ m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
+
+ if ( m_pDlgEditor )
+ EndListening( *m_pDlgEditor );
+
+ if ( m_pDlgEdModel )
+ EndListening( *m_pDlgEdModel );
+
+ delete m_pExternalLock;
+ m_pExternalLock = NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::UpdateFocused()
+{
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
+ if ( xChild.is() )
+ {
+ AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
+ if ( pShape )
+ pShape->SetFocused( pShape->IsFocused() );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::UpdateSelected()
+{
+ NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
+
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
+ if ( xChild.is() )
+ {
+ AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
+ if ( pShape )
+ pShape->SetSelected( pShape->IsSelected() );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::UpdateBounds()
+{
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
+ if ( xChild.is() )
+ {
+ AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
+ if ( pShape )
+ pShape->SetBounds( pShape->GetBounds() );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool AccessibleDialogWindow::IsChildVisible( const ChildDescriptor& rDesc )
+{
+ sal_Bool bVisible = sal_False;
+
+ if ( m_pDialogWindow )
+ {
+ // first check, if the shape is in a visible layer
+ SdrModel* pSdrModel = m_pDialogWindow->GetModel();
+ if ( pSdrModel )
+ {
+ SdrLayerAdmin& rLayerAdmin = pSdrModel->GetLayerAdmin();
+ DlgEdObj* pDlgEdObj = rDesc.pDlgEdObj;
+ if ( pDlgEdObj )
+ {
+ SdrLayerID nLayerId = pDlgEdObj->GetLayer();
+ const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId );
+ if ( pSdrLayer )
+ {
+ String aLayerName = pSdrLayer->GetName();
+ SdrView* pSdrView = m_pDialogWindow->GetView();
+ if ( pSdrView && pSdrView->IsLayerVisible( aLayerName ) )
+ {
+ // get the bounding box of the shape in logic units
+ Rectangle aRect = pDlgEdObj->GetSnapRect();
+
+ // transform coordinates relative to the parent
+ MapMode aMap = m_pDialogWindow->GetMapMode();
+ Point aOrg = aMap.GetOrigin();
+ aRect.Move( aOrg.X(), aOrg.Y() );
+
+ // convert logic units to pixel
+ aRect = m_pDialogWindow->LogicToPixel( aRect, MapMode(MAP_100TH_MM) );
+
+ // check, if the shape's bounding box intersects with the bounding box of its parent
+ Rectangle aParentRect( Point( 0, 0 ), m_pDialogWindow->GetSizePixel() );
+ if ( aParentRect.IsOver( aRect ) )
+ bVisible = sal_True;
+ }
+ }
+ }
+ }
+ }
+
+ return bVisible;
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::InsertChild( const ChildDescriptor& rDesc )
+{
+ // check, if object is already in child list
+ AccessibleChildren::iterator aIter = ::std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
+
+ // if not found, insert in child list
+ if ( aIter == m_aAccessibleChildren.end() )
+ {
+ // insert entry in child list
+ m_aAccessibleChildren.push_back( rDesc );
+
+ // get the accessible of the inserted child
+ Reference< XAccessible > xChild( getAccessibleChild( m_aAccessibleChildren.size() - 1 ) );
+
+ // sort child list
+ SortChildren();
+
+ // send accessible child event
+ if ( xChild.is() )
+ {
+ Any aOldValue, aNewValue;
+ aNewValue <<= xChild;
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc )
+{
+ // find object in child list
+ AccessibleChildren::iterator aIter = ::std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
+
+ // if found, remove from child list
+ if ( aIter != m_aAccessibleChildren.end() )
+ {
+ // get the accessible of the removed child
+ Reference< XAccessible > xChild( aIter->rxAccessible );
+
+ // remove entry from child list
+ m_aAccessibleChildren.erase( aIter );
+
+ // send accessible child event
+ if ( xChild.is() )
+ {
+ Any aOldValue, aNewValue;
+ aOldValue <<= xChild;
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
+
+ Reference< XComponent > xComponent( xChild, UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::UpdateChild( const ChildDescriptor& rDesc )
+{
+ if ( IsChildVisible( rDesc ) )
+ {
+ // if the object is not in the child list, insert child
+ InsertChild( rDesc );
+ }
+ else
+ {
+ // if the object is in the child list, remove child
+ RemoveChild( rDesc );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::UpdateChildren()
+{
+ if ( m_pDialogWindow )
+ {
+ SdrPage* pSdrPage = m_pDialogWindow->GetPage();
+ if ( pSdrPage )
+ {
+ for ( ULONG i = 0, nCount = pSdrPage->GetObjCount(); i < nCount; ++i )
+ {
+ SdrObject* pObj = pSdrPage->GetObj( i );
+ DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
+ if ( pDlgEdObj )
+ UpdateChild( ChildDescriptor( pDlgEdObj ) );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::SortChildren()
+{
+ // sort child list
+ ::std::sort( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end() );
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( AccessibleDialogWindow, WindowEventListener, VclSimpleEvent*, pEvent )
+{
+ DBG_CHKTHIS( AccessibleDialogWindow, 0 );
+ DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "AccessibleDialogWindow::WindowEventListener: unknown window event!" );
+
+ if ( pEvent && pEvent->ISA( VclWindowEvent ) )
+ {
+ DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "AccessibleDialogWindow::WindowEventListener: no window!" );
+ if ( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) )
+ {
+ ProcessWindowEvent( *(VclWindowEvent*)pEvent );
+ }
+ }
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ Any aOldValue, aNewValue;
+
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_WINDOW_ENABLED:
+ {
+ aNewValue <<= AccessibleStateType::ENABLED;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+ break;
+ case VCLEVENT_WINDOW_DISABLED:
+ {
+ aOldValue <<= AccessibleStateType::ENABLED;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+ break;
+ case VCLEVENT_WINDOW_ACTIVATE:
+ {
+ aNewValue <<= AccessibleStateType::ACTIVE;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+ break;
+ case VCLEVENT_WINDOW_DEACTIVATE:
+ {
+ aOldValue <<= AccessibleStateType::ACTIVE;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+ break;
+ case VCLEVENT_WINDOW_GETFOCUS:
+ {
+ aNewValue <<= AccessibleStateType::FOCUSED;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+ break;
+ case VCLEVENT_WINDOW_LOSEFOCUS:
+ {
+ aOldValue <<= AccessibleStateType::FOCUSED;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+ break;
+ case VCLEVENT_WINDOW_SHOW:
+ {
+ aNewValue <<= AccessibleStateType::SHOWING;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+ break;
+ case VCLEVENT_WINDOW_HIDE:
+ {
+ aOldValue <<= AccessibleStateType::SHOWING;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+ break;
+ case VCLEVENT_WINDOW_RESIZE:
+ {
+ NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED, aOldValue, aNewValue );
+ UpdateChildren();
+ UpdateBounds();
+ }
+ break;
+ case VCLEVENT_OBJECT_DYING:
+ {
+ if ( m_pDialogWindow )
+ {
+ m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
+ m_pDialogWindow = NULL;
+
+ if ( m_pDlgEditor )
+ EndListening( *m_pDlgEditor );
+ m_pDlgEditor = NULL;
+
+ if ( m_pDlgEdModel )
+ EndListening( *m_pDlgEdModel );
+ m_pDlgEdModel = NULL;
+
+ // dispose all children
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XComponent > xComponent( m_aAccessibleChildren[i].rxAccessible, UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+ }
+ m_aAccessibleChildren.clear();
+ }
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+{
+ if ( m_pDialogWindow )
+ {
+ if ( m_pDialogWindow->IsEnabled() )
+ rStateSet.AddState( AccessibleStateType::ENABLED );
+
+ rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+
+ if ( m_pDialogWindow->HasFocus() )
+ rStateSet.AddState( AccessibleStateType::FOCUSED );
+
+ rStateSet.AddState( AccessibleStateType::VISIBLE );
+
+ if ( m_pDialogWindow->IsVisible() )
+ rStateSet.AddState( AccessibleStateType::SHOWING );
+
+ rStateSet.AddState( AccessibleStateType::OPAQUE );
+
+ rStateSet.AddState( AccessibleStateType::RESIZABLE );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// OCommonAccessibleComponent
+// -----------------------------------------------------------------------------
+
+awt::Rectangle AccessibleDialogWindow::implGetBounds() throw (RuntimeException)
+{
+ awt::Rectangle aBounds;
+ if ( m_pDialogWindow )
+ aBounds = AWTRectangle( Rectangle( m_pDialogWindow->GetPosPixel(), m_pDialogWindow->GetSizePixel() ) );
+
+ return aBounds;
+}
+
+// -----------------------------------------------------------------------------
+// SfxListener
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SdrHint ) )
+ {
+ SdrHint* pSdrHint = (SdrHint*)&rHint;
+ switch ( pSdrHint->GetKind() )
+ {
+ case HINT_OBJINSERTED:
+ {
+ SdrObject* pObj = (SdrObject*)pSdrHint->GetObject();
+ DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
+ if ( pDlgEdObj )
+ {
+ ChildDescriptor aDesc( pDlgEdObj );
+ if ( IsChildVisible( aDesc ) )
+ InsertChild( aDesc );
+ }
+ }
+ break;
+ case HINT_OBJREMOVED:
+ {
+ SdrObject* pObj = (SdrObject*)pSdrHint->GetObject();
+ DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
+ if ( pDlgEdObj )
+ RemoveChild( ChildDescriptor( pDlgEdObj ) );
+ }
+ break;
+ default: ;
+ }
+ }
+ else if ( rHint.ISA( DlgEdHint ) )
+ {
+ DlgEdHint* pDlgEdHint = (DlgEdHint*)&rHint;
+ switch ( pDlgEdHint->GetKind() )
+ {
+ case DLGED_HINT_WINDOWSCROLLED:
+ {
+ UpdateChildren();
+ UpdateBounds();
+ }
+ break;
+ case DLGED_HINT_LAYERCHANGED:
+ {
+ DlgEdObj* pDlgEdObj = pDlgEdHint->GetObject();
+ if ( pDlgEdObj )
+ UpdateChild( ChildDescriptor( pDlgEdObj ) );
+ }
+ break;
+ case DLGED_HINT_OBJORDERCHANGED:
+ {
+ SortChildren();
+ }
+ break;
+ case DLGED_HINT_SELECTIONCHANGED:
+ {
+ UpdateFocused();
+ UpdateSelected();
+ }
+ break;
+ default: ;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogWindow, AccessibleExtendedComponentHelper_BASE, AccessibleDialogWindow_BASE )
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogWindow, AccessibleExtendedComponentHelper_BASE, AccessibleDialogWindow_BASE )
+
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::disposing()
+{
+ AccessibleExtendedComponentHelper_BASE::disposing();
+
+ if ( m_pDialogWindow )
+ {
+ m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
+ m_pDialogWindow = NULL;
+
+ if ( m_pDlgEditor )
+ EndListening( *m_pDlgEditor );
+ m_pDlgEditor = NULL;
+
+ if ( m_pDlgEdModel )
+ EndListening( *m_pDlgEdModel );
+ m_pDlgEdModel = NULL;
+
+ // dispose all children
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XComponent > xComponent( m_aAccessibleChildren[i].rxAccessible, UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+ }
+ m_aAccessibleChildren.clear();
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString AccessibleDialogWindow::getImplementationName() throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.comp.basctl.AccessibleWindow" );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool AccessibleDialogWindow::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pNames + aNames.getLength();
+ for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
+ ;
+
+ return pNames != pEnd;
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > AccessibleDialogWindow::getSupportedServiceNames() throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleWindow" );
+ return aNames;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessible
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleContext > AccessibleDialogWindow::getAccessibleContext( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return this;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleContext
+// -----------------------------------------------------------------------------
+
+sal_Int32 AccessibleDialogWindow::getAccessibleChildCount() throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return m_aAccessibleChildren.size();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( i < 0 || i >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ Reference< XAccessible > xChild = m_aAccessibleChildren[i].rxAccessible;
+ if ( !xChild.is() )
+ {
+ if ( m_pDialogWindow )
+ {
+ DlgEdObj* pDlgEdObj = m_aAccessibleChildren[i].pDlgEdObj;
+ if ( pDlgEdObj )
+ {
+ xChild = new AccessibleDialogControlShape( m_pDialogWindow, pDlgEdObj );
+
+ // insert into child list
+ m_aAccessibleChildren[i].rxAccessible = xChild;
+ }
+ }
+ }
+
+ return xChild;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > AccessibleDialogWindow::getAccessibleParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< XAccessible > xParent;
+ if ( m_pDialogWindow )
+ {
+ Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
+ if ( pParent )
+ xParent = pParent->GetAccessible();
+ }
+
+ return xParent;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 AccessibleDialogWindow::getAccessibleIndexInParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nIndexInParent = -1;
+ if ( m_pDialogWindow )
+ {
+ Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
+ if ( pParent )
+ {
+ for ( USHORT i = 0, nCount = pParent->GetAccessibleChildWindowCount(); i < nCount; ++i )
+ {
+ Window* pChild = pParent->GetAccessibleChildWindow( i );
+ if ( pChild == static_cast< Window* >( m_pDialogWindow ) )
+ {
+ nIndexInParent = i;
+ break;
+ }
+ }
+ }
+ }
+
+ return nIndexInParent;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 AccessibleDialogWindow::getAccessibleRole( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return AccessibleRole::PANEL;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString AccessibleDialogWindow::getAccessibleDescription( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sDescription;
+ if ( m_pDialogWindow )
+ sDescription = m_pDialogWindow->GetAccessibleDescription();
+
+ return sDescription;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString AccessibleDialogWindow::getAccessibleName( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sName;
+ if ( m_pDialogWindow )
+ sName = m_pDialogWindow->GetAccessibleName();
+
+ return sName;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleRelationSet > AccessibleDialogWindow::getAccessibleRelationSet( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
+ Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
+ return xSet;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessibleStateSet > AccessibleDialogWindow::getAccessibleStateSet( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
+ Reference< XAccessibleStateSet > xSet = pStateSetHelper;
+
+ if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
+ {
+ FillAccessibleStateSet( *pStateSetHelper );
+ }
+ else
+ {
+ pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
+ }
+
+ return xSet;
+}
+
+// -----------------------------------------------------------------------------
+
+Locale AccessibleDialogWindow::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return Application::GetSettings().GetLocale();
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleComponent
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > AccessibleDialogWindow::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< XAccessible > xChild;
+ for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
+ {
+ Reference< XAccessible > xAcc = getAccessibleChild( i );
+ if ( xAcc.is() )
+ {
+ Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
+ if ( xComp.is() )
+ {
+ Rectangle aRect = VCLRectangle( xComp->getBounds() );
+ Point aPos = VCLPoint( rPoint );
+ if ( aRect.IsInside( aPos ) )
+ {
+ xChild = xAcc;
+ break;
+ }
+ }
+ }
+ }
+
+ return xChild;
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::grabFocus( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( m_pDialogWindow )
+ m_pDialogWindow->GrabFocus();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 AccessibleDialogWindow::getForeground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ if ( m_pDialogWindow )
+ {
+ if ( m_pDialogWindow->IsControlForeground() )
+ nColor = m_pDialogWindow->GetControlForeground().GetColor();
+ else
+ {
+ Font aFont;
+ if ( m_pDialogWindow->IsControlFont() )
+ aFont = m_pDialogWindow->GetControlFont();
+ else
+ aFont = m_pDialogWindow->GetFont();
+ nColor = aFont.GetColor().GetColor();
+ }
+ }
+
+ return nColor;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 AccessibleDialogWindow::getBackground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ if ( m_pDialogWindow )
+ {
+ if ( m_pDialogWindow->IsControlBackground() )
+ nColor = m_pDialogWindow->GetControlBackground().GetColor();
+ else
+ nColor = m_pDialogWindow->GetBackground().GetColor().GetColor();
+ }
+
+ return nColor;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleExtendedComponent
+// -----------------------------------------------------------------------------
+
+Reference< awt::XFont > AccessibleDialogWindow::getFont( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ Reference< awt::XFont > xFont;
+ if ( m_pDialogWindow )
+ {
+ Reference< awt::XDevice > xDev( m_pDialogWindow->GetComponentInterface(), UNO_QUERY );
+ if ( xDev.is() )
+ {
+ Font aFont;
+ if ( m_pDialogWindow->IsControlFont() )
+ aFont = m_pDialogWindow->GetControlFont();
+ else
+ aFont = m_pDialogWindow->GetFont();
+ VCLXFont* pVCLXFont = new VCLXFont;
+ pVCLXFont->Init( *xDev.get(), aFont );
+ xFont = pVCLXFont;
+ }
+ }
+
+ return xFont;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString AccessibleDialogWindow::getTitledBorderText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ return ::rtl::OUString();
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString AccessibleDialogWindow::getToolTipText( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::rtl::OUString sText;
+ if ( m_pDialogWindow )
+ sText = m_pDialogWindow->GetQuickHelpText();
+
+ return sText;
+}
+
+// -----------------------------------------------------------------------------
+// XAccessibleSelection
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ if ( m_pDialogWindow )
+ {
+ DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj;
+ if ( pDlgEdObj )
+ {
+ SdrView* pSdrView = m_pDialogWindow->GetView();
+ if ( pSdrView )
+ {
+ SdrPageView* pPgView = pSdrView->GetSdrPageView();
+ if ( pPgView )
+ pSdrView->MarkObj( pDlgEdObj, pPgView );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool AccessibleDialogWindow::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ sal_Bool bSelected = sal_False;
+ if ( m_pDialogWindow )
+ {
+ DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj;
+ if ( pDlgEdObj )
+ {
+ SdrView* pSdrView = m_pDialogWindow->GetView();
+ if ( pSdrView )
+ bSelected = pSdrView->IsObjMarked( pDlgEdObj );
+ }
+ }
+
+ return bSelected;
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::clearAccessibleSelection( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( m_pDialogWindow )
+ {
+ SdrView* pSdrView = m_pDialogWindow->GetView();
+ if ( pSdrView )
+ pSdrView->UnmarkAll();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::selectAllAccessibleChildren( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( m_pDialogWindow )
+ {
+ SdrView* pSdrView = m_pDialogWindow->GetView();
+ if ( pSdrView )
+ pSdrView->MarkAll();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 AccessibleDialogWindow::getSelectedAccessibleChildCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nRet = 0;
+
+ for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
+ {
+ if ( isAccessibleChildSelected( i ) )
+ ++nRet;
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ Reference< XAccessible > xChild;
+
+ for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
+ {
+ if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
+ {
+ xChild = getAccessibleChild( i );
+ break;
+ }
+ }
+
+ return xChild;
+}
+
+// -----------------------------------------------------------------------------
+
+void AccessibleDialogWindow::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
+ throw IndexOutOfBoundsException();
+
+ if ( m_pDialogWindow )
+ {
+ DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj;
+ if ( pDlgEdObj )
+ {
+ SdrView* pSdrView = m_pDialogWindow->GetView();
+ if ( pSdrView )
+ {
+ SdrPageView* pPgView = pSdrView->GetSdrPageView();
+ if ( pPgView )
+ pSdrView->MarkObj( pDlgEdObj, pPgView, TRUE );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/accessibility/makefile.mk b/basctl/source/accessibility/makefile.mk
new file mode 100644
index 000000000000..ec899b893944
--- /dev/null
+++ b/basctl/source/accessibility/makefile.mk
@@ -0,0 +1,48 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=basctl
+TARGET=accessibility
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/accessibledialogwindow.obj \
+ $(SLO)$/accessibledialogcontrolshape.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/basctl/source/basicide/basdoc.cxx b/basctl/source/basicide/basdoc.cxx
new file mode 100644
index 000000000000..83d2d10e1256
--- /dev/null
+++ b/basctl/source/basicide/basdoc.cxx
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include <ide_pch.hxx>
+#include <svx/svxids.hrc>
+
+#define GLOBALOVERFLOW2
+
+#include <sfx2/docfac.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
+#include <vcl/status.hxx>
+
+#include <svx/xmlsecctrl.hxx>
+
+#include <basdoc.hxx>
+
+#define BasicDocShell
+#include <basslots.hxx>
+
+#include "basicmod.hxx"
+#include "unomodel.hxx"
+
+TYPEINIT1(BasicDocShell, SfxObjectShell);
+DBG_NAME(BasicDocShell);
+
+SFX_IMPL_OBJECTFACTORY( BasicDocShell, SvGlobalName(), SFXOBJECTSHELL_STD_NORMAL, "sbasic" )
+
+SFX_IMPL_INTERFACE( BasicDocShell, SfxObjectShell, IDEResId( 0 ) )
+{
+ SFX_STATUSBAR_REGISTRATION( IDEResId( SID_BASICIDE_STATUSBAR ) );
+}
+
+BasicDocShell::BasicDocShell()
+ :SfxObjectShell( SFXMODEL_DISABLE_EMBEDDED_SCRIPTS | SFXMODEL_DISABLE_DOCUMENT_RECOVERY )
+{
+ pPrinter = 0;
+ SetPool( &SFX_APP()->GetPool() );
+ SetBaseModel( new SIDEModel(this) );
+}
+
+__EXPORT BasicDocShell::~BasicDocShell()
+{
+ delete pPrinter;
+}
+
+SfxPrinter* BasicDocShell::GetPrinter( BOOL bCreate )
+{
+ if ( !pPrinter && bCreate )
+ pPrinter = new SfxPrinter( new SfxItemSet( GetPool(), SID_PRINTER_NOTFOUND_WARN , SID_PRINTER_NOTFOUND_WARN ) );
+
+ return pPrinter;
+}
+
+void BasicDocShell::SetPrinter( SfxPrinter* pPr )
+{
+ if ( pPr != pPrinter )
+ {
+ delete pPrinter;
+ pPrinter = pPr;
+ }
+}
+
+void BasicDocShell::FillStatusBar( StatusBar& rStatusBar )
+{
+ String aTmp;
+
+ // Titel
+ aTmp.Fill( 30, 'X' );
+ rStatusBar.InsertItem( SID_BASICIDE_STAT_TITLE,
+ rStatusBar.GetTextWidth( aTmp ), SIB_AUTOSIZE | SIB_LEFT);
+
+ // Modify
+ rStatusBar.InsertItem( SID_DOC_MODIFIED,
+ rStatusBar.GetTextWidth( '*' ) );
+
+ // signatures
+ rStatusBar.InsertItem( SID_SIGNATURE, XmlSecStatusBarControl::GetDefItemWidth( rStatusBar ), SIB_USERDRAW );
+ rStatusBar.SetHelpId(SID_SIGNATURE, SID_SIGNATURE);
+
+ // Position
+ aTmp.Erase();
+ aTmp.Fill( 15, 'X' );
+ rStatusBar.InsertItem( SID_BASICIDE_STAT_POS,
+ rStatusBar.GetTextWidth( aTmp ), SIB_LEFT);
+
+ // Insert/Overwrite
+ rStatusBar.InsertItem( SID_ATTR_INSERT,
+ rStatusBar.GetTextWidth( String( RTL_CONSTASCII_USTRINGPARAM( "XXXXX" /* "EINFG" */ ) ) ) );
+
+ // Uhrzeit
+ aTmp.Fill( 20, 'X' );
+ rStatusBar.InsertItem( SID_ATTR_SIZE,
+ rStatusBar.GetTextWidth( aTmp ), SIB_AUTOSIZE | SIB_LEFT | SIB_USERDRAW );
+
+// return pStatusBar;
+
+}
+
+void BasicDocShell::FillClass( SvGlobalName*, sal_uInt32*, String*, String*, String*, sal_Int32, sal_Bool bTemplate) const
+{
+ (void)bTemplate;
+ DBG_ASSERT( bTemplate == sal_False, "No template for Basic" );
+}
+
+void BasicDocShell::Draw( OutputDevice *, const JobSetup &, USHORT )
+{}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basdoc.hxx b/basctl/source/basicide/basdoc.hxx
new file mode 100644
index 000000000000..ba98e47efee1
--- /dev/null
+++ b/basctl/source/basicide/basdoc.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASDOC_HXX
+#define _BASDOC_HXX
+
+#include <svx/ifaceids.hxx>
+#include <iderid.hxx>
+#include <sfx2/objsh.hxx>
+
+class SfxPrinter;
+
+class BasicDocShell: public SfxObjectShell
+{
+ SfxPrinter* pPrinter;
+
+protected:
+ virtual void FillStatusBar( StatusBar& rBar);
+ virtual void Draw( OutputDevice *, const JobSetup & rSetup,
+ USHORT nAspect = ASPECT_CONTENT );
+ virtual void FillClass( SvGlobalName * pClassName,
+ sal_uInt32 * pFormat,
+ String * pAppName,
+ String * pFullTypeName,
+ String * pShortTypeName,
+ sal_Int32 nVersion,
+ sal_Bool bTemplate = sal_False ) const;
+
+public:
+ TYPEINFO();
+
+ using SotObject::GetInterface;
+ SFX_DECL_OBJECTFACTORY();
+ SFX_DECL_INTERFACE( SVX_INTERFACE_BASIDE_DOCSH )
+ BasicDocShell();
+ ~BasicDocShell();
+
+ SfxPrinter* GetPrinter( BOOL bCreate );
+ void SetPrinter( SfxPrinter* pPrinter );
+};
+
+#endif // _BASDOC_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basicbox.cxx b/basctl/source/basicide/basicbox.cxx
new file mode 100644
index 000000000000..9ac79df53864
--- /dev/null
+++ b/basctl/source/basicide/basicbox.cxx
@@ -0,0 +1,548 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include <ide_pch.hxx>
+
+
+#include <basidesh.hrc>
+#include <basidesh.hxx>
+#include <basobj.hxx>
+
+#include <basicbox.hxx>
+#include <iderid.hxx>
+#include <iderdll.hxx>
+#include <bastypes.hxx>
+#include "bastype2.hxx"
+#include "basdoc.hxx"
+
+#include "localizationmgr.hxx"
+#include "managelang.hxx"
+#include "dlgresid.hrc"
+#include <editeng/unolingu.hxx>
+
+#include <svtools/langtab.hxx>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+
+SFX_IMPL_TOOLBOX_CONTROL( LibBoxControl, SfxStringItem );
+
+LibBoxControl::LibBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ : SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+}
+
+
+
+LibBoxControl::~LibBoxControl()
+{
+}
+
+
+
+void LibBoxControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* pState )
+{
+ BasicLibBox* pBox = (BasicLibBox*) GetToolBox().GetItemWindow( GetId() );
+
+ DBG_ASSERT( pBox, "Box not found" );
+ if ( !pBox )
+ return;
+
+ if ( eState != SFX_ITEM_AVAILABLE )
+ pBox->Disable();
+ else
+ {
+ pBox->Enable();
+
+ if ( pState->ISA(SfxStringItem) )
+ pBox->Update( (const SfxStringItem*)pState );
+ else
+ pBox->Update( NULL );
+ }
+}
+
+
+
+Window* LibBoxControl::CreateItemWindow( Window *pParent )
+{
+ return new BasicLibBox( pParent, m_xFrame );
+}
+
+//=============================================================================
+//= DocListenerBox
+//=============================================================================
+
+DocListenerBox::DocListenerBox( Window* pParent )
+ :ListBox( pParent, WinBits( WB_BORDER | WB_DROPDOWN ) )
+ ,m_aNotifier( *this )
+{
+}
+
+DocListenerBox::~DocListenerBox()
+{
+ m_aNotifier.dispose();
+}
+
+void DocListenerBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
+{
+ FillBox();
+}
+
+void DocListenerBox::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
+{
+ FillBox();
+}
+
+void DocListenerBox::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void DocListenerBox::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void DocListenerBox::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void DocListenerBox::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ )
+{
+ FillBox();
+}
+
+void DocListenerBox::onDocumentClosed( const ScriptDocument& /*_rDocument*/ )
+{
+ if ( SFX_APP()->IsInBasicCall() )
+ // Nicht wenn Office beendet
+ FillBox();
+}
+
+void DocListenerBox::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void DocListenerBox::onDocumentModeChanged( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+//=============================================================================
+//= BasicLibBox
+//=============================================================================
+BasicLibBox::BasicLibBox( Window* pParent, const uno::Reference< frame::XFrame >& rFrame ) :
+ DocListenerBox( pParent ),
+ m_xFrame( rFrame )
+{
+ FillBox();
+ bIgnoreSelect = TRUE; // Select von 0 noch nicht weiterleiten
+ bFillBox = TRUE;
+ SelectEntryPos( 0 );
+ aCurText = GetEntry( 0 );
+ SetSizePixel( Size( 250, 200 ) );
+ bIgnoreSelect = FALSE;
+}
+
+
+
+__EXPORT BasicLibBox::~BasicLibBox()
+{
+ ClearBox();
+}
+
+void __EXPORT BasicLibBox::Update( const SfxStringItem* pItem )
+{
+ // Immer auf dem laufenden sein...
+// if ( !pItem || !pItem->GetValue().Len() )
+ FillBox();
+
+ if ( pItem )
+ {
+ aCurText = pItem->GetValue();
+ if ( aCurText.Len() == 0 )
+ aCurText = String( IDEResId( RID_STR_ALL ) );
+ }
+
+ if ( GetSelectEntry() != aCurText )
+ SelectEntry( aCurText );
+}
+
+void __EXPORT BasicLibBox::ReleaseFocus()
+{
+ SfxViewShell* pCurSh = SfxViewShell::Current();
+ DBG_ASSERT( pCurSh, "Current ViewShell not found!" );
+
+ if ( pCurSh )
+ {
+ Window* pShellWin = pCurSh->GetWindow();
+ if ( !pShellWin ) // sonst werde ich ihn nicht los
+ pShellWin = Application::GetDefDialogParent();
+
+ pShellWin->GrabFocus();
+ }
+}
+
+void BasicLibBox::FillBox()
+{
+ SetUpdateMode( FALSE );
+ bIgnoreSelect = TRUE;
+
+ aCurText = GetSelectEntry();
+
+ SelectEntryPos( 0 );
+ ClearBox();
+
+ // create list box entries
+ USHORT nPos = InsertEntry( String( IDEResId( RID_STR_ALL ) ), LISTBOX_APPEND );
+ SetEntryData( nPos, new BasicLibEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_UNKNOWN, String() ) );
+ InsertEntries( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER );
+ InsertEntries( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_SHARE );
+
+ ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::DocumentsSorted ) );
+ for ( ScriptDocuments::const_iterator doc = aDocuments.begin();
+ doc != aDocuments.end();
+ ++doc
+ )
+ {
+ InsertEntries( *doc, LIBRARY_LOCATION_DOCUMENT );
+ }
+
+ SetUpdateMode( TRUE );
+
+ SelectEntry( aCurText );
+ if ( !GetSelectEntryCount() )
+ {
+ SelectEntryPos( GetEntryCount() ); // gibst es nicht => leer?
+ aCurText = GetSelectEntry();
+ }
+ bIgnoreSelect = FALSE;
+}
+
+void BasicLibBox::InsertEntries( const ScriptDocument& rDocument, LibraryLocation eLocation )
+{
+ // get a sorted list of library names
+ Sequence< ::rtl::OUString > aLibNames = rDocument.getLibraryNames();
+ sal_Int32 nLibCount = aLibNames.getLength();
+ const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
+
+ for ( sal_Int32 i = 0 ; i < nLibCount ; ++i )
+ {
+ String aLibName = pLibNames[ i ];
+ if ( eLocation == rDocument.getLibraryLocation( aLibName ) )
+ {
+ String aName( rDocument.getTitle( eLocation ) );
+ String aEntryText( CreateMgrAndLibStr( aName, aLibName ) );
+ USHORT nPos = InsertEntry( aEntryText, LISTBOX_APPEND );
+ SetEntryData( nPos, new BasicLibEntry( rDocument, eLocation, aLibName ) );
+ }
+ }
+}
+
+long BasicLibBox::PreNotify( NotifyEvent& rNEvt )
+{
+ long nDone = 0;
+ if( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
+ USHORT nKeyCode = aKeyEvt.GetKeyCode().GetCode();
+ switch( nKeyCode )
+ {
+ case KEY_RETURN:
+ {
+ NotifyIDE();
+ nDone = 1;
+ }
+ break;
+
+ case KEY_ESCAPE:
+ {
+ SelectEntry( aCurText );
+ ReleaseFocus();
+ nDone = 1;
+ }
+ break;
+ }
+ }
+ else if( rNEvt.GetType() == EVENT_GETFOCUS )
+ {
+ if ( bFillBox )
+ {
+ FillBox();
+ bFillBox = FALSE;
+ }
+ }
+ else if( rNEvt.GetType() == EVENT_LOSEFOCUS )
+ {
+ if ( !HasChildPathFocus( TRUE ) )
+ {
+ bIgnoreSelect = TRUE;
+ bFillBox = TRUE;
+ }
+ }
+
+ return nDone ? nDone : ListBox::PreNotify( rNEvt );
+}
+
+void __EXPORT BasicLibBox::Select()
+{
+ if ( !IsTravelSelect() )
+ {
+ if ( !bIgnoreSelect )
+ NotifyIDE();
+ else
+ SelectEntry( aCurText ); // Seit 306... (Select nach Escape)
+ }
+}
+
+void BasicLibBox::NotifyIDE()
+{
+ USHORT nSelPos = GetSelectEntryPos();
+ BasicLibEntry* pEntry = (BasicLibEntry*)GetEntryData( nSelPos );
+ if ( pEntry )
+ {
+ ScriptDocument aDocument( pEntry->GetDocument() );
+ SfxUsrAnyItem aDocumentItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, uno::makeAny( aDocument.getDocumentOrNull() ) );
+ String aLibName = pEntry->GetLibName();
+ SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if ( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_LIBSELECTED,
+ SFX_CALLMODE_SYNCHRON, &aDocumentItem, &aLibNameItem, 0L );
+ }
+ }
+ ReleaseFocus();
+}
+
+void BasicLibBox::ClearBox()
+{
+ USHORT nCount = GetEntryCount();
+ for ( USHORT i = 0; i < nCount; ++i )
+ {
+ BasicLibEntry* pEntry = (BasicLibEntry*)GetEntryData( i );
+ delete pEntry;
+ }
+ ListBox::Clear();
+}
+
+// class LanguageBoxControl ----------------------------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( LanguageBoxControl, SfxStringItem );
+
+LanguageBoxControl::LanguageBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ : SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+}
+
+LanguageBoxControl::~LanguageBoxControl()
+{
+}
+
+void LanguageBoxControl::StateChanged( USHORT _nID, SfxItemState _eState, const SfxPoolItem* _pItem )
+{
+ (void)_nID;
+
+ BasicLanguageBox* pBox = (BasicLanguageBox*)( GetToolBox().GetItemWindow( GetId() ) );
+
+ if ( pBox )
+ {
+ if ( _eState != SFX_ITEM_AVAILABLE )
+ pBox->Disable();
+ else
+ {
+ pBox->Enable();
+ if ( _pItem->ISA(SfxStringItem) )
+ pBox->Update( (const SfxStringItem*)_pItem );
+ else
+ pBox->Update( NULL );
+ }
+ }
+}
+
+Window* LanguageBoxControl::CreateItemWindow( Window *pParent )
+{
+ return new BasicLanguageBox( pParent );
+}
+
+// class BasicLanguageBox ------------------------------------------------
+
+BasicLanguageBox::BasicLanguageBox( Window* pParent ) :
+
+ DocListenerBox( pParent ),
+
+ m_sNotLocalizedStr( IDEResId( RID_STR_TRANSLATION_NOTLOCALIZED ) ),
+ m_sDefaultLanguageStr( IDEResId( RID_STR_TRANSLATION_DEFAULT ) ),
+
+ m_bIgnoreSelect( false )
+
+{
+ SetSizePixel( Size( 210, 200 ) );
+
+ FillBox();
+}
+
+BasicLanguageBox::~BasicLanguageBox()
+{
+ ClearBox();
+}
+
+void BasicLanguageBox::FillBox()
+{
+ SetUpdateMode( FALSE );
+ m_bIgnoreSelect = true;
+ m_sCurrentText = GetSelectEntry();
+ ClearBox();
+
+ LocalizationMgr* pCurMgr = IDE_DLL()->GetShell()->GetCurLocalizationMgr();
+ if ( pCurMgr->isLibraryLocalized() )
+ {
+ Enable();
+ SvtLanguageTable aLangTable;
+ Locale aDefaultLocale = pCurMgr->getStringResourceManager()->getDefaultLocale();
+ Locale aCurrentLocale = pCurMgr->getStringResourceManager()->getCurrentLocale();
+ Sequence< Locale > aLocaleSeq = pCurMgr->getStringResourceManager()->getLocales();
+ const Locale* pLocale = aLocaleSeq.getConstArray();
+ INT32 i, nCount = aLocaleSeq.getLength();
+ USHORT nSelPos = LISTBOX_ENTRY_NOTFOUND;
+ for ( i = 0; i < nCount; ++i )
+ {
+ bool bIsDefault = localesAreEqual( aDefaultLocale, pLocale[i] );
+ bool bIsCurrent = localesAreEqual( aCurrentLocale, pLocale[i] );
+ LanguageType eLangType = SvxLocaleToLanguage( pLocale[i] );
+ String sLanguage = aLangTable.GetString( eLangType );
+ if ( bIsDefault )
+ {
+ sLanguage += ' ';
+ sLanguage += m_sDefaultLanguageStr;
+ }
+ USHORT nPos = InsertEntry( sLanguage );
+ SetEntryData( nPos, new LanguageEntry( sLanguage, pLocale[i], bIsDefault ) );
+
+ if ( bIsCurrent )
+ nSelPos = nPos;
+ }
+
+ if ( nSelPos != LISTBOX_ENTRY_NOTFOUND )
+ {
+ SelectEntryPos( nSelPos );
+ m_sCurrentText = GetSelectEntry();
+ }
+ }
+ else
+ {
+ InsertEntry( m_sNotLocalizedStr );
+ SelectEntryPos(0);
+ Disable();
+ }
+
+ SetUpdateMode( TRUE );
+ m_bIgnoreSelect = false;
+}
+
+void BasicLanguageBox::ClearBox()
+{
+ USHORT nCount = GetEntryCount();
+ for ( USHORT i = 0; i < nCount; ++i )
+ {
+ LanguageEntry* pEntry = (LanguageEntry*)GetEntryData(i);
+ delete pEntry;
+ }
+ ListBox::Clear();
+}
+
+void BasicLanguageBox::SetLanguage()
+{
+ LanguageEntry* pEntry = (LanguageEntry*)GetEntryData( GetSelectEntryPos() );
+ if ( pEntry )
+ IDE_DLL()->GetShell()->GetCurLocalizationMgr()->handleSetCurrentLocale( pEntry->m_aLocale );
+}
+
+void BasicLanguageBox::Select()
+{
+ if ( !m_bIgnoreSelect )
+ SetLanguage();
+ else
+ SelectEntry( m_sCurrentText ); // Select after Escape
+}
+
+long BasicLanguageBox::PreNotify( NotifyEvent& rNEvt )
+{
+ long nDone = 0;
+ if( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ USHORT nKeyCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
+ switch( nKeyCode )
+ {
+ case KEY_RETURN:
+ {
+ SetLanguage();
+ nDone = 1;
+ }
+ break;
+
+ case KEY_ESCAPE:
+ {
+ SelectEntry( m_sCurrentText );
+ nDone = 1;
+ }
+ break;
+ }
+ }
+ else if( rNEvt.GetType() == EVENT_GETFOCUS )
+ {
+ }
+ else if( rNEvt.GetType() == EVENT_LOSEFOCUS )
+ {
+ }
+
+ return nDone ? nDone : ListBox::PreNotify( rNEvt );
+}
+
+void BasicLanguageBox::Update( const SfxStringItem* pItem )
+{
+ FillBox();
+
+ if ( pItem && pItem->GetValue().Len() > 0 )
+ {
+ m_sCurrentText = pItem->GetValue();
+ if ( GetSelectEntry() != m_sCurrentText )
+ SelectEntry( m_sCurrentText );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basicbox.hxx b/basctl/source/basicide/basicbox.hxx
new file mode 100644
index 000000000000..f5a938194889
--- /dev/null
+++ b/basctl/source/basicide/basicbox.hxx
@@ -0,0 +1,154 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+//
+#ifndef _BASICBOX_HXX
+#define _BASICBOX_HXX
+
+#include "doceventnotifier.hxx"
+#include <svl/stritem.hxx>
+#include <svheader.hxx>
+#include <sfx2/tbxctrl.hxx>
+#include <vcl/lstbox.hxx>
+
+
+class LibBoxControl: public SfxToolBoxControl
+{
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ LibBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx );
+ ~LibBoxControl();
+
+ virtual void StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState );
+ virtual Window* CreateItemWindow( Window *pParent );
+};
+
+/** base class for list boxes which need to update their content according to the list
+ of open documents
+*/
+class DocListenerBox :public ListBox
+ ,public ::basctl::DocumentEventListener
+{
+protected:
+ DocListenerBox( Window* pParent );
+ ~DocListenerBox();
+
+protected:
+ virtual void FillBox() = 0;
+
+private:
+ // DocumentEventListener
+ virtual void onDocumentCreated( const ScriptDocument& _rDocument );
+ virtual void onDocumentOpened( const ScriptDocument& _rDocument );
+ virtual void onDocumentSave( const ScriptDocument& _rDocument );
+ virtual void onDocumentSaveDone( const ScriptDocument& _rDocument );
+ virtual void onDocumentSaveAs( const ScriptDocument& _rDocument );
+ virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument );
+ virtual void onDocumentClosed( const ScriptDocument& _rDocument );
+ virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument );
+ virtual void onDocumentModeChanged( const ScriptDocument& _rDocument );
+
+private:
+ ::basctl::DocumentEventNotifier m_aNotifier;
+};
+
+//
+
+class BasicLibBox : public DocListenerBox
+{
+private:
+ String aCurText;
+ BOOL bIgnoreSelect;
+ BOOL bFillBox;
+ com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
+
+ void ReleaseFocus();
+ void InsertEntries( const ScriptDocument& rDocument, LibraryLocation eLocation );
+
+ void ClearBox();
+ void NotifyIDE();
+
+ // DocListenerBox
+ virtual void FillBox();
+
+protected:
+ virtual void Select();
+ virtual long PreNotify( NotifyEvent& rNEvt );
+
+public:
+ BasicLibBox( Window* pParent,
+ const com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame );
+ ~BasicLibBox();
+
+ using Window::Update;
+ void Update( const SfxStringItem* pItem );
+};
+
+class LanguageBoxControl: public SfxToolBoxControl
+{
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ LanguageBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx );
+ ~LanguageBoxControl();
+
+ virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState );
+ virtual Window* CreateItemWindow( Window *pParent );
+};
+
+class BasicLanguageBox : public DocListenerBox
+{
+private:
+ String m_sNotLocalizedStr;
+ String m_sDefaultLanguageStr;
+ String m_sCurrentText;
+
+ bool m_bIgnoreSelect;
+
+ void ClearBox();
+ void SetLanguage();
+
+ // DocListenerBox
+ virtual void FillBox();
+
+protected:
+ virtual void Select();
+ virtual long PreNotify( NotifyEvent& rNEvt );
+
+public:
+ BasicLanguageBox( Window* pParent );
+ ~BasicLanguageBox();
+
+ using Window::Update;
+ void Update( const SfxStringItem* pItem );
+};
+
+#endif // _BASICBOX_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basicmod.hxx b/basctl/source/basicide/basicmod.hxx
new file mode 100644
index 000000000000..da7556613561
--- /dev/null
+++ b/basctl/source/basicide/basicmod.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef BASICMOD_HXX
+#define BASICMOD_HXX
+
+#include <sfx2/module.hxx>
+#include <tools/shl.hxx>
+
+class BasicIDEModule : public SfxModule
+{
+public:
+ BasicIDEModule( ResMgr *pMgr, SfxObjectFactory *pObjFact) :
+ SfxModule( pMgr, FALSE, pObjFact, NULL )
+ {}
+};
+
+
+#define BASIC_MOD() ( *(BasicIDEModule**) GetAppData(SHL_IDE) )
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basicprint.src b/basctl/source/basicide/basicprint.src
new file mode 100644
index 000000000000..1f301d3461a9
--- /dev/null
+++ b/basctl/source/basicide/basicprint.src
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <basidesh.hrc>
+
+StringArray RID_PRINTDLG_STRLIST
+{
+ ItemList [en-US] =
+ {
+ < "Print range"; >;
+ < "All ~Pages"; >;
+ < "Print all pages of the printable content."; >;
+ < "Pa~ges"; >;
+ < "Print only some pages of the printable content."; >;
+ };
+};
diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx
new file mode 100644
index 000000000000..889e09b7f633
--- /dev/null
+++ b/basctl/source/basicide/basicrenderable.cxx
@@ -0,0 +1,196 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_basctl.hxx"
+
+#include "basicrenderable.hxx"
+#include "bastypes.hxx"
+#include "basidesh.hrc"
+
+#include "com/sun/star/awt/XDevice.hpp"
+#include "toolkit/awt/vclxdevice.hxx"
+#include "vcl/print.hxx"
+#include "tools/multisel.hxx"
+#include "tools/resary.hxx"
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace basicide;
+
+BasicRenderable::BasicRenderable( IDEBaseWindow* pWin )
+: cppu::WeakComponentImplHelper1< com::sun::star::view::XRenderable >( maMutex )
+, mpWindow( pWin )
+{
+ ResStringArray aStrings( IDEResId( RID_PRINTDLG_STRLIST ) );
+ DBG_ASSERT( aStrings.Count() >= 5, "resource incomplete" );
+ if( aStrings.Count() < 5 ) // bad resource ?
+ return;
+
+ m_aUIProperties.realloc( 3 );
+
+ // create Subgroup for print range
+ vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt;
+ aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) );
+ aPrintRangeOpt.mbInternalOnly = sal_True;
+ m_aUIProperties[0].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 0 ) ),
+ rtl::OUString(),
+ aPrintRangeOpt
+ );
+
+ // create a choice for the range to print
+ rtl::OUString aPrintContentName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) );
+ Sequence< rtl::OUString > aChoices( 2 );
+ Sequence< rtl::OUString > aHelpTexts( 2 );
+ aChoices[0] = aStrings.GetString( 1 );
+ aHelpTexts[0] = aStrings.GetString( 2 );
+ aChoices[1] = aStrings.GetString( 3 );
+ aHelpTexts[1] = aStrings.GetString( 4 );
+ m_aUIProperties[1].Value = getChoiceControlOpt( rtl::OUString(),
+ aHelpTexts,
+ aPrintContentName,
+ aChoices,
+ 0 );
+
+ // create a an Edit dependent on "Pages" selected
+ vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintContentName, 1, sal_True );
+ m_aUIProperties[2].Value = getEditControlOpt( rtl::OUString(),
+ rtl::OUString(),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ),
+ rtl::OUString(),
+ aPageRangeOpt
+ );
+}
+
+BasicRenderable::~BasicRenderable()
+{
+}
+
+Printer* BasicRenderable::getPrinter()
+{
+ Printer* pPrinter = NULL;
+ Any aValue( getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) ) );
+ Reference<awt::XDevice> xRenderDevice;
+
+ if( aValue >>= xRenderDevice )
+ {
+ VCLXDevice* pDevice = VCLXDevice::GetImplementation(xRenderDevice);
+ OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
+ pPrinter = dynamic_cast<Printer*>(pOut);
+ }
+ return pPrinter;
+}
+
+sal_Int32 SAL_CALL BasicRenderable::getRendererCount (
+ const Any&, const Sequence<beans::PropertyValue >& i_xOptions
+ ) throw (lang::IllegalArgumentException, RuntimeException)
+{
+ processProperties( i_xOptions );
+
+ sal_Int32 nCount = 0;
+ if( mpWindow )
+ {
+ Printer* pPrinter = getPrinter();
+ if( pPrinter )
+ {
+ nCount = mpWindow->countPages( pPrinter );
+ sal_Int64 nContent = getIntValue( "PrintContent", -1 );
+ if( nContent == 1 )
+ {
+ rtl::OUString aPageRange( getStringValue( "PageRange" ) );
+ MultiSelection aSel( aPageRange );
+ long nSelCount = aSel.GetSelectCount();
+ if( nSelCount >= 0 && nSelCount < nCount )
+ nCount = nSelCount;
+ }
+ }
+ else
+ throw lang::IllegalArgumentException();
+ }
+
+ return nCount;
+}
+
+Sequence<beans::PropertyValue> SAL_CALL BasicRenderable::getRenderer (
+ sal_Int32, const Any&, const Sequence<beans::PropertyValue>& i_xOptions
+ ) throw (lang::IllegalArgumentException, RuntimeException)
+{
+ processProperties( i_xOptions );
+
+ Sequence< beans::PropertyValue > aVals;
+ // insert page size here
+ Printer* pPrinter = getPrinter();
+ // no renderdevice is legal; the first call is to get our print ui options
+ if( pPrinter )
+ {
+ Size aPageSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) );
+
+ aVals.realloc( 1 );
+ aVals[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) );
+ awt::Size aSize;
+ aSize.Width = aPageSize.Width();
+ aSize.Height = aPageSize.Height();
+ aVals[0].Value <<= aSize;
+ }
+
+ appendPrintUIOptions( aVals );
+
+ return aVals;
+}
+
+void SAL_CALL BasicRenderable::render (
+ sal_Int32 nRenderer, const Any&,
+ const Sequence<beans::PropertyValue>& i_xOptions
+ ) throw (lang::IllegalArgumentException, RuntimeException)
+{
+ processProperties( i_xOptions );
+
+ if( mpWindow )
+ {
+ Printer* pPrinter = getPrinter();
+ if( pPrinter )
+ {
+ sal_Int64 nContent = getIntValue( "PrintContent", -1 );
+ if( nContent == 1 )
+ {
+ rtl::OUString aPageRange( getStringValue( "PageRange" ) );
+ MultiSelection aSel( aPageRange );
+ long nSelect = aSel.FirstSelected();
+ while( nSelect != long(SFX_ENDOFSELECTION) && nRenderer-- )
+ nSelect = aSel.NextSelected();
+ if( nSelect != long(SFX_ENDOFSELECTION) )
+ mpWindow->printPage( sal_Int32(nSelect-1), pPrinter );
+ }
+ else
+ mpWindow->printPage( nRenderer, pPrinter );
+ }
+ else
+ throw lang::IllegalArgumentException();
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basicrenderable.hxx b/basctl/source/basicide/basicrenderable.hxx
new file mode 100644
index 000000000000..aadddae90ed0
--- /dev/null
+++ b/basctl/source/basicide/basicrenderable.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BASICRENDERABLE_HXX
+#define _BASICRENDERABLE_HXX
+
+#include "com/sun/star/view/XRenderable.hpp"
+#include "cppuhelper/compbase1.hxx"
+
+#include "vcl/print.hxx"
+
+class IDEBaseWindow;
+
+namespace basicide
+{
+class BasicRenderable :
+ public cppu::WeakComponentImplHelper1< com::sun::star::view::XRenderable >,
+ public vcl::PrinterOptionsHelper
+{
+ IDEBaseWindow* mpWindow;
+ osl::Mutex maMutex;
+
+ Printer* getPrinter();
+public:
+ BasicRenderable( IDEBaseWindow* pWin );
+ virtual ~BasicRenderable();
+
+ // XRenderable
+ virtual sal_Int32 SAL_CALL getRendererCount (
+ const com::sun::star::uno::Any& aSelection,
+ const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue >& xOptions)
+ throw (com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException);
+
+ virtual com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> SAL_CALL getRenderer (
+ sal_Int32 nRenderer,
+ const com::sun::star::uno::Any& rSelection,
+ const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rxOptions)
+ throw (com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL render (
+ sal_Int32 nRenderer,
+ const com::sun::star::uno::Any& rSelection,
+ const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rxOptions)
+ throw (com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException);
+
+};
+
+} // namespace
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
new file mode 100644
index 000000000000..ef1289736106
--- /dev/null
+++ b/basctl/source/basicide/baside2.cxx
@@ -0,0 +1,1759 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include <ide_pch.hxx>
+
+
+#include <svtools/texteng.hxx>
+#include <svtools/textview.hxx>
+#include <svtools/xtextedt.hxx>
+#include <basic/sbx.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include <com/sun/star/script/XLibraryContainer2.hpp>
+#include <com/sun/star/document/MacroExecMode.hpp>
+#include <com/sun/star/script/ModuleType.hpp>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <sfx2/docfile.hxx>
+#include <basic/basrdll.hxx>
+
+
+#include <baside2.hrc>
+#include <baside2.hxx>
+#include <objdlg.hxx>
+#include <iderdll.hxx>
+#include <iderdll2.hxx>
+
+#include <basobj.hxx>
+#include <brkdlg.hxx>
+
+#include <svx/srchdlg.hxx>
+
+#include <vcl/sound.hxx>
+
+#include <unotools/textsearch.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+#define SPLIT_MARGIN 5
+#define SPLIT_HEIGHT 2
+
+#define LMARGPRN 1700
+#define RMARGPRN 900
+#define TMARGPRN 2000
+#define BMARGPRN 1000
+#define BORDERPRN 300
+
+#define APPWAIT_START 100
+
+#define VALIDWINDOW 0x1234
+
+#if defined(OW) || defined(MTF)
+#define FILTERMASK_ALL "*"
+#elif defined(PM2)
+#define FILTERMASK_ALL ""
+#else
+#define FILTERMASK_ALL "*.*"
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace utl;
+using namespace comphelper;
+
+
+DBG_NAME( ModulWindow )
+
+TYPEINIT1( ModulWindow , IDEBaseWindow );
+
+void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const String& rTitle, bool bOutput )
+{
+ short nLeftMargin = LMARGPRN;
+ Size aSz = pPrinter->GetOutputSize();
+ short nBorder = BORDERPRN;
+
+ const Color aOldLineColor( pPrinter->GetLineColor() );
+ const Color aOldFillColor( pPrinter->GetFillColor() );
+ const Font aOldFont( pPrinter->GetFont() );
+
+ pPrinter->SetLineColor( Color( COL_BLACK ) );
+ pPrinter->SetFillColor();
+
+ Font aFont( aOldFont );
+ aFont.SetWeight( WEIGHT_BOLD );
+ aFont.SetAlign( ALIGN_BOTTOM );
+ pPrinter->SetFont( aFont );
+
+ long nFontHeight = pPrinter->GetTextHeight();
+
+ // 1.Border => Strich, 2+3 Border = Freiraum.
+ long nYTop = TMARGPRN-3*nBorder-nFontHeight;
+
+ long nXLeft = nLeftMargin-nBorder;
+ long nXRight = aSz.Width()-RMARGPRN+nBorder;
+
+ if( bOutput )
+ pPrinter->DrawRect( Rectangle(
+ Point( nXLeft, nYTop ),
+ Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) );
+
+
+ long nY = TMARGPRN-2*nBorder;
+ Point aPos( nLeftMargin, nY );
+ if( bOutput )
+ pPrinter->DrawText( aPos, rTitle );
+ if ( nPages != 1 )
+ {
+ aFont.SetWeight( WEIGHT_NORMAL );
+ pPrinter->SetFont( aFont );
+ String aPageStr( RTL_CONSTASCII_USTRINGPARAM( " [" ) );
+ aPageStr += String( IDEResId( RID_STR_PAGE ) );
+ aPageStr += ' ';
+ aPageStr += String::CreateFromInt32( nCurPage );
+ aPageStr += ']';
+ aPos.X() += pPrinter->GetTextWidth( rTitle );
+ if( bOutput )
+ pPrinter->DrawText( aPos, aPageStr );
+ }
+
+
+ nY = TMARGPRN-nBorder;
+
+ if( bOutput )
+ pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) );
+
+ pPrinter->SetFont( aOldFont );
+ pPrinter->SetFillColor( aOldFillColor );
+ pPrinter->SetLineColor( aOldLineColor );
+}
+
+void lcl_ConvertTabsToSpaces( String& rLine )
+{
+ if ( rLine.Len() )
+ {
+ USHORT nPos = 0;
+ USHORT nMax = rLine.Len();
+ while ( nPos < nMax )
+ {
+ if ( rLine.GetChar( nPos ) == '\t' )
+ {
+ // Nicht 4 Blanks, sondern an 4er TabPos:
+ String aBlanker;
+ aBlanker.Fill( ( 4 - ( nPos % 4 ) ), ' ' );
+ rLine.Erase( nPos, 1 );
+ rLine.Insert( aBlanker, nPos );
+ nMax = rLine.Len();
+ }
+ nPos++; // Nicht optimal, falls Tab, aber auch nicht verkehrt...
+ }
+ }
+}
+
+
+ModulWindow::ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDocument, String aLibName,
+ String aName, ::rtl::OUString& aModule )
+ :IDEBaseWindow( pParent, rDocument, aLibName, aName )
+ ,aXEditorWindow( this )
+ ,m_aModule( aModule )
+{
+ DBG_CTOR( ModulWindow, 0 );
+ nValid = VALIDWINDOW;
+ pLayout = pParent;
+ aXEditorWindow.Show();
+
+ SetBackground();
+}
+
+SbModuleRef ModulWindow::XModule()
+{
+ // ModuleWindows can now be created as a result of the
+ // modules getting created via the api. This is a result of an
+ // elementInserted event from the BasicLibrary container.
+ // However the SbModule is also created from a different listener to
+ // the same event ( in basmgr ) Therefore it is possible when we look
+ // for xModule it may not yet be available, here we keep tring to access
+ // the module until such time as it exists
+
+ if ( !xModule.Is() )
+ {
+ BasicManager* pBasMgr = GetDocument().getBasicManager();
+ if ( pBasMgr )
+ {
+ StarBASIC* pBasic = pBasMgr->GetLib( GetLibName() );
+ if ( pBasic )
+ {
+ xBasic = pBasic;
+ xModule = (SbModule*)pBasic->FindModule( GetName() );
+ }
+ }
+ }
+ return xModule;
+}
+
+__EXPORT ModulWindow::~ModulWindow()
+{
+ DBG_DTOR( ModulWindow, 0 );
+ nValid = 0;
+
+ StarBASIC::Stop();
+}
+
+
+void __EXPORT ModulWindow::GetFocus()
+{
+ if ( nValid != VALIDWINDOW )
+ return;
+ DBG_CHKTHIS( ModulWindow, 0 );
+ aXEditorWindow.GetEdtWindow().GrabFocus();
+ // Basisklasse nicht rufen, weil Focus jetzt woanders...
+}
+
+void ModulWindow::DoInit()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ // Wird beim Umschalten der Fenster gerufen...
+ if ( GetVScrollBar() )
+ GetVScrollBar()->Hide();
+ GetHScrollBar()->Show();
+// GetEditorWindow().SetScrollBarRanges();
+ GetEditorWindow().InitScrollBars();
+// GetEditorWindow().GrabFocus();
+}
+
+
+void __EXPORT ModulWindow::Paint( const Rectangle& )
+{
+}
+
+void __EXPORT ModulWindow::Resize()
+{
+ aXEditorWindow.SetPosSizePixel( Point( 0, 0 ),
+ Size( GetOutputSizePixel() ) );
+}
+
+
+// "Import" von baside4.cxx
+void CreateEngineForBasic( StarBASIC* pBasic );
+
+void ModulWindow::CheckCompileBasic()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+
+ if ( XModule().Is() )
+ {
+ // Zur Laufzeit wird niemals compiliert!
+ BOOL bRunning = StarBASIC::IsRunning();
+ BOOL bModified = ( !xModule->IsCompiled() ||
+ ( GetEditEngine() && GetEditEngine()->IsModified() ) );
+
+ if ( !bRunning && bModified )
+ {
+ BOOL bDone = FALSE;
+
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ pIDEShell->GetViewFrame()->GetWindow().EnterWait();
+
+ if( bModified )
+ {
+ AssertValidEditEngine();
+ GetEditorWindow().SetSourceInBasic( FALSE );
+ }
+
+ BOOL bWasModified = GetBasic()->IsModified();
+
+ bDone = GetBasic()->Compile( xModule );
+ if ( !bWasModified )
+ GetBasic()->SetModified( FALSE );
+
+ if ( bDone )
+ {
+ GetBreakPoints().SetBreakPointsInBasic( xModule );
+ }
+
+ pIDEShell->GetViewFrame()->GetWindow().LeaveWait();
+
+ aStatus.bError = !bDone;
+ aStatus.bIsRunning = FALSE;
+ }
+ }
+}
+
+BOOL ModulWindow::BasicExecute()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+
+ // #116444# check security settings before macro execution
+ ScriptDocument aDocument( GetDocument() );
+ if ( aDocument.isDocument() )
+ {
+ if ( !aDocument.allowMacros() )
+ {
+ WarningBox( this, WB_OK, String( IDEResId( RID_STR_CANNOTRUNMACRO ) ) ).Execute();
+ return FALSE;
+ }
+ }
+
+ CheckCompileBasic();
+
+ if ( XModule().Is() && xModule->IsCompiled() && !aStatus.bError )
+ {
+ if ( GetBreakPoints().Count() )
+ aStatus.nBasicFlags = aStatus.nBasicFlags | SbDEBUG_BREAK;
+
+ if ( !aStatus.bIsRunning )
+ {
+ DBG_ASSERT( xModule.Is(), "Kein Modul!" );
+ AddStatus( BASWIN_RUNNINGBASIC );
+ USHORT nStart, nEnd, nCurMethodStart = 0;
+ TextSelection aSel = GetEditView()->GetSelection();
+ // Init cursor to top
+ nCurMethodStart = ( aSel.GetStart().GetPara() + 1 );
+ SbMethod* pMethod = 0;
+ // erstes Macro, sonst blind "Main" (ExtSearch?)
+ for ( USHORT nMacro = 0; nMacro < xModule->GetMethods()->Count(); nMacro++ )
+ {
+ SbMethod* pM = (SbMethod*)xModule->GetMethods()->Get( nMacro );
+ DBG_ASSERT( pM, "Method?" );
+ pM->GetLineRange( nStart, nEnd );
+ if ( nCurMethodStart >= nStart && nCurMethodStart <= nEnd )
+ {
+ // matched a method to the cursor position
+ pMethod = pM;
+ break;
+ }
+ }
+ if ( !pMethod )
+ {
+ // If not in a method then prompt the user
+ return ( BasicIDE::ChooseMacro( uno::Reference< frame::XModel >(), FALSE, rtl::OUString() ).getLength() > 0 ) ? TRUE : FALSE;
+ }
+ if ( pMethod )
+ {
+ pMethod->SetDebugFlags( aStatus.nBasicFlags );
+ BasicDLL::SetDebugMode( TRUE );
+ BasicIDE::RunMethod( pMethod );
+ BasicDLL::SetDebugMode( FALSE );
+ // Falls waehrend Interactive=FALSE abgebrochen
+ BasicDLL::EnableBreak( TRUE );
+ }
+ ClearStatus( BASWIN_RUNNINGBASIC );
+ }
+ else
+ aStatus.bIsRunning = FALSE; // Abbruch von Reschedule()
+ }
+
+ BOOL bDone = !aStatus.bError;
+
+ return bDone;
+}
+
+BOOL ModulWindow::CompileBasic()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ CheckCompileBasic();
+
+ BOOL bIsCompiled = FALSE;
+ if ( XModule().Is() )
+ bIsCompiled = xModule->IsCompiled();
+
+ return bIsCompiled;
+}
+
+BOOL ModulWindow::BasicRun()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+
+ aStatus.nBasicFlags = 0;
+ BOOL bDone = BasicExecute();
+ return bDone;
+}
+
+BOOL ModulWindow::BasicStepOver()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ aStatus.nBasicFlags = SbDEBUG_STEPINTO | SbDEBUG_STEPOVER;
+ BOOL bDone = BasicExecute();
+ return bDone;
+}
+
+
+BOOL ModulWindow::BasicStepInto()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+
+ aStatus.nBasicFlags = SbDEBUG_STEPINTO;
+ BOOL bDone = BasicExecute();
+ return bDone;
+}
+
+BOOL ModulWindow::BasicStepOut()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+
+ aStatus.nBasicFlags = SbDEBUG_STEPOUT;
+ BOOL bDone = BasicExecute();
+ return bDone;
+}
+
+
+
+void ModulWindow::BasicStop()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+
+ GetBasic()->Stop();
+ aStatus.bIsRunning = FALSE;
+}
+
+BOOL ModulWindow::LoadBasic()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ BOOL bDone = FALSE;
+
+ Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
+ Reference < XFilePicker > xFP;
+ if( xMSF.is() )
+ {
+ Sequence <Any> aServiceType(1);
+ aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
+ xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
+ }
+
+ if ( aCurPath.Len() )
+ xFP->setDisplayDirectory ( aCurPath );
+
+ //xFP->setTitle( String( IDEResId( RID_STR_OPEN ) ) );
+
+ Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
+ xFltMgr->appendFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.bas" ) ) );
+ xFltMgr->appendFilter( String( IDEResId( RID_STR_FILTER_ALLFILES ) ), String( RTL_CONSTASCII_USTRINGPARAM( FILTERMASK_ALL ) ) );
+ xFltMgr->setCurrentFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ) );
+
+ if( xFP->execute() == RET_OK )
+ {
+ Sequence< ::rtl::OUString > aPaths = xFP->getFiles();
+ aCurPath = aPaths[0];
+ SfxMedium aMedium( aCurPath, STREAM_READ | STREAM_SHARE_DENYWRITE | STREAM_NOCREATE, TRUE );
+ SvStream* pStream = aMedium.GetInStream();
+ if ( pStream )
+ {
+ AssertValidEditEngine();
+ ULONG nLines = CalcLineCount( *pStream );
+ // nLines*4: ReadText/Formatting/Highlighting/Formatting
+ GetEditorWindow().CreateProgress( String( IDEResId( RID_STR_GENERATESOURCE ) ), nLines*4 );
+ GetEditEngine()->SetUpdateMode( FALSE );
+ GetEditView()->Read( *pStream );
+ GetEditEngine()->SetUpdateMode( TRUE );
+ GetEditorWindow().Update(); // Es wurde bei UpdateMode = TRUE nur Invalidiert
+ GetEditorWindow().ForceSyntaxTimeout();
+ GetEditorWindow().DestroyProgress();
+ ULONG nError = aMedium.GetError();
+ if ( nError )
+ ErrorHandler::HandleError( nError );
+ else
+ bDone = TRUE;
+ }
+ else
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_COULDNTREAD ) ) ).Execute();
+ }
+ return bDone;
+}
+
+
+BOOL ModulWindow::SaveBasicSource()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ BOOL bDone = FALSE;
+
+ Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
+ Reference < XFilePicker > xFP;
+ if( xMSF.is() )
+ {
+ Sequence <Any> aServiceType(1);
+ aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD;
+ xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
+ }
+
+ Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
+ xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, sal_False);
+ Any aValue;
+ aValue <<= (sal_Bool) sal_True;
+ xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
+
+ if ( aCurPath.Len() )
+ xFP->setDisplayDirectory ( aCurPath );
+
+ //xFP->setTitle( String( IDEResId( RID_STR_SAVE ) ) );
+
+ Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
+ xFltMgr->appendFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.bas" ) ) );
+ xFltMgr->appendFilter( String( IDEResId( RID_STR_FILTER_ALLFILES ) ), String( RTL_CONSTASCII_USTRINGPARAM( FILTERMASK_ALL ) ) );
+ xFltMgr->setCurrentFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ) );
+
+ if( xFP->execute() == RET_OK )
+ {
+ Sequence< ::rtl::OUString > aPaths = xFP->getFiles();
+ aCurPath = aPaths[0];
+ SfxMedium aMedium( aCurPath, STREAM_WRITE | STREAM_SHARE_DENYWRITE | STREAM_TRUNC, TRUE, FALSE );
+ SvStream* pStream = aMedium.GetOutStream();
+ if ( pStream )
+ {
+ EnterWait();
+ AssertValidEditEngine();
+ GetEditEngine()->Write( *pStream );
+ aMedium.Commit();
+ LeaveWait();
+ ULONG nError = aMedium.GetError();
+ if ( nError )
+ ErrorHandler::HandleError( nError );
+ else
+ bDone = TRUE;
+ }
+ else
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_COULDNTWRITE) ) ).Execute();
+ }
+
+ return bDone;
+}
+
+BOOL implImportDialog( Window* pWin, const String& rCurPath, const ScriptDocument& rDocument, const String& aLibName );
+
+BOOL ModulWindow::ImportDialog()
+{
+ const ScriptDocument& rDocument = GetDocument();
+ String aLibName = GetLibName();
+ BOOL bRet = implImportDialog( this, aCurPath, rDocument, aLibName );
+ return bRet;
+}
+
+BOOL ModulWindow::ToggleBreakPoint( ULONG nLine )
+{
+ DBG_ASSERT( XModule().Is(), "Kein Modul!" );
+
+ BOOL bNewBreakPoint = FALSE;
+
+ if ( XModule().Is() )
+ {
+ CheckCompileBasic();
+ if ( aStatus.bError )
+ {
+ Sound::Beep();
+ return FALSE;
+ }
+
+ BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nLine );
+ if ( pBrk ) // entfernen
+ {
+ xModule->ClearBP( (USHORT)nLine );
+ delete GetBreakPoints().Remove( pBrk );
+ }
+ else // einen erzeugen
+ {
+ if ( xModule->SetBP( (USHORT)nLine) )
+ {
+ GetBreakPoints().InsertSorted( new BreakPoint( nLine ) );
+ bNewBreakPoint = TRUE;
+ if ( StarBASIC::IsRunning() )
+ {
+ for ( USHORT nMethod = 0; nMethod < xModule->GetMethods()->Count(); nMethod++ )
+ {
+ SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( nMethod );
+ DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" );
+ pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK );
+ }
+ }
+ }
+
+ if ( !bNewBreakPoint )
+ Sound::Beep();
+ }
+ }
+
+ return bNewBreakPoint;
+}
+
+void ModulWindow::UpdateBreakPoint( const BreakPoint& rBrk )
+{
+ DBG_ASSERT( XModule().Is(), "Kein Modul!" );
+
+ if ( XModule().Is() )
+ {
+ CheckCompileBasic();
+
+ if ( rBrk.bEnabled )
+ xModule->SetBP( (USHORT)rBrk.nLine );
+ else
+ xModule->ClearBP( (USHORT)rBrk.nLine );
+ }
+}
+
+
+BOOL ModulWindow::BasicToggleBreakPoint()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ AssertValidEditEngine();
+
+ TextSelection aSel = GetEditView()->GetSelection();
+ aSel.GetStart().GetPara()++; // Basic-Zeilen beginnen bei 1!
+ aSel.GetEnd().GetPara()++;
+
+ BOOL bNewBreakPoint = FALSE;
+
+ for ( ULONG nLine = aSel.GetStart().GetPara(); nLine <= aSel.GetEnd().GetPara(); nLine++ )
+ {
+ if ( ToggleBreakPoint( nLine ) )
+ bNewBreakPoint = TRUE;
+ }
+
+ aXEditorWindow.GetBrkWindow().Invalidate();
+ return bNewBreakPoint;
+}
+
+
+void ModulWindow::BasicToggleBreakPointEnabled()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ AssertValidEditEngine();
+
+ ExtTextView* pView = GetEditView();
+ if ( pView )
+ {
+ TextSelection aSel = pView->GetSelection();
+ BreakPointList& rList = GetBreakPoints();
+
+ for ( ULONG nLine = ++aSel.GetStart().GetPara(), nEnd = ++aSel.GetEnd().GetPara(); nLine <= nEnd; ++nLine )
+ {
+ BreakPoint* pBrk = rList.FindBreakPoint( nLine );
+ if ( pBrk )
+ {
+ pBrk->bEnabled = pBrk->bEnabled ? FALSE : TRUE;
+ UpdateBreakPoint( *pBrk );
+ }
+ }
+
+ GetBreakPointWindow().Invalidate();
+ }
+}
+
+
+void ModulWindow::ManageBreakPoints()
+{
+ BreakPointWindow& rBrkWin = GetBreakPointWindow();
+ BreakPointDialog aBrkDlg( &rBrkWin, GetBreakPoints() );
+ aBrkDlg.Execute();
+ rBrkWin.Invalidate();
+}
+
+
+IMPL_LINK( ModulWindow, BasicErrorHdl, StarBASIC *, pBasic )
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ GoOnTop();
+
+ // ReturnWert: BOOL
+ // FALSE: Abbrechen
+ // TRUE: Weiter....
+ String aErrorText( pBasic->GetErrorText() );
+ USHORT nErrorLine = pBasic->GetLine() - 1;
+ USHORT nErrCol1 = pBasic->GetCol1();
+ USHORT nErrCol2 = pBasic->GetCol2();
+ if ( nErrCol2 != 0xFFFF )
+ nErrCol2++;
+
+ AssertValidEditEngine();
+ GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine, nErrCol1 ), TextPaM( nErrorLine, nErrCol2 ) ) );
+
+ String aErrorTextPrefix;
+ if( pBasic->IsCompilerError() )
+ {
+ aErrorTextPrefix = String( IDEResId( RID_STR_COMPILEERROR ) );
+ }
+ else
+ {
+ aErrorTextPrefix = String( IDEResId( RID_STR_RUNTIMEERROR ) );
+ aErrorTextPrefix += StarBASIC::GetVBErrorCode( pBasic->GetErrorCode() );
+ aErrorTextPrefix += ' ';
+ pLayout->GetStackWindow().UpdateCalls();
+ }
+ // Wenn anderes Basic, dan sollte die IDE versuchen, da richtige
+ // Modul anzuzeigen...
+ BOOL bMarkError = ( pBasic == GetBasic() ) ? TRUE : FALSE;
+ if ( bMarkError )
+ aXEditorWindow.GetBrkWindow().SetMarkerPos( nErrorLine, TRUE );
+// ErrorBox( this, WB_OK | WB_DEF_OK, String( aErrorTextPrefix + aErrorText ) ).Execute();
+// ErrorHandler::HandleError( pBasic->GetErrorCode() );
+
+ // #i47002#
+ Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( this );
+
+ ErrorHandler::HandleError( StarBASIC::GetErrorCode() );
+
+ // #i47002#
+ Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
+ if ( !pWindow )
+ return FALSE;
+
+ if ( bMarkError )
+ aXEditorWindow.GetBrkWindow().SetMarkerPos( MARKER_NOMARKER );
+ return FALSE;
+}
+
+long __EXPORT ModulWindow::BasicBreakHdl( StarBASIC* pBasic )
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ // Ein GoOnTop aktiviert da Fenster, das veraendert aber den Context fuer
+ // das Programm!
+// GoOnTop();
+
+ // #i69280 Required in Window despite normal usage in next command!
+ (void)pBasic;
+
+ // ReturnWert: USHORT => siehe SB-Debug-Flags
+ USHORT nErrorLine = pBasic->GetLine();
+
+ // Gibt es hier einen BreakPoint?
+ BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nErrorLine );
+ if ( pBrk )
+ {
+ pBrk->nHitCount++;
+ if ( pBrk->nHitCount < pBrk->nStopAfter && GetBasic()->IsBreak() )
+ return aStatus.nBasicFlags; // weiterlaufen...
+ }
+
+ nErrorLine--; // EditEngine begint bei 0, Basic bei 1
+ // Alleine schon damit gescrollt wird...
+ AssertValidEditEngine();
+ GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine, 0 ), TextPaM( nErrorLine, 0 ) ) );
+ aXEditorWindow.GetBrkWindow().SetMarkerPos( nErrorLine );
+
+ pLayout->GetWatchWindow().UpdateWatches();
+ pLayout->GetStackWindow().UpdateCalls();
+
+ aStatus.bIsInReschedule = TRUE;
+ aStatus.bIsRunning = TRUE;
+
+ AddStatus( BASWIN_INRESCHEDULE );
+
+ BasicIDE::InvalidateDebuggerSlots();
+
+ while( aStatus.bIsRunning )
+ Application::Yield();
+
+ aStatus.bIsInReschedule = FALSE;
+ aXEditorWindow.GetBrkWindow().SetMarkerPos( MARKER_NOMARKER );
+
+ ClearStatus( BASWIN_INRESCHEDULE );
+
+ return aStatus.nBasicFlags;
+}
+
+void ModulWindow::BasicAddWatch()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ String aWatchStr;
+ BOOL bInserted = FALSE;
+ AssertValidEditEngine();
+ BOOL bAdd = TRUE;
+ if ( !GetEditView()->HasSelection() )
+ {
+// bAdd = GetEditView()->SelectCurrentWord();
+ TextPaM aWordStart;
+ String aWord = GetEditEngine()->GetWord( GetEditView()->GetSelection().GetEnd(), &aWordStart );
+ if ( aWord.Len() )
+ {
+ TextSelection aSel( aWordStart );
+ USHORT& rIndex = aSel.GetEnd().GetIndex();
+ rIndex = rIndex + aWord.Len();
+ // aSel.GetEnd().GetIndex() += sal::static_int_cast<int>( aWord.Len() );
+ GetEditView()->SetSelection( aSel );
+ bAdd = TRUE;
+ }
+ }
+ if ( bAdd )
+ {
+ TextSelection aSel = GetEditView()->GetSelection();
+ if ( aSel.GetStart().GetPara() == aSel.GetEnd().GetPara() )
+ {
+ aWatchStr = GetEditView()->GetSelected();
+ pLayout->GetWatchWindow().AddWatch( aWatchStr );
+ pLayout->GetWatchWindow().UpdateWatches();
+ bInserted = TRUE;
+ }
+ }
+
+ if ( !bInserted )
+ Sound::Beep();
+}
+
+
+
+void ModulWindow::BasicRemoveWatch()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ BOOL bRemoved = pLayout->GetWatchWindow().RemoveSelectedWatch();
+
+ if ( !bRemoved )
+ Sound::Beep();
+}
+
+
+void ModulWindow::EditMacro( const String& rMacroName )
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ DBG_ASSERT( XModule().Is(), "Kein Modul!" );
+
+ if ( XModule().Is() )
+ {
+ CheckCompileBasic();
+
+ if ( !aStatus.bError )
+ {
+ USHORT nStart, nEnd;
+ SbMethod* pMethod = (SbMethod*)xModule->Find( rMacroName, SbxCLASS_METHOD );
+ if ( pMethod )
+ {
+ pMethod->GetLineRange( nStart, nEnd );
+ if ( nStart )
+ {
+ // Basic beginnt bei 1
+ nStart--;
+ nEnd--;
+ }
+ TextSelection aSel( TextPaM( nStart, 0 ), TextPaM( nStart, 0 ) );
+ AssertValidEditEngine();
+ TextView * pView = GetEditView();
+ // ggf. hinscrollen, so dass erste Zeile oben...
+ long nVisHeight = GetOutputSizePixel().Height();
+ if ( (long)pView->GetTextEngine()->GetTextHeight() > nVisHeight )
+ {
+ long nMaxY = pView->GetTextEngine()->GetTextHeight() - nVisHeight;
+ long nOldStartY = pView->GetStartDocPos().Y();
+ long nNewStartY = nStart * pView->GetTextEngine()->GetCharHeight();
+ nNewStartY = Min( nNewStartY, nMaxY );
+ pView->Scroll( 0, -(nNewStartY-nOldStartY) );
+ pView->ShowCursor( FALSE, TRUE );
+ GetEditVScrollBar().SetThumbPos( pView->GetStartDocPos().Y() );
+ }
+ pView->SetSelection( aSel );
+ pView->ShowCursor();
+ pView->GetWindow()->GrabFocus();
+ }
+ }
+ }
+}
+
+
+void __EXPORT ModulWindow::StoreData()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ // StoreData wird gerufen, wenn der BasicManager zerstoert oder
+ // dieses Fenster beendet wird.
+ // => Keine Unterbrechungen erwuenscht!
+ // Und bei SAVE, wenn AppBasic...
+ GetEditorWindow().SetSourceInBasic( TRUE );
+ // Nicht das Modify loeschen, sonst wird das Basic nicht gespeichert
+ // Es wird beim Speichern sowieso geloescht.
+// xModule->SetModified( FALSE );
+}
+
+BOOL __EXPORT ModulWindow::CanClose()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ return TRUE;
+}
+
+
+BOOL __EXPORT ModulWindow::AllowUndo()
+{
+ return GetEditorWindow().CanModify();
+}
+
+
+void __EXPORT ModulWindow::UpdateData()
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ DBG_ASSERT( XModule().Is(), "Kein Modul!" );
+ // UpdateData wird gerufen, wenn sich der Source von aussen
+ // geaendert hat.
+ // => Keine Unterbrechungen erwuenscht!
+
+ if ( XModule().Is() )
+ {
+ SetModule( xModule->GetSource32() );
+
+ if ( GetEditView() )
+ {
+ TextSelection aSel = GetEditView()->GetSelection();
+ setTextEngineText( GetEditEngine(), xModule->GetSource32() );
+ GetEditView()->SetSelection( aSel );
+ GetEditEngine()->SetModified( FALSE );
+ BasicIDE::MarkDocumentModified( GetDocument() );
+ }
+ }
+}
+
+sal_Int32 ModulWindow::countPages( Printer* pPrinter )
+{
+ return FormatAndPrint( pPrinter, -1 );
+}
+
+void ModulWindow::printPage( sal_Int32 nPage, Printer* pPrinter )
+{
+ FormatAndPrint( pPrinter, nPage );
+}
+
+/* implementation note: this is totally inefficient for the XRenderable interface
+ usage since the whole "document" will be format for every page. Should this ever
+ become a problem we should
+ - format only once for every new printer
+ - keep an index list for each page which is the starting paragraph
+*/
+sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage )
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+
+ AssertValidEditEngine();
+
+ MapMode eOldMapMode( pPrinter->GetMapMode() );
+ Font aOldFont( pPrinter->GetFont() );
+
+// Font aFont( GetEditEngine()->CreateFontFromItemSet( GetEditEngine()->GetEmptyItemSet() ) );
+ Font aFont( GetEditEngine()->GetFont() );
+ aFont.SetAlign( ALIGN_BOTTOM );
+ aFont.SetTransparent( TRUE );
+ aFont.SetSize( Size( 0, 360 ) );
+ pPrinter->SetFont( aFont );
+ pPrinter->SetMapMode( MAP_100TH_MM );
+
+ String aTitle( CreateQualifiedName() );
+
+ USHORT nLineHeight = (USHORT) pPrinter->GetTextHeight(); // etwas mehr.
+ USHORT nParaSpace = 10;
+
+ Size aPaperSz = pPrinter->GetOutputSize();
+ aPaperSz.Width() -= (LMARGPRN+RMARGPRN);
+ aPaperSz.Height() -= (TMARGPRN+BMARGPRN);
+
+ // nLinepPage stimmt nicht, wenn Zeilen umgebrochen werden muessen...
+ USHORT nLinespPage = (USHORT) (aPaperSz.Height()/nLineHeight);
+ USHORT nCharspLine = (USHORT) (aPaperSz.Width() / pPrinter->GetTextWidth( 'X' ) );
+ ULONG nParas = GetEditEngine()->GetParagraphCount();
+
+ USHORT nPages = (USHORT) (nParas/nLinespPage+1 );
+ USHORT nCurPage = 1;
+
+ // Header drucken...
+ lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nPrintPage == 0 );
+ Point aPos( LMARGPRN, TMARGPRN );
+ for ( ULONG nPara = 0; nPara < nParas; nPara++ )
+ {
+ String aLine( GetEditEngine()->GetText( nPara ) );
+ lcl_ConvertTabsToSpaces( aLine );
+ USHORT nLines = aLine.Len()/nCharspLine+1;
+ for ( USHORT nLine = 0; nLine < nLines; nLine++ )
+ {
+ String aTmpLine( aLine, nLine*nCharspLine, nCharspLine );
+ aPos.Y() += nLineHeight;
+ if ( aPos.Y() > ( aPaperSz.Height()+TMARGPRN ) )
+ {
+ nCurPage++;
+ lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nCurPage-1 == nPrintPage );
+ aPos = Point( LMARGPRN, TMARGPRN+nLineHeight );
+ }
+ if( nCurPage-1 == nPrintPage )
+ pPrinter->DrawText( aPos, aTmpLine );
+ }
+ aPos.Y() += nParaSpace;
+ }
+
+ pPrinter->SetFont( aOldFont );
+ pPrinter->SetMapMode( eOldMapMode );
+
+ return sal_Int32(nCurPage);
+}
+
+
+void __EXPORT ModulWindow::ExecuteCommand( SfxRequest& rReq )
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ AssertValidEditEngine();
+ USHORT nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case SID_BASICRUN:
+ {
+ BasicRun();
+ }
+ break;
+ case SID_BASICCOMPILE:
+ {
+ CompileBasic();
+ }
+ break;
+ case SID_BASICSTEPOVER:
+ {
+ BasicStepOver();
+ }
+ break;
+ case SID_BASICSTEPINTO:
+ {
+ BasicStepInto();
+ }
+ break;
+ case SID_BASICSTEPOUT:
+ {
+ BasicStepOut();
+ }
+ break;
+ case SID_BASICLOAD:
+ {
+ LoadBasic();
+ }
+ break;
+ case SID_BASICSAVEAS:
+ {
+ SaveBasicSource();
+ }
+ break;
+ case SID_IMPORT_DIALOG:
+ {
+ ImportDialog();
+ }
+ break;
+ case SID_BASICIDE_MATCHGROUP:
+ {
+ if ( !GetEditView()->MatchGroup() )
+ Sound::Beep();
+ }
+ break;
+ case SID_BASICIDE_TOGGLEBRKPNT:
+ {
+ BasicToggleBreakPoint();
+ }
+ break;
+ case SID_BASICIDE_MANAGEBRKPNTS:
+ {
+ ManageBreakPoints();
+ }
+ break;
+ case SID_BASICIDE_TOGGLEBRKPNTENABLED:
+ {
+ BasicToggleBreakPointEnabled();
+ }
+ break;
+ case SID_BASICIDE_ADDWATCH:
+ {
+ BasicAddWatch();
+ }
+ break;
+ case SID_BASICIDE_REMOVEWATCH:
+ {
+ BasicRemoveWatch();
+ }
+ break;
+ case SID_CUT:
+ {
+ if ( !IsReadOnly() )
+ {
+ GetEditView()->Cut();
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_DOC_MODIFIED );
+ }
+ }
+ break;
+ case SID_COPY:
+ {
+ GetEditView()->Copy();
+ }
+ break;
+ case SID_PASTE:
+ {
+ if ( !IsReadOnly() )
+ {
+ GetEditView()->Paste();
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_DOC_MODIFIED );
+ }
+ }
+ break;
+ case SID_BASICIDE_BRKPNTSCHANGED:
+ {
+ GetBreakPointWindow().Invalidate();
+ }
+ break;
+ }
+}
+
+
+
+void __EXPORT ModulWindow::GetState( SfxItemSet &rSet )
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ SfxWhichIter aIter(rSet);
+ for ( USHORT nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich() )
+ {
+ switch ( nWh )
+ {
+ // allgemeine Items:
+ case SID_CUT:
+ {
+ if ( !GetEditView() || !GetEditView()->HasSelection() )
+ rSet.DisableItem( nWh );
+
+ if ( IsReadOnly() )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_COPY:
+ {
+ if ( !GetEditView() || !GetEditView()->HasSelection() )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_PASTE:
+ {
+ if ( !IsPasteAllowed() )
+ rSet.DisableItem( nWh );
+
+ if ( IsReadOnly() )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_BASICIDE_STAT_POS:
+ {
+ TextView* pView = GetEditView();
+ if ( pView )
+ {
+ TextSelection aSel = pView->GetSelection();
+ String aPos( IDEResId( RID_STR_LINE ) );
+ aPos += ' ';
+ aPos += String::CreateFromInt32( aSel.GetEnd().GetPara()+1 );
+ aPos += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
+ aPos += String( IDEResId( RID_STR_COLUMN ) );
+ aPos += ' ';
+ aPos += String::CreateFromInt32( aSel.GetEnd().GetIndex()+1 );
+ SfxStringItem aItem( SID_BASICIDE_STAT_POS, aPos );
+ rSet.Put( aItem );
+ }
+ }
+ break;
+ case SID_ATTR_INSERT:
+ {
+ TextView* pView = GetEditView();
+ if ( pView )
+ {
+ SfxBoolItem aItem( SID_ATTR_INSERT, pView->IsInsertMode() );
+ rSet.Put( aItem );
+ }
+ }
+ break;
+ }
+ }
+}
+
+
+void __EXPORT ModulWindow::DoScroll( ScrollBar* pCurScrollBar )
+{
+ DBG_CHKTHIS( ModulWindow, 0 );
+ if ( ( pCurScrollBar == GetHScrollBar() ) && GetEditView() )
+ {
+ // Nicht mit dem Wert Scrollen, sondern lieber die Thumb-Pos fuer die
+ // VisArea verwenden:
+ long nDiff = GetEditView()->GetStartDocPos().X() - pCurScrollBar->GetThumbPos();
+ GetEditView()->Scroll( nDiff, 0 );
+ GetEditView()->ShowCursor( FALSE, TRUE );
+ pCurScrollBar->SetThumbPos( GetEditView()->GetStartDocPos().X() );
+
+ }
+}
+
+
+BOOL __EXPORT ModulWindow::IsModified()
+{
+ return GetEditEngine() ? GetEditEngine()->IsModified() : FALSE;
+}
+
+
+
+void __EXPORT ModulWindow::GoOnTop()
+{
+ IDE_DLL()->GetShell()->GetViewFrame()->ToTop();
+}
+
+String ModulWindow::GetSbModuleName()
+{
+ String aModuleName;
+ if ( XModule().Is() )
+ aModuleName = xModule->GetName();
+ return aModuleName;
+}
+
+
+
+String __EXPORT ModulWindow::GetTitle()
+{
+ return GetSbModuleName();
+}
+
+
+
+void ModulWindow::FrameWindowMoved()
+{
+// if ( GetEditEngine() && GetEditEngine()->IsInSelectionMode() )
+// GetEditEngine()->StopSelectionMode();
+}
+
+
+
+void ModulWindow::ShowCursor( BOOL bOn )
+{
+ if ( GetEditEngine() )
+ {
+ TextView* pView = GetEditEngine()->GetActiveView();
+ if ( pView )
+ {
+ if ( bOn )
+ pView->ShowCursor();
+ else
+ pView->HideCursor();
+ }
+ }
+}
+
+
+Window* __EXPORT ModulWindow::GetLayoutWindow()
+{
+ return pLayout;
+}
+
+void ModulWindow::AssertValidEditEngine()
+{
+ if ( !GetEditEngine() )
+ GetEditorWindow().CreateEditEngine();
+}
+
+void ModulWindow::Deactivating()
+{
+ if ( GetEditView() )
+ GetEditView()->EraseVirtualDevice();
+}
+
+USHORT ModulWindow::StartSearchAndReplace( const SvxSearchItem& rSearchItem, BOOL bFromStart )
+{
+ // Mann koennte fuer das blinde Alle-Ersetzen auch auf
+ // Syntaxhighlighting/Formatierung verzichten...
+ AssertValidEditEngine();
+ ExtTextView* pView = GetEditView();
+ TextSelection aSel;
+ if ( bFromStart )
+ {
+ aSel = pView->GetSelection();
+ if ( !rSearchItem.GetBackward() )
+ pView->SetSelection( TextSelection() );
+ else
+ pView->SetSelection( TextSelection( TextPaM( 0xFFFFFFFF, 0xFFFF ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) );
+ }
+
+ BOOL bForward = !rSearchItem.GetBackward();
+ USHORT nFound = 0;
+ if ( ( rSearchItem.GetCommand() == SVX_SEARCHCMD_FIND ) ||
+ ( rSearchItem.GetCommand() == SVX_SEARCHCMD_FIND_ALL ) )
+ {
+ nFound = pView->Search( rSearchItem.GetSearchOptions() , bForward );
+ }
+ else if ( ( rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE ) ||
+ ( rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL ) )
+ {
+ if ( !IsReadOnly() )
+ {
+ BOOL bAll = rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL;
+ nFound = pView->Replace( rSearchItem.GetSearchOptions() , bAll , bForward );
+ }
+ }
+
+ if ( bFromStart && !nFound )
+ pView->SetSelection( aSel );
+
+ return nFound;
+}
+
+SfxUndoManager* __EXPORT ModulWindow::GetUndoManager()
+{
+ if ( GetEditEngine() )
+ return &GetEditEngine()->GetUndoManager();
+ return NULL;
+}
+
+USHORT __EXPORT ModulWindow::GetSearchOptions()
+{
+ USHORT nOptions = SEARCH_OPTIONS_SEARCH |
+ SEARCH_OPTIONS_WHOLE_WORDS |
+ SEARCH_OPTIONS_BACKWARDS |
+ SEARCH_OPTIONS_REG_EXP |
+ SEARCH_OPTIONS_EXACT |
+ SEARCH_OPTIONS_SELECTION |
+ SEARCH_OPTIONS_SIMILARITY;
+
+ if ( !IsReadOnly() )
+ {
+ nOptions |= SEARCH_OPTIONS_REPLACE;
+ nOptions |= SEARCH_OPTIONS_REPLACE_ALL;
+ }
+
+ return nOptions;
+}
+
+void __EXPORT ModulWindow::BasicStarted()
+{
+ if ( XModule().Is() )
+ {
+ aStatus.bIsRunning = TRUE;
+ BreakPointList& rList = GetBreakPoints();
+ if ( rList.Count() )
+ {
+ rList.ResetHitCount();
+ rList.SetBreakPointsInBasic( xModule );
+ for ( USHORT nMethod = 0; nMethod < xModule->GetMethods()->Count(); nMethod++ )
+ {
+ SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( nMethod );
+ DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" );
+ pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK );
+ }
+ }
+ }
+}
+
+void __EXPORT ModulWindow::BasicStopped()
+{
+ aStatus.bIsRunning = FALSE;
+ GetBreakPointWindow().SetMarkerPos( MARKER_NOMARKER );
+}
+
+BasicEntryDescriptor ModulWindow::CreateEntryDescriptor()
+{
+ ScriptDocument aDocument( GetDocument() );
+ String aLibName( GetLibName() );
+ LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
+ String aModName( GetName() );
+ String aLibSubName;
+ if( xBasic.Is() && aDocument.isInVBAMode() && XModule().Is() )
+ {
+ switch( xModule->GetModuleType() )
+ {
+ case script::ModuleType::DOCUMENT:
+ {
+ aLibSubName = String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) );
+ uno::Reference< container::XNameContainer > xLib = aDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
+ if( xLib.is() )
+ {
+ String sObjName;
+ ModuleInfoHelper::getObjectName( xLib, aModName, sObjName );
+ if( sObjName.Len() )
+ {
+ aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")");
+ }
+ }
+ break;
+ }
+ case script::ModuleType::FORM:
+ aLibSubName = String( IDEResId( RID_STR_USERFORMS ) );
+ break;
+ case script::ModuleType::NORMAL:
+ aLibSubName = String( IDEResId( RID_STR_NORMAL_MODULES ) );
+ break;
+ case script::ModuleType::CLASS:
+ aLibSubName = String( IDEResId( RID_STR_CLASS_MODULES ) );
+ break;
+ }
+ }
+ return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aModName, OBJ_TYPE_MODULE );
+}
+
+void ModulWindow::SetReadOnly( BOOL b )
+{
+ if ( GetEditView() )
+ GetEditView()->SetReadOnly( b );
+}
+
+BOOL ModulWindow::IsReadOnly()
+{
+ BOOL bReadOnly = FALSE;
+
+ if ( GetEditView() )
+ bReadOnly = GetEditView()->IsReadOnly();
+
+ return bReadOnly;
+}
+
+BOOL ModulWindow::IsPasteAllowed()
+{
+ BOOL bPaste = FALSE;
+
+ // get clipboard
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = GetClipboard();
+ if ( xClipboard.is() )
+ {
+ // get clipboard content
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
+ Application::AcquireSolarMutex( nRef );
+ if ( xTransf.is() )
+ {
+ datatransfer::DataFlavor aFlavor;
+ SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
+ if ( xTransf->isDataFlavorSupported( aFlavor ) )
+ {
+ bPaste = TRUE;
+ }
+ }
+ }
+
+ return bPaste;
+}
+
+ModulWindowLayout::ModulWindowLayout( Window* pParent ) :
+ Window( pParent, WB_CLIPCHILDREN ),
+ aVSplitter( this, WinBits( WB_VSCROLL ) ),
+ aHSplitter( this, WinBits( WB_HSCROLL ) ),
+ aWatchWindow( this ),
+ aStackWindow( this ),
+ bVSplitted(FALSE),
+ bHSplitted(FALSE),
+ m_pModulWindow(0),
+ m_aImagesNormal(IDEResId(RID_IMGLST_LAYOUT)),
+ m_aImagesHighContrast(IDEResId(RID_IMGLST_LAYOUT_HC))
+{
+ SetBackground(GetSettings().GetStyleSettings().GetWindowColor());
+
+ aVSplitter.SetSplitHdl( LINK( this, ModulWindowLayout, SplitHdl ) );
+ aHSplitter.SetSplitHdl( LINK( this, ModulWindowLayout, SplitHdl ) );
+ aVSplitter.Show();
+ aHSplitter.Show();
+
+ aWatchWindow.Show();
+ aStackWindow.Show();
+
+ Color aColor(GetSettings().GetStyleSettings().GetFieldTextColor());
+ m_aSyntaxColors[TT_UNKNOWN] = aColor;
+ m_aSyntaxColors[TT_WHITESPACE] = aColor;
+ m_aSyntaxColors[TT_EOL] = aColor;
+ m_aColorConfig.AddListener(this);
+ m_aSyntaxColors[TT_IDENTIFIER]
+ = Color(m_aColorConfig.GetColorValue(svtools::BASICIDENTIFIER).nColor);
+ m_aSyntaxColors[TT_NUMBER]
+ = Color(m_aColorConfig.GetColorValue(svtools::BASICNUMBER).nColor);
+ m_aSyntaxColors[TT_STRING]
+ = Color(m_aColorConfig.GetColorValue(svtools::BASICSTRING).nColor);
+ m_aSyntaxColors[TT_COMMENT]
+ = Color(m_aColorConfig.GetColorValue(svtools::BASICCOMMENT).nColor);
+ m_aSyntaxColors[TT_ERROR]
+ = Color(m_aColorConfig.GetColorValue(svtools::BASICERROR).nColor);
+ m_aSyntaxColors[TT_OPERATOR]
+ = Color(m_aColorConfig.GetColorValue(svtools::BASICOPERATOR).nColor);
+ m_aSyntaxColors[TT_KEYWORDS]
+ = Color(m_aColorConfig.GetColorValue(svtools::BASICKEYWORD).nColor);
+
+ Font aFont( GetFont() );
+ Size aSz( aFont.GetSize() );
+ aSz.Height() *= 3;
+ aSz.Height() /= 2;
+ aFont.SetSize( aSz );
+ aFont.SetWeight( WEIGHT_BOLD );
+ aFont.SetColor(GetSettings().GetStyleSettings().GetWindowTextColor());
+ SetFont( aFont );
+}
+
+ModulWindowLayout::~ModulWindowLayout()
+{
+ m_aColorConfig.RemoveListener(this);
+}
+
+void __EXPORT ModulWindowLayout::Resize()
+{
+ // ScrollBars, etc. passiert in BasicIDEShell:Adjust...
+ ArrangeWindows();
+// Invalidate();
+}
+
+void __EXPORT ModulWindowLayout::Paint( const Rectangle& )
+{
+ DrawText( Point(), String( IDEResId( RID_STR_NOMODULE ) ) );
+}
+
+
+void ModulWindowLayout::ArrangeWindows()
+{
+ Size aSz = GetOutputSizePixel();
+
+ // prueffen, ob der Splitter in einem gueltigen Bereich liegt...
+ long nMinPos = SPLIT_MARGIN;
+ long nMaxPos = aSz.Height() - SPLIT_MARGIN;
+
+ long nVSplitPos = aVSplitter.GetSplitPosPixel();
+ long nHSplitPos = aHSplitter.GetSplitPosPixel();
+ if ( !bVSplitted )
+ {
+ // Wenn noch nie gesplitted wurde, Verhaeltniss = 3 : 4
+ nVSplitPos = aSz.Height() * 3 / 4;
+ aVSplitter.SetSplitPosPixel( nVSplitPos );
+ }
+ if ( !bHSplitted )
+ {
+ // Wenn noch nie gesplitted wurde, Verhaeltniss = 2 : 3
+ nHSplitPos = aSz.Width() * 2 / 3;
+ aHSplitter.SetSplitPosPixel( nHSplitPos );
+ }
+ if ( ( nVSplitPos < nMinPos ) || ( nVSplitPos > nMaxPos ) )
+ nVSplitPos = ( nVSplitPos < nMinPos ) ? 0 : ( aSz.Height() - SPLIT_HEIGHT );
+
+ Size aXEWSz;
+ aXEWSz.Width() = aSz.Width();
+ aXEWSz.Height() = nVSplitPos + 1;
+ if ( m_pModulWindow )
+ {
+ DBG_CHKOBJ( m_pModulWindow, ModulWindow, 0 );
+ m_pModulWindow->SetPosSizePixel( Point( 0, 0 ), aXEWSz );
+ }
+
+ aVSplitter.SetDragRectPixel( Rectangle( Point( 0, 0 ), Size( aSz.Width(), aSz.Height() ) ) );
+ aVSplitter.SetPosPixel( Point( 0, nVSplitPos ) );
+ aVSplitter.SetSizePixel( Size( aSz.Width(), SPLIT_HEIGHT ) );
+
+ aHSplitter.SetDragRectPixel( Rectangle( Point( 0, nVSplitPos+SPLIT_HEIGHT ), Size( aSz.Width(), aSz.Height() - nVSplitPos - SPLIT_HEIGHT ) ) );
+ aHSplitter.SetPosPixel( Point( nHSplitPos, nVSplitPos ) );
+ aHSplitter.SetSizePixel( Size( SPLIT_HEIGHT, aSz.Height() - nVSplitPos ) );
+
+ Size aWWSz;
+ Point aWWPos( 0, nVSplitPos+SPLIT_HEIGHT );
+ aWWSz.Width() = nHSplitPos;
+ aWWSz.Height() = aSz.Height() - aWWPos.Y();
+ if ( !aWatchWindow.IsFloatingMode() )
+ aWatchWindow.SetPosSizePixel( aWWPos, aWWSz );
+
+ Size aSWSz;
+ Point aSWPos( nHSplitPos+SPLIT_HEIGHT, nVSplitPos+SPLIT_HEIGHT );
+ aSWSz.Width() = aSz.Width() - aSWPos.X();
+ aSWSz.Height() = aSz.Height() - aSWPos.Y();
+ if ( !aStackWindow.IsFloatingMode() )
+ aStackWindow.SetPosSizePixel( aSWPos, aSWSz );
+
+ if ( aStackWindow.IsFloatingMode() && aWatchWindow.IsFloatingMode() )
+ aHSplitter.Hide();
+ else
+ aHSplitter.Show();
+
+ long nHDoubleClickSplitPosX = aSz.Width()-aHSplitter.GetSizePixel().Width();
+ if ( aHSplitter.GetSplitPosPixel() < nHDoubleClickSplitPosX )
+ aHSplitter.SetLastSplitPosPixel( nHDoubleClickSplitPosX );
+
+
+ long nHDoubleClickSplitPosY = aSz.Height()-aVSplitter.GetSizePixel().Height();
+ if ( aVSplitter.GetSplitPosPixel() < nHDoubleClickSplitPosY )
+ aVSplitter.SetLastSplitPosPixel( nHDoubleClickSplitPosY );
+}
+
+IMPL_LINK( ModulWindowLayout, SplitHdl, Splitter *, pSplitter )
+{
+ if ( pSplitter == &aVSplitter )
+ bVSplitted = TRUE;
+ else
+ bHSplitted = TRUE;
+
+ ArrangeWindows();
+ return 0;
+}
+
+BOOL ModulWindowLayout::IsToBeDocked( DockingWindow* pDockingWindow, const Point& rPos, Rectangle& rRect )
+{
+ // prueffen, ob als Dock oder als Child:
+ // TRUE: Floating
+ // FALSE: Child
+ Point aPosInMe = ScreenToOutputPixel( rPos );
+ Size aSz = GetOutputSizePixel();
+ if ( ( aPosInMe.X() > 0 ) && ( aPosInMe.X() < aSz.Width() ) &&
+ ( aPosInMe.Y() > 0 ) && ( aPosInMe.Y() < aSz.Height() ) )
+ {
+ long nVSplitPos = aVSplitter.GetSplitPosPixel();
+ long nHSplitPos = aHSplitter.GetSplitPosPixel();
+ if ( pDockingWindow == &aWatchWindow )
+ {
+ if ( ( aPosInMe.Y() > nVSplitPos ) && ( aPosInMe.X() < nHSplitPos ) )
+ {
+ rRect.SetSize( Size( nHSplitPos, aSz.Height() - nVSplitPos ) );
+ rRect.SetPos( OutputToScreenPixel( Point( 0, nVSplitPos ) ) );
+ return TRUE;
+ }
+ }
+ if ( pDockingWindow == &aStackWindow )
+ {
+ if ( ( aPosInMe.Y() > nVSplitPos ) && ( aPosInMe.X() > nHSplitPos ) )
+ {
+ rRect.SetSize( Size( aSz.Width() - nHSplitPos, aSz.Height() - nVSplitPos ) );
+ rRect.SetPos( OutputToScreenPixel( Point( nHSplitPos, nVSplitPos ) ) );
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+void ModulWindowLayout::DockaWindow( DockingWindow* pDockingWindow )
+{
+ if ( pDockingWindow == &aWatchWindow )
+ {
+ // evtl. Sonderbehandlung...
+ ArrangeWindows();
+ }
+ else if ( pDockingWindow == &aStackWindow )
+ {
+ // evtl. Sonderbehandlung...
+ ArrangeWindows();
+ }
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR( "Wer will sich denn hier andocken ?" );
+#endif
+}
+
+void ModulWindowLayout::SetModulWindow( ModulWindow* pModWin )
+{
+ m_pModulWindow = pModWin;
+ ArrangeWindows();
+}
+
+// virtual
+void ModulWindowLayout::DataChanged(DataChangedEvent const & rDCEvt)
+{
+ Window::DataChanged(rDCEvt);
+ if (rDCEvt.GetType() == DATACHANGED_SETTINGS
+ && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
+ {
+ bool bInvalidate = false;
+ Color aColor(GetSettings().GetStyleSettings().GetWindowColor());
+ if (aColor
+ != rDCEvt.GetOldSettings()->GetStyleSettings().GetWindowColor())
+ {
+ SetBackground(Wallpaper(aColor));
+ bInvalidate = true;
+ }
+ aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
+ if (aColor != rDCEvt.GetOldSettings()->
+ GetStyleSettings().GetWindowTextColor())
+ {
+ Font aFont(GetFont());
+ aFont.SetColor(aColor);
+ SetFont(aFont);
+ bInvalidate = true;
+ }
+ if (bInvalidate)
+ Invalidate();
+ aColor = GetSettings().GetStyleSettings().GetFieldTextColor();
+ if (aColor != m_aSyntaxColors[TT_UNKNOWN])
+ {
+ m_aSyntaxColors[TT_UNKNOWN] = aColor;
+ m_aSyntaxColors[TT_WHITESPACE] = aColor;
+ m_aSyntaxColors[TT_EOL] = aColor;
+ updateSyntaxHighlighting();
+ }
+ }
+}
+
+// virtual
+void ModulWindowLayout::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
+{
+ {
+ Color aColor(m_aColorConfig.GetColorValue(svtools::BASICIDENTIFIER).
+ nColor);
+ bool bChanged = aColor != m_aSyntaxColors[TT_IDENTIFIER];
+ m_aSyntaxColors[TT_IDENTIFIER] = aColor;
+ aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICNUMBER).nColor);
+ if (bChanged || aColor != m_aSyntaxColors[TT_NUMBER])
+ bChanged = true;
+ m_aSyntaxColors[TT_NUMBER] = aColor;
+ aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICSTRING).nColor);
+ if (bChanged || aColor != m_aSyntaxColors[TT_STRING])
+ bChanged = true;
+ m_aSyntaxColors[TT_STRING] = aColor;
+ aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICCOMMENT).
+ nColor);
+ if (bChanged || aColor != m_aSyntaxColors[TT_COMMENT])
+ bChanged = true;
+ m_aSyntaxColors[TT_COMMENT] = aColor;
+ aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICERROR).nColor);
+ if (bChanged || aColor != m_aSyntaxColors[TT_ERROR])
+ bChanged = true;
+ m_aSyntaxColors[TT_ERROR] = aColor;
+ aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICOPERATOR).
+ nColor);
+ if (bChanged || aColor != m_aSyntaxColors[TT_OPERATOR])
+ bChanged = true;
+ m_aSyntaxColors[TT_OPERATOR] = aColor;
+ aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICKEYWORD).
+ nColor);
+ if (bChanged || aColor != m_aSyntaxColors[TT_KEYWORDS])
+ bChanged = true;
+ m_aSyntaxColors[TT_KEYWORDS] = aColor;
+ if (bChanged)
+ updateSyntaxHighlighting();
+ }
+}
+
+void ModulWindowLayout::updateSyntaxHighlighting()
+{
+ if (m_pModulWindow != 0)
+ {
+ EditorWindow & rEditor = m_pModulWindow->GetEditorWindow();
+ ULONG nCount = rEditor.GetEditEngine()->GetParagraphCount();
+ for (ULONG i = 0; i < nCount; ++i)
+ rEditor.DoDelayedSyntaxHighlight(i);
+ }
+}
+
+Image ModulWindowLayout::getImage(USHORT nId, bool bHighContrastMode) const
+{
+ return (bHighContrastMode ? m_aImagesHighContrast : m_aImagesNormal).
+ GetImage(nId);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/baside2.hrc b/basctl/source/basicide/baside2.hrc
new file mode 100644
index 000000000000..f97a0d897912
--- /dev/null
+++ b/basctl/source/basicide/baside2.hrc
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BASIDE2_HRC
+#define _BASIDE2_HRC
+
+#include <basidesh.hrc>
+
+// Diese Dateien enthaelt nur die lokalen ID's.
+
+// RID_POPUP_BRKPROPS
+#define RID_BRKPROPS 1
+#define RID_ACTIV 2
+
+// RID_POPUP_BRKDLG
+#define RID_BRKDLG 1
+
+// RID_POPUP_TABBAR
+#define RID_INSERT 1
+
+// ModulWindowLayout
+#define IMGID_BRKENABLED ( SID_BASICIDE_IMAGESTART + 20 )
+#define IMGID_BRKDISABLED ( SID_BASICIDE_IMAGESTART + 21 )
+#define IMGID_STEPMARKER ( SID_BASICIDE_IMAGESTART + 22 )
+#define IMGID_ERRORMARKER ( SID_BASICIDE_IMAGESTART + 23 )
+
+#endif // _BASIDE2_HRC
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
new file mode 100644
index 000000000000..12ae6a23fb6f
--- /dev/null
+++ b/basctl/source/basicide/baside2.hxx
@@ -0,0 +1,507 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASIDE2_HXX
+#define _BASIDE2_HXX
+
+#include <svheader.hxx>
+
+#include <bastypes.hxx>
+#include <bastype3.hxx>
+#include <basidesh.hxx>
+
+class ExtTextEngine;
+class ExtTextView;
+class SvxSearchItem;
+#include <svtools/svtabbx.hxx>
+#include <svtools/headbar.hxx>
+
+#include <vcl/button.hxx>
+#include <basic/sbmod.hxx>
+#include <vcl/split.hxx>
+#include "svl/lstner.hxx"
+#include <svtools/colorcfg.hxx>
+
+#include <sfx2/progress.hxx>
+#include <svtools/syntaxhighlight.hxx>
+
+DBG_NAMEEX( ModulWindow )
+
+#define MARKER_NOMARKER 0xFFFF
+
+namespace utl
+{
+ class SourceViewConfig;
+}
+
+// #108672 Helper functions to get/set text in TextEngine
+// using the stream interface (get/setText() only supports
+// tools Strings limited to 64K).
+::rtl::OUString getTextEngineText( ExtTextEngine* pEngine );
+void setTextEngineText( ExtTextEngine* pEngine, const ::rtl::OUString aStr );
+
+class ProgressInfo : public SfxProgress
+{
+private:
+ ULONG nCurState;
+
+public:
+
+ inline ProgressInfo( SfxObjectShell* pObjSh, const String& rText, ULONG nRange );
+
+// inline void StartProgress( const String& rName, ULONG nStates );
+// inline void EndProgress();
+ inline void StepProgress();
+};
+
+inline ProgressInfo::ProgressInfo( SfxObjectShell* pObjSh, const String& rText, ULONG nRange )
+ : SfxProgress( pObjSh, rText, nRange )
+{
+ nCurState = 0;
+}
+
+// inline void ProgressInfo::StartProgress( const String& rName, ULONG nStates )
+// {
+// nCurState = 0;
+// if ( pStbMgr )
+// pStbMgr->StartProgressMode( rName, nStates );
+// }
+
+// inline void ProgressInfo::EndProgress()
+// {
+// if ( pStbMgr )
+// pStbMgr->EndProgressMode();
+//}
+
+inline void ProgressInfo::StepProgress()
+{
+ SetState( ++nCurState );
+}
+
+
+namespace svt {
+class SourceViewConfig;
+}
+
+class EditorWindow : public Window, public SfxListener, public utl::ConfigurationListener
+{
+private:
+ ExtTextView* pEditView;
+ ExtTextEngine* pEditEngine;
+
+ utl::SourceViewConfig* pSourceViewConfig;
+
+ long nCurTextWidth;
+
+ SyntaxHighlighter aHighlighter;
+ Timer aSyntaxIdleTimer;
+ Table aSyntaxLineTable;
+ DECL_LINK( SyntaxTimerHdl, Timer * );
+ ProgressInfo* pProgress;
+ ModulWindow* pModulWindow;
+
+ virtual void DataChanged(DataChangedEvent const & rDCEvt);
+
+ using Window::Notify;
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ void ImpDoHighlight( ULONG nLineOff );
+ void ImplSetFont();
+
+ BOOL bHighlightning;
+ BOOL bDoSyntaxHighlight;
+ BOOL bDelayHighlight;
+
+ virtual
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
+ GetComponentInterface(BOOL bCreate = TRUE);
+
+protected:
+ virtual void Paint( const Rectangle& );
+ virtual void Resize();
+ virtual void KeyInput( const KeyEvent& rKeyEvt );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual void LoseFocus();
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+ virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
+
+ void DoSyntaxHighlight( ULONG nPara );
+ String GetWordAtCursor();
+ BOOL ImpCanModify();
+
+public:
+ EditorWindow( Window* pParent );
+ ~EditorWindow();
+
+ ExtTextEngine* GetEditEngine() const { return (ExtTextEngine*)pEditEngine; }
+ ExtTextView* GetEditView() const { return pEditView; }
+ ProgressInfo* GetProgress() const { return pProgress; }
+
+ void CreateProgress( const String& rText, ULONG nRange );
+ void DestroyProgress();
+
+ void ParagraphInsertedDeleted( ULONG nNewPara, BOOL bInserted );
+ void DoDelayedSyntaxHighlight( ULONG nPara );
+
+ void CreateEditEngine();
+ void SetScrollBarRanges();
+ void InitScrollBars();
+ void SetModulWindow( ModulWindow* pWin )
+ { pModulWindow = pWin; }
+
+ void ForceSyntaxTimeout();
+ BOOL SetSourceInBasic( BOOL bQuiet = TRUE );
+
+ BOOL CanModify() { return ImpCanModify(); }
+};
+
+
+class BreakPointWindow : public Window
+{
+private:
+ long nCurYOffset;
+ USHORT nMarkerPos;
+ BreakPointList aBreakPointList;
+ ModulWindow* pModulWindow;
+ BOOL bErrorMarker;
+ bool m_bHighContrastMode;
+
+ virtual void DataChanged(DataChangedEvent const & rDCEvt);
+
+ void setBackgroundColor(Color aColor);
+
+protected:
+ virtual void Paint( const Rectangle& );
+ virtual void Resize();
+ BreakPoint* FindBreakPoint( const Point& rMousePos );
+ void ShowMarker( BOOL bShow );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+
+ BOOL SyncYOffset();
+
+public:
+ BreakPointWindow( Window* pParent );
+ ~BreakPointWindow();
+
+ void SetModulWindow( ModulWindow* pWin )
+ { pModulWindow = pWin; }
+
+ void SetMarkerPos( USHORT nLine, BOOL bErrorMarker = FALSE );
+
+ void DoScroll( long nHorzScroll, long nVertScroll );
+ long& GetCurYOffset() { return nCurYOffset; }
+ BreakPointList& GetBreakPoints() { return aBreakPointList; }
+};
+
+
+class WatchTreeListBox : public SvHeaderTabListBox
+{
+ String aEditingRes;
+
+protected:
+ virtual BOOL EditingEntry( SvLBoxEntry* pEntry, Selection& rSel );
+ virtual BOOL EditedEntry( SvLBoxEntry* pEntry, const String& rNewText );
+
+ BOOL ImplBasicEntryEdited( SvLBoxEntry* pEntry, const String& rResult );
+ SbxBase* ImplGetSBXForEntry( SvLBoxEntry* pEntry, bool& rbArrayElement );
+
+// virtual DragDropMode NotifyBeginDrag( SvLBoxEntry* );
+// virtual BOOL NotifyQueryDrop( SvLBoxEntry* );
+
+// virtual BOOL NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
+// SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos );
+// virtual BOOL NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
+// SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos );
+// BOOL NotifyCopyingMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
+// SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos, BOOL bMove );
+
+public:
+ WatchTreeListBox( Window* pParent, WinBits nWinBits );
+ ~WatchTreeListBox();
+
+ void RequestingChilds( SvLBoxEntry * pParent );
+ void UpdateWatches( bool bBasicStopped = false );
+
+ using SvTabListBox::SetTabs;
+ virtual void SetTabs();
+};
+
+
+
+class WatchWindow : public BasicDockingWindow
+{
+private:
+ String aWatchStr;
+ ExtendedEdit aXEdit;
+ ImageButton aRemoveWatchButton;
+ WatchTreeListBox aTreeListBox;
+ HeaderBar aHeaderBar;
+
+protected:
+ virtual void Resize();
+ virtual void Paint( const Rectangle& rRect );
+
+ DECL_LINK( ButtonHdl, ImageButton * );
+ DECL_LINK( TreeListHdl, SvTreeListBox * );
+ DECL_LINK( implEndDragHdl, HeaderBar * );
+ DECL_LINK( EditAccHdl, Accelerator * );
+
+
+public:
+ WatchWindow( Window* pParent );
+ ~WatchWindow();
+
+ void AddWatch( const String& rVName );
+ BOOL RemoveSelectedWatch();
+ void UpdateWatches( bool bBasicStopped = false );
+
+ WatchTreeListBox& GetWatchTreeListBox() { return aTreeListBox; }
+};
+
+
+class StackWindow : public BasicDockingWindow
+{
+private:
+ SvTreeListBox aTreeListBox;
+ ImageButton aGotoCallButton;
+ String aStackStr;
+
+protected:
+ virtual void Resize();
+ virtual void Paint( const Rectangle& rRect );
+ DECL_LINK( ButtonHdl, ImageButton * );
+
+public:
+ StackWindow( Window* pParent );
+ ~StackWindow();
+
+ void UpdateCalls();
+};
+
+
+class ComplexEditorWindow : public Window
+{
+private:
+ BreakPointWindow aBrkWindow;
+ EditorWindow aEdtWindow;
+ ScrollBar aEWVScrollBar;
+
+ virtual void DataChanged(DataChangedEvent const & rDCEvt);
+
+protected:
+ virtual void Resize();
+ DECL_LINK( ScrollHdl, ScrollBar * );
+
+public:
+ ComplexEditorWindow( ModulWindow* pParent );
+
+ BreakPointWindow& GetBrkWindow() { return aBrkWindow; }
+ EditorWindow& GetEdtWindow() { return aEdtWindow; }
+ ScrollBar& GetEWVScrollBar() { return aEWVScrollBar; }
+};
+
+
+#define SYNTAX_COLOR_MAX 5
+
+class ModulWindow: public IDEBaseWindow
+{
+ friend class BasicIDEShell;
+
+private:
+ StarBASICRef xBasic;
+ short nValid;
+ ComplexEditorWindow aXEditorWindow;
+ BasicStatus aStatus;
+ SbModuleRef xModule;
+ ModulWindowLayout* pLayout;
+ String aCurPath;
+ ::rtl::OUString m_aModule;
+
+ DECL_LINK( BasicErrorHdl, StarBASIC * );
+ long BasicBreakHdl( StarBASIC* pBasic );
+
+ void CheckCompileBasic();
+ BOOL BasicExecute();
+
+ void GoOnTop();
+ void AssertValidEditEngine();
+
+ sal_Int32 FormatAndPrint( Printer* pPrinter, sal_Int32 nPage = -1 );
+ SbModuleRef XModule();
+protected:
+ virtual void Resize();
+ virtual void GetFocus();
+ virtual void Paint( const Rectangle& );
+ virtual void Deactivating();
+ virtual void DoInit();
+ virtual void DoScroll( ScrollBar* pCurScrollBar );
+
+public:
+ TYPEINFO();
+
+ ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDocument, String aLibName,
+ String aName, ::rtl::OUString& aModule );
+
+ ~ModulWindow();
+
+ virtual void ExecuteCommand( SfxRequest& rReq );
+ virtual void GetState( SfxItemSet& );
+ virtual void StoreData();
+ virtual void UpdateData();
+ virtual BOOL CanClose();
+ // virtual void PrintData( Printer* pPrinter );
+ // return number of pages to be printed
+ virtual sal_Int32 countPages( Printer* pPrinter );
+ // print page
+ virtual void printPage( sal_Int32 nPage, Printer* pPrinter );
+ virtual String GetTitle();
+ virtual BasicEntryDescriptor CreateEntryDescriptor();
+ virtual BOOL AllowUndo();
+ virtual void SetReadOnly( BOOL bReadOnly );
+ virtual BOOL IsReadOnly();
+
+ StarBASIC* GetBasic() { XModule(); return xBasic; }
+
+ SbModule* GetSbModule() { return xModule; }
+ void SetSbModule( SbModule* pModule ) { xModule = pModule; }
+ String GetSbModuleName();
+
+ BOOL CompileBasic();
+ BOOL BasicRun();
+ BOOL BasicStepOver();
+ BOOL BasicStepInto();
+ BOOL BasicStepOut();
+ void BasicStop();
+ BOOL BasicToggleBreakPoint();
+ void BasicToggleBreakPointEnabled();
+ void ManageBreakPoints();
+ void UpdateBreakPoint( const BreakPoint& rBrk );
+ void BasicAddWatch();
+ void BasicRemoveWatch();
+
+ BOOL LoadBasic();
+ BOOL SaveBasicSource();
+ BOOL ImportDialog();
+
+ void EditMacro( const String& rMacroName );
+
+// void InsertFromObjectCatalog( ObjectCatalog* pObjDlg );
+
+ BOOL ToggleBreakPoint( ULONG nLine );
+
+ BasicStatus& GetBasicStatus() { return aStatus; }
+
+ virtual BOOL IsModified();
+ virtual BOOL IsPasteAllowed();
+
+ void FrameWindowMoved();
+ void ShowCursor( BOOL bOn );
+
+ virtual USHORT GetSearchOptions();
+ USHORT StartSearchAndReplace( const SvxSearchItem& rSearchItem, BOOL bFromStart = FALSE );
+
+ virtual Window* GetLayoutWindow();
+
+ EditorWindow& GetEditorWindow() { return aXEditorWindow.GetEdtWindow(); }
+ BreakPointWindow& GetBreakPointWindow() { return aXEditorWindow.GetBrkWindow(); }
+ ScrollBar& GetEditVScrollBar() { return aXEditorWindow.GetEWVScrollBar(); }
+ ExtTextEngine* GetEditEngine() { return GetEditorWindow().GetEditEngine(); }
+ ExtTextView* GetEditView() { return GetEditorWindow().GetEditView(); }
+ BreakPointList& GetBreakPoints() { return GetBreakPointWindow().GetBreakPoints(); }
+ ModulWindowLayout* GetLayout() const { return pLayout; }
+
+ virtual void BasicStarted();
+ virtual void BasicStopped();
+
+ virtual SfxUndoManager* GetUndoManager();
+
+ const ::rtl::OUString& GetModule() const { return m_aModule; }
+ void SetModule( const ::rtl::OUString& aModule ) { m_aModule = aModule; }
+};
+
+class ModulWindowLayout: public Window, public utl::ConfigurationListener
+{
+private:
+
+ Splitter aVSplitter;
+ Splitter aHSplitter;
+
+ WatchWindow aWatchWindow;
+ StackWindow aStackWindow;
+
+ BOOL bVSplitted;
+ BOOL bHSplitted;
+
+ ModulWindow * m_pModulWindow;
+
+ Color m_aSyntaxColors[TT_KEYWORDS + 1];
+ svtools::ColorConfig m_aColorConfig;
+
+ ImageList m_aImagesNormal;
+ ImageList m_aImagesHighContrast;
+
+ virtual void DataChanged(DataChangedEvent const & rDCEvt);
+
+ virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
+
+ void updateSyntaxHighlighting();
+
+ DECL_LINK( SplitHdl, Splitter * );
+
+ void ArrangeWindows();
+
+protected:
+ virtual void Resize();
+ virtual void Paint( const Rectangle& rRect );
+
+public:
+ ModulWindowLayout( Window* pParent );
+ ~ModulWindowLayout();
+
+ void DockaWindow( DockingWindow* pDockingWin );
+ BOOL IsToBeDocked( DockingWindow* pDockingWin, const Point& rPos, Rectangle& rRect );
+
+ void SetModulWindow( ModulWindow* pModWin );
+ ModulWindow* GetModulWindow() const { return m_pModulWindow; }
+
+ WatchWindow& GetWatchWindow() { return aWatchWindow; }
+ StackWindow& GetStackWindow() { return aStackWindow; }
+
+ Image getImage(USHORT nId, bool bHighContrastMode) const;
+
+ inline Color const & getSyntaxColor(TokenTypes eType) const
+ { return m_aSyntaxColors[eType]; }
+};
+
+#endif // _BASIDE2_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
new file mode 100644
index 000000000000..2fa67b22fb48
--- /dev/null
+++ b/basctl/source/basicide/baside2b.cxx
@@ -0,0 +1,2317 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include <svl/svarray.hxx>
+#define _BASIC_TEXTPORTIONS
+#include <basic/sbdef.hxx>
+#include <ide_pch.hxx>
+
+
+#include <tools/urlobj.hxx>
+#include <unotools/charclass.hxx>
+#include <svl/urihelper.hxx>
+#include <basic/sbx.hxx>
+#include <vcl/sound.hxx>
+#include <svtools/xtextedt.hxx>
+#include <svtools/txtattr.hxx>
+#include <svtools/textwindowpeer.hxx>
+#include <basic/sbuno.hxx>
+
+#include <helpid.hrc>
+#include <baside2.hrc>
+#include <baside2.hxx>
+#include <brkdlg.hxx>
+#include <objdlg.hxx>
+#include <basobj.hxx>
+#include <iderdll.hxx>
+#include <iderdll2.hxx>
+#include <vcl/taskpanelist.hxx>
+#include <vcl/help.hxx>
+
+#include <unotools/sourceviewconfig.hxx>
+
+#include <com/sun/star/script/XLibraryContainer2.hpp>
+#include <comphelper/processfactory.hxx>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+long nVirtToolBoxHeight; // wird im WatchWindow init., im Stackwindow verw.
+long nHeaderBarHeight;
+
+#define SCROLL_LINE 12
+#define SCROLL_PAGE 60
+
+#define DWBORDER 3
+
+static const char cSuffixes[] = "%&!#@$";
+
+MapUnit eEditMapUnit = MAP_100TH_MM;
+
+
+// #108672 Helper functions to get/set text in TextEngine
+// using the stream interface (get/setText() only supports
+// tools Strings limited to 64K).
+::rtl::OUString getTextEngineText( ExtTextEngine* pEngine )
+{
+ SvMemoryStream aMemStream;
+ aMemStream.SetStreamCharSet( RTL_TEXTENCODING_UTF8 );
+ aMemStream.SetLineDelimiter( LINEEND_LF );
+ pEngine->Write( aMemStream );
+ ULONG nSize = aMemStream.Tell();
+ ::rtl::OUString aText( (const sal_Char*)aMemStream.GetData(),
+ nSize, RTL_TEXTENCODING_UTF8 );
+ return aText;
+}
+
+void setTextEngineText( ExtTextEngine* pEngine, const ::rtl::OUString aStr )
+{
+ pEngine->SetText( String() );
+ ::rtl::OString aUTF8Str = ::rtl::OUStringToOString( aStr, RTL_TEXTENCODING_UTF8 );
+ SvMemoryStream aMemStream( (void*)aUTF8Str.getStr(), aUTF8Str.getLength(),
+ STREAM_READ | STREAM_SEEK_TO_BEGIN );
+ aMemStream.SetStreamCharSet( RTL_TEXTENCODING_UTF8 );
+ aMemStream.SetLineDelimiter( LINEEND_LF );
+ pEngine->Read( aMemStream );
+}
+
+void lcl_DrawIDEWindowFrame( DockingWindow* pWin )
+{
+ // The result of using explicit colors here appears to be harmless when
+ // switching to high contrast mode:
+ if ( !pWin->IsFloatingMode() )
+ {
+ Size aSz = pWin->GetOutputSizePixel();
+ const Color aOldLineColor( pWin->GetLineColor() );
+ pWin->SetLineColor( Color( COL_WHITE ) );
+ // oben eine weisse..
+ pWin->DrawLine( Point( 0, 0 ), Point( aSz.Width(), 0 ) );
+ // unten eine schwarze...
+ pWin->SetLineColor( Color( COL_BLACK ) );
+ pWin->DrawLine( Point( 0, aSz.Height() - 1 ), Point( aSz.Width(), aSz.Height() - 1 ) );
+ pWin->SetLineColor( aOldLineColor );
+ }
+}
+
+void lcl_SeparateNameAndIndex( const String& rVName, String& rVar, String& rIndex )
+{
+ rVar = rVName;
+ rIndex.Erase();
+ USHORT nIndexStart = rVar.Search( '(' );
+ if ( nIndexStart != STRING_NOTFOUND )
+ {
+ USHORT nIndexEnd = rVar.Search( ')', nIndexStart );
+ if ( nIndexStart != STRING_NOTFOUND )
+ {
+ rIndex = rVar.Copy( nIndexStart+1, nIndexEnd-nIndexStart-1 );
+ rVar.Erase( nIndexStart );
+ rVar.EraseTrailingChars();
+ rIndex.EraseLeadingChars();
+ rIndex.EraseTrailingChars();
+ }
+ }
+
+ if ( rVar.Len() )
+ {
+ USHORT nLastChar = rVar.Len()-1;
+ if ( strchr( cSuffixes, rVar.GetChar( nLastChar ) ) )
+ rVar.Erase( nLastChar, 1 );
+ }
+ if ( rIndex.Len() )
+ {
+ USHORT nLastChar = rIndex.Len()-1;
+ if ( strchr( cSuffixes, rIndex.GetChar( nLastChar ) ) )
+ rIndex.Erase( nLastChar, 1 );
+ }
+}
+
+
+EditorWindow::EditorWindow( Window* pParent ) :
+ Window( pParent, WB_BORDER )
+{
+ bDoSyntaxHighlight = TRUE;
+ bDelayHighlight = TRUE;
+ pModulWindow = 0;
+ pEditView = 0;
+ pEditEngine = 0;
+ pSourceViewConfig = new utl::SourceViewConfig;
+ bHighlightning = FALSE;
+ pProgress = 0;
+ nCurTextWidth = 0;
+ SetBackground(
+ Wallpaper(GetSettings().GetStyleSettings().GetFieldColor()));
+ SetPointer( Pointer( POINTER_TEXT ) );
+
+ SetHelpId( HID_BASICIDE_EDITORWINDOW );
+ pSourceViewConfig->AddListener(this);
+}
+
+
+
+__EXPORT EditorWindow::~EditorWindow()
+{
+ pSourceViewConfig->RemoveListener(this);
+ delete pSourceViewConfig;
+
+ aSyntaxIdleTimer.Stop();
+
+ if ( pEditEngine )
+ {
+ EndListening( *pEditEngine );
+ pEditEngine->RemoveView( pEditView );
+// pEditEngine->SetViewWin( 0 );
+ delete pEditView;
+ delete pEditEngine;
+ }
+}
+
+String EditorWindow::GetWordAtCursor()
+{
+ String aWord;
+
+ if ( pEditView )
+ {
+ TextEngine* pTextEngine = pEditView->GetTextEngine();
+ if ( pTextEngine )
+ {
+ // check first, if the cursor is at a help URL
+ const TextSelection& rSelection = pEditView->GetSelection();
+ const TextPaM& rSelStart = rSelection.GetStart();
+ const TextPaM& rSelEnd = rSelection.GetEnd();
+ String aText = pTextEngine->GetText( rSelEnd.GetPara() );
+ CharClass aClass( ::comphelper::getProcessServiceFactory() , Application::GetSettings().GetLocale() );
+ xub_StrLen nSelStart = static_cast< xub_StrLen >( rSelStart.GetIndex() );
+ xub_StrLen nSelEnd = static_cast< xub_StrLen >( rSelEnd.GetIndex() );
+ xub_StrLen nLength = static_cast< xub_StrLen >( aText.Len() );
+ xub_StrLen nStart = 0;
+ xub_StrLen nEnd = nLength;
+ while ( nStart < nLength )
+ {
+ String aURL( URIHelper::FindFirstURLInText( aText, nStart, nEnd, aClass ) );
+ INetURLObject aURLObj( aURL );
+ if ( aURLObj.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP
+ && nSelStart >= nStart && nSelStart <= nEnd && nSelEnd >= nStart && nSelEnd <= nEnd )
+ {
+ aWord = aURL;
+ break;
+ }
+ nStart = nEnd;
+ nEnd = nLength;
+ }
+
+ // Nicht den Selektierten Bereich, sondern an der CursorPosition,
+ // falls Teil eines Worts markiert.
+ if ( !aWord.Len() )
+ aWord = pTextEngine->GetWord( rSelEnd );
+
+ // Kann leer sein, wenn komplettes Word markiert, da Cursor dahinter.
+ if ( !aWord.Len() && pEditView->HasSelection() )
+ aWord = pTextEngine->GetWord( rSelStart );
+ }
+ }
+
+ return aWord;
+}
+
+void __EXPORT EditorWindow::RequestHelp( const HelpEvent& rHEvt )
+{
+ BOOL bDone = FALSE;
+
+ // Sollte eigentlich mal aktiviert werden...
+ if ( pEditEngine )
+ {
+ if ( rHEvt.GetMode() & HELPMODE_CONTEXT )
+ {
+ String aKeyword = GetWordAtCursor();
+ Application::GetHelp()->Start( aKeyword, this );
+ bDone = TRUE;
+ }
+ else if ( rHEvt.GetMode() & HELPMODE_QUICK )
+ {
+ String aHelpText;
+ Point aTopLeft;
+ if ( StarBASIC::IsRunning() )
+ {
+ Point aWindowPos = rHEvt.GetMousePosPixel();
+ aWindowPos = ScreenToOutputPixel( aWindowPos );
+ Point aDocPos = GetEditView()->GetDocPos( aWindowPos );
+ TextPaM aCursor = GetEditView()->GetTextEngine()->GetPaM( aDocPos, FALSE );
+ TextPaM aStartOfWord;
+ String aWord = GetEditView()->GetTextEngine()->GetWord( aCursor, &aStartOfWord );
+ if ( aWord.Len() && !ByteString( aWord, RTL_TEXTENCODING_UTF8 ).IsNumericAscii() )
+ {
+ USHORT nLastChar =aWord.Len()-1;
+ if ( strchr( cSuffixes, aWord.GetChar( nLastChar ) ) )
+ aWord.Erase( nLastChar, 1 );
+ SbxBase* pSBX = StarBASIC::FindSBXInCurrentScope( aWord );
+ if ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) )
+ {
+ SbxVariable* pVar = (SbxVariable*)pSBX;
+ SbxDataType eType = pVar->GetType();
+ if ( (BYTE)eType == (BYTE)SbxOBJECT )
+ // Kann zu Absturz, z.B. bei Selections-Objekt fuehren
+ // Type == Object heisst nicht, dass pVar == Object!
+ ; // aHelpText = ((SbxObject*)pVar)->GetClassName();
+ else if ( eType & SbxARRAY )
+ ; // aHelpText = "{...}";
+ else if ( (BYTE)eType != (BYTE)SbxEMPTY )
+ {
+ aHelpText = pVar->GetName();
+ if ( !aHelpText.Len() ) // Bei Uebergabeparametern wird der Name nicht kopiert
+ aHelpText = aWord;
+ aHelpText += '=';
+ aHelpText += pVar->GetString();
+ }
+ }
+ if ( aHelpText.Len() )
+ {
+ aTopLeft = GetEditView()->GetTextEngine()->PaMtoEditCursor( aStartOfWord ).BottomLeft();
+ aTopLeft = GetEditView()->GetWindowPos( aTopLeft );
+ aTopLeft.X() += 5;
+ aTopLeft.Y() += 5;
+ aTopLeft = OutputToScreenPixel( aTopLeft );
+ }
+ }
+ }
+ Help::ShowQuickHelp( this, Rectangle( aTopLeft, Size( 1, 1 ) ), aHelpText, QUICKHELP_TOP|QUICKHELP_LEFT);
+ bDone = TRUE;
+ }
+ }
+
+ if ( !bDone )
+ Window::RequestHelp( rHEvt );
+}
+
+
+void __EXPORT EditorWindow::Resize()
+{
+ // ScrollBars, etc. passiert in Adjust...
+ if ( pEditView )
+ {
+ long nVisY = pEditView->GetStartDocPos().Y();
+// pEditView->SetOutputArea( Rectangle( Point( 0, 0 ), GetOutputSize() ) );
+ pEditView->ShowCursor();
+ Size aOutSz( GetOutputSizePixel() );
+ long nMaxVisAreaStart = pEditView->GetTextEngine()->GetTextHeight() - aOutSz.Height();
+ if ( nMaxVisAreaStart < 0 )
+ nMaxVisAreaStart = 0;
+ if ( pEditView->GetStartDocPos().Y() > nMaxVisAreaStart )
+ {
+ Point aStartDocPos( pEditView->GetStartDocPos() );
+ aStartDocPos.Y() = nMaxVisAreaStart;
+ pEditView->SetStartDocPos( aStartDocPos );
+ pEditView->ShowCursor();
+ pModulWindow->GetBreakPointWindow().GetCurYOffset() = aStartDocPos.Y();
+ }
+ InitScrollBars();
+ if ( nVisY != pEditView->GetStartDocPos().Y() )
+ Invalidate();
+ }
+}
+
+
+
+void __EXPORT EditorWindow::MouseMove( const MouseEvent &rEvt )
+{
+ if ( pEditView )
+ pEditView->MouseMove( rEvt );
+}
+
+
+
+void __EXPORT EditorWindow::MouseButtonUp( const MouseEvent &rEvt )
+{
+ if ( pEditView )
+ {
+ pEditView->MouseButtonUp( rEvt );
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_BASICIDE_STAT_POS );
+ }
+}
+
+void __EXPORT EditorWindow::MouseButtonDown( const MouseEvent &rEvt )
+{
+ GrabFocus();
+ if ( pEditView )
+ {
+ pEditView->MouseButtonDown( rEvt );
+ }
+}
+
+void __EXPORT EditorWindow::Command( const CommandEvent& rCEvt )
+{
+ if ( pEditView )
+ {
+ pEditView->Command( rCEvt );
+ if ( ( rCEvt.GetCommand() == COMMAND_WHEEL ) ||
+ ( rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL ) ||
+ ( rCEvt.GetCommand() == COMMAND_AUTOSCROLL ) )
+ {
+ HandleScrollCommand( rCEvt, pModulWindow->GetHScrollBar(), &pModulWindow->GetEditVScrollBar() );
+ }
+ }
+}
+
+BOOL EditorWindow::ImpCanModify()
+{
+ BOOL bCanModify = TRUE;
+ if ( StarBASIC::IsRunning() )
+ {
+ // Wenn im Trace-Mode, entweder Trace abbrechen oder
+ // Eingabe verweigern
+ // Im Notify bei Basic::Stoped die Markierungen in den Modulen
+ // entfernen!
+ if ( QueryBox( 0, WB_OK_CANCEL, String( IDEResId( RID_STR_WILLSTOPPRG ) ) ).Execute() == RET_OK )
+ {
+ pModulWindow->GetBasicStatus().bIsRunning = FALSE;
+ BasicIDE::StopBasic();
+ }
+ else
+ bCanModify = FALSE;
+ }
+ return bCanModify;
+}
+
+void __EXPORT EditorWindow::KeyInput( const KeyEvent& rKEvt )
+{
+ if ( !pEditView ) // Passiert unter W95 bei letzte Version, Ctrl-Tab
+ return;
+
+#if OSL_DEBUG_LEVEL > 1
+ Range aRange = pModulWindow->GetHScrollBar()->GetRange(); (void)aRange;
+ long nVisSz = pModulWindow->GetHScrollBar()->GetVisibleSize(); (void)nVisSz;
+ long nPapSz = pModulWindow->GetHScrollBar()->GetPageSize(); (void)nPapSz;
+ long nLinSz = pModulWindow->GetHScrollBar()->GetLineSize(); (void)nLinSz;
+ long nThumb = pModulWindow->GetHScrollBar()->GetThumbPos(); (void)nThumb;
+#endif
+ BOOL bDone = FALSE;
+ BOOL bWasModified = pEditEngine->IsModified();
+ if ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() )
+ {
+ if ( ( rKEvt.GetKeyCode().GetCode() == KEY_A) && rKEvt.GetKeyCode().IsMod1() )
+ pEditView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) );
+ else if ( ( rKEvt.GetKeyCode().GetCode() == KEY_Y ) && rKEvt.GetKeyCode().IsMod1() )
+ bDone = TRUE; // CTRL-Y schlucken, damit kein Vorlagenkatalog
+ else
+ {
+ if ( ( rKEvt.GetKeyCode().GetCode() == KEY_TAB ) && !rKEvt.GetKeyCode().IsMod1() &&
+ !rKEvt.GetKeyCode().IsMod2() && !GetEditView()->IsReadOnly() )
+ {
+ TextSelection aSel( pEditView->GetSelection() );
+ if ( aSel.GetStart().GetPara() != aSel.GetEnd().GetPara() )
+ {
+ bDelayHighlight = FALSE;
+ if ( !rKEvt.GetKeyCode().IsShift() )
+ pEditView->IndentBlock();
+ else
+ pEditView->UnindentBlock();
+ bDelayHighlight = TRUE;
+ bDone = TRUE;
+ }
+ }
+ if ( !bDone )
+ bDone = pEditView->KeyInput( rKEvt );
+ }
+ }
+ if ( !bDone )
+ {
+ if ( !SfxViewShell::Current()->KeyInput( rKEvt ) )
+ Window::KeyInput( rKEvt );
+ }
+ else
+ {
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ {
+ pBindings->Invalidate( SID_BASICIDE_STAT_POS );
+ if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR )
+ pBindings->Update( SID_BASICIDE_STAT_POS );
+ if ( !bWasModified && pEditEngine->IsModified() )
+ {
+ pBindings->Invalidate( SID_SAVEDOC );
+ pBindings->Invalidate( SID_DOC_MODIFIED );
+ }
+ if ( rKEvt.GetKeyCode().GetCode() == KEY_INSERT )
+ pBindings->Invalidate( SID_ATTR_INSERT );
+ }
+ }
+}
+
+void __EXPORT EditorWindow::Paint( const Rectangle& rRect )
+{
+ if ( !pEditEngine ) // spaetestens jetzt brauche ich sie...
+ CreateEditEngine();
+
+ pEditView->Paint( rRect );
+}
+
+void __EXPORT EditorWindow::LoseFocus()
+{
+ SetSourceInBasic();
+ Window::LoseFocus();
+}
+
+BOOL EditorWindow::SetSourceInBasic( BOOL bQuiet )
+{
+ (void)bQuiet;
+
+ BOOL bChanged = FALSE;
+ if ( pEditEngine && pEditEngine->IsModified()
+ && !GetEditView()->IsReadOnly() ) // Added because of #i60626, otherwise
+ // any read only bug in the text engine could lead to a crash later
+ {
+ if ( !StarBASIC::IsRunning() ) // Nicht zur Laufzeit!
+ {
+ ::rtl::OUString aModule = getTextEngineText( pEditEngine );
+
+ // update module in basic
+#ifdef DBG_UTIL
+ SbModule* pModule = pModulWindow->GetSbModule();
+#endif
+ DBG_ASSERT(pModule, "EditorWindow::SetSourceInBasic: No Module found!");
+
+ // update module in module window
+ pModulWindow->SetModule( aModule );
+
+ // update module in library
+ ScriptDocument aDocument( pModulWindow->GetDocument() );
+ String aLibName = pModulWindow->GetLibName();
+ String aName = pModulWindow->GetName();
+ OSL_VERIFY( aDocument.updateModule( aLibName, aName, aModule ) );
+
+ pEditEngine->SetModified( FALSE );
+ BasicIDE::MarkDocumentModified( aDocument );
+ bChanged = TRUE;
+ }
+ }
+ return bChanged;
+}
+
+
+// Returns the position of the last character of any of the following
+// EOL char combinations: CR, CR/LF, LF, return -1 if no EOL is found
+sal_Int32 searchEOL( const ::rtl::OUString& rStr, sal_Int32 fromIndex )
+{
+ sal_Int32 iRetPos = -1;
+
+ sal_Int32 iLF = rStr.indexOf( LINE_SEP, fromIndex );
+ if( iLF != -1 )
+ {
+ iRetPos = iLF;
+ }
+ else
+ {
+ iRetPos = rStr.indexOf( LINE_SEP_CR, fromIndex );
+ }
+ return iRetPos;
+}
+
+
+void EditorWindow::CreateEditEngine()
+{
+ if ( pEditEngine )
+ return;
+
+ pEditEngine = new ExtTextEngine;
+ pEditView = new ExtTextView( pEditEngine, this );
+ pEditView->SetAutoIndentMode( TRUE );
+ pEditEngine->SetUpdateMode( FALSE );
+ pEditEngine->InsertView( pEditView );
+
+ ImplSetFont();
+
+ aSyntaxIdleTimer.SetTimeout( 200 );
+ aSyntaxIdleTimer.SetTimeoutHdl( LINK( this, EditorWindow, SyntaxTimerHdl ) );
+
+ aHighlighter.initialize( HIGHLIGHT_BASIC );
+
+ BOOL bWasDoSyntaxHighlight = bDoSyntaxHighlight;
+ bDoSyntaxHighlight = FALSE; // Bei grossen Texten zu langsam...
+ ::rtl::OUString aOUSource( pModulWindow->GetModule() );
+ sal_Int32 nLines = 0;
+ sal_Int32 nIndex = -1;
+ do
+ {
+ nLines++;
+ nIndex = searchEOL( aOUSource, nIndex+1 );
+ }
+ while ( nIndex >= 0 );
+
+ // nLines*4: SetText+Formatting+DoHighlight+Formatting
+ // 1 Formatting koennte eingespart werden, aber dann wartet man
+ // bei einem langen Sourcecode noch laenger auf den Text...
+ pProgress = new ProgressInfo( IDE_DLL()->GetShell()->GetViewFrame()->GetObjectShell(), String( IDEResId( RID_STR_GENERATESOURCE ) ), nLines*4 );
+ setTextEngineText( pEditEngine, aOUSource );
+
+ pEditView->SetStartDocPos( Point( 0, 0 ) );
+ pEditView->SetSelection( TextSelection() );
+ pModulWindow->GetBreakPointWindow().GetCurYOffset() = 0;
+ pEditEngine->SetUpdateMode( TRUE );
+ Update(); // Es wurde bei UpdateMode = TRUE nur Invalidiert
+
+ // Die anderen Fenster auch, damit keine halben Sachen auf dem Bildschirm!
+ pModulWindow->GetLayout()->GetWatchWindow().Update();
+ pModulWindow->GetLayout()->GetStackWindow().Update();
+ pModulWindow->GetBreakPointWindow().Update();
+
+ pEditView->ShowCursor( TRUE, TRUE );
+
+ StartListening( *pEditEngine );
+
+ // Das Syntax-Highlightning legt ein rel. groesse VDev an.
+ aSyntaxIdleTimer.Stop();
+ bDoSyntaxHighlight = bWasDoSyntaxHighlight;
+
+
+ for ( USHORT nLine = 0; nLine < nLines; nLine++ )
+ aSyntaxLineTable.Insert( nLine, (void*)(USHORT)1 );
+ ForceSyntaxTimeout();
+
+ DELETEZ( pProgress );
+
+ pEditView->EraseVirtualDevice();
+ pEditEngine->SetModified( FALSE );
+ pEditEngine->EnableUndo( TRUE );
+
+ InitScrollBars();
+
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_BASICIDE_STAT_POS );
+
+ DBG_ASSERT( pModulWindow->GetBreakPointWindow().GetCurYOffset() == 0, "CreateEditEngine: Brechpunkte verschoben?" );
+
+ // set readonly mode for readonly libraries
+ ScriptDocument aDocument( pModulWindow->GetDocument() );
+ ::rtl::OUString aOULibName( pModulWindow->GetLibName() );
+ Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) )
+ {
+ pModulWindow->SetReadOnly( TRUE );
+ }
+
+ if ( aDocument.isDocument() && aDocument.isReadOnly() )
+ pModulWindow->SetReadOnly( TRUE );
+}
+
+// virtual
+void EditorWindow::DataChanged(DataChangedEvent const & rDCEvt)
+{
+ Window::DataChanged(rDCEvt);
+ if (rDCEvt.GetType() == DATACHANGED_SETTINGS
+ && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
+ {
+ Color aColor(GetSettings().GetStyleSettings().GetFieldColor());
+ if (aColor
+ != rDCEvt.GetOldSettings()->GetStyleSettings().GetFieldColor())
+ {
+ SetBackground(Wallpaper(aColor));
+ Invalidate();
+ }
+ if (pEditEngine != 0)
+ {
+ aColor = GetSettings().GetStyleSettings().GetFieldTextColor();
+ if (aColor != rDCEvt.GetOldSettings()->
+ GetStyleSettings().GetFieldTextColor())
+ {
+ Font aFont(pEditEngine->GetFont());
+ aFont.SetColor(aColor);
+ pEditEngine->SetFont(aFont);
+ }
+ }
+ }
+}
+
+void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+{
+ if ( rHint.ISA( TextHint ) )
+ {
+ const TextHint& rTextHint = (const TextHint&)rHint;
+ if( rTextHint.GetId() == TEXT_HINT_VIEWSCROLLED )
+ {
+ if ( pModulWindow->GetHScrollBar() )
+ pModulWindow->GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
+ pModulWindow->GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() );
+ pModulWindow->GetBreakPointWindow().DoScroll
+ ( 0, pModulWindow->GetBreakPointWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() );
+ }
+ else if( rTextHint.GetId() == TEXT_HINT_TEXTHEIGHTCHANGED )
+ {
+ if ( pEditView->GetStartDocPos().Y() )
+ {
+ long nOutHeight = GetOutputSizePixel().Height();
+ long nTextHeight = pEditEngine->GetTextHeight();
+ if ( nTextHeight < nOutHeight )
+ pEditView->Scroll( 0, pEditView->GetStartDocPos().Y() );
+ }
+
+ SetScrollBarRanges();
+ }
+ else if( rTextHint.GetId() == TEXT_HINT_TEXTFORMATTED )
+ {
+ if ( pModulWindow->GetHScrollBar() )
+ {
+ ULONG nWidth = pEditEngine->CalcTextWidth();
+ if ( (long)nWidth != nCurTextWidth )
+ {
+ nCurTextWidth = nWidth;
+ pModulWindow->GetHScrollBar()->SetRange( Range( 0, (long)nCurTextWidth-1) );
+ pModulWindow->GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
+ }
+ }
+ long nPrevTextWidth = nCurTextWidth;
+ nCurTextWidth = pEditEngine->CalcTextWidth();
+ if ( nCurTextWidth != nPrevTextWidth )
+ SetScrollBarRanges();
+ }
+ else if( rTextHint.GetId() == TEXT_HINT_PARAINSERTED )
+ {
+ ParagraphInsertedDeleted( rTextHint.GetValue(), TRUE );
+ DoDelayedSyntaxHighlight( rTextHint.GetValue() );
+ }
+ else if( rTextHint.GetId() == TEXT_HINT_PARAREMOVED )
+ {
+ ParagraphInsertedDeleted( rTextHint.GetValue(), FALSE );
+ }
+ else if( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED )
+ {
+ DoDelayedSyntaxHighlight( rTextHint.GetValue() );
+ }
+ }
+}
+
+void EditorWindow::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
+{
+ ImplSetFont();
+}
+
+void EditorWindow::SetScrollBarRanges()
+{
+ // Extra-Methode, nicht InitScrollBars, da auch fuer EditEngine-Events.
+ if ( !pEditEngine )
+ return;
+
+ if ( pModulWindow->GetHScrollBar() )
+ pModulWindow->GetHScrollBar()->SetRange( Range( 0, nCurTextWidth-1 ) );
+
+ pModulWindow->GetEditVScrollBar().SetRange( Range( 0, pEditEngine->GetTextHeight()-1 ) );
+}
+
+void EditorWindow::InitScrollBars()
+{
+ if ( !pEditEngine )
+ return;
+
+ SetScrollBarRanges();
+ Size aOutSz( GetOutputSizePixel() );
+ pModulWindow->GetEditVScrollBar().SetVisibleSize( aOutSz.Height() );
+ pModulWindow->GetEditVScrollBar().SetPageSize( aOutSz.Height() * 8 / 10 );
+ pModulWindow->GetEditVScrollBar().SetLineSize( GetTextHeight() );
+ pModulWindow->GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() );
+ pModulWindow->GetEditVScrollBar().Show();
+
+ if ( pModulWindow->GetHScrollBar() )
+ {
+ pModulWindow->GetHScrollBar()->SetVisibleSize( aOutSz.Width() );
+ pModulWindow->GetHScrollBar()->SetPageSize( aOutSz.Width() * 8 / 10 );
+ pModulWindow->GetHScrollBar()->SetLineSize( GetTextWidth( 'x' ) );
+ pModulWindow->GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
+ pModulWindow->GetHScrollBar()->Show();
+ }
+}
+
+void EditorWindow::ImpDoHighlight( ULONG nLine )
+{
+ if ( bDoSyntaxHighlight )
+ {
+ String aLine( pEditEngine->GetText( nLine ) );
+ Range aChanges = aHighlighter.notifyChange( nLine, 0, &aLine, 1 );
+ if ( aChanges.Len() )
+ {
+ for ( long n = aChanges.Min() + 1; n <= aChanges.Max(); n++ )
+ aSyntaxLineTable.Insert( n, (void*)(ULONG)1 );
+ aSyntaxIdleTimer.Start();
+ }
+
+ BOOL bWasModified = pEditEngine->IsModified();
+ pEditEngine->RemoveAttribs( nLine, TRUE );
+ HighlightPortions aPortions;
+ aHighlighter.getHighlightPortions( nLine, aLine, aPortions );
+ USHORT nCount = aPortions.Count();
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ HighlightPortion& r = aPortions[i];
+ const Color& rColor = ((ModulWindowLayout*)pModulWindow->GetLayoutWindow())->getSyntaxColor(r.tokenType);
+ pEditEngine->SetAttrib( TextAttribFontColor( rColor ), nLine, r.nBegin, r.nEnd, TRUE );
+ }
+
+ // Das Highlighten soll kein Modify setzen
+ pEditEngine->SetModified( bWasModified );
+ }
+}
+
+void EditorWindow::ImplSetFont()
+{
+ if ( pSourceViewConfig )
+ {
+ String sFontName = pSourceViewConfig->GetFontName();
+ if ( !sFontName.Len() )
+ {
+ Font aTmpFont( OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, Application::GetSettings().GetUILanguage(), 0 , this ) );
+ sFontName = aTmpFont.GetName();
+ }
+ Size aFontSize( 0, pSourceViewConfig->GetFontHeight() );
+ Font aFont( sFontName, aFontSize );
+ aFont.SetColor( GetSettings().GetStyleSettings().GetFieldTextColor() );
+ SetPointFont( aFont );
+ aFont = GetFont();
+
+ if ( pModulWindow )
+ pModulWindow->GetBreakPointWindow().SetFont( aFont );
+
+ if ( pEditEngine )
+ {
+ BOOL bModified = pEditEngine->IsModified();
+ pEditEngine->SetFont( aFont );
+ pEditEngine->SetModified( bModified );
+ }
+ }
+}
+
+void EditorWindow::DoSyntaxHighlight( ULONG nPara )
+{
+ // Durch das DelayedSyntaxHighlight kann es passieren,
+ // dass die Zeile nicht mehr existiert!
+ if ( nPara < pEditEngine->GetParagraphCount() )
+ {
+ // leider weis ich nicht, ob genau diese Zeile Modified() ...
+ if ( pProgress )
+ pProgress->StepProgress();
+ ImpDoHighlight( nPara );
+ }
+}
+
+void EditorWindow::DoDelayedSyntaxHighlight( ULONG nPara )
+{
+ // Zeile wird nur in 'Liste' aufgenommen, im TimerHdl abgearbeitet.
+ // => Nicht Absaetze manipulieren, waehrend EditEngine formatiert.
+ if ( pProgress )
+ pProgress->StepProgress();
+
+ if ( !bHighlightning && bDoSyntaxHighlight )
+ {
+ if ( bDelayHighlight )
+ {
+ aSyntaxLineTable.Insert( nPara, (void*)(ULONG)1 );
+ aSyntaxIdleTimer.Start();
+ }
+ else
+ DoSyntaxHighlight( nPara );
+ }
+}
+
+IMPL_LINK( EditorWindow, SyntaxTimerHdl, Timer *, EMPTYARG )
+{
+ DBG_ASSERT( pEditView, "Noch keine View, aber Syntax-Highlight ?!" );
+
+ BOOL bWasModified = pEditEngine->IsModified();
+ // pEditEngine->SetUpdateMode( FALSE );
+
+ bHighlightning = TRUE;
+ USHORT nLine;
+ void* p = aSyntaxLineTable.First();
+ while ( p )
+ {
+ nLine = (USHORT)aSyntaxLineTable.GetCurKey();
+ DoSyntaxHighlight( nLine );
+ p = aSyntaxLineTable.Next();
+ }
+
+ // MT: Removed, because of idle format now when set/remove attribs...
+ // pEditView->SetAutoScroll( FALSE ); // #101043# Don't scroll because of syntax highlight
+ // pEditEngine->SetUpdateMode( TRUE );
+ // pEditView->ShowCursor( FALSE, TRUE );
+ // pEditView->SetAutoScroll( TRUE );
+
+ // #i45572#
+ if ( pEditView )
+ pEditView->ShowCursor( FALSE, TRUE );
+
+ pEditEngine->SetModified( bWasModified );
+
+ aSyntaxLineTable.Clear();
+ bHighlightning = FALSE;
+
+ return 0;
+}
+
+void EditorWindow::ParagraphInsertedDeleted( ULONG nPara, BOOL bInserted )
+{
+ if ( pProgress )
+ pProgress->StepProgress();
+
+ if ( !bInserted && ( nPara == TEXT_PARA_ALL ) )
+ {
+ pModulWindow->GetBreakPoints().reset();
+ pModulWindow->GetBreakPointWindow().Invalidate();
+ aHighlighter.initialize( HIGHLIGHT_BASIC );
+ }
+ else
+ {
+ // Brechpunkte Aktualisieren...
+ // keine Sonderbehandlung fuer EditEngine-CTOR ( Erste-Zeile-Problem ),
+ // da in diesem Moment noch keine BreakPoints.
+ // +1: Basic-Zeilen beginnen bei 1!
+ pModulWindow->GetBreakPoints().AdjustBreakPoints( (USHORT)nPara+1, bInserted );
+
+ // Im BreakPointWindow invalidieren...
+ long nLineHeight = GetTextHeight();
+ Size aSz = pModulWindow->GetBreakPointWindow().GetOutputSize();
+ Rectangle aInvRec( Point( 0, 0 ), aSz );
+ long nY = nPara*nLineHeight - pModulWindow->GetBreakPointWindow().GetCurYOffset();
+ aInvRec.Top() = nY;
+ pModulWindow->GetBreakPointWindow().Invalidate( aInvRec );
+
+ if ( bDoSyntaxHighlight )
+ {
+ String aDummy;
+ aHighlighter.notifyChange( nPara, bInserted ? 1 : (-1), &aDummy, 1 );
+ }
+ }
+}
+
+void EditorWindow::CreateProgress( const String& rText, ULONG nRange )
+{
+ DBG_ASSERT( !pProgress, "ProgressInfo existiert schon" );
+ pProgress = new ProgressInfo( IDE_DLL()->GetShell()->GetViewFrame()->GetObjectShell(), rText, nRange );
+}
+
+void EditorWindow::DestroyProgress()
+{
+ DELETEZ( pProgress );
+}
+
+void EditorWindow::ForceSyntaxTimeout()
+{
+ aSyntaxIdleTimer.Stop();
+ ((Link&)aSyntaxIdleTimer.GetTimeoutHdl()).Call( &aSyntaxIdleTimer );
+}
+
+
+
+BreakPointWindow::BreakPointWindow( Window* pParent ) :
+ Window( pParent, WB_BORDER )
+{
+ pModulWindow = 0;
+ nCurYOffset = 0;
+ setBackgroundColor(GetSettings().GetStyleSettings().GetFieldColor());
+ m_bHighContrastMode = GetSettings().GetStyleSettings().GetHighContrastMode();
+ nMarkerPos = MARKER_NOMARKER;
+
+ // nCurYOffset merken und nicht von EditEngine holen.
+ // Falls in EditEngine autom. gescrollt wurde, wuesste ich sonst nicht,
+ // wo ich gerade stehe.
+
+ SetHelpId( HID_BASICIDE_BREAKPOINTWINDOW );
+}
+
+
+
+__EXPORT BreakPointWindow::~BreakPointWindow()
+{
+}
+
+
+
+void __EXPORT BreakPointWindow::Resize()
+{
+/// Invalidate();
+}
+
+
+
+void __EXPORT BreakPointWindow::Paint( const Rectangle& )
+{
+ if ( SyncYOffset() )
+ return;
+
+ Size aOutSz( GetOutputSize() );
+ long nLineHeight = GetTextHeight();
+
+ Image aBrk1(((ModulWindowLayout *) pModulWindow->GetLayoutWindow())->
+ getImage(IMGID_BRKENABLED, m_bHighContrastMode));
+ Image aBrk0(((ModulWindowLayout *) pModulWindow->GetLayoutWindow())->
+ getImage(IMGID_BRKDISABLED, m_bHighContrastMode));
+ Size aBmpSz( aBrk1.GetSizePixel() );
+ aBmpSz = PixelToLogic( aBmpSz );
+ Point aBmpOff( 0, 0 );
+ aBmpOff.X() = ( aOutSz.Width() - aBmpSz.Width() ) / 2;
+ aBmpOff.Y() = ( nLineHeight - aBmpSz.Height() ) / 2;
+
+ BreakPoint* pBrk = GetBreakPoints().First();
+ while ( pBrk )
+ {
+ ULONG nLine = pBrk->nLine-1;
+ ULONG nY = nLine*nLineHeight - nCurYOffset;
+ DrawImage( Point( 0, nY ) + aBmpOff, pBrk->bEnabled ? aBrk1 : aBrk0 );
+ pBrk = GetBreakPoints().Next();
+ }
+ ShowMarker( TRUE );
+}
+
+
+
+void BreakPointWindow::DoScroll( long nHorzScroll, long nVertScroll )
+{
+ nCurYOffset -= nVertScroll;
+ Window::Scroll( nHorzScroll, nVertScroll );
+}
+
+
+
+void BreakPointWindow::SetMarkerPos( USHORT nLine, BOOL bError )
+{
+ if ( SyncYOffset() )
+ Update();
+
+ ShowMarker( FALSE ); // Alten wegzeichen...
+ nMarkerPos = nLine;
+ bErrorMarker = bError;
+ ShowMarker( TRUE ); // Neuen zeichnen...
+}
+
+void BreakPointWindow::ShowMarker( BOOL bShow )
+{
+ if ( nMarkerPos == MARKER_NOMARKER )
+ return;
+
+ Size aOutSz( GetOutputSize() );
+ long nLineHeight = GetTextHeight();
+
+ Image aMarker(((ModulWindowLayout*)pModulWindow->GetLayoutWindow())->
+ getImage(bErrorMarker
+ ? IMGID_ERRORMARKER : IMGID_STEPMARKER,
+ m_bHighContrastMode));
+
+ Size aMarkerSz( aMarker.GetSizePixel() );
+ aMarkerSz = PixelToLogic( aMarkerSz );
+ Point aMarkerOff( 0, 0 );
+ aMarkerOff.X() = ( aOutSz.Width() - aMarkerSz.Width() ) / 2;
+ aMarkerOff.Y() = ( nLineHeight - aMarkerSz.Height() ) / 2;
+
+ ULONG nY = nMarkerPos*nLineHeight - nCurYOffset;
+ Point aPos( 0, nY );
+ aPos += aMarkerOff;
+ if ( bShow )
+ DrawImage( aPos, aMarker );
+ else
+ Invalidate( Rectangle( aPos, aMarkerSz ) );
+}
+
+
+
+
+BreakPoint* BreakPointWindow::FindBreakPoint( const Point& rMousePos )
+{
+ long nLineHeight = GetTextHeight();
+ long nYPos = rMousePos.Y() + nCurYOffset;
+// Image aBrk( ((ModulWindowLayout*)pModulWindow->GetLayoutWindow())->GetImage( IMGID_BRKENABLED ) );
+// Size aBmpSz( aBrk.GetSizePixel() );
+// aBmpSz = PixelToLogic( aBmpSz );
+
+ BreakPoint* pBrk = GetBreakPoints().First();
+ while ( pBrk )
+ {
+ ULONG nLine = pBrk->nLine-1;
+ long nY = nLine*nLineHeight;
+ if ( ( nYPos > nY ) && ( nYPos < ( nY + nLineHeight ) ) )
+ return pBrk;
+ pBrk = GetBreakPoints().Next();
+ }
+ return 0;
+}
+
+void __EXPORT BreakPointWindow::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if ( rMEvt.GetClicks() == 2 )
+ {
+ Point aMousePos( PixelToLogic( rMEvt.GetPosPixel() ) );
+ long nLineHeight = GetTextHeight();
+ long nYPos = aMousePos.Y() + nCurYOffset;
+ long nLine = nYPos / nLineHeight + 1;
+ pModulWindow->ToggleBreakPoint( (ULONG)nLine );
+ // vielleicht mal etwas genauer...
+ Invalidate();
+ }
+}
+
+
+
+void __EXPORT BreakPointWindow::Command( const CommandEvent& rCEvt )
+{
+ if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
+ {
+ Point aPos( rCEvt.IsMouseEvent() ? rCEvt.GetMousePosPixel() : Point(1,1) );
+ Point aEventPos( PixelToLogic( aPos ) );
+ BreakPoint* pBrk = rCEvt.IsMouseEvent() ? FindBreakPoint( aEventPos ) : 0;
+ if ( pBrk )
+ {
+ // prueffen, ob Brechpunkt enabled....
+ PopupMenu aBrkPropMenu( IDEResId( RID_POPUP_BRKPROPS ) );
+ aBrkPropMenu.CheckItem( RID_ACTIV, pBrk->bEnabled );
+ switch ( aBrkPropMenu.Execute( this, aPos ) )
+ {
+ case RID_ACTIV:
+ {
+ pBrk->bEnabled = pBrk->bEnabled ? FALSE : TRUE;
+ pModulWindow->UpdateBreakPoint( *pBrk );
+ Invalidate();
+ }
+ break;
+ case RID_BRKPROPS:
+ {
+ BreakPointDialog aBrkDlg( this, GetBreakPoints() );
+ aBrkDlg.SetCurrentBreakPoint( pBrk );
+ aBrkDlg.Execute();
+ Invalidate();
+ }
+ break;
+ }
+ }
+ else
+ {
+ PopupMenu aBrkListMenu( IDEResId( RID_POPUP_BRKDLG ) );
+ switch ( aBrkListMenu.Execute( this, aPos ) )
+ {
+ case RID_BRKDLG:
+ {
+ BreakPointDialog aBrkDlg( this, GetBreakPoints() );
+ aBrkDlg.Execute();
+ Invalidate();
+ }
+ break;
+ }
+ }
+ }
+}
+
+BOOL BreakPointWindow::SyncYOffset()
+{
+ TextView* pView = pModulWindow->GetEditView();
+ if ( pView )
+ {
+ long nViewYOffset = pView->GetStartDocPos().Y();
+ if ( nCurYOffset != nViewYOffset )
+ {
+ nCurYOffset = nViewYOffset;
+ Invalidate();
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+// virtual
+void BreakPointWindow::DataChanged(DataChangedEvent const & rDCEvt)
+{
+ Window::DataChanged(rDCEvt);
+ if (rDCEvt.GetType() == DATACHANGED_SETTINGS
+ && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
+ {
+ Color aColor(GetSettings().GetStyleSettings().GetFieldColor());
+ if (aColor
+ != rDCEvt.GetOldSettings()->GetStyleSettings().GetFieldColor())
+ {
+ setBackgroundColor(aColor);
+ m_bHighContrastMode = GetSettings().GetStyleSettings().GetHighContrastMode();
+ Invalidate();
+ }
+ }
+}
+
+void BreakPointWindow::setBackgroundColor(Color aColor)
+{
+ SetBackground(Wallpaper(aColor));
+}
+
+
+const USHORT ITEM_ID_VARIABLE = 1;
+const USHORT ITEM_ID_VALUE = 2;
+const USHORT ITEM_ID_TYPE = 3;
+
+WatchWindow::WatchWindow( Window* pParent ) :
+ BasicDockingWindow( pParent ),
+ aWatchStr( IDEResId( RID_STR_REMOVEWATCH ) ),
+ aXEdit( this, IDEResId( RID_EDT_WATCHEDIT ) ),
+ aRemoveWatchButton( this, IDEResId( RID_IMGBTN_REMOVEWATCH ) ),
+ aTreeListBox( this, WB_BORDER | WB_3DLOOK | WB_HASBUTTONS | WB_HASLINES | WB_HSCROLL | WB_TABSTOP
+ | WB_HASLINESATROOT | WB_HASBUTTONSATROOT ),
+ aHeaderBar( this, WB_BUTTONSTYLE | WB_BORDER )
+{
+ nVirtToolBoxHeight = aXEdit.GetSizePixel().Height() + 7;
+ nHeaderBarHeight = 16;
+
+ aTreeListBox.SetHelpId(HID_BASICIDE_WATCHWINDOW_LIST);
+ aTreeListBox.EnableInplaceEditing( TRUE );
+ aTreeListBox.SetSelectHdl( LINK( this, WatchWindow, TreeListHdl ) );
+ aTreeListBox.SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight + nHeaderBarHeight ) );
+ aTreeListBox.SetHighlightRange( 1, 5 );
+
+ Point aPnt( DWBORDER, nVirtToolBoxHeight + 1 );
+ aHeaderBar.SetPosPixel( aPnt );
+ aHeaderBar.SetEndDragHdl( LINK( this, WatchWindow, implEndDragHdl ) );
+
+ long nVarTabWidth = 220;
+ long nValueTabWidth = 100;
+ long nTypeTabWidth = 1250;
+ aHeaderBar.InsertItem( ITEM_ID_VARIABLE, String( IDEResId( RID_STR_WATCHVARIABLE ) ), nVarTabWidth );
+ aHeaderBar.InsertItem( ITEM_ID_VALUE, String( IDEResId( RID_STR_WATCHVALUE ) ), nValueTabWidth );
+ aHeaderBar.InsertItem( ITEM_ID_TYPE, String( IDEResId( RID_STR_WATCHTYPE ) ), nTypeTabWidth );
+
+ long tabs[ 4 ];
+ tabs[ 0 ] = 3; // two tabs
+ tabs[ 1 ] = 0;
+ tabs[ 2 ] = nVarTabWidth;
+ tabs[ 3 ] = nVarTabWidth + nValueTabWidth;
+ aTreeListBox.SvHeaderTabListBox::SetTabs( tabs, MAP_PIXEL );
+ aTreeListBox.InitHeaderBar( &aHeaderBar );
+
+ aTreeListBox.SetNodeDefaultImages( );
+
+ aHeaderBar.Show();
+
+ aRemoveWatchButton.Disable();
+
+ aTreeListBox.Show();
+
+ long nTextLen = GetTextWidth( aWatchStr ) + DWBORDER;
+ aXEdit.SetPosPixel( Point( nTextLen, 3 ) );
+ aXEdit.SetAccHdl( LINK( this, WatchWindow, EditAccHdl ) );
+ aXEdit.GetAccelerator().InsertItem( 1, KeyCode( KEY_RETURN ) );
+ aXEdit.GetAccelerator().InsertItem( 2, KeyCode( KEY_ESCAPE ) );
+ aXEdit.Show();
+
+ aRemoveWatchButton.SetModeImage(Image(IDEResId(RID_IMG_REMOVEWATCH_HC)),
+ BMP_COLOR_HIGHCONTRAST);
+ aRemoveWatchButton.SetClickHdl( LINK( this, WatchWindow, ButtonHdl ) );
+ aRemoveWatchButton.SetPosPixel( Point( nTextLen + aXEdit.GetSizePixel().Width() + 4, 2 ) );
+ Size aSz( aRemoveWatchButton.GetModeImage().GetSizePixel() );
+ aSz.Width() += 6;
+ aSz.Height() += 6;
+ aRemoveWatchButton.SetSizePixel( aSz );
+ aRemoveWatchButton.Show();
+
+ SetText( String( IDEResId( RID_STR_WATCHNAME ) ) );
+
+ SetHelpId( HID_BASICIDE_WATCHWINDOW );
+
+ // make watch window keyboard accessible
+ GetSystemWindow()->GetTaskPaneList()->AddWindow( this );
+}
+
+
+
+__EXPORT WatchWindow::~WatchWindow()
+{
+ GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this );
+}
+
+
+
+void __EXPORT WatchWindow::Paint( const Rectangle& )
+{
+ DrawText( Point( DWBORDER, 7 ), aWatchStr );
+ lcl_DrawIDEWindowFrame( this );
+}
+
+
+
+void __EXPORT WatchWindow::Resize()
+{
+ Size aSz = GetOutputSizePixel();
+ Size aBoxSz( aSz.Width() - 2*DWBORDER, aSz.Height() - nVirtToolBoxHeight - DWBORDER );
+
+ if ( aBoxSz.Width() < 4 ) // < 4, weil noch Border...
+ aBoxSz.Width() = 0;
+ if ( aBoxSz.Height() < 4 )
+ aBoxSz.Height() = 0;
+
+ aBoxSz.Height() -= nHeaderBarHeight;
+ aTreeListBox.SetSizePixel( aBoxSz );
+ aTreeListBox.GetHScroll()->SetPageSize( aTreeListBox.GetHScroll()->GetVisibleSize() );
+
+ aBoxSz.Height() = nHeaderBarHeight;
+ aHeaderBar.SetSizePixel( aBoxSz );
+
+ Invalidate(); //Wegen DrawLine im Paint...
+}
+
+struct MemberList
+{
+ String* mpMemberNames;
+ int mnMemberCount;
+
+ MemberList( void )
+ : mpMemberNames( NULL )
+ , mnMemberCount( 0 )
+ {}
+ ~MemberList()
+ {
+ clear();
+ }
+
+ void clear( void );
+ void allocList( int nCount );
+};
+
+void MemberList::clear( void )
+{
+ if( mnMemberCount )
+ {
+ delete[] mpMemberNames;
+ mnMemberCount = 0;
+ }
+}
+
+void MemberList::allocList( int nCount )
+{
+ clear();
+ if( nCount > 0 )
+ {
+ mnMemberCount = nCount;
+ mpMemberNames = new String[ mnMemberCount ];
+ }
+}
+
+struct WatchItem
+{
+ String maName;
+ String maDisplayName;
+ SbxObjectRef mpObject;
+ MemberList maMemberList;
+
+ SbxDimArrayRef mpArray;
+ int nDimLevel; // 0 = Root
+ int nDimCount;
+ short* pIndices;
+
+ WatchItem* mpArrayParentItem;
+
+ WatchItem( void )
+ : nDimLevel( 0 )
+ , nDimCount( 0 )
+ , pIndices( NULL )
+ , mpArrayParentItem( NULL )
+ {}
+ ~WatchItem()
+ { clearWatchItem(); }
+
+ void clearWatchItem( bool bIncludeArrayData=true )
+ {
+ mpObject = NULL;
+ maMemberList.clear();
+ if( bIncludeArrayData )
+ {
+ mpArray = NULL;
+ nDimLevel = 0;
+ nDimCount = 0;
+ delete[] pIndices;
+ pIndices = NULL;
+ }
+ }
+
+ WatchItem* GetRootItem( void );
+ SbxDimArray* GetRootArray( void );
+};
+
+WatchItem* WatchItem::GetRootItem( void )
+{
+ WatchItem* pItem = mpArrayParentItem;
+ while( pItem )
+ {
+ if( pItem->mpArray.Is() )
+ break;
+ pItem = pItem->mpArrayParentItem;
+ }
+ return pItem;
+}
+
+SbxDimArray* WatchItem::GetRootArray( void )
+{
+ WatchItem* pRootItem = GetRootItem();
+ SbxDimArray* pRet = NULL;
+ if( pRootItem )
+ pRet = pRootItem->mpArray;
+ return pRet;
+}
+
+void WatchWindow::AddWatch( const String& rVName )
+{
+ WatchItem* pWatchItem = new WatchItem;
+ String aVar, aIndex;
+ lcl_SeparateNameAndIndex( rVName, aVar, aIndex );
+ pWatchItem->maName = aVar;
+
+ String aWatchStr_( aVar );
+ aWatchStr_ += String( RTL_CONSTASCII_USTRINGPARAM( "\t\t" ) );
+ SvLBoxEntry* pNewEntry = aTreeListBox.InsertEntry( aWatchStr_, 0, TRUE, LIST_APPEND );
+ pNewEntry->SetUserData( pWatchItem );
+
+ aTreeListBox.Select( pNewEntry, TRUE );
+ aTreeListBox.MakeVisible( pNewEntry );
+ aRemoveWatchButton.Enable();
+}
+
+BOOL WatchWindow::RemoveSelectedWatch()
+{
+ SvLBoxEntry* pEntry = aTreeListBox.GetCurEntry();
+ if ( pEntry )
+ {
+ aTreeListBox.GetModel()->Remove( pEntry );
+ pEntry = aTreeListBox.GetCurEntry();
+ if ( pEntry )
+ aXEdit.SetText( ((WatchItem*)pEntry->GetUserData())->maName );
+ else
+ aXEdit.SetText( String() );
+ if ( !aTreeListBox.GetEntryCount() )
+ aRemoveWatchButton.Disable();
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+
+IMPL_LINK_INLINE_START( WatchWindow, ButtonHdl, ImageButton *, pButton )
+{
+ if ( pButton == &aRemoveWatchButton )
+ {
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_REMOVEWATCH );
+ }
+ }
+ return 0;
+}
+IMPL_LINK_INLINE_END( WatchWindow, ButtonHdl, ImageButton *, pButton )
+
+
+
+IMPL_LINK_INLINE_START( WatchWindow, TreeListHdl, SvTreeListBox *, EMPTYARG )
+{
+ SvLBoxEntry* pCurEntry = aTreeListBox.GetCurEntry();
+ if ( pCurEntry && pCurEntry->GetUserData() )
+ aXEdit.SetText( ((WatchItem*)pCurEntry->GetUserData())->maName );
+
+ return 0;
+}
+IMPL_LINK_INLINE_END( WatchWindow, TreeListHdl, SvTreeListBox *, EMPTYARG )
+
+
+IMPL_LINK_INLINE_START( WatchWindow, implEndDragHdl, HeaderBar *, pBar )
+{
+ (void)pBar;
+
+ const sal_Int32 TAB_WIDTH_MIN = 10;
+ sal_Int32 nMaxWidth =
+ aHeaderBar.GetSizePixel().getWidth() - 2 * TAB_WIDTH_MIN;
+
+ sal_Int32 nVariableWith = aHeaderBar.GetItemSize( ITEM_ID_VARIABLE );
+ if( nVariableWith < TAB_WIDTH_MIN )
+ aHeaderBar.SetItemSize( ITEM_ID_VARIABLE, TAB_WIDTH_MIN );
+ else if( nVariableWith > nMaxWidth )
+ aHeaderBar.SetItemSize( ITEM_ID_VARIABLE, nMaxWidth );
+
+ sal_Int32 nValueWith = aHeaderBar.GetItemSize( ITEM_ID_VALUE );
+ if( nValueWith < TAB_WIDTH_MIN )
+ aHeaderBar.SetItemSize( ITEM_ID_VALUE, TAB_WIDTH_MIN );
+ else if( nValueWith > nMaxWidth )
+ aHeaderBar.SetItemSize( ITEM_ID_VALUE, nMaxWidth );
+
+ if (aHeaderBar.GetItemSize( ITEM_ID_TYPE ) < TAB_WIDTH_MIN)
+ aHeaderBar.SetItemSize( ITEM_ID_TYPE, TAB_WIDTH_MIN );
+
+ sal_Int32 nPos = 0;
+ USHORT nTabs = aHeaderBar.GetItemCount();
+ // OSL_ASSERT( m_treelb->TabCount() == nTabs );
+ for( USHORT i = 1 ; i < nTabs ; ++i )
+ {
+ nPos += aHeaderBar.GetItemSize( i );
+ aTreeListBox.SetTab( i, nPos, MAP_PIXEL );
+ }
+ return 0;
+}
+IMPL_LINK_INLINE_END( WatchWindow, implEndDragHdl, HeaderBar *, pBar )
+
+
+IMPL_LINK( WatchWindow, EditAccHdl, Accelerator *, pAcc )
+{
+ switch ( pAcc->GetCurKeyCode().GetCode() )
+ {
+ case KEY_RETURN:
+ {
+ String aCurText( aXEdit.GetText() );
+ if ( aCurText.Len() )
+ {
+ AddWatch( aCurText );
+ aXEdit.SetSelection( Selection( 0, 0xFFFF ) );
+ UpdateWatches();
+ }
+ else
+ Sound::Beep();
+ }
+ break;
+ case KEY_ESCAPE:
+ {
+ aXEdit.SetText( String() );
+ }
+ break;
+ }
+
+ return 0;
+}
+
+void WatchWindow::UpdateWatches( bool bBasicStopped )
+{
+ aTreeListBox.UpdateWatches( bBasicStopped );
+}
+
+
+StackWindow::StackWindow( Window* pParent ) :
+ BasicDockingWindow( pParent ),
+ aTreeListBox( this, WB_BORDER | WB_3DLOOK | WB_HSCROLL | WB_TABSTOP ),
+ aGotoCallButton( this, IDEResId( RID_IMGBTN_GOTOCALL ) ),
+ aStackStr( IDEResId( RID_STR_STACK ) )
+{
+ aTreeListBox.SetHelpId(HID_BASICIDE_STACKWINDOW_LIST);
+ aTreeListBox.SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight ) );
+ aTreeListBox.SetHighlightRange();
+ aTreeListBox.SetSelectionMode( NO_SELECTION );
+ aTreeListBox.InsertEntry( String(), 0, FALSE, LIST_APPEND );
+ aTreeListBox.Show();
+
+ SetText( String( IDEResId( RID_STR_STACKNAME ) ) );
+
+ SetHelpId( HID_BASICIDE_STACKWINDOW );
+
+ aGotoCallButton.SetClickHdl( LINK( this, StackWindow, ButtonHdl ) );
+ aGotoCallButton.SetPosPixel( Point( DWBORDER, 2 ) );
+ Size aSz( aGotoCallButton.GetModeImage().GetSizePixel() );
+ aSz.Width() += 6;
+ aSz.Height() += 6;
+ aGotoCallButton.SetSizePixel( aSz );
+// aGotoCallButton.Show(); // wird vom Basic noch nicht unterstuetzt!
+ aGotoCallButton.Hide();
+
+ // make stack window keyboard accessible
+ GetSystemWindow()->GetTaskPaneList()->AddWindow( this );
+}
+
+
+
+__EXPORT StackWindow::~StackWindow()
+{
+ GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this );
+}
+
+
+
+void __EXPORT StackWindow::Paint( const Rectangle& )
+{
+ DrawText( Point( DWBORDER, 7 ), aStackStr );
+ lcl_DrawIDEWindowFrame( this );
+}
+
+
+
+void __EXPORT StackWindow::Resize()
+{
+ Size aSz = GetOutputSizePixel();
+ Size aBoxSz( aSz.Width() - 2*DWBORDER, aSz.Height() - nVirtToolBoxHeight - DWBORDER );
+
+ if ( aBoxSz.Width() < 4 ) // < 4, weil noch Border...
+ aBoxSz.Width() = 0;
+ if ( aBoxSz.Height() < 4 )
+ aBoxSz.Height() = 0;
+
+ aTreeListBox.SetSizePixel( aBoxSz );
+
+ Invalidate(); //Wegen DrawLine im Paint...
+}
+
+
+
+IMPL_LINK_INLINE_START( StackWindow, ButtonHdl, ImageButton *, pButton )
+{
+ if ( pButton == &aGotoCallButton )
+ {
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_GOTOCALL );
+ }
+ }
+ return 0;
+}
+IMPL_LINK_INLINE_END( StackWindow, ButtonHdl, ImageButton *, pButton )
+
+
+
+void __EXPORT StackWindow::UpdateCalls()
+{
+ aTreeListBox.SetUpdateMode( FALSE );
+ aTreeListBox.Clear();
+
+ if ( StarBASIC::IsRunning() )
+ {
+ SbxError eOld = SbxBase::GetError();
+ aTreeListBox.SetSelectionMode( SINGLE_SELECTION );
+
+ USHORT nScope = 0;
+ SbMethod* pMethod = StarBASIC::GetActiveMethod( nScope );
+ while ( pMethod )
+ {
+ String aEntry( String::CreateFromInt32(nScope ));
+ if ( aEntry.Len() < 2 )
+ aEntry.Insert( ' ', 0 );
+ aEntry += String( RTL_CONSTASCII_USTRINGPARAM( ": " ) );
+ aEntry += pMethod->GetName();
+ SbxArray* pParams = pMethod->GetParameters();
+ SbxInfo* pInfo = pMethod->GetInfo();
+ if ( pParams )
+ {
+ aEntry += '(';
+ // 0 ist der Name der Sub...
+ for ( USHORT nParam = 1; nParam < pParams->Count(); nParam++ )
+ {
+ SbxVariable* pVar = pParams->Get( nParam );
+ DBG_ASSERT( pVar, "Parameter?!" );
+ if ( pVar->GetName().Len() )
+ aEntry += pVar->GetName();
+ else if ( pInfo )
+ {
+ const SbxParamInfo* pParam = pInfo->GetParam( nParam );
+ if ( pParam )
+ aEntry += pParam->aName;
+ }
+ aEntry += '=';
+ if( pVar->GetType() & SbxARRAY )
+ aEntry += String( RTL_CONSTASCII_USTRINGPARAM( "..." ) );
+ else
+ aEntry += pVar->GetString();
+ if ( nParam < ( pParams->Count() - 1 ) )
+ aEntry += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
+ }
+ aEntry += ')';
+ }
+ aTreeListBox.InsertEntry( aEntry, 0, FALSE, LIST_APPEND );
+ nScope++;
+ pMethod = StarBASIC::GetActiveMethod( nScope );
+ }
+
+ SbxBase::ResetError();
+ if( eOld != SbxERR_OK )
+ SbxBase::SetError( eOld );
+ }
+ else
+ {
+ aTreeListBox.SetSelectionMode( NO_SELECTION );
+ aTreeListBox.InsertEntry( String(), 0, FALSE, LIST_APPEND );
+ }
+
+ aTreeListBox.SetUpdateMode( TRUE );
+}
+
+
+
+
+ComplexEditorWindow::ComplexEditorWindow( ModulWindow* pParent ) :
+ Window( pParent, WB_3DLOOK | WB_CLIPCHILDREN ),
+ aBrkWindow( this ),
+ aEdtWindow( this ),
+ aEWVScrollBar( this, WB_VSCROLL | WB_DRAG )
+{
+ aEdtWindow.SetModulWindow( pParent );
+ aBrkWindow.SetModulWindow( pParent );
+ aEdtWindow.Show();
+ aBrkWindow.Show();
+
+ aEWVScrollBar.SetLineSize( SCROLL_LINE );
+ aEWVScrollBar.SetPageSize( SCROLL_PAGE );
+ aEWVScrollBar.SetScrollHdl( LINK( this, ComplexEditorWindow, ScrollHdl ) );
+ aEWVScrollBar.Show();
+}
+
+
+
+void __EXPORT ComplexEditorWindow::Resize()
+{
+ Size aOutSz = GetOutputSizePixel();
+ Size aSz( aOutSz );
+ aSz.Width() -= 2*DWBORDER;
+ aSz.Height() -= 2*DWBORDER;
+ long nBrkWidth = 20;
+ long nSBWidth = aEWVScrollBar.GetSizePixel().Width();
+
+ Size aBrkSz( Size( nBrkWidth, aSz.Height() ) );
+ aBrkWindow.SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz );
+
+ Size aEWSz( Size( aSz.Width() - nBrkWidth - nSBWidth + 2, aSz.Height() ) );
+ aEdtWindow.SetPosSizePixel( Point( DWBORDER+aBrkSz.Width()-1, DWBORDER ), aEWSz );
+
+ aEWVScrollBar.SetPosSizePixel( Point( aOutSz.Width()-DWBORDER-nSBWidth, DWBORDER ), Size( nSBWidth, aSz.Height() ) );
+
+ // Macht das EditorWindow, ausserdem hier falsch, da Pixel
+// aEWVScrollBar.SetPageSize( aEWSz.Height() * 8 / 10 );
+// aEWVScrollBar.SetVisibleSize( aSz.Height() );
+// Invalidate();
+}
+
+IMPL_LINK( ComplexEditorWindow, ScrollHdl, ScrollBar *, pCurScrollBar )
+{
+ if ( aEdtWindow.GetEditView() )
+ {
+ DBG_ASSERT( pCurScrollBar == &aEWVScrollBar, "Wer scrollt hier ?" );
+ long nDiff = aEdtWindow.GetEditView()->GetStartDocPos().Y() - pCurScrollBar->GetThumbPos();
+ aEdtWindow.GetEditView()->Scroll( 0, nDiff );
+ aBrkWindow.DoScroll( 0, nDiff );
+ aEdtWindow.GetEditView()->ShowCursor( FALSE, TRUE );
+ pCurScrollBar->SetThumbPos( aEdtWindow.GetEditView()->GetStartDocPos().Y() );
+ }
+
+ return 0;
+}
+
+// virtual
+void ComplexEditorWindow::DataChanged(DataChangedEvent const & rDCEvt)
+{
+ Window::DataChanged(rDCEvt);
+ if (rDCEvt.GetType() == DATACHANGED_SETTINGS
+ && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
+ {
+ Color aColor(GetSettings().GetStyleSettings().GetFaceColor());
+ if (aColor
+ != rDCEvt.GetOldSettings()->GetStyleSettings().GetFaceColor())
+ {
+ SetBackground(Wallpaper(aColor));
+ Invalidate();
+ }
+ }
+}
+
+// virtual
+uno::Reference< awt::XWindowPeer >
+EditorWindow::GetComponentInterface(BOOL bCreate)
+{
+ uno::Reference< awt::XWindowPeer > xPeer(
+ Window::GetComponentInterface(false));
+ if (!xPeer.is() && bCreate)
+ {
+ // Make sure edit engine and view are available:
+ if (!pEditEngine)
+ CreateEditEngine();
+
+ xPeer = new ::svt::TextWindowPeer(*GetEditView());
+ SetComponentInterface(xPeer);
+ }
+ return xPeer;
+}
+
+WatchTreeListBox::WatchTreeListBox( Window* pParent, WinBits nWinBits )
+ : SvHeaderTabListBox( pParent, nWinBits )
+{}
+
+WatchTreeListBox::~WatchTreeListBox()
+{
+ // User-Daten zerstoeren...
+ SvLBoxEntry* pEntry = First();
+ while ( pEntry )
+ {
+ delete (WatchItem*)pEntry->GetUserData();
+ pEntry = Next( pEntry );
+ }
+}
+
+void WatchTreeListBox::SetTabs()
+{
+ SvHeaderTabListBox::SetTabs();
+ USHORT nTabCount_ = aTabs.Count();
+ for( USHORT i = 0 ; i < nTabCount_ ; i++ )
+ {
+ SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(i);
+ if( i == 2 )
+ pTab->nFlags |= SV_LBOXTAB_EDITABLE;
+ else
+ pTab->nFlags &= ~SV_LBOXTAB_EDITABLE;
+ }
+}
+
+void WatchTreeListBox::RequestingChilds( SvLBoxEntry * pParent )
+{
+ if( !StarBASIC::IsRunning() )
+ return;
+
+ if( GetChildCount( pParent ) > 0 )
+ return;
+
+ SvLBoxEntry * pEntry = pParent;
+ WatchItem* pItem = (WatchItem*)pEntry->GetUserData();
+
+ SbxDimArray* pArray = pItem->mpArray;
+ SbxDimArray* pRootArray = pItem->GetRootArray();
+ bool bArrayIsRootArray = false;
+ if( !pArray && pRootArray )
+ {
+ pArray = pRootArray;
+ bArrayIsRootArray = true;
+ }
+
+ SbxObject* pObj = pItem->mpObject;
+ if( pObj )
+ {
+ createAllObjectProperties( pObj );
+ SbxArray* pProps = pObj->GetProperties();
+ USHORT nPropCount = pProps->Count();
+ pItem->maMemberList.allocList( nPropCount );
+
+ for( USHORT i = 0 ; i < nPropCount - 3 ; i++ )
+ {
+ SbxVariable* pVar = pProps->Get( i );
+
+ String aName( pVar->GetName() );
+ pItem->maMemberList.mpMemberNames[i] = aName;
+ SvLBoxEntry* pChildEntry = SvTreeListBox::InsertEntry( aName, pEntry );
+ WatchItem* pChildItem = new WatchItem();
+ pChildItem->maName = aName;
+ pChildEntry->SetUserData( pChildItem );
+ }
+ if( nPropCount > 0 )
+ {
+ UpdateWatches();
+ }
+ }
+ else if( pArray )
+ {
+ USHORT nElementCount = 0;
+
+ // Loop through indices of current level
+ int nParentLevel = bArrayIsRootArray ? pItem->nDimLevel : 0;
+ int nThisLevel = nParentLevel + 1;
+ INT32 nMin, nMax;
+ pArray->GetDim32( nThisLevel, nMin, nMax );
+ for( INT32 i = nMin ; i <= nMax ; i++ )
+ {
+ WatchItem* pChildItem = new WatchItem();
+
+ // Copy data and create name
+ String aBaseName( pItem->maName );
+ pChildItem->maName = aBaseName;
+
+ String aIndexStr = String( RTL_CONSTASCII_USTRINGPARAM( "(" ) );
+ // pChildItem->mpArray = pItem->mpArray;
+ pChildItem->mpArrayParentItem = pItem;
+ pChildItem->nDimLevel = nThisLevel;
+ pChildItem->nDimCount = pItem->nDimCount;
+ pChildItem->pIndices = new short[ pChildItem->nDimCount ];
+ USHORT j;
+ for( j = 0 ; j < nParentLevel ; j++ )
+ {
+ short n = pChildItem->pIndices[j] = pItem->pIndices[j];
+ aIndexStr += String::CreateFromInt32( n );
+ aIndexStr += String( RTL_CONSTASCII_USTRINGPARAM( "," ) );
+ }
+ pChildItem->pIndices[ nParentLevel ] = sal::static_int_cast<short>( i );
+ aIndexStr += String::CreateFromInt32( i );
+ aIndexStr += String( RTL_CONSTASCII_USTRINGPARAM( ")" ) );
+
+ String aDisplayName;
+ WatchItem* pArrayRootItem = pChildItem->GetRootItem();
+ if( pArrayRootItem && pArrayRootItem->mpArrayParentItem )
+ aDisplayName = pItem->maDisplayName;
+ else
+ aDisplayName = aBaseName;
+ aDisplayName += aIndexStr;
+ pChildItem->maDisplayName = aDisplayName;
+
+ SvLBoxEntry* pChildEntry = SvTreeListBox::InsertEntry( aDisplayName, pEntry );
+ nElementCount++;
+ pChildEntry->SetUserData( pChildItem );
+ }
+ if( nElementCount > 0 )
+ {
+ UpdateWatches();
+ }
+ }
+}
+
+SbxBase* WatchTreeListBox::ImplGetSBXForEntry( SvLBoxEntry* pEntry, bool& rbArrayElement )
+{
+ SbxBase* pSBX = NULL;
+ rbArrayElement = false;
+
+ WatchItem* pItem = (WatchItem*)pEntry->GetUserData();
+ String aVName( pItem->maName );
+
+ SvLBoxEntry* pParentEntry = GetParent( pEntry );
+ WatchItem* pParentItem = pParentEntry ? (WatchItem*)pParentEntry->GetUserData() : NULL;
+ if( pParentItem )
+ {
+ SbxObject* pObj = pParentItem->mpObject;
+ SbxDimArray* pArray;
+ if( pObj )
+ {
+ pSBX = pObj->Find( aVName, SbxCLASS_DONTCARE );
+
+ SbxVariable* pVar;
+ if ( pSBX && (pVar = PTR_CAST( SbxVariable, pSBX )) != NULL
+ && !pSBX->ISA( SbxMethod ) )
+ {
+ // Force getting value
+ SbxValues aRes;
+ aRes.eType = SbxVOID;
+ pVar->Get( aRes );
+ }
+ }
+ // Array?
+ else if( (pArray = pItem->GetRootArray()) != NULL )
+ // else if( (pArray = pItem->mpArray) != NULL )
+ {
+ rbArrayElement = true;
+ if( pParentItem->nDimLevel + 1 == pParentItem->nDimCount )
+ // if( pItem->nDimLevel == pItem->nDimCount )
+ pSBX = pArray->Get( pItem->pIndices );
+ // else
+ // pSBX = pArray;
+ }
+ }
+ else
+ {
+ pSBX = StarBASIC::FindSBXInCurrentScope( aVName );
+ }
+ return pSBX;
+}
+
+BOOL __EXPORT WatchTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& )
+{
+ WatchItem* pItem = (WatchItem*)pEntry->GetUserData();
+
+ BOOL bEdit = FALSE;
+ if ( StarBASIC::IsRunning() && StarBASIC::GetActiveMethod() && !SbxBase::IsError() )
+ {
+ // No out of scope entries
+ bool bArrayElement;
+ SbxBase* pSBX = ImplGetSBXForEntry( pEntry, bArrayElement );
+ if ( ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) ) || bArrayElement )
+ {
+ // Accept no objects and only end nodes of arrays for editing
+ if( !pItem->mpObject && (pItem->mpArray == NULL || pItem->nDimLevel == pItem->nDimCount) )
+ {
+ aEditingRes = SvHeaderTabListBox::GetEntryText( pEntry, ITEM_ID_VALUE-1 );
+ aEditingRes.EraseLeadingChars();
+ aEditingRes.EraseTrailingChars();
+ bEdit = TRUE;
+ }
+ }
+ }
+
+ if ( !bEdit )
+ Sound::Beep();
+
+ return bEdit;
+}
+
+BOOL __EXPORT WatchTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const String& rNewText )
+{
+ WatchItem* pItem = (WatchItem*)pEntry->GetUserData();
+ String aVName( pItem->maName );
+
+ String aResult = rNewText;
+ aResult.EraseLeadingChars();
+ aResult.EraseTrailingChars();
+
+ USHORT nResultLen = aResult.Len();
+ sal_Unicode cFirst = aResult.GetChar( 0 );
+ sal_Unicode cLast = aResult.GetChar( nResultLen - 1 );
+ if( cFirst == '\"' && cLast == '\"' )
+ aResult = aResult.Copy( 1, nResultLen - 2 );
+
+ BOOL bResModified = ( aResult != aEditingRes ) ? TRUE : FALSE;
+ BOOL bError = FALSE;
+ if ( !aVName.Len() )
+ {
+ bError = TRUE;
+ }
+
+ BOOL bRet = FALSE;
+
+ if ( bError )
+ {
+ Sound::Beep();
+ }
+ else if ( bResModified )
+ {
+ bRet = ImplBasicEntryEdited( pEntry, aResult );
+ }
+
+ return bRet;
+}
+
+BOOL WatchTreeListBox::ImplBasicEntryEdited( SvLBoxEntry* pEntry, const String& rResult )
+{
+ WatchItem* pItem = (WatchItem*)pEntry->GetUserData();
+ String aVName( pItem->maName );
+
+ BOOL bError = FALSE;
+ String aResult( rResult );
+ String aIndex;
+ bool bArrayElement;
+ SbxBase* pSBX = ImplGetSBXForEntry( pEntry, bArrayElement );
+
+ SbxBase* pToBeChanged = NULL;
+ if ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) )
+ {
+ SbxVariable* pVar = (SbxVariable*)pSBX;
+ SbxDataType eType = pVar->GetType();
+ if ( (BYTE)eType == (BYTE)SbxOBJECT )
+ bError = TRUE;
+ else if ( eType & SbxARRAY )
+ bError = TRUE;
+ else
+ pToBeChanged = pSBX;
+ }
+
+ if ( pToBeChanged )
+ {
+ if ( pToBeChanged->ISA( SbxVariable ) )
+ {
+ // Wenn der Typ variabel ist, macht die Konvertierung des SBX nichts,
+ // bei festem Typ wird der String konvertiert.
+ ((SbxVariable*)pToBeChanged)->PutStringExt( aResult );
+ }
+ else
+ bError = TRUE;
+ }
+
+ // Wenn jemand z.B. einen zu grossen Wert fuer ein Int eingegeben hat,
+ // folgt beim naechsten Step() ein Runtime-Error.
+ if ( SbxBase::IsError() )
+ {
+ bError = TRUE;
+ SbxBase::ResetError();
+ }
+
+ if ( bError )
+ Sound::Beep();
+
+ UpdateWatches();
+
+ // Der Text soll niemals 1-zu-1 uebernommen werden, weil dann das
+ // UpdateWatches verlorengeht.
+ return FALSE;
+}
+
+
+static void implCollapseModifiedObjectEntry( SvLBoxEntry* pParent, WatchTreeListBox* pThis )
+{
+ pThis->Collapse( pParent );
+
+ SvLBoxTreeList* pModel = pThis->GetModel();
+ SvLBoxEntry* pDeleteEntry;
+ while( (pDeleteEntry = pThis->SvTreeListBox::GetEntry( pParent, 0 )) != NULL )
+ {
+ implCollapseModifiedObjectEntry( pDeleteEntry, pThis );
+
+ WatchItem* pItem = (WatchItem*)pDeleteEntry->GetUserData();
+ delete pItem;
+ pModel->Remove( pDeleteEntry );
+ }
+}
+
+static String implCreateTypeStringForDimArray( WatchItem* pItem, SbxDataType eType )
+{
+ String aRetStr = getBasicTypeName( eType );
+
+ SbxDimArray* pArray = pItem->mpArray;
+ if( !pArray )
+ pArray = pItem->GetRootArray();
+ if( pArray )
+ {
+ int nDimLevel = pItem->nDimLevel;
+ int nDims = pItem->nDimCount;
+ if( nDimLevel < nDims )
+ {
+ aRetStr += '(';
+ for( int i = nDimLevel ; i < nDims ; i++ )
+ {
+ short nMin, nMax;
+ pArray->GetDim( sal::static_int_cast<short>( i+1 ), nMin, nMax );
+ aRetStr += String::CreateFromInt32( nMin );
+ aRetStr += String( RTL_CONSTASCII_USTRINGPARAM( " to " ) );
+ aRetStr += String::CreateFromInt32( nMax );
+ if( i < nDims - 1 )
+ aRetStr += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
+ }
+ aRetStr += ')';
+ }
+ }
+ return aRetStr;
+}
+
+
+void implEnableChildren( SvLBoxEntry* pEntry, bool bEnable )
+// inline void implEnableChildren( SvLBoxEntry* pEntry, bool bEnable )
+{
+ if( bEnable )
+ {
+ pEntry->SetFlags(
+ (pEntry->GetFlags() &
+ ~(SV_ENTRYFLAG_NO_NODEBMP | SV_ENTRYFLAG_HAD_CHILDREN))
+ | SV_ENTRYFLAG_CHILDS_ON_DEMAND );
+ }
+ else
+ {
+ pEntry->SetFlags(
+ (pEntry->GetFlags() & ~(SV_ENTRYFLAG_CHILDS_ON_DEMAND)) );
+ }
+}
+
+void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
+{
+ SbMethod* pCurMethod = StarBASIC::GetActiveMethod();
+
+ SbxError eOld = SbxBase::GetError();
+ setBasicWatchMode( true );
+
+ SvLBoxEntry* pEntry = First();
+ while ( pEntry )
+ {
+ WatchItem* pItem = (WatchItem*)pEntry->GetUserData();
+ String aVName( pItem->maName );
+ DBG_ASSERT( aVName.Len(), "Var? - Darf nicht leer sein!" );
+ String aWatchStr;
+ String aTypeStr;
+ if ( pCurMethod )
+ {
+ bool bArrayElement;
+ SbxBase* pSBX = ImplGetSBXForEntry( pEntry, bArrayElement );
+
+ // Array? If no end node create type string
+ if( bArrayElement && pItem->nDimLevel < pItem->nDimCount )
+ {
+ SbxDimArray* pRootArray = pItem->GetRootArray();
+ SbxDataType eType = pRootArray->GetType();
+ // SbxDataType eType = pItem->mpArray->GetType();
+ aTypeStr = implCreateTypeStringForDimArray( pItem, eType );
+ implEnableChildren( pEntry, true );
+ }
+
+ bool bCollapse = false;
+ if ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) )
+ {
+ SbxVariable* pVar = (SbxVariable*)pSBX;
+ // Sonderbehandlung fuer Arrays:
+ SbxDataType eType = pVar->GetType();
+ if ( eType & SbxARRAY )
+ {
+ // Mehrdimensionale Arrays beruecksichtigen!
+ SbxBase* pBase = pVar->GetObject();
+ if ( pBase && pBase->ISA( SbxDimArray ) )
+ {
+ SbxDimArray* pNewArray = (SbxDimArray*)pBase;
+ SbxDimArray* pOldArray = pItem->mpArray;
+
+ bool bArrayChanged = false;
+ if( pNewArray != NULL && pOldArray != NULL )
+ {
+ // Compare Array dimensions to see if array has changed
+ // Can be a copy, so comparing pointers does not work
+ USHORT nOldDims = pOldArray->GetDims();
+ USHORT nNewDims = pNewArray->GetDims();
+ if( nOldDims != nNewDims )
+ {
+ bArrayChanged = true;
+ }
+ else
+ {
+ for( int i = 0 ; i < nOldDims ; i++ )
+ {
+ short nOldMin, nOldMax;
+ short nNewMin, nNewMax;
+
+ pOldArray->GetDim( sal::static_int_cast<short>( i+1 ), nOldMin, nOldMax );
+ pNewArray->GetDim( sal::static_int_cast<short>( i+1 ), nNewMin, nNewMax );
+ if( nOldMin != nNewMin || nOldMax != nNewMax )
+ {
+ bArrayChanged = true;
+ break;
+ }
+ }
+ }
+ }
+ else if( pNewArray == NULL || pOldArray == NULL )
+ bArrayChanged = true;
+
+ if( pNewArray )
+ implEnableChildren( pEntry, true );
+
+ // #i37227 Clear always and replace array
+ if( pNewArray != pOldArray )
+ {
+ pItem->clearWatchItem( false );
+ if( pNewArray )
+ {
+ implEnableChildren( pEntry, true );
+
+ pItem->mpArray = pNewArray;
+ USHORT nDims = pNewArray->GetDims();
+ pItem->nDimLevel = 0;
+ pItem->nDimCount = nDims;
+ }
+ }
+ if( bArrayChanged && pOldArray != NULL )
+ bCollapse = true;
+
+ aTypeStr = implCreateTypeStringForDimArray( pItem, eType );
+ }
+ else
+ aWatchStr += String( RTL_CONSTASCII_USTRINGPARAM( "<?>" ) );
+ }
+ else if ( (BYTE)eType == (BYTE)SbxOBJECT )
+ {
+ SbxObject* pObj = NULL;
+ SbxBase* pBase = pVar->GetObject();
+ if( pBase && pBase->ISA( SbxObject ) )
+ pObj = (SbxObject*)pBase;
+
+ if( pObj )
+ {
+ // Check if member list has changed
+ bool bObjChanged = false;
+ if( pItem->mpObject != NULL && pItem->maMemberList.mpMemberNames != NULL )
+ {
+ SbxArray* pProps = pObj->GetProperties();
+ USHORT nPropCount = pProps->Count();
+ for( USHORT i = 0 ; i < nPropCount - 3 ; i++ )
+ {
+ SbxVariable* pVar_ = pProps->Get( i );
+ String aName( pVar_->GetName() );
+ if( pItem->maMemberList.mpMemberNames[i] != aName )
+ {
+ bObjChanged = true;
+ break;
+ }
+ }
+ if( bObjChanged )
+ bCollapse = true;
+ }
+
+ pItem->mpObject = pObj;
+ implEnableChildren( pEntry, true );
+ aTypeStr = getBasicObjectTypeName( pObj );
+ }
+ else
+ {
+ aWatchStr = String( RTL_CONSTASCII_USTRINGPARAM( "Null" ) );
+ if( pItem->mpObject != NULL )
+ {
+ bCollapse = true;
+ pItem->clearWatchItem( false );
+
+ implEnableChildren( pEntry, false );
+ }
+ }
+ }
+ else
+ {
+ if( pItem->mpObject != NULL )
+ {
+ bCollapse = true;
+ pItem->clearWatchItem( false );
+
+ implEnableChildren( pEntry, false );
+ }
+
+ bool bString = ((BYTE)eType == (BYTE)SbxSTRING);
+ String aStrStr( RTL_CONSTASCII_USTRINGPARAM( "\"" ) );
+ if( bString )
+ aWatchStr += aStrStr;
+ aWatchStr += pVar->GetString();
+ if( bString )
+ aWatchStr += aStrStr;
+ }
+ if( !aTypeStr.Len() )
+ {
+ if( !pVar->IsFixed() )
+ aTypeStr = String( RTL_CONSTASCII_USTRINGPARAM( "Variant/" ) );
+ aTypeStr += getBasicTypeName( pVar->GetType() );
+ }
+ }
+ else if( !bArrayElement )
+ aWatchStr += String( RTL_CONSTASCII_USTRINGPARAM( "<Out of Scope>" ) );
+
+ if( bCollapse )
+ implCollapseModifiedObjectEntry( pEntry, this );
+
+ }
+ else if( bBasicStopped )
+ {
+ if( pItem->mpObject || pItem->mpArray )
+ {
+ implCollapseModifiedObjectEntry( pEntry, this );
+ pItem->mpObject = NULL;
+ }
+ }
+
+ SvHeaderTabListBox::SetEntryText( aWatchStr, pEntry, ITEM_ID_VALUE-1 );
+ SvHeaderTabListBox::SetEntryText( aTypeStr, pEntry, ITEM_ID_TYPE-1 );
+
+ pEntry = Next( pEntry );
+ }
+
+ // Force redraw
+ Invalidate();
+
+ SbxBase::ResetError();
+ if( eOld != SbxERR_OK )
+ SbxBase::SetError( eOld );
+ setBasicWatchMode( false );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
new file mode 100644
index 000000000000..244440823169
--- /dev/null
+++ b/basctl/source/basicide/baside3.cxx
@@ -0,0 +1,1415 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+//svdraw.hxx
+//#define _SVDRAW_HXX ***
+#define _SDR_NOITEMS
+#define _SDR_NOTOUCH
+#define _SDR_NOTRANSFORM
+#define _SDR_NOOBJECTS
+//#define _SDR_NOVIEWS ***
+#define _SDR_NOVIEWMARKER
+#define _SDR_NODRAGMETHODS
+//#define _SDR_NOUNDO ***
+#define _SDR_NOXOUTDEV
+
+#include <ide_pch.hxx>
+
+
+#include <vector>
+#include <basidesh.hrc>
+#include <baside3.hxx>
+#include <localizationmgr.hxx>
+#include <accessibledialogwindow.hxx>
+#include <dlged.hxx>
+#include <dlgedmod.hxx>
+#include <dlgedview.hxx>
+#include <dlgeddef.hxx>
+#include <propbrw.hxx>
+
+#include <basobj.hxx>
+#include <iderdll.hxx>
+#include <basidesh.hxx>
+#include <idetemp.hxx>
+#include <helpid.hrc>
+#include <bastype2.hxx>
+#include <svx/svdview.hxx>
+#include <editeng/unolingu.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/urlobj.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <xmlscript/xmldlg_imexp.hxx>
+#include <com/sun/star/script/XLibraryContainer2.hpp>
+#include <svtools/ehdl.hxx>
+#include <svtools/langtab.hxx>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/resource/XStringResourceResolver.hpp>
+#include <com/sun/star/resource/StringResourceWithLocation.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/script/vba/XVBACompatibility.hpp>
+
+using namespace comphelper;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::resource;
+using namespace ::com::sun::star::ui::dialogs;
+
+#if defined(MAC)
+#define FILTERMASK_ALL "****"
+#elif defined(OW) || defined(MTF)
+#define FILTERMASK_ALL "*"
+#elif defined(PM2)
+#define FILTERMASK_ALL ""
+#else
+#define FILTERMASK_ALL "*.*"
+#endif
+
+DBG_NAME( DialogWindow )
+
+TYPEINIT1( DialogWindow, IDEBaseWindow );
+
+DialogWindow::DialogWindow( Window* pParent, const ScriptDocument& rDocument, String aLibName, String aName,
+ const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >& xDialogModel )
+ :IDEBaseWindow( pParent, rDocument, aLibName, aName )
+ ,pUndoMgr(NULL)
+{
+ InitSettings( TRUE, TRUE, TRUE );
+
+ pEditor = new DlgEditor( rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() );
+ pEditor->SetWindow( this );
+ pEditor->SetDialog( xDialogModel );
+
+ // Undo einrichten
+ pUndoMgr = new SfxUndoManager;
+
+ Link aDummyLink;
+ aOldNotifyUndoActionHdl = pEditor->GetModel()->GetNotifyUndoActionHdl();
+ pEditor->GetModel()->SetNotifyUndoActionHdl(
+ LINK(this, DialogWindow, NotifyUndoActionHdl));
+
+ SetHelpId( HID_BASICIDE_DIALOGWINDOW );
+
+ // set readonly mode for readonly libraries
+ ::rtl::OUString aOULibName( aLibName );
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( GetDocument().getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) )
+ SetReadOnly( TRUE );
+
+ if ( rDocument.isDocument() && rDocument.isReadOnly() )
+ SetReadOnly( TRUE );
+}
+
+DialogWindow::~DialogWindow()
+{
+ delete pEditor;
+ delete pUndoMgr;
+}
+
+void DialogWindow::LoseFocus()
+{
+ if ( IsModified() )
+ StoreData();
+
+ Window::LoseFocus();
+}
+
+
+
+void DialogWindow::Paint( const Rectangle& rRect )
+{
+ pEditor->Paint( rRect );
+}
+
+
+
+void DialogWindow::Resize()
+{
+ if ( GetHScrollBar() && GetVScrollBar() ) {
+ pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
+ }
+}
+
+
+
+void DialogWindow::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ pEditor->MouseButtonDown( rMEvt );
+
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_SHOW_PROPERTYBROWSER );
+}
+
+
+
+void DialogWindow::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ pEditor->MouseButtonUp( rMEvt );
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if( (pEditor->GetMode() == DLGED_INSERT) && !pEditor->IsCreateOK() )
+ {
+ pEditor->SetMode( DLGED_SELECT );
+ if ( pBindings )
+ pBindings->Invalidate( SID_CHOOSE_CONTROLS );
+ }
+ if ( pBindings )
+ {
+ pBindings->Invalidate( SID_SHOW_PROPERTYBROWSER );
+ pBindings->Invalidate( SID_DOC_MODIFIED );
+ pBindings->Invalidate( SID_SAVEDOC );
+ }
+}
+
+
+
+void DialogWindow::MouseMove( const MouseEvent& rMEvt )
+{
+ pEditor->MouseMove( rMEvt );
+}
+
+
+
+void DialogWindow::KeyInput( const KeyEvent& rKEvt )
+{
+ if( rKEvt.GetKeyCode() == KEY_BACKSPACE )
+ {
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BACKSPACE );
+ }
+ }
+ else
+ {
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if( pBindings && rKEvt.GetKeyCode() == KEY_TAB )
+ pBindings->Invalidate( SID_SHOW_PROPERTYBROWSER );
+
+ if( !pEditor->KeyInput( rKEvt ) )
+ {
+ if( !SfxViewShell::Current()->KeyInput( rKEvt ) )
+ Window::KeyInput( rKEvt );
+ }
+ }
+}
+
+void DialogWindow::Command( const CommandEvent& rCEvt )
+{
+ if ( ( rCEvt.GetCommand() == COMMAND_WHEEL ) ||
+ ( rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL ) ||
+ ( rCEvt.GetCommand() == COMMAND_AUTOSCROLL ) )
+ {
+ HandleScrollCommand( rCEvt, GetHScrollBar(), GetVScrollBar() );
+ }
+ else if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
+ {
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if ( pDispatcher )
+ {
+ SdrView* pView = GetView();
+ if( !rCEvt.IsMouseEvent() && pView->AreObjectsMarked() )
+ {
+ Rectangle aMarkedRect( pView->GetMarkedRect() );
+ Point MarkedCenter( aMarkedRect.Center() );
+ Point PosPixel( LogicToPixel( MarkedCenter ) );
+ pDispatcher->ExecutePopup( IDEResId(RID_POPUP_DLGED), this, &PosPixel );
+ }
+ else
+ {
+ pDispatcher->ExecutePopup( IDEResId(RID_POPUP_DLGED) );
+ }
+
+ }
+ }
+ else
+ IDEBaseWindow::Command( rCEvt );
+}
+
+
+
+
+IMPL_LINK( DialogWindow, NotifyUndoActionHdl, SfxUndoAction *, pUndoAction )
+{
+ (void)pUndoAction;
+
+ // not working yet for unocontrols
+ /*
+ if (pUndoAction)
+ {
+ pUndoMgr->AddUndoAction( pUndoAction );
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_UNDO );
+ }
+ */
+
+ return 0;
+}
+
+
+
+void __EXPORT DialogWindow::DoInit()
+{
+ GetHScrollBar()->Show();
+ GetVScrollBar()->Show();
+ pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
+}
+
+
+
+void __EXPORT DialogWindow::DoScroll( ScrollBar* pCurScrollBar )
+{
+ pEditor->DoScroll( pCurScrollBar );
+}
+
+void __EXPORT DialogWindow::GetState( SfxItemSet& rSet )
+{
+ SfxWhichIter aIter(rSet);
+ for ( USHORT nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich() )
+ {
+ switch ( nWh )
+ {
+ case SID_PASTE:
+ {
+ if ( !IsPasteAllowed() )
+ rSet.DisableItem( nWh );
+
+ if ( IsReadOnly() )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_COPY:
+ {
+ // any object selected?
+ if ( !pEditor->GetView()->AreObjectsMarked() )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_CUT:
+ case SID_DELETE:
+ case SID_BACKSPACE:
+ {
+ // any object selected?
+ if ( !pEditor->GetView()->AreObjectsMarked() )
+ rSet.DisableItem( nWh );
+
+ if ( IsReadOnly() )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_REDO:
+ {
+ if ( !pUndoMgr->GetUndoActionCount() )
+ rSet.DisableItem( nWh );
+ }
+ break;
+
+ // Nur Dialogfenster:
+ case SID_DIALOG_TESTMODE:
+ {
+ // ist die IDE noch aktiv?
+ if( IDE_DLL()->GetShell()->GetFrame() )
+ {
+ rSet.Put( SfxBoolItem( SID_DIALOG_TESTMODE,
+ (pEditor->GetMode() == DLGED_TEST) ? TRUE : FALSE) );
+ }
+ else
+ rSet.Put( SfxBoolItem( SID_DIALOG_TESTMODE,FALSE ));
+ }
+ break;
+
+ case SID_CHOOSE_CONTROLS:
+ {
+ if ( IsReadOnly() )
+ {
+ rSet.DisableItem( nWh );
+ }
+ else
+ {
+ SfxAllEnumItem aItem( SID_CHOOSE_CONTROLS );
+ if ( GetEditor()->GetMode() == DLGED_SELECT )
+ aItem.SetValue( SVX_SNAP_SELECT );
+ else
+ {
+ USHORT 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_TREECONTROL: nObj = SVX_SNAP_TREECONTROL; break;
+ default: nObj = 0;
+ }
+#ifdef DBG_UTIL
+ if( !nObj )
+ {
+ DBG_WARNING( "SID_CHOOSE_CONTROLS: Unbekannt!" );
+ }
+#endif
+ aItem.SetValue( nObj );
+ }
+
+ rSet.Put( aItem );
+ }
+ }
+ break;
+
+ case SID_SHOW_PROPERTYBROWSER:
+ {
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ if ( pViewFrame && !pViewFrame->HasChildWindow( SID_SHOW_PROPERTYBROWSER ) && !pEditor->GetView()->AreObjectsMarked() )
+ rSet.DisableItem( nWh );
+
+ if ( IsReadOnly() )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ }
+ }
+}
+
+
+
+void __EXPORT DialogWindow::ExecuteCommand( SfxRequest& rReq )
+{
+ switch ( rReq.GetSlot() )
+ {
+ case SID_CUT:
+ if ( !IsReadOnly() )
+ {
+ GetEditor()->Cut();
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_DOC_MODIFIED );
+ }
+ break;
+ case SID_DELETE:
+ if ( !IsReadOnly() )
+ {
+ GetEditor()->Delete();
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_DOC_MODIFIED );
+ }
+ break;
+ case SID_COPY:
+ GetEditor()->Copy();
+ break;
+ case SID_PASTE:
+ if ( !IsReadOnly() )
+ {
+ GetEditor()->Paste();
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_DOC_MODIFIED );
+ }
+ break;
+ 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( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_PUSHBUTTON );
+ }
+ break;
+ case SVX_SNAP_RADIOBUTTON:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_RADIOBUTTON );
+ }
+ break;
+ case SVX_SNAP_CHECKBOX:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_CHECKBOX);
+ }
+ break;
+ case SVX_SNAP_LISTBOX:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_LISTBOX );
+ }
+ break;
+ case SVX_SNAP_COMBOBOX:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_COMBOBOX );
+ }
+ break;
+ case SVX_SNAP_GROUPBOX:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_GROUPBOX );
+ }
+ break;
+ case SVX_SNAP_EDIT:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_EDIT );
+ }
+ break;
+ case SVX_SNAP_FIXEDTEXT:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_FIXEDTEXT );
+ }
+ break;
+ case SVX_SNAP_IMAGECONTROL:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_IMAGECONTROL );
+ }
+ break;
+ case SVX_SNAP_PROGRESSBAR:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_PROGRESSBAR );
+ }
+ break;
+ case SVX_SNAP_HSCROLLBAR:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_HSCROLLBAR );
+ }
+ break;
+ case SVX_SNAP_VSCROLLBAR:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_VSCROLLBAR );
+ }
+ break;
+ case SVX_SNAP_HFIXEDLINE:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_HFIXEDLINE );
+ }
+ break;
+ case SVX_SNAP_VFIXEDLINE:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_VFIXEDLINE );
+ }
+ break;
+ case SVX_SNAP_DATEFIELD:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_DATEFIELD );
+ }
+ break;
+ case SVX_SNAP_TIMEFIELD:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_TIMEFIELD );
+ }
+ break;
+ case SVX_SNAP_NUMERICFIELD:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_NUMERICFIELD );
+ }
+ break;
+ case SVX_SNAP_CURRENCYFIELD:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_CURRENCYFIELD );
+ }
+ break;
+ case SVX_SNAP_FORMATTEDFIELD:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_FORMATTEDFIELD );
+ }
+ break;
+ case SVX_SNAP_PATTERNFIELD:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_PATTERNFIELD );
+ }
+ break;
+ case SVX_SNAP_FILECONTROL:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_FILECONTROL );
+ }
+ break;
+ case SVX_SNAP_TREECONTROL:
+ {
+ GetEditor()->SetMode( DLGED_INSERT );
+ GetEditor()->SetInsertObj( OBJ_DLG_TREECONTROL );
+ }
+ break;
+
+ case SVX_SNAP_SELECT:
+ {
+ GetEditor()->SetMode( DLGED_SELECT );
+ }
+ break;
+ }
+
+ if ( rReq.GetModifier() & KEY_MOD1 )
+ {
+ if ( GetEditor()->GetMode() == DLGED_INSERT )
+ GetEditor()->CreateDefaultObject();
+ }
+
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_DOC_MODIFIED );
+ }
+ break;
+
+ case SID_DIALOG_TESTMODE:
+ {
+ DlgEdMode eOldMode = GetEditor()->GetMode();
+ GetEditor()->SetMode( DLGED_TEST );
+ GetEditor()->SetMode( eOldMode );
+ rReq.Done();
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_DIALOG_TESTMODE );
+ return;
+ }
+ case SID_EXPORT_DIALOG:
+ SaveDialog();
+ break;
+
+ case SID_IMPORT_DIALOG:
+ ImportDialog();
+ break;
+ }
+
+ rReq.Done();
+}
+
+Reference< container::XNameContainer > DialogWindow::GetDialog() const
+{
+ return pEditor->GetDialog();
+}
+
+BOOL DialogWindow::RenameDialog( const String& rNewName )
+{
+ if ( !BasicIDE::RenameDialog( this, GetDocument(), GetLibName(), GetName(), rNewName ) )
+ return FALSE;
+
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_DOC_MODIFIED );
+
+ return TRUE;
+}
+
+void DialogWindow::DisableBrowser()
+{
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow(SID_SHOW_PROPERTYBROWSER) : NULL;
+ if( pChildWin )
+ ((PropBrw*)(pChildWin->GetWindow()))->Update( NULL );
+}
+
+void DialogWindow::UpdateBrowser()
+{
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow(SID_SHOW_PROPERTYBROWSER) : NULL;
+ if( pChildWin )
+ ((PropBrw*)(pChildWin->GetWindow()))->Update( pIDEShell );
+}
+
+static ::rtl::OUString aResourceResolverPropName =
+ ::rtl::OUString::createFromAscii( "ResourceResolver" );
+
+BOOL DialogWindow::SaveDialog()
+{
+ DBG_CHKTHIS( DialogWindow, 0 );
+ BOOL bDone = FALSE;
+
+ Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
+ Reference < XFilePicker > xFP;
+ if( xMSF.is() )
+ {
+ Sequence <Any> aServiceType(1);
+ aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD;
+ xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
+ }
+
+ Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
+ xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, sal_False);
+ Any aValue;
+ aValue <<= (sal_Bool) sal_True;
+ xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
+
+ if ( aCurPath.Len() )
+ xFP->setDisplayDirectory ( aCurPath );
+
+ xFP->setDefaultName( ::rtl::OUString( GetName() ) );
+
+ String aDialogStr( IDEResId( RID_STR_STDDIALOGNAME ) );
+ Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
+ xFltMgr->appendFilter( aDialogStr, String( RTL_CONSTASCII_USTRINGPARAM( "*.xdl" ) ) );
+ xFltMgr->appendFilter( String( IDEResId( RID_STR_FILTER_ALLFILES ) ), String( RTL_CONSTASCII_USTRINGPARAM( FILTERMASK_ALL ) ) );
+ xFltMgr->setCurrentFilter( aDialogStr );
+
+ if( xFP->execute() == RET_OK )
+ {
+ Sequence< ::rtl::OUString > aPaths = xFP->getFiles();
+ aCurPath = aPaths[0];
+
+ // export dialog model to xml
+ Reference< container::XNameContainer > xDialogModel = GetDialog();
+ Reference< XComponentContext > xContext;
+ Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
+ OSL_ASSERT( xProps.is() );
+ OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() );
+ Reference< XInputStream > xInput( xISP->createInputStream() );
+
+ Reference< XSimpleFileAccess > xSFI( xMSF->createInstance
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY );
+
+ Reference< XOutputStream > xOutput;
+ try
+ {
+ if( xSFI->exists( aCurPath ) )
+ xSFI->kill( aCurPath );
+ xOutput = xSFI->openFileWrite( aCurPath );
+ }
+ catch( 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( 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();
+ ::rtl::OUString aDialogName( aURLObj.getName() );
+ aURLObj.removeSegment();
+ ::rtl::OUString aURL( aURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
+ sal_Bool bReadOnly = sal_False;
+ ::rtl::OUString aComment( ::rtl::OUString::createFromAscii( "# " ) );
+ aComment += aDialogName;
+ aComment += ::rtl::OUString::createFromAscii( " strings" );
+ Reference< task::XInteractionHandler > xDummyHandler;
+
+ // Remove old properties files in case of overwriting Dialog files
+ if( xSFI->isFolder( aURL ) )
+ {
+ Sequence< ::rtl::OUString > aContentSeq = xSFI->getFolderContents( aURL, false );
+
+ ::rtl::OUString aDialogName_( aDialogName );
+ aDialogName_ += ::rtl::OUString::createFromAscii( "_" );
+ sal_Int32 nCount = aContentSeq.getLength();
+ const ::rtl::OUString* pFiles = aContentSeq.getConstArray();
+ for( int i = 0 ; i < nCount ; i++ )
+ {
+ ::rtl::OUString aCompleteName = pFiles[i];
+ rtl::OUString aPureName;
+ rtl::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.equalsAscii( "properties" ) ||
+ aExtension.equalsAscii( "default" ) )
+ {
+ if( aPureName.indexOf( aDialogName_ ) == 0 )
+ {
+ try
+ {
+ xSFI->kill( aCompleteName );
+ }
+ catch( 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 );
+ }
+
+ Reference< XStringResourceManager > xTargetStringResourceManager( xStringResourceWithLocation, uno::UNO_QUERY );
+
+ LocalizationMgr::copyResourceForDialog( xDialogModel,
+ xStringResourceResolver, xTargetStringResourceManager );
+
+ xStringResourceWithLocation->store();
+ }
+ }
+ else
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( 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 XubString& rTitle, const XubString& rMessage );
+};
+
+NameClashQueryBox::NameClashQueryBox( Window* pParent,
+ const XubString& rTitle, const XubString& rMessage )
+ : MessBox( pParent, 0, rTitle, rMessage )
+{
+ if ( rTitle.Len() )
+ SetText( rTitle );
+
+ maMessText = rMessage;
+
+ AddButton( String( IDEResId( RID_STR_DLGIMP_CLASH_RENAME ) ), RET_YES,
+ BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_OKBUTTON | BUTTONDIALOG_FOCUSBUTTON );
+ AddButton( String( IDEResId( RID_STR_DLGIMP_CLASH_REPLACE ) ), RET_NO, 0 );
+ AddButton( BUTTON_CANCEL, RET_CANCEL, BUTTONDIALOG_CANCELBUTTON );
+
+ SetImage( GetSettings().GetStyleSettings().GetHighContrastMode() ?
+ QueryBox::GetStandardImageHC() : QueryBox::GetStandardImage() );
+}
+
+
+class LanguageMismatchQueryBox : public MessBox
+{
+public:
+ LanguageMismatchQueryBox( Window* pParent,
+ const XubString& rTitle, const XubString& rMessage );
+};
+
+LanguageMismatchQueryBox::LanguageMismatchQueryBox( Window* pParent,
+ const XubString& rTitle, const XubString& rMessage )
+ : MessBox( pParent, 0, rTitle, rMessage )
+{
+ if ( rTitle.Len() )
+ SetText( rTitle );
+
+ maMessText = rMessage;
+ AddButton( String( IDEResId( RID_STR_DLGIMP_MISMATCH_ADD ) ), RET_YES,
+ BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_OKBUTTON | BUTTONDIALOG_FOCUSBUTTON );
+ AddButton( String( IDEResId( RID_STR_DLGIMP_MISMATCH_OMIT ) ), RET_NO, 0 );
+ AddButton( BUTTON_CANCEL, RET_CANCEL, BUTTONDIALOG_CANCELBUTTON );
+ AddButton( BUTTON_HELP, BUTTONID_HELP, BUTTONDIALOG_HELPBUTTON, 4 );
+
+ SetImage( GetSettings().GetStyleSettings().GetHighContrastMode() ?
+ QueryBox::GetStandardImageHC() : QueryBox::GetStandardImage() );
+}
+
+BOOL implImportDialog( Window* pWin, const String& rCurPath, const ScriptDocument& rDocument, const String& aLibName )
+{
+ BOOL bDone = FALSE;
+
+ Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
+ Reference < XFilePicker > xFP;
+ if( xMSF.is() )
+ {
+ Sequence <Any> aServiceType(1);
+ aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
+ xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
+ }
+
+ Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
+ xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, sal_False);
+ Any aValue;
+ aValue <<= (sal_Bool) sal_True;
+ xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
+
+ String aCurPath( rCurPath );
+ if ( aCurPath.Len() )
+ xFP->setDisplayDirectory ( aCurPath );
+
+ String aDialogStr( IDEResId( RID_STR_STDDIALOGNAME ) );
+ Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
+ xFltMgr->appendFilter( aDialogStr, String( RTL_CONSTASCII_USTRINGPARAM( "*.xdl" ) ) );
+ xFltMgr->appendFilter( String( IDEResId( RID_STR_FILTER_ALLFILES ) ), String( RTL_CONSTASCII_USTRINGPARAM( FILTERMASK_ALL ) ) );
+ xFltMgr->setCurrentFilter( aDialogStr );
+
+ if( xFP->execute() == RET_OK )
+ {
+ Sequence< ::rtl::OUString > aPaths = xFP->getFiles();
+ aCurPath = aPaths[0];
+
+ ::rtl::OUString aBasePath;
+ ::rtl::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( xMSF->createInstance
+ ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY_THROW );
+
+ Reference< XSimpleFileAccess > xSFI( xMSF->createInstance
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY_THROW );
+
+ Reference< XInputStream > xInput;
+ if( xSFI->exists( aCurPath ) )
+ xInput = xSFI->openFileRead( aCurPath );
+
+ Reference< XComponentContext > xContext;
+ Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
+ OSL_ASSERT( xProps.is() );
+ OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() );
+
+ String aXmlDlgName;
+ Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY );
+ if( xDialogModelPropSet.is() )
+ {
+ try
+ {
+ Any aXmlDialogNameAny = xDialogModelPropSet->getPropertyValue( DLGED_PROP_NAME );
+ ::rtl::OUString aOUXmlDialogName;
+ aXmlDialogNameAny >>= aOUXmlDialogName;
+ aXmlDlgName = aOUXmlDialogName;
+ }
+ catch( beans::UnknownPropertyException& )
+ {}
+ }
+ bool bValidName = (aXmlDlgName.Len() != 0);
+ OSL_ASSERT( bValidName );
+ if( !bValidName )
+ return bDone;
+
+ bool bDialogAlreadyExists = rDocument.hasDialog( aLibName, aXmlDlgName );
+
+ String aNewDlgName = aXmlDlgName;
+ enum NameClashMode
+ {
+ NO_CLASH,
+ CLASH_OVERWRITE_DIALOG,
+ CLASH_RENAME_DIALOG,
+ };
+ NameClashMode eNameClashMode = NO_CLASH;
+ if( bDialogAlreadyExists )
+ {
+ String aQueryBoxTitle( IDEResId( RID_STR_DLGIMP_CLASH_TITLE ) );
+ String aQueryBoxText( IDEResId( RID_STR_DLGIMP_CLASH_TEXT ) );
+ aQueryBoxText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "$(ARG1)" ) ), aXmlDlgName );
+
+ NameClashQueryBox aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText );
+ USHORT 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;
+ }
+ }
+
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if( pIDEShell == NULL )
+ {
+ OSL_ASSERT( pIDEShell != NULL );
+ return bDone;
+ }
+
+ // Resource?
+ ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
+ Reference< task::XInteractionHandler > xDummyHandler;
+ bool bReadOnly = true;
+ Reference< XStringResourceWithLocation > xImportStringResource =
+ StringResourceWithLocation::create( xContext, aBasePath, bReadOnly,
+ aLocale, aXmlDlgName, ::rtl::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 )
+ {
+ String aQueryBoxTitle( IDEResId( RID_STR_DLGIMP_MISMATCH_TITLE ) );
+ String aQueryBoxText( IDEResId( RID_STR_DLGIMP_MISMATCH_TEXT ) );
+ LanguageMismatchQueryBox aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText );
+ USHORT 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 )
+ {
+ LocalizationMgr* pCurMgr = pIDEShell->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 ( BasicIDE::RemoveDialog( rDocument, aLibName, aNewDlgName ) )
+ {
+ IDEBaseWindow* pDlgWin = pIDEShell->FindDlgWin( rDocument, aLibName, aNewDlgName, FALSE, TRUE );
+ if( pDlgWin != NULL )
+ pIDEShell->RemoveWindow( pDlgWin, TRUE );
+ BasicIDE::MarkDocumentModified( rDocument );
+ }
+ else
+ {
+ // TODO: Assertion?
+ return bDone;
+ }
+ }
+
+ if( eNameClashMode == CLASH_RENAME_DIALOG )
+ {
+ bool bRenamed = false;
+ if( xDialogModelPropSet.is() )
+ {
+ try
+ {
+ Any aXmlDialogNameAny;
+ aXmlDialogNameAny <<= ::rtl::OUString( aNewDlgName );
+ xDialogModelPropSet->setPropertyValue( DLGED_PROP_NAME, aXmlDialogNameAny );
+ bRenamed = true;
+ }
+ catch( 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 = pIDEShell->CreateDlgWin( rDocument, aLibName, aNewDlgName );
+ pIDEShell->SetCurWindow( pNewDlgWin, TRUE );
+ }
+
+ bDone = TRUE;
+ }
+ catch( Exception& )
+ {}
+ }
+
+ return bDone;
+}
+
+BOOL DialogWindow::ImportDialog()
+{
+ DBG_CHKTHIS( DialogWindow, 0 );
+
+ const ScriptDocument& rDocument = GetDocument();
+ String aLibName = GetLibName();
+ BOOL bRet = implImportDialog( this, aCurPath, rDocument, aLibName );
+ return bRet;
+}
+
+DlgEdModel* DialogWindow::GetModel() const
+{
+ return pEditor ? pEditor->GetModel() : NULL;
+}
+
+DlgEdPage* DialogWindow::GetPage() const
+{
+ return pEditor ? pEditor->GetPage() : NULL;
+}
+
+DlgEdView* DialogWindow::GetView() const
+{
+ return pEditor ? pEditor->GetView() : NULL;
+}
+
+BOOL __EXPORT DialogWindow::IsModified()
+{
+ return pEditor->IsModified();
+}
+
+SfxUndoManager* __EXPORT DialogWindow::GetUndoManager()
+{
+ return pUndoMgr;
+}
+
+String DialogWindow::GetTitle()
+{
+ return GetName();
+}
+
+BasicEntryDescriptor DialogWindow::CreateEntryDescriptor()
+{
+ ScriptDocument aDocument( GetDocument() );
+ String aLibName( GetLibName() );
+ String aLibSubName;
+ LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
+ return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, GetName(), OBJ_TYPE_DIALOG );
+}
+
+void DialogWindow::SetReadOnly( BOOL b )
+{
+ if ( pEditor )
+ {
+ if ( b )
+ pEditor->SetMode( DLGED_READONLY );
+ else
+ pEditor->SetMode( DLGED_SELECT );
+ }
+}
+
+BOOL DialogWindow::IsReadOnly()
+{
+ BOOL bReadOnly = FALSE;
+
+ if ( pEditor && pEditor->GetMode() == DLGED_READONLY )
+ bReadOnly = TRUE;
+
+ return bReadOnly;
+}
+
+BOOL DialogWindow::IsPasteAllowed()
+{
+ return pEditor ? pEditor->IsPasteAllowed() : FALSE;
+}
+
+void DialogWindow::StoreData()
+{
+ if ( IsModified() )
+ {
+ try
+ {
+ Reference< container::XNameContainer > xLib = GetDocument().getLibrary( E_DIALOGS, GetLibName(), true );
+
+ if( xLib.is() )
+ {
+ Reference< container::XNameContainer > xDialogModel = pEditor->GetDialog();
+
+ if( xDialogModel.is() )
+ {
+ Reference< XComponentContext > xContext;
+ Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
+ OSL_ASSERT( xProps.is() );
+ OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() );
+ xLib->replaceByName( ::rtl::OUString( GetName() ), makeAny( xISP ) );
+ }
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ BasicIDE::MarkDocumentModified( GetDocument() );
+ pEditor->ClearModifyFlag();
+ }
+}
+
+void DialogWindow::Deactivating()
+{
+ if ( IsModified() )
+ BasicIDE::MarkDocumentModified( GetDocument() );
+}
+
+sal_Int32 DialogWindow::countPages( Printer* pPrinter )
+{
+ return pEditor->countPages( pPrinter );
+}
+
+void DialogWindow::printPage( sal_Int32 nPage, Printer* pPrinter )
+{
+ pEditor->printPage( nPage, pPrinter, CreateQualifiedName() );
+}
+
+void DialogWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if( (rDCEvt.GetType()==DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ InitSettings( TRUE, TRUE, TRUE );
+ Invalidate();
+ }
+ else
+ IDEBaseWindow::DataChanged( rDCEvt );
+}
+
+void DialogWindow::InitSettings(BOOL bFont,BOOL bForeground,BOOL bBackground)
+{
+ 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 );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basidectrlr.cxx b/basctl/source/basicide/basidectrlr.cxx
new file mode 100644
index 000000000000..9bce6c13c294
--- /dev/null
+++ b/basctl/source/basicide/basidectrlr.cxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include <basidectrlr.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <comphelper/sequence.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+#include <vcl/syswin.hxx>
+
+#include <basidesh.hxx>
+
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+
+
+#define PROPERTY_ID_ICONID 1
+#define PROPERTY_ICONID ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IconId" ) )
+
+
+//----------------------------------------------------------------------------
+
+BasicIDEController::BasicIDEController( BasicIDEShell* pViewShell )
+ :OPropertyContainer( m_aBHelper )
+ ,SfxBaseController( pViewShell )
+ ,m_nIconId( ICON_MACROLIBRARY )
+{
+ registerProperty( PROPERTY_ICONID, PROPERTY_ID_ICONID, PropertyAttribute::READONLY, &m_nIconId, ::getCppuType( &m_nIconId ) );
+}
+
+//----------------------------------------------------------------------------
+
+BasicIDEController::~BasicIDEController()
+{
+}
+
+// XInterface
+//----------------------------------------------------------------------------
+
+Any SAL_CALL BasicIDEController::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aReturn = SfxBaseController::queryInterface( rType );
+ if ( !aReturn.hasValue() )
+ aReturn = OPropertyContainer::queryInterface( rType );
+
+ return aReturn;
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL BasicIDEController::acquire() throw()
+{
+ SfxBaseController::acquire();
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL BasicIDEController::release() throw()
+{
+ SfxBaseController::release();
+}
+
+
+// XTypeProvider ( ::SfxBaseController )
+//----------------------------------------------------------------------------
+
+Sequence< Type > SAL_CALL BasicIDEController::getTypes() throw(RuntimeException)
+{
+ Sequence< Type > aTypes = ::comphelper::concatSequences(
+ SfxBaseController::getTypes(),
+ OPropertyContainer::getTypes()
+ );
+
+ return aTypes;
+}
+
+//----------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SAL_CALL BasicIDEController::getImplementationId() throw(RuntimeException)
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if ( !pId )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pId )
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// XPropertySet
+//----------------------------------------------------------------------------
+
+Reference< beans::XPropertySetInfo > SAL_CALL BasicIDEController::getPropertySetInfo() throw(RuntimeException)
+{
+ Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+// OPropertySetHelper
+//----------------------------------------------------------------------------
+
+::cppu::IPropertyArrayHelper& BasicIDEController::getInfoHelper()
+{
+ return *getArrayHelper();
+}
+
+// OPropertyArrayUsageHelper
+//----------------------------------------------------------------------------
+
+::cppu::IPropertyArrayHelper* BasicIDEController::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+}
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx
new file mode 100644
index 000000000000..80928ca87ec5
--- /dev/null
+++ b/basctl/source/basicide/basides1.cxx
@@ -0,0 +1,1443 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include "docsignature.hxx"
+
+#define GLOBALOVERFLOW2
+#include <basic/sbx.hxx>
+#define _SVSTDARR_STRINGS
+#include <svl/svstdarr.hxx>
+#include <ide_pch.hxx>
+
+#define _SOLAR__PRIVATE 1
+
+// #define _SVX_NOIDERESIDS
+
+#define SI_NOCONTROL
+#define SI_NOSBXCONTROLS
+#define SI_NOITEMS
+#define SI_NODRW
+#define _VCTRLS_HXX
+
+#include <basidesh.hrc>
+#include <basidesh.hxx>
+#include <baside2.hxx>
+#include <baside3.hxx>
+#include <basobj.hxx>
+#include <iderdll.hxx>
+#include <iderdll2.hxx>
+#include <sbxitem.hxx>
+#include <managelang.hxx>
+#include <localizationmgr.hxx>
+#include <helpid.hrc>
+
+#include <svtools/texteng.hxx>
+#include <svtools/textview.hxx>
+#include <svtools/xtextedt.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
+#include <sfx2/minfitem.hxx>
+#include <sfx2/docfile.hxx>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/script/XLibraryContainerPassword.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+
+#include <algorithm>
+#include <memory>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+
+class SvxSearchItem;
+
+// Egal was, einfach ans aktuelle Fenster:
+void __EXPORT BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
+{
+ if ( !pCurWin )
+ return;
+
+ switch ( rReq.GetSlot() )
+ {
+ case SID_BASICIDE_HIDECURPAGE:
+ {
+ pCurWin->StoreData();
+ RemoveWindow( pCurWin, FALSE );
+ }
+ break;
+ case SID_BASICIDE_DELETECURRENT:
+ {
+ ScriptDocument aDocument( pCurWin->GetDocument() );
+ String aLibName = pCurWin->GetLibName();
+ String aName = pCurWin->GetName();
+
+ if ( pCurWin->ISA( ModulWindow ) )
+ {
+ // module
+ if ( QueryDelModule( aName, pCurWin ) )
+ {
+ if ( aDocument.removeModule( aLibName, aName ) )
+ {
+ BasicIDE::MarkDocumentModified( aDocument );
+ }
+ }
+ }
+ else
+ {
+ // dialog
+ if ( QueryDelDialog( aName, pCurWin ) )
+ {
+ if ( BasicIDE::RemoveDialog( aDocument, aLibName, aName ) )
+ {
+ RemoveWindow( pCurWin, TRUE );
+ BasicIDE::MarkDocumentModified( aDocument );
+ }
+ }
+ }
+ }
+ break;
+ case SID_BASICIDE_RENAMECURRENT:
+ {
+ pTabBar->StartEditMode( pTabBar->GetCurPageId() );
+ }
+ break;
+ case FID_SEARCH_NOW:
+ {
+ if ( pCurWin->ISA( ModulWindow ) )
+ {
+ DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ // Leider kenne ich die ID nicht:
+ USHORT nWhich = pArgs->GetWhichByPos( 0 );
+ DBG_ASSERT( nWhich, "Wich fuer SearchItem ?" );
+ const SfxPoolItem& rItem = pArgs->Get( nWhich );
+ DBG_ASSERT( rItem.ISA( SvxSearchItem ), "Kein Searchitem!" );
+ if ( rItem.ISA( SvxSearchItem ) )
+ {
+ // Item wegen der Einstellungen merken...
+ IDE_DLL()->GetExtraData()->SetSearchItem( (const SvxSearchItem&)rItem );
+ USHORT nFound = 0;
+ BOOL bCanceled = FALSE;
+ if ( ((const SvxSearchItem&)rItem).GetCommand() == SVX_SEARCHCMD_REPLACE_ALL )
+ {
+ USHORT nActModWindows = 0;
+ IDEBaseWindow* pWin = aIDEWindowTable.First();
+ while ( pWin )
+ {
+ if ( !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) )
+ nActModWindows++;
+ pWin = aIDEWindowTable.Next();
+ }
+
+ if ( ( nActModWindows <= 1 ) || ( !((const SvxSearchItem&)rItem).GetSelection() && QueryBox( pCurWin, WB_YES_NO|WB_DEF_YES, String( IDEResId( RID_STR_SEARCHALLMODULES ) ) ).Execute() == RET_YES ) )
+ {
+ pWin = aIDEWindowTable.First();
+ while ( pWin )
+ {
+ if ( !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) )
+ nFound = nFound + ((ModulWindow*)pWin)->StartSearchAndReplace( (const SvxSearchItem&)rItem );
+ pWin = aIDEWindowTable.Next();
+ }
+ }
+ else
+ nFound = ((ModulWindow*)pCurWin)->StartSearchAndReplace( (const SvxSearchItem&)rItem );
+
+ IDEResId nId( RID_STR_SEARCHREPLACES );
+ String aReplStr( nId );
+ aReplStr.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), String::CreateFromInt32( nFound ) );
+ InfoBox( pCurWin, aReplStr ).Execute();
+ }
+ else
+ {
+ nFound = ((ModulWindow*)pCurWin)->StartSearchAndReplace( (const SvxSearchItem&)rItem );
+ if ( !nFound && !((const SvxSearchItem&)rItem).GetSelection() )
+ {
+ // Andere Module durchsuchen...
+ BOOL bChangeCurWindow = FALSE;
+ aIDEWindowTable.Seek( pCurWin );
+ // Erstmal beim naechsten Anfangen, ggf. spaeter von vorne
+ IDEBaseWindow* pWin = aIDEWindowTable.Next();
+ BOOL bSearchedFromStart = FALSE;
+ while ( !nFound && !bCanceled && ( pWin || !bSearchedFromStart ) )
+ {
+ if ( !pWin )
+ {
+ SfxViewFrame* pViewFrame = GetViewFrame();
+ SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow( SID_SEARCH_DLG ) : NULL;
+ Window* pParent = pChildWin ? pChildWin->GetWindow() : NULL;
+ QueryBox aQuery( pParent, WB_YES_NO|WB_DEF_YES, String( IDEResId( RID_STR_SEARCHFROMSTART ) ) );
+ if ( aQuery.Execute() == RET_YES )
+ {
+ pWin = aIDEWindowTable.First();
+ bSearchedFromStart = TRUE;
+ }
+ else
+ bCanceled = TRUE;
+ }
+
+ if ( pWin && !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) )
+ {
+ if ( pWin != pCurWin )
+ {
+ // Groesse einstellen, damit die View
+ // gleich richtig justiert werden kann.
+ if ( pCurWin )
+ pWin->SetSizePixel( pCurWin->GetSizePixel() );
+ nFound = ((ModulWindow*)pWin)->StartSearchAndReplace( (const SvxSearchItem&)rItem, TRUE );
+ }
+ if ( nFound )
+ {
+ bChangeCurWindow = TRUE;
+ break;
+ }
+ }
+ if ( pWin && ( pWin != pCurWin ) )
+ pWin = aIDEWindowTable.Next();
+ else
+ pWin = 0; // Dann sind wir durch...
+ }
+ if ( !nFound && bSearchedFromStart ) // Aktuelles von vorne...
+ nFound = ((ModulWindow*)pCurWin)->StartSearchAndReplace( (const SvxSearchItem&)rItem, TRUE );
+ if ( bChangeCurWindow )
+ SetCurWindow( pWin, TRUE );
+ }
+ if ( !nFound && !bCanceled )
+ InfoBox( pCurWin, String( IDEResId( RID_STR_SEARCHNOTFOUND ) ) ).Execute();
+ }
+
+ rReq.Done();
+ }
+ }
+ }
+ break;
+ case FID_SEARCH_OFF:
+ {
+ if ( pCurWin && pCurWin->ISA( ModulWindow ) )
+ pCurWin->GrabFocus();
+ }
+ break;
+ case SID_UNDO:
+ case SID_REDO:
+ {
+ if ( GetUndoManager() && pCurWin->AllowUndo() )
+ {
+ GetViewFrame()->ExecuteSlot( rReq );
+ }
+ }
+ break;
+ default:
+ {
+ pCurWin->ExecuteCommand( rReq );
+ }
+ }
+}
+
+// Egal, wer oben, Einfluss auf die Shell:
+void __EXPORT BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
+{
+ USHORT nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case SID_BASICSTOP:
+ {
+ // Evtl. nicht einfach anhalten, falls auf Brechpunkt!
+ if ( pCurWin && pCurWin->IsA( TYPE( ModulWindow ) ) )
+ ((ModulWindow*)pCurWin)->BasicStop();
+ BasicIDE::StopBasic();
+ }
+ break;
+
+ case SID_SAVEDOC:
+ {
+ if ( pCurWin )
+ {
+ // Daten ins BASIC zurueckschreiben
+ StoreAllWindowData();
+
+ // document basic
+ ScriptDocument aDocument( pCurWin->GetDocument() );
+ if ( aDocument.isDocument() )
+ {
+ uno::Reference< task::XStatusIndicator > xStatusIndicator;
+
+ SFX_REQUEST_ARG( rReq, pStatusIndicatorItem, SfxUnoAnyItem, SID_PROGRESS_STATUSBAR_CONTROL, FALSE );
+ if ( pStatusIndicatorItem )
+ OSL_VERIFY( pStatusIndicatorItem->GetValue() >>= xStatusIndicator );
+ else
+ {
+ // get statusindicator
+ SfxViewFrame *pFrame_ = GetFrame();
+ if ( pFrame_ )
+ {
+ uno::Reference< task::XStatusIndicatorFactory > xStatFactory(
+ pFrame_->GetFrame().GetFrameInterface(),
+ uno::UNO_QUERY );
+ if( xStatFactory.is() )
+ xStatusIndicator = xStatFactory->createStatusIndicator();
+ }
+
+ if ( xStatusIndicator.is() )
+ rReq.AppendItem( SfxUnoAnyItem( SID_PROGRESS_STATUSBAR_CONTROL, uno::makeAny( xStatusIndicator ) ) );
+ }
+
+ aDocument.saveDocument( xStatusIndicator );
+ }
+
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ {
+ pBindings->Invalidate( SID_DOC_MODIFIED );
+ pBindings->Invalidate( SID_SAVEDOC );
+ pBindings->Invalidate( SID_SIGNATURE );
+ }
+ }
+ }
+ break;
+ case SID_SIGNATURE:
+ {
+ if ( pCurWin )
+ {
+ ::basctl::DocumentSignature aSignature( pCurWin->GetDocument() );
+ if ( aSignature.supportsSignatures() )
+ {
+ aSignature.signScriptingContent();
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_SIGNATURE );
+ }
+ }
+ }
+ break;
+
+ case SID_BASICIDE_MODULEDLG:
+ {
+ if ( rReq.GetArgs() )
+ {
+ const SfxUInt16Item &rTabId = (const SfxUInt16Item&)rReq.GetArgs()->Get(SID_BASICIDE_ARG_TABID );
+ BasicIDE::Organize( rTabId.GetValue() );
+ }
+ else
+ BasicIDE::Organize( 0 );
+ }
+ break;
+ case SID_BASICIDE_CHOOSEMACRO:
+ {
+ BasicIDE::ChooseMacro( NULL, FALSE, ::rtl::OUString() );
+ }
+ break;
+ case SID_BASICIDE_CREATEMACRO:
+ case SID_BASICIDE_EDITMACRO:
+ {
+ DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
+ const SfxMacroInfoItem& rInfo = (const SfxMacroInfoItem&)rReq.GetArgs()->Get(SID_BASICIDE_ARG_MACROINFO );
+ BasicManager* pBasMgr = (BasicManager*)rInfo.GetBasicManager();
+ DBG_ASSERT( pBasMgr, "Nichts selektiert im Basic-Baum ?" );
+
+ ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
+
+ StartListening( *pBasMgr, TRUE /* Nur einmal anmelden */ );
+ String aLibName( rInfo.GetLib() );
+ if ( !aLibName.Len() )
+ aLibName = String::CreateFromAscii( "Standard" );
+ StarBASIC* pBasic = pBasMgr->GetLib( aLibName );
+ if ( !pBasic )
+ {
+ // load module and dialog library (if not loaded)
+ aDocument.loadLibraryIfExists( E_SCRIPTS, aLibName );
+ aDocument.loadLibraryIfExists( E_DIALOGS, aLibName );
+
+ // get Basic
+ pBasic = pBasMgr->GetLib( aLibName );
+ }
+ DBG_ASSERT( pBasic, "Kein Basic!" );
+
+ SetCurLib( aDocument, aLibName );
+
+ if ( rReq.GetSlot() == SID_BASICIDE_CREATEMACRO )
+ {
+ SbModule* pModule = pBasic->FindModule( rInfo.GetModule() );
+ if ( !pModule )
+ {
+ if ( rInfo.GetModule().Len() || !pBasic->GetModules()->Count() )
+ {
+ String aModName = rInfo.GetModule();
+
+ ::rtl::OUString sModuleCode;
+ if ( aDocument.createModule( aLibName, aModName, FALSE, sModuleCode ) )
+ pModule = pBasic->FindModule( aModName );
+ }
+ else
+ pModule = (SbModule*) pBasic->GetModules()->Get(0);
+ }
+ DBG_ASSERT( pModule, "Kein Modul!" );
+ if ( !pModule->GetMethods()->Find( rInfo.GetMethod(), SbxCLASS_METHOD ) )
+ BasicIDE::CreateMacro( pModule, rInfo.GetMethod() );
+ }
+ SfxViewFrame* pViewFrame = GetViewFrame();
+ if ( pViewFrame )
+ pViewFrame->ToTop();
+ ModulWindow* pWin = FindBasWin( aDocument, aLibName, rInfo.GetModule(), TRUE );
+ DBG_ASSERT( pWin, "Edit/Create Macro: Fenster wurde nicht erzeugt/gefunden!" );
+ SetCurWindow( pWin, TRUE );
+ pWin->EditMacro( rInfo.GetMethod() );
+ }
+ break;
+ case SID_BASICIDE_OBJCAT:
+ {
+ ShowObjectDialog( TRUE, TRUE );
+ }
+ break;
+ case SID_BASICIDE_NAMECHANGEDONTAB:
+ {
+ DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
+ const SfxUInt16Item &rTabId = (const SfxUInt16Item&)rReq.GetArgs()->Get(SID_BASICIDE_ARG_TABID );
+ const SfxStringItem &rModName = (const SfxStringItem&)rReq.GetArgs()->Get(SID_BASICIDE_ARG_MODULENAME );
+ IDEBaseWindow* pWin = aIDEWindowTable.Get( rTabId.GetValue() );
+ DBG_ASSERT( pWin, "Window nicht im Liste, aber in TabBar ?" );
+ if ( pWin )
+ {
+ String aNewName( rModName.GetValue() );
+ String aOldName( pWin->GetName() );
+ if ( aNewName != aOldName )
+ {
+ bool bRenameOk = false;
+ if ( pWin->IsA( TYPE( ModulWindow ) ) )
+ {
+ ModulWindow* pModWin = (ModulWindow*)pWin;
+ String aLibName = ( pModWin->GetLibName() );
+ ScriptDocument aDocument( pWin->GetDocument() );
+
+ if ( BasicIDE::RenameModule( pModWin, aDocument, aLibName, aOldName, aNewName ) )
+ {
+ bRenameOk = true;
+ // Because we listen for container events for script
+ // modules, rename will delete the 'old' window
+ // pWin has been invalidated, restore now
+ pWin = FindBasWin( aDocument, aLibName, aNewName, TRUE );
+ }
+
+ }
+ else if ( pWin->IsA( TYPE( DialogWindow ) ) )
+ {
+ DialogWindow* pDlgWin = (DialogWindow*)pWin;
+ bRenameOk = pDlgWin->RenameDialog( aNewName );
+ }
+ if ( bRenameOk )
+ {
+ BasicIDE::MarkDocumentModified( pWin->GetDocument() );
+ }
+ else
+ {
+ // set old name in TabWriter
+ USHORT nId = (USHORT)aIDEWindowTable.GetKey( pWin );
+ DBG_ASSERT( nId, "No entry in Tabbar!" );
+ if ( nId )
+ pTabBar->SetPageText( nId, aOldName );
+ }
+ }
+
+ // set focus to current window
+ pWin->GrabFocus();
+ }
+ }
+ break;
+ case SID_BASICIDE_STOREMODULESOURCE:
+ case SID_BASICIDE_UPDATEMODULESOURCE:
+ {
+ DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
+ const SfxMacroInfoItem& rInfo = (const SfxMacroInfoItem&)rReq.GetArgs()->Get(SID_BASICIDE_ARG_MACROINFO );
+ BasicManager* pBasMgr = (BasicManager*)rInfo.GetBasicManager();
+ DBG_ASSERT( pBasMgr, "Store source: Kein BasMgr?" );
+ ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
+ ModulWindow* pWin = FindBasWin( aDocument, rInfo.GetLib(), rInfo.GetModule(), FALSE, TRUE );
+ if ( pWin )
+ {
+ if ( rReq.GetSlot() == SID_BASICIDE_STOREMODULESOURCE )
+ pWin->StoreData();
+ else
+ pWin->UpdateData();
+ }
+ }
+ break;
+ case SID_BASICIDE_STOREALLMODULESOURCES:
+ case SID_BASICIDE_UPDATEALLMODULESOURCES:
+ {
+ IDEBaseWindow* pWin = aIDEWindowTable.First();
+ while ( pWin )
+ {
+ if ( !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) )
+ {
+ if ( rReq.GetSlot() == SID_BASICIDE_STOREALLMODULESOURCES )
+ pWin->StoreData();
+ else
+ pWin->UpdateData();
+ }
+ pWin = aIDEWindowTable.Next();
+ }
+ }
+ break;
+ case SID_BASICIDE_LIBSELECTED:
+ case SID_BASICIDE_LIBREMOVED:
+ case SID_BASICIDE_LIBLOADED:
+ {
+ DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
+ const SfxUsrAnyItem& rShellItem = (const SfxUsrAnyItem&)rReq.GetArgs()->Get( SID_BASICIDE_ARG_DOCUMENT_MODEL );
+ uno::Reference< frame::XModel > xModel( rShellItem.GetValue(), UNO_QUERY );
+ ScriptDocument aDocument( xModel.is() ? ScriptDocument( xModel ) : ScriptDocument::getApplicationScriptDocument() );
+ const SfxStringItem& rLibNameItem = (const SfxStringItem&)rReq.GetArgs()->Get( SID_BASICIDE_ARG_LIBNAME );
+ String aLibName( rLibNameItem.GetValue() );
+
+ if ( nSlot == SID_BASICIDE_LIBSELECTED )
+ {
+ // load module and dialog library (if not loaded)
+ aDocument.loadLibraryIfExists( E_SCRIPTS, aLibName );
+ aDocument.loadLibraryIfExists( E_DIALOGS, aLibName );
+
+ // check password, if library is password protected and not verified
+ BOOL bOK = TRUE;
+ Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
+ {
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
+ {
+ String aPassword;
+ bOK = QueryPassword( xModLibContainer, aLibName, aPassword );
+ }
+ }
+
+ if ( bOK )
+ {
+ SetCurLib( aDocument, aLibName, true, false );
+ }
+ else
+ {
+ // alten Wert einstellen...
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR, TRUE, FALSE );
+ }
+ }
+ else if ( nSlot == SID_BASICIDE_LIBREMOVED )
+ {
+ if ( !m_aCurLibName.Len() || ( aDocument == m_aCurDocument && aLibName == m_aCurLibName ) )
+ {
+ RemoveWindows( aDocument, aLibName, TRUE );
+ if ( aDocument == m_aCurDocument && aLibName == m_aCurLibName )
+ {
+ m_aCurDocument = ScriptDocument::getApplicationScriptDocument();
+ m_aCurLibName = String();
+ // Kein UpdateWindows!
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR );
+ }
+ }
+ }
+ else // Loaded...
+ UpdateWindows();
+ }
+ break;
+ case SID_BASICIDE_NEWMODULE:
+ {
+ ModulWindow* pWin = CreateBasWin( m_aCurDocument, m_aCurLibName, String() );
+ DBG_ASSERT( pWin, "New Module: Konnte Fenster nicht erzeugen!" );
+ SetCurWindow( pWin, TRUE );
+ }
+ break;
+ case SID_BASICIDE_NEWDIALOG:
+ {
+ DialogWindow* pWin = CreateDlgWin( m_aCurDocument, m_aCurLibName, String() );
+ DBG_ASSERT( pWin, "New Module: Konnte Fenster nicht erzeugen!" );
+ SetCurWindow( pWin, TRUE );
+ }
+ break;
+ case SID_BASICIDE_SBXRENAMED:
+ {
+ DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
+ }
+ break;
+ case SID_BASICIDE_SBXINSERTED:
+ {
+ DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
+ const SbxItem& rSbxItem = (const SbxItem&)rReq.GetArgs()->Get(SID_BASICIDE_ARG_SBX );
+ ScriptDocument aDocument( rSbxItem.GetDocument() );
+ String aLibName( rSbxItem.GetLibName() );
+ String aName( rSbxItem.GetName() );
+ if ( !m_aCurLibName.Len() || ( aDocument == m_aCurDocument && aLibName == m_aCurLibName ) )
+ {
+ IDEBaseWindow* pWin = 0;
+ if ( rSbxItem.GetType() == BASICIDE_TYPE_MODULE )
+ pWin = FindBasWin( aDocument, aLibName, aName, TRUE );
+ else if ( rSbxItem.GetType() == BASICIDE_TYPE_DIALOG )
+ pWin = FindDlgWin( aDocument, aLibName, aName, TRUE );
+ }
+ }
+ break;
+ case SID_BASICIDE_SBXDELETED:
+ {
+ DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
+ const SbxItem& rSbxItem = (const SbxItem&)rReq.GetArgs()->Get(SID_BASICIDE_ARG_SBX );
+ ScriptDocument aDocument( rSbxItem.GetDocument() );
+ IDEBaseWindow* pWin = FindWindow( aDocument, rSbxItem.GetLibName(), rSbxItem.GetName(), rSbxItem.GetType(), TRUE );
+ if ( pWin )
+ RemoveWindow( pWin, TRUE );
+ }
+ break;
+ case SID_BASICIDE_SHOWSBX:
+ {
+ DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
+ const SbxItem& rSbxItem = (const SbxItem&)rReq.GetArgs()->Get(SID_BASICIDE_ARG_SBX );
+ ScriptDocument aDocument( rSbxItem.GetDocument() );
+ String aLibName( rSbxItem.GetLibName() );
+ String aName( rSbxItem.GetName() );
+ SetCurLib( aDocument, aLibName );
+ IDEBaseWindow* pWin = 0;
+ if ( rSbxItem.GetType() == BASICIDE_TYPE_DIALOG )
+ {
+ pWin = FindDlgWin( aDocument, aLibName, aName, TRUE );
+ }
+ else if ( rSbxItem.GetType() == BASICIDE_TYPE_MODULE )
+ {
+ pWin = FindBasWin( aDocument, aLibName, aName, TRUE );
+ }
+ else if ( rSbxItem.GetType() == BASICIDE_TYPE_METHOD )
+ {
+ pWin = FindBasWin( aDocument, aLibName, aName, TRUE );
+ ((ModulWindow*)pWin)->EditMacro( rSbxItem.GetMethodName() );
+ }
+ DBG_ASSERT( pWin, "Fenster wurde nicht erzeugt!" );
+ SetCurWindow( pWin, TRUE );
+ pTabBar->MakeVisible( pTabBar->GetCurPageId() );
+ }
+ break;
+ case SID_SHOW_PROPERTYBROWSER:
+ {
+ GetViewFrame()->ChildWindowExecute( rReq );
+ rReq.Done();
+ }
+ break;
+ case SID_BASICIDE_SHOWWINDOW:
+ {
+ ::std::auto_ptr< ScriptDocument > pDocument;
+
+ SFX_REQUEST_ARG( rReq, pDocumentItem, SfxStringItem, SID_BASICIDE_ARG_DOCUMENT, sal_False );
+ if ( pDocumentItem )
+ {
+ String sDocumentCaption = pDocumentItem->GetValue();
+ if ( sDocumentCaption.Len() )
+ pDocument.reset( new ScriptDocument( ScriptDocument::getDocumentWithURLOrCaption( sDocumentCaption ) ) );
+ }
+
+ SFX_REQUEST_ARG( rReq, pDocModelItem, SfxUsrAnyItem, SID_BASICIDE_ARG_DOCUMENT_MODEL, sal_False );
+ if ( !pDocument.get() && pDocModelItem )
+ {
+ uno::Reference< frame::XModel > xModel( pDocModelItem->GetValue(), UNO_QUERY );
+ if ( xModel.is() )
+ pDocument.reset( new ScriptDocument( xModel ) );
+ }
+
+ if ( !pDocument.get() )
+ break;
+
+ SFX_REQUEST_ARG( rReq, pLibNameItem, SfxStringItem, SID_BASICIDE_ARG_LIBNAME, sal_False );
+ if ( !pLibNameItem )
+ break;
+
+ String aLibName( pLibNameItem->GetValue() );
+ pDocument->loadLibraryIfExists( E_SCRIPTS, aLibName );
+ SetCurLib( *pDocument, aLibName );
+ SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_BASICIDE_ARG_NAME, sal_False );
+ if ( pNameItem )
+ {
+ String aName( pNameItem->GetValue() );
+ String aModType( String::CreateFromAscii( "Module" ) );
+ String aDlgType( String::CreateFromAscii( "Dialog" ) );
+ String aType( aModType );
+ SFX_REQUEST_ARG( rReq, pTypeItem, SfxStringItem, SID_BASICIDE_ARG_TYPE, sal_False );
+ if ( pTypeItem )
+ aType = pTypeItem->GetValue();
+
+ IDEBaseWindow* pWin = 0;
+ if ( aType == aModType )
+ pWin = FindBasWin( *pDocument, aLibName, aName, FALSE );
+ else if ( aType == aDlgType )
+ pWin = FindDlgWin( *pDocument, aLibName, aName, FALSE );
+
+ if ( pWin )
+ {
+ SetCurWindow( pWin, TRUE );
+ if ( pTabBar )
+ pTabBar->MakeVisible( pTabBar->GetCurPageId() );
+
+ if ( pWin->ISA( ModulWindow ) )
+ {
+ ModulWindow* pModWin = (ModulWindow*)pWin;
+ SFX_REQUEST_ARG( rReq, pLineItem, SfxUInt32Item, SID_BASICIDE_ARG_LINE, sal_False );
+ if ( pLineItem )
+ {
+ pModWin->AssertValidEditEngine();
+ TextView* pTextView = pModWin->GetEditView();
+ if ( pTextView )
+ {
+ TextEngine* pTextEngine = pTextView->GetTextEngine();
+ if ( pTextEngine )
+ {
+ sal_uInt32 nLine = pLineItem->GetValue();
+ sal_uInt32 nLineCount = 0;
+ for ( sal_uInt32 i = 0, nCount = pTextEngine->GetParagraphCount(); i < nCount; ++i )
+ nLineCount += pTextEngine->GetLineCount( i );
+ if ( nLine > nLineCount )
+ nLine = nLineCount;
+ if ( nLine > 0 )
+ --nLine;
+
+ // scroll window and set selection
+ long nVisHeight = pModWin->GetOutputSizePixel().Height();
+ long nTextHeight = pTextEngine->GetTextHeight();
+ if ( nTextHeight > nVisHeight )
+ {
+ long nMaxY = nTextHeight - nVisHeight;
+ long nOldY = pTextView->GetStartDocPos().Y();
+ long nNewY = nLine * pTextEngine->GetCharHeight() - nVisHeight / 2;
+ nNewY = ::std::min( nNewY, nMaxY );
+ pTextView->Scroll( 0, -( nNewY - nOldY ) );
+ pTextView->ShowCursor( FALSE, TRUE );
+ pModWin->GetEditVScrollBar().SetThumbPos( pTextView->GetStartDocPos().Y() );
+ }
+ sal_uInt16 nCol1 = 0, nCol2 = 0;
+ SFX_REQUEST_ARG( rReq, pCol1Item, SfxUInt16Item, SID_BASICIDE_ARG_COLUMN1, sal_False );
+ if ( pCol1Item )
+ {
+ nCol1 = pCol1Item->GetValue();
+ if ( nCol1 > 0 )
+ --nCol1;
+ nCol2 = nCol1;
+ }
+ SFX_REQUEST_ARG( rReq, pCol2Item, SfxUInt16Item, SID_BASICIDE_ARG_COLUMN2, sal_False );
+ if ( pCol2Item )
+ {
+ nCol2 = pCol2Item->GetValue();
+ if ( nCol2 > 0 )
+ --nCol2;
+ }
+ TextSelection aSel( TextPaM( nLine, nCol1 ), TextPaM( nLine, nCol2 ) );
+ pTextView->SetSelection( aSel );
+ pTextView->ShowCursor();
+ Window* pWindow_ = pTextView->GetWindow();
+ if ( pWindow_ )
+ pWindow_->GrabFocus();
+ }
+ }
+ }
+ }
+ }
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_BASICIDE_MANAGE_LANG:
+ {
+ ManageLanguageDialog aDlg( GetCurWindow(), GetCurLocalizationMgr() );
+ aDlg.Execute();
+ rReq.Done();
+ }
+ break;
+ }
+}
+
+void __EXPORT BasicIDEShell::GetState(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter(rSet);
+ for ( USHORT nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich() )
+ {
+ switch ( nWh )
+ {
+ case SID_DOCINFO:
+ {
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_SAVEDOC:
+ {
+ BOOL bDisable = FALSE;
+
+ if ( pCurWin )
+ {
+ if ( !pCurWin->IsModified() )
+ {
+ ScriptDocument aDocument( pCurWin->GetDocument() );
+ bDisable = ( !aDocument.isAlive() )
+ || ( aDocument.isDocument() ? !aDocument.isDocumentModified() : !IsAppBasicModified() );
+ }
+ }
+ else
+ {
+ bDisable = TRUE;
+ }
+
+ if ( bDisable )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_NEWWINDOW:
+ case SID_SAVEASDOC:
+ {
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_SIGNATURE:
+ {
+ sal_uInt16 nState = 0;
+ if ( pCurWin )
+ {
+ ::basctl::DocumentSignature aSignature( pCurWin->GetDocument() );
+ nState = aSignature.getScriptingSignatureState();
+ }
+ rSet.Put( SfxUInt16Item( SID_SIGNATURE, nState ) );
+ }
+ break;
+ case SID_BASICIDE_MODULEDLG:
+ {
+ if ( StarBASIC::IsRunning() )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_BASICIDE_CHOOSEMACRO:
+ case SID_BASICIDE_OBJCAT:
+ case SID_BASICIDE_SHOWSBX:
+ case SID_BASICIDE_CREATEMACRO:
+ case SID_BASICIDE_EDITMACRO:
+ case SID_BASICIDE_NAMECHANGEDONTAB:
+ {
+ ;
+ }
+ break;
+
+ case SID_BASICIDE_ADDWATCH:
+ case SID_BASICIDE_REMOVEWATCH:
+ case SID_BASICLOAD:
+ case SID_BASICSAVEAS:
+ case SID_BASICIDE_MATCHGROUP:
+ {
+ if ( !pCurWin || !pCurWin->IsA( TYPE( ModulWindow ) ) )
+ rSet.DisableItem( nWh );
+ else if ( ( nWh == SID_BASICLOAD ) && ( StarBASIC::IsRunning() || ( pCurWin && pCurWin->IsReadOnly() ) ) )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_BASICRUN:
+ case SID_BASICSTEPINTO:
+ case SID_BASICSTEPOVER:
+ case SID_BASICSTEPOUT:
+ case SID_BASICIDE_TOGGLEBRKPNT:
+ case SID_BASICIDE_MANAGEBRKPNTS:
+ {
+ if ( !pCurWin || !pCurWin->IsA( TYPE( ModulWindow ) ) )
+ rSet.DisableItem( nWh );
+ else if ( StarBASIC::IsRunning() && !((ModulWindow*)pCurWin)->GetBasicStatus().bIsInReschedule )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_BASICCOMPILE:
+ {
+ if ( !pCurWin || !pCurWin->IsA( TYPE( ModulWindow ) ) || StarBASIC::IsRunning() )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_BASICSTOP:
+ {
+ // Stop immermoeglich, wenn irgendein Basic lauft...
+ if ( !StarBASIC::IsRunning() )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_CHOOSE_CONTROLS:
+ case SID_DIALOG_TESTMODE:
+ {
+ if( !pCurWin || !pCurWin->IsA( TYPE( DialogWindow ) ) )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_SHOW_FORMS:
+ case SID_SHOW_HIDDEN:
+ {
+ rSet.DisableItem( nWh );
+ }
+ break;
+ case SID_SEARCH_OPTIONS:
+ {
+ USHORT nOptions = 0;
+ if( pCurWin )
+ nOptions = pCurWin->GetSearchOptions();
+ rSet.Put( SfxUInt16Item( SID_SEARCH_OPTIONS, nOptions ) );
+ }
+ break;
+ case SID_BASICIDE_LIBSELECTOR:
+ {
+ String aName;
+ if ( m_aCurLibName.Len() )
+ {
+ LibraryLocation eLocation = m_aCurDocument.getLibraryLocation( m_aCurLibName );
+ aName = CreateMgrAndLibStr( m_aCurDocument.getTitle( eLocation ), m_aCurLibName );
+ }
+ SfxStringItem aItem( SID_BASICIDE_LIBSELECTOR, aName );
+ rSet.Put( aItem );
+ }
+ break;
+ case SID_SEARCH_ITEM:
+ {
+ String aSelected = GetSelectionText( TRUE );
+ SvxSearchItem& rItem = IDE_DLL()->GetExtraData()->GetSearchItem();
+ rItem.SetSearchString( aSelected );
+ rSet.Put( rItem );
+ }
+ break;
+ case SID_BASICIDE_STAT_DATE:
+ {
+ String aDate;
+ aDate = String( RTL_CONSTASCII_USTRINGPARAM( "Datum?!" ) );
+ SfxStringItem aItem( SID_BASICIDE_STAT_DATE, aDate );
+ rSet.Put( aItem );
+ }
+ break;
+ case SID_DOC_MODIFIED:
+ {
+ String aModifiedMarker;
+ BOOL bModified = FALSE;
+
+ if ( pCurWin )
+ {
+ if ( pCurWin->IsModified() )
+ bModified = TRUE;
+ else
+ {
+ ScriptDocument aDocument( pCurWin->GetDocument() );
+ bModified = aDocument.isDocument() ? aDocument.isDocumentModified() : IsAppBasicModified();
+ }
+ }
+
+ if ( bModified )
+ aModifiedMarker = '*';
+
+ SfxStringItem aItem( SID_DOC_MODIFIED, aModifiedMarker );
+ rSet.Put( aItem );
+ }
+ break;
+ case SID_BASICIDE_STAT_TITLE:
+ {
+ if ( pCurWin )
+ {
+ String aTitle = pCurWin->CreateQualifiedName();
+ SfxStringItem aItem( SID_BASICIDE_STAT_TITLE, aTitle );
+ rSet.Put( aItem );
+ }
+ }
+ break;
+ // Werden vom Controller ausgewertet:
+ case SID_ATTR_SIZE:
+ case SID_ATTR_INSERT:
+ break;
+ case SID_UNDO:
+ case SID_REDO:
+ {
+ if( GetUndoManager() ) // sonst rekursives GetState
+ GetViewFrame()->GetSlotState( nWh, NULL, &rSet );
+ }
+ break;
+ case SID_SHOW_PROPERTYBROWSER:
+ {
+ if ( GetViewFrame()->KnowsChildWindow( nWh ) )
+ rSet.Put( SfxBoolItem( nWh, GetViewFrame()->HasChildWindow( nWh ) ) );
+ else
+ rSet.DisableItem( nWh );
+ }
+ break;
+
+ case SID_BASICIDE_CURRENT_LANG:
+ {
+ if( (pCurWin && pCurWin->IsReadOnly()) || GetCurLibName().Len() == 0 )
+ rSet.DisableItem( nWh );
+ else
+ {
+ String aItemStr;
+ LocalizationMgr* pCurMgr = GetCurLocalizationMgr();
+ if ( pCurMgr->isLibraryLocalized() )
+ {
+ Sequence< lang::Locale > aLocaleSeq = pCurMgr->getStringResourceManager()->getLocales();
+ const lang::Locale* pLocale = aLocaleSeq.getConstArray();
+ INT32 i, nCount = aLocaleSeq.getLength();
+
+ // Force different results for any combination of locales and default locale
+ ::rtl::OUString aLangStr;
+ for ( i = 0; i <= nCount; ++i )
+ {
+ lang::Locale aLocale;
+ if( i < nCount )
+ aLocale = pLocale[i];
+ else
+ aLocale = pCurMgr->getStringResourceManager()->getDefaultLocale();
+
+ aLangStr += aLocale.Language;
+ aLangStr += aLocale.Country;
+ aLangStr += aLocale.Variant;
+ }
+ aItemStr = aLangStr;
+ }
+ rSet.Put( SfxStringItem( nWh, aItemStr ) );
+ }
+ }
+ break;
+
+ case SID_BASICIDE_MANAGE_LANG:
+ {
+ if( (pCurWin && pCurWin->IsReadOnly()) || GetCurLibName().Len() == 0 )
+ rSet.DisableItem( nWh );
+ }
+ break;
+ }
+ }
+ if ( pCurWin )
+ pCurWin->GetState( rSet );
+}
+
+sal_Bool BasicIDEShell::HasUIFeature( sal_uInt32 nFeature )
+{
+ sal_Bool bResult = sal_False;
+
+ if ( (nFeature & BASICIDE_UI_FEATURE_SHOW_BROWSER) == BASICIDE_UI_FEATURE_SHOW_BROWSER )
+ {
+ // fade out (in) property browser in module (dialog) windows
+ if ( pCurWin && pCurWin->IsA( TYPE( DialogWindow ) ) && !pCurWin->IsReadOnly() )
+ bResult = sal_True;
+ }
+
+ return bResult;
+}
+
+void BasicIDEShell::SetCurWindow( IDEBaseWindow* pNewWin, BOOL bUpdateTabBar, BOOL bRememberAsCurrent )
+{
+ // Es muss ein EditWindow am Sfx gesetzt sein, sonst kommt kein
+ // Resize, also stehen die Controls auf den Wiese...
+ // Sieht dann sowieso besser aus, wenn das Modul-Layout angezeigt wird...
+ if ( !pNewWin && ( GetWindow() != pModulLayout ) )
+ {
+ pModulLayout->Show();
+ AdjustPosSizePixel( Point( 0, 0 ), GetViewFrame()->GetWindow().GetOutputSizePixel() );
+ SetWindow( pModulLayout );
+ EnableScrollbars( FALSE );
+ aVScrollBar.Hide();
+ }
+
+ if ( pNewWin != pCurWin )
+ {
+ IDEBaseWindow* pPrevCurWin = pCurWin;
+ pCurWin = pNewWin;
+ if ( pPrevCurWin )
+ {
+ pPrevCurWin->Hide();
+ pPrevCurWin->Deactivating();
+// pPrevCurWin->GetLayoutWindow()->Hide();
+ if( pPrevCurWin->IsA( TYPE( DialogWindow ) ) )
+ {
+ ((DialogWindow*)pPrevCurWin)->DisableBrowser();
+ }
+ else
+ {
+ pModulLayout->SetModulWindow( NULL );
+ }
+ }
+ if ( pCurWin )
+ {
+ AdjustPosSizePixel( Point( 0, 0 ), GetViewFrame()->GetWindow().GetOutputSizePixel() );
+ if( pCurWin->IsA( TYPE( ModulWindow ) ) )
+ {
+ GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW );
+ pModulLayout->SetModulWindow( (ModulWindow*)pCurWin );
+ pModulLayout->Show();
+ }
+ else
+ {
+ pModulLayout->Hide();
+ GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_DIALOGWINDOW );
+ }
+
+ if ( bRememberAsCurrent )
+ {
+ BasicIDEData* pData = IDE_DLL()->GetExtraData();
+ if ( pData )
+ {
+ USHORT nCurrentType = pCurWin->IsA( TYPE( ModulWindow ) ) ? BASICIDE_TYPE_MODULE : BASICIDE_TYPE_DIALOG;
+ LibInfoItem* pLibInfoItem = new LibInfoItem( pCurWin->GetDocument(), pCurWin->GetLibName(), pCurWin->GetName(), nCurrentType );
+ pData->GetLibInfos().InsertInfo( pLibInfoItem );
+ }
+ }
+
+ if ( GetViewFrame()->GetWindow().IsVisible() ) // sonst macht es spaeter der SFX
+ pCurWin->Show();
+
+ pCurWin->Init();
+
+ if ( !IDE_DLL()->GetExtraData()->ShellInCriticalSection() )
+ {
+ Window* pFrameWindow = &GetViewFrame()->GetWindow();
+ Window* pFocusWindow = Application::GetFocusWindow();
+ while ( pFocusWindow && ( pFocusWindow != pFrameWindow ) )
+ pFocusWindow = pFocusWindow->GetParent();
+ if ( pFocusWindow ) // Focus in BasicIDE
+ pNewWin->GrabFocus();
+ }
+ if( pCurWin->IsA( TYPE( DialogWindow ) ) )
+ ((DialogWindow*)pCurWin)->UpdateBrowser();
+ }
+ if ( bUpdateTabBar )
+ {
+ ULONG nKey = aIDEWindowTable.GetKey( pCurWin );
+ if ( pCurWin && ( pTabBar->GetPagePos( (USHORT)nKey ) == TAB_PAGE_NOTFOUND ) )
+ pTabBar->InsertPage( (USHORT)nKey, pCurWin->GetTitle() ); // wurde neu eingeblendet
+ pTabBar->SetCurPageId( (USHORT)nKey );
+ }
+ if ( pCurWin && pCurWin->IsSuspended() ) // Wenn das Fenster im Fehlerfall angezeigt wird...
+ pCurWin->SetStatus( pCurWin->GetStatus() & ~BASWIN_SUSPENDED );
+ if ( pCurWin )
+ {
+ SetWindow( pCurWin );
+ if ( pCurWin->GetDocument().isDocument() )
+ SfxObjectShell::SetCurrentComponent( pCurWin->GetDocument().getDocument() );
+ }
+ else
+ {
+ SetWindow( pModulLayout );
+ GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW );
+ SfxObjectShell::SetCurrentComponent( NULL );
+ }
+ SetUndoManager( pCurWin ? pCurWin->GetUndoManager() : 0 );
+ InvalidateBasicIDESlots();
+ EnableScrollbars( pCurWin ? TRUE : FALSE );
+
+ if ( m_pCurLocalizationMgr )
+ m_pCurLocalizationMgr->handleTranslationbar();
+
+ ManageToolbars();
+
+ // fade out (in) property browser in module (dialog) windows
+ UIFeatureChanged();
+ }
+}
+
+void BasicIDEShell::ManageToolbars()
+{
+ static ::rtl::OUString aLayoutManagerName = ::rtl::OUString::createFromAscii( "LayoutManager" );
+ static ::rtl::OUString aMacroBarResName =
+ ::rtl::OUString::createFromAscii( "private:resource/toolbar/macrobar" );
+ static ::rtl::OUString aDialogBarResName =
+ ::rtl::OUString::createFromAscii( "private:resource/toolbar/dialogbar" );
+ static ::rtl::OUString aInsertControlsBarResName =
+ ::rtl::OUString::createFromAscii( "private:resource/toolbar/insertcontrolsbar" );
+ (void)aInsertControlsBarResName;
+
+ if( !pCurWin )
+ return;
+
+ Reference< beans::XPropertySet > xFrameProps
+ ( GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
+ if ( xFrameProps.is() )
+ {
+ Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
+ uno::Any a = xFrameProps->getPropertyValue( aLayoutManagerName );
+ a >>= xLayoutManager;
+ if ( xLayoutManager.is() )
+ {
+ xLayoutManager->lock();
+ if( pCurWin->IsA( TYPE( DialogWindow ) ) )
+ {
+ xLayoutManager->destroyElement( aMacroBarResName );
+
+ xLayoutManager->requestElement( aDialogBarResName );
+ xLayoutManager->requestElement( aInsertControlsBarResName );
+ }
+ else
+ {
+ xLayoutManager->destroyElement( aDialogBarResName );
+ xLayoutManager->destroyElement( aInsertControlsBarResName );
+
+ xLayoutManager->requestElement( aMacroBarResName );
+ }
+ xLayoutManager->unlock();
+ }
+ }
+}
+
+IDEBaseWindow* BasicIDEShell::FindApplicationWindow()
+{
+ return FindWindow( ScriptDocument::getApplicationScriptDocument() );
+}
+
+IDEBaseWindow* BasicIDEShell::FindWindow( const ScriptDocument& rDocument, const String& rLibName, const String& rName, USHORT nType, BOOL bFindSuspended )
+{
+ IDEBaseWindow* pWin = aIDEWindowTable.First();
+ while ( pWin )
+ {
+ if ( !pWin->IsSuspended() || bFindSuspended )
+ {
+ if ( !rLibName.Len() || !rName.Len() || nType == BASICIDE_TYPE_UNKNOWN )
+ {
+ // return any non-suspended window
+ return pWin;
+ }
+ else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rName &&
+ ( ( pWin->IsA( TYPE( ModulWindow ) ) && nType == BASICIDE_TYPE_MODULE ) ||
+ ( pWin->IsA( TYPE( DialogWindow ) ) && nType == BASICIDE_TYPE_DIALOG ) ) )
+ {
+ return pWin;
+ }
+ }
+ pWin = aIDEWindowTable.Next();
+ }
+ return 0;
+}
+
+long BasicIDEShell::CallBasicErrorHdl( StarBASIC* pBasic )
+{
+ long nRet = 0;
+ ModulWindow* pModWin = ShowActiveModuleWindow( pBasic );
+ if ( pModWin )
+ nRet = pModWin->BasicErrorHdl( pBasic );
+ return nRet;
+}
+
+long BasicIDEShell::CallBasicBreakHdl( StarBASIC* pBasic )
+{
+ long nRet = 0;
+ ModulWindow* pModWin = ShowActiveModuleWindow( pBasic );
+ if ( pModWin )
+ {
+ BOOL bAppWindowDisabled, bDispatcherLocked;
+ USHORT nWaitCount;
+ SfxUInt16Item *pSWActionCount, *pSWLockViewCount;
+ BasicIDE::BasicStopped( &bAppWindowDisabled, &bDispatcherLocked,
+ &nWaitCount, &pSWActionCount, &pSWLockViewCount );
+
+ nRet = pModWin->BasicBreakHdl( pBasic );
+
+ if ( StarBASIC::IsRunning() ) // Falls abgebrochen...
+ {
+ if ( bAppWindowDisabled )
+ Application::GetDefDialogParent()->Enable( FALSE );
+ /*
+ if ( bDispatcherLocked )
+ SFX_APP()->LockDispatcher( TRUE );
+ */
+ if ( nWaitCount )
+ {
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ for ( USHORT n = 0; n < nWaitCount; n++ )
+ pIDEShell->GetViewFrame()->GetWindow().EnterWait();
+ }
+ }
+ }
+ return nRet;
+}
+
+ModulWindow* BasicIDEShell::ShowActiveModuleWindow( StarBASIC* pBasic )
+{
+ SetCurLib( ScriptDocument::getApplicationScriptDocument(), String(), false );
+
+ SbModule* pActiveModule = StarBASIC::GetActiveModule();
+ SbClassModuleObject* pClassModuleObject = PTR_CAST(SbClassModuleObject,pActiveModule);
+ if( pClassModuleObject != NULL )
+ pActiveModule = pClassModuleObject->getClassModule();
+
+ DBG_ASSERT( pActiveModule, "Kein aktives Modul im ErrorHdl?!" );
+ if ( pActiveModule )
+ {
+ ModulWindow* pWin = 0;
+ SbxObject* pParent = pActiveModule->GetParent();
+ DBG_ASSERT( pParent && pParent->ISA( StarBASIC ), "Kein BASIC!" );
+ StarBASIC* pLib = static_cast< StarBASIC* >( pParent );
+ if ( pLib )
+ {
+ BasicManager* pBasMgr = BasicIDE::FindBasicManager( pLib );
+ if ( pBasMgr )
+ {
+ ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
+ String aLibName = pLib->GetName();
+ pWin = FindBasWin( aDocument, aLibName, pActiveModule->GetName(), TRUE );
+ DBG_ASSERT( pWin, "Error/Step-Hdl: Fenster wurde nicht erzeugt/gefunden!" );
+ SetCurLib( aDocument, aLibName );
+ SetCurWindow( pWin, TRUE );
+ }
+ }
+ BasicManager* pBasicMgr = BasicIDE::FindBasicManager( pBasic );
+ if ( pBasicMgr )
+ StartListening( *pBasicMgr, TRUE /* Nur einmal anmelden */ );
+ return pWin;
+ }
+ return 0;
+}
+
+void __EXPORT BasicIDEShell::AdjustPosSizePixel( const Point &rPos, const Size &rSize )
+{
+ // Nicht wenn minimiert, weil dann bei Restore der Text verschoben ist.
+ if ( GetViewFrame()->GetWindow().GetOutputSizePixel().Height() == 0 )
+ return;
+
+ Size aSz( rSize );
+// long nScrollbarWidthPixel = aVScrollBar.GetSizePixel().Width();
+ Size aScrollBarBoxSz( aScrollBarBox.GetSizePixel() );
+ aSz.Height() -= aScrollBarBoxSz.Height();
+
+ Size aOutSz( aSz );
+ aSz.Width() -= aScrollBarBoxSz.Width();
+ aScrollBarBox.SetPosPixel( Point( rSize.Width() - aScrollBarBoxSz.Width(), rSize.Height() - aScrollBarBoxSz.Height() ) );
+ aVScrollBar.SetPosSizePixel( Point( rPos.X()+aSz.Width(), rPos.Y() ), Size( aScrollBarBoxSz.Width(), aSz.Height() ) );
+ if ( bTabBarSplitted )
+ {
+ // SplitSize ist beim Resize 0 !
+ long nSplitPos = pTabBar->GetSizePixel().Width();
+ if ( nSplitPos > aSz.Width() )
+ nSplitPos = aSz.Width();
+ pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( nSplitPos, aScrollBarBoxSz.Height() ) );
+ long nScrlStart = rPos.X() + nSplitPos;
+ aHScrollBar.SetPosSizePixel( Point( nScrlStart, rPos.Y()+aSz.Height() ), Size( aSz.Width() - nScrlStart + 1, aScrollBarBoxSz.Height() ) );
+ aHScrollBar.Update();
+ }
+ else
+ {
+ aHScrollBar.SetPosSizePixel( Point( rPos.X()+ aSz.Width()/2 - 1, rPos.Y()+aSz.Height() ), Size( aSz.Width()/2 + 2, aScrollBarBoxSz.Height() ) );
+ pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( aSz.Width()/2, aScrollBarBoxSz.Height() ) );
+ }
+
+ Window* pEdtWin = pCurWin ? pCurWin->GetLayoutWindow() : pModulLayout;
+ if ( pEdtWin )
+ {
+ if( pCurWin && pCurWin->IsA( TYPE( DialogWindow ) ) )
+ pEdtWin->SetPosSizePixel( rPos, aSz ); // Ohne ScrollBar
+ else
+ pEdtWin->SetPosSizePixel( rPos, aOutSz );
+ }
+}
+
+Reference< XModel > BasicIDEShell::GetCurrentDocument() const
+{
+ Reference< XModel > xDocument;
+ if ( pCurWin && pCurWin->GetDocument().isDocument() )
+ xDocument = pCurWin->GetDocument().getDocument();
+ return xDocument;
+}
+
+void __EXPORT BasicIDEShell::Activate( BOOL bMDI )
+{
+ SfxViewShell::Activate( bMDI );
+
+ if ( bMDI )
+ {
+ if( pCurWin && pCurWin->IsA( TYPE( DialogWindow ) ) )
+ ((DialogWindow*)pCurWin)->UpdateBrowser();
+
+ ShowObjectDialog( TRUE, FALSE );
+ }
+}
+
+void __EXPORT BasicIDEShell::Deactivate( BOOL bMDI )
+{
+ // bMDI TRUE heisst, dass ein anderes MDI aktiviert wurde, bei einem
+ // Deactivate durch eine MessageBox ist bMDI FALSE
+ if ( bMDI )
+ {
+ if( pCurWin && pCurWin->IsA( TYPE( DialogWindow ) ) )
+ {
+ DialogWindow* pXDlgWin = (DialogWindow*)pCurWin;
+ pXDlgWin->DisableBrowser();
+ if( pXDlgWin->IsModified() )
+ BasicIDE::MarkDocumentModified( pXDlgWin->GetDocument() );
+ }
+
+ // CanClose pruefen, damit auch beim deaktivieren der BasicIDE geprueft wird,
+ // ob in einem Modul der Sourcecode zu gross ist...
+ for ( ULONG nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ )
+ {
+ IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin );
+ if ( /* !pWin->IsSuspended() && */ !pWin->CanClose() )
+ {
+ if ( m_aCurLibName.Len() && ( pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName ) )
+ SetCurLib( ScriptDocument::getApplicationScriptDocument(), String(), false );
+ SetCurWindow( pWin, TRUE );
+ break;
+ }
+ }
+
+ ShowObjectDialog( FALSE, FALSE );
+ }
+}
+
+
+IMPL_LINK( BasicIDEShell, AccelSelectHdl, Accelerator*, pAccel )
+{
+ BOOL bDone = TRUE;
+ SfxViewFrame* pViewFrame = GetViewFrame();
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( !pDispatcher )
+ return FALSE;
+ switch ( pAccel->GetCurKeyCode().GetCode() )
+ {
+ case KEY_F5:
+ if ( pAccel->GetCurKeyCode().IsShift() )
+ pDispatcher->Execute( SID_BASICSTOP, SFX_CALLMODE_SYNCHRON );
+ else
+ pDispatcher->Execute( SID_BASICRUN, SFX_CALLMODE_SYNCHRON );
+ break;
+ case KEY_F7:
+ pDispatcher->Execute( SID_BASICIDE_ADDWATCH, SFX_CALLMODE_SYNCHRON );
+ break;
+ case KEY_F8:
+ if ( pAccel->GetCurKeyCode().IsShift() )
+ pDispatcher->Execute( SID_BASICSTEPOVER, SFX_CALLMODE_SYNCHRON );
+ else
+ pDispatcher->Execute( SID_BASICSTEPINTO, SFX_CALLMODE_SYNCHRON );
+ break;
+ case KEY_F9:
+ if ( pAccel->GetCurKeyCode().IsShift() )
+ pDispatcher->Execute( SID_BASICIDE_TOGGLEBRKPNTENABLED, SFX_CALLMODE_SYNCHRON );
+ else
+ pDispatcher->Execute( SID_BASICIDE_TOGGLEBRKPNT, SFX_CALLMODE_SYNCHRON );
+ break;
+ default: bDone = FALSE;
+ }
+ return bDone;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx
new file mode 100644
index 000000000000..4092529a5e17
--- /dev/null
+++ b/basctl/source/basicide/basides2.cxx
@@ -0,0 +1,353 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include "docsignature.hxx"
+
+#define SI_NOCONTROL
+#define SI_NOSBXCONTROLS
+
+#include <ide_pch.hxx>
+#include <basic/sbx.hxx>
+#include "basicrenderable.hxx"
+
+#include <com/sun/star/frame/XTitle.hpp>
+
+#include <vcl/sound.hxx>
+#include <basidesh.hxx>
+#include <basidesh.hrc>
+#include <baside2.hxx>
+#include <basdoc.hxx>
+#include <basobj.hxx>
+#include <svtools/texteng.hxx>
+#include <svtools/textview.hxx>
+#include <svtools/xtextedt.hxx>
+#include <tools/diagnose_ex.h>
+#include <sfx2/sfxdefs.hxx>
+#include <sfx2/signaturestate.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+namespace css = ::com::sun::star;
+
+IMPL_LINK_INLINE_START( BasicIDEShell, ObjectDialogCancelHdl, ObjectCatalog *, EMPTYARG )
+{
+ ShowObjectDialog( FALSE, TRUE );
+ return 0;
+}
+IMPL_LINK_INLINE_END( BasicIDEShell, ObjectDialogCancelHdl, ObjectCatalog *, EMPTYARG )
+
+/*
+IMPL_LINK( BasicIDEShell, ObjectDialogInsertHdl, ObjectCatalog *, pObjCat )
+{
+ if ( !pCurWin )
+ return 0;
+
+ if ( pCurWin->IsA( TYPE( ModulWindow ) ) )
+ {
+ ModulWindow* pEditWin = (ModulWindow*)pCurWin;
+ pEditWin->InsertFromObjectCatalog( pObjCat );
+ }
+ else
+ Sound::Beep();
+
+ return 0;
+}
+*/
+
+Reference< view::XRenderable > BasicIDEShell::GetRenderable()
+{
+ return Reference< view::XRenderable >( new basicide::BasicRenderable( pCurWin ) );
+}
+
+#if 0
+USHORT __EXPORT BasicIDEShell::Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pPrintDialog )
+{
+ if ( pCurWin )
+ {
+ SfxPrinter* pPrinter = GetPrinter( TRUE );
+ if ( pPrinter )
+ {
+ SfxViewShell::Print( rProgress, bIsAPI, pPrintDialog );
+ pCurWin->PrintData( pPrinter );
+ }
+ }
+ return 0;
+}
+#endif
+
+BOOL BasicIDEShell::HasSelection( BOOL /* bText */ ) const
+{
+ BOOL bSel = FALSE;
+ if ( pCurWin && pCurWin->ISA( ModulWindow ) )
+ {
+ TextView* pEditView = ((ModulWindow*)pCurWin)->GetEditView();
+ if ( pEditView && pEditView->HasSelection() )
+ bSel = TRUE;
+ }
+ return bSel;
+}
+
+String BasicIDEShell::GetSelectionText( BOOL bWholeWord )
+{
+ String aText;
+ if ( pCurWin && pCurWin->ISA( ModulWindow ) )
+ {
+ TextView* pEditView = ((ModulWindow*)pCurWin)->GetEditView();
+ if ( pEditView )
+ {
+ if ( bWholeWord && !pEditView->HasSelection() )
+ {
+ // String aStrCurrentDelimiters = pEngine->GetWordDelimiters();
+ // pEngine->SetWordDelimiters( " .,;\"'" );
+ aText = pEditView->GetTextEngine()->GetWord( pEditView->GetSelection().GetEnd() );
+ // pEngine->SetWordDelimiters( aStrCurrentDelimiters );
+ }
+ else
+ {
+ TextSelection aSel = pEditView->GetSelection();
+ if ( !bWholeWord || ( aSel.GetStart().GetPara() == aSel.GetEnd().GetPara() ) )
+ aText = pEditView->GetSelected();
+ }
+ }
+ }
+ return aText;
+}
+
+SfxPrinter* __EXPORT BasicIDEShell::GetPrinter( BOOL bCreate )
+{
+ if ( pCurWin ) // && pCurWin->ISA( ModulWindow ) )
+ {
+ BasicDocShell* pDocShell = (BasicDocShell*)GetViewFrame()->GetObjectShell();
+ DBG_ASSERT( pDocShell, "DocShell ?!" );
+ return pDocShell->GetPrinter( bCreate );
+ }
+ return 0;
+}
+
+USHORT __EXPORT BasicIDEShell::SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags, bool )
+{
+ (void)nDiffFlags;
+ BasicDocShell* pDocShell = (BasicDocShell*)GetViewFrame()->GetObjectShell();
+ DBG_ASSERT( pDocShell, "DocShell ?!" );
+ pDocShell->SetPrinter( pNewPrinter );
+ return 0;
+}
+
+void BasicIDEShell::SetMDITitle()
+{
+ String aTitle;
+
+ if ( m_aCurLibName.Len() )
+ {
+ LibraryLocation eLocation = m_aCurDocument.getLibraryLocation( m_aCurLibName );
+ aTitle = m_aCurDocument.getTitle( eLocation );
+ aTitle += '.';
+ aTitle += m_aCurLibName;
+ }
+ else
+ {
+ aTitle = String( IDEResId( RID_STR_ALL ) );
+ }
+
+ ::basctl::DocumentSignature aCurSignature( m_aCurDocument );
+ if ( aCurSignature.getScriptingSignatureState() == SIGNATURESTATE_SIGNATURES_OK )
+ {
+ aTitle += String::CreateFromAscii( " " );
+ aTitle += String( IDEResId( RID_STR_SIGNED ) );
+ aTitle += String::CreateFromAscii( " " );
+ }
+
+ SfxViewFrame* pViewFrame = GetViewFrame();
+ if ( pViewFrame )
+ {
+ SfxObjectShell* pShell = pViewFrame->GetObjectShell();
+ if ( pShell && aTitle != pShell->GetTitle( SFX_TITLE_CAPTION ) )
+ {
+ pShell->SetTitle( aTitle );
+ pShell->SetModified( FALSE );
+ }
+
+ css::uno::Reference< css::frame::XController > xController = GetController ();
+ css::uno::Reference< css::frame::XTitle > xTitle (xController, css::uno::UNO_QUERY);
+ if (xTitle.is ())
+ xTitle->setTitle (aTitle);
+ }
+}
+
+void BasicIDEShell::DestroyModulWindowLayout()
+{
+ delete pModulLayout;
+ pModulLayout = 0;
+}
+
+
+void BasicIDEShell::UpdateModulWindowLayout( bool bBasicStopped )
+{
+ if ( pModulLayout )
+ {
+ pModulLayout->GetStackWindow().UpdateCalls();
+ pModulLayout->GetWatchWindow().UpdateWatches( bBasicStopped );
+ }
+}
+
+void BasicIDEShell::CreateModulWindowLayout()
+{
+ pModulLayout = new ModulWindowLayout( &GetViewFrame()->GetWindow() );
+}
+
+ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const String& rLibName, const String& rModName )
+{
+ bCreatingWindow = TRUE;
+
+ ULONG nKey = 0;
+ ModulWindow* pWin = 0;
+
+ String aLibName( rLibName );
+ String aModName( rModName );
+
+ if ( !aLibName.Len() )
+ aLibName = String::CreateFromAscii( "Standard" );
+
+ uno::Reference< container::XNameContainer > xLib = rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
+
+ if ( !aModName.Len() )
+ aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
+
+ // Vielleicht gibt es ein suspendiertes?
+ pWin = FindBasWin( rDocument, aLibName, aModName, FALSE, TRUE );
+
+ if ( !pWin )
+ {
+ ::rtl::OUString aModule;
+ bool bSuccess = false;
+ if ( rDocument.hasModule( aLibName, aModName ) )
+ bSuccess = rDocument.getModule( aLibName, aModName, aModule );
+ else
+ bSuccess = rDocument.createModule( aLibName, aModName, TRUE, aModule );
+
+ if ( bSuccess )
+ {
+ pWin = FindBasWin( rDocument, aLibName, aModName, FALSE, TRUE );
+ if( !pWin )
+ {
+ // new module window
+ pWin = new ModulWindow( pModulLayout, rDocument, aLibName, aModName, aModule );
+ nKey = InsertWindowInTable( pWin );
+ }
+ else // we've gotten called recursively ( via listener from createModule above ), get outta here
+ return pWin;
+ }
+ }
+ else
+ {
+ pWin->SetStatus( pWin->GetStatus() & ~BASWIN_SUSPENDED );
+ IDEBaseWindow* pTmp = aIDEWindowTable.First();
+ while ( pTmp && !nKey )
+ {
+ if ( pTmp == pWin )
+ nKey = aIDEWindowTable.GetCurKey();
+ pTmp = aIDEWindowTable.Next();
+ }
+ DBG_ASSERT( nKey, "CreateBasWin: Kein Key- Fenster nicht gefunden!" );
+ }
+ if( nKey && xLib.is() && rDocument.isInVBAMode() )
+ {
+ // display a nice friendly name in the ObjectModule tab,
+ // combining the objectname and module name, e.g. Sheet1 ( Financials )
+ String sObjName;
+ ModuleInfoHelper::getObjectName( xLib, rModName, sObjName );
+ if( sObjName.Len() )
+ {
+ aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")");
+ }
+ }
+ pTabBar->InsertPage( (USHORT)nKey, aModName );
+ pTabBar->Sort();
+ pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar );
+ if ( !pCurWin )
+ SetCurWindow( pWin, FALSE, FALSE );
+
+ bCreatingWindow = FALSE;
+ return pWin;
+}
+
+ModulWindow* BasicIDEShell::FindBasWin( const ScriptDocument& rDocument, const String& rLibName, const String& rModName, BOOL bCreateIfNotExist, BOOL bFindSuspended )
+{
+ ModulWindow* pModWin = 0;
+ IDEBaseWindow* pWin = aIDEWindowTable.First();
+ while ( pWin && !pModWin )
+ {
+ if ( ( !pWin->IsSuspended() || bFindSuspended ) && pWin->IsA( TYPE( ModulWindow ) ) )
+ {
+ if ( !rLibName.Len() ) // nur irgendeins finden...
+ pModWin = (ModulWindow*)pWin;
+ else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rModName )
+ pModWin = (ModulWindow*)pWin;
+ }
+ pWin = aIDEWindowTable.Next();
+ }
+ if ( !pModWin && bCreateIfNotExist )
+ pModWin = CreateBasWin( rDocument, rLibName, rModName );
+
+ return pModWin;
+}
+
+void __EXPORT BasicIDEShell::Move()
+{
+ if ( pCurWin && pCurWin->ISA( ModulWindow ) )
+ ((ModulWindow*)pCurWin)->FrameWindowMoved();
+}
+
+void __EXPORT BasicIDEShell::ShowCursor( bool bOn )
+{
+ if ( pCurWin && pCurWin->ISA( ModulWindow ) )
+ ((ModulWindow*)pCurWin)->ShowCursor( bOn );
+}
+
+// Hack for #101048
+sal_Int32 getBasicIDEShellCount( void );
+
+// Nur wenn Basicfenster oben:
+void __EXPORT BasicIDEShell::ExecuteBasic( SfxRequest& rReq )
+{
+ if ( !pCurWin || !pCurWin->IsA( TYPE( ModulWindow ) ) )
+ return;
+
+ pCurWin->ExecuteCommand( rReq );
+ sal_Int32 nCount = getBasicIDEShellCount();
+ if( nCount )
+ CheckWindows();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basides3.cxx b/basctl/source/basicide/basides3.cxx
new file mode 100644
index 000000000000..3825eaef11bf
--- /dev/null
+++ b/basctl/source/basicide/basides3.cxx
@@ -0,0 +1,179 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#define SI_NOCONTROL
+#define SI_NOSBXCONTROLS
+
+#include <basidesh.hrc>
+#include <ide_pch.hxx>
+
+
+#define _SOLAR__PRIVATE 1
+
+#include <basidesh.hxx>
+#include <baside2.hxx>
+#include <baside3.hxx>
+#include <basobj.hxx>
+#include <localizationmgr.hxx>
+#include <dlgedview.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <xmlscript/xmldlg_imexp.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace comphelper;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+
+
+DialogWindow* BasicIDEShell::CreateDlgWin( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName )
+{
+ bCreatingWindow = TRUE;
+
+ ULONG nKey = 0;
+ DialogWindow* pWin = 0;
+ String aLibName( rLibName );
+ String aDlgName( rDlgName );
+
+ if ( !aLibName.Len() )
+ aLibName = String::CreateFromAscii( "Standard" );
+
+ rDocument.getOrCreateLibrary( E_DIALOGS, aLibName );
+
+ if ( !aDlgName.Len() )
+ aDlgName = rDocument.createObjectName( E_DIALOGS, aLibName );
+
+ // Vielleicht gibt es ein suspendiertes?
+ pWin = FindDlgWin( rDocument, aLibName, aDlgName, FALSE, TRUE );
+
+ if ( !pWin )
+ {
+ try
+ {
+ Reference< io::XInputStreamProvider > xISP;
+ if ( rDocument.hasDialog( aLibName, aDlgName ) )
+ rDocument.getDialog( aLibName, aDlgName, xISP );
+ else
+ rDocument.createDialog( aLibName, aDlgName, xISP );
+
+ if ( xISP.is() )
+ {
+ // create dialog model
+ Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
+ Reference< container::XNameContainer > xDialogModel( xMSF->createInstance
+ ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY );
+ Reference< XInputStream > xInput( xISP->createInputStream() );
+ Reference< XComponentContext > xContext;
+ Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
+ OSL_ASSERT( xProps.is() );
+ OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() );
+ LocalizationMgr::setStringResourceAtDialog( rDocument, rLibName, aDlgName, xDialogModel );
+
+ // new dialog window
+ pWin = new DialogWindow( &GetViewFrame()->GetWindow(), rDocument, aLibName, aDlgName, xDialogModel );
+ nKey = InsertWindowInTable( pWin );
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ else
+ {
+ pWin->SetStatus( pWin->GetStatus() & ~BASWIN_SUSPENDED );
+ IDEBaseWindow* pTmp = aIDEWindowTable.First();
+ while ( pTmp && !nKey )
+ {
+ if ( pTmp == pWin )
+ nKey = aIDEWindowTable.GetCurKey();
+ pTmp = aIDEWindowTable.Next();
+ }
+ DBG_ASSERT( nKey, "CreateDlgWin: Kein Key - Fenster nicht gefunden!" );
+ }
+
+ if( pWin )
+ {
+ pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar );
+ pTabBar->InsertPage( (USHORT)nKey, aDlgName );
+ pTabBar->Sort();
+ if ( !pCurWin )
+ SetCurWindow( pWin, FALSE, FALSE );
+ }
+
+ bCreatingWindow = FALSE;
+ return pWin;
+}
+
+DialogWindow* BasicIDEShell::FindDlgWin( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName, BOOL bCreateIfNotExist, BOOL bFindSuspended )
+{
+ DialogWindow* pDlgWin = 0;
+ IDEBaseWindow* pWin = aIDEWindowTable.First();
+ while ( pWin && !pDlgWin )
+ {
+ if ( ( !pWin->IsSuspended() || bFindSuspended ) && pWin->IsA( TYPE( DialogWindow ) ) )
+ {
+ if ( !rLibName.Len() ) // nur irgendeins finden...
+ pDlgWin = (DialogWindow*)pWin;
+ else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rDlgName )
+ pDlgWin = (DialogWindow*)pWin;
+ }
+ pWin = aIDEWindowTable.Next();
+ }
+ if ( !pDlgWin && bCreateIfNotExist )
+ pDlgWin = CreateDlgWin( rDocument, rLibName, rDlgName );
+
+ return pDlgWin;
+}
+
+SdrView* BasicIDEShell::GetCurDlgView() const
+{
+ if ( !pCurWin || !pCurWin->IsA( TYPE( DialogWindow ) ) )
+ return NULL;
+
+ DialogWindow* pWin = (DialogWindow*)pCurWin;
+ return pWin->GetView();
+}
+
+// Nur wenn Dialogfenster oben:
+void __EXPORT BasicIDEShell::ExecuteDialog( SfxRequest& rReq )
+{
+ if ( pCurWin && ( pCurWin->IsA( TYPE( DialogWindow) ) ||
+ (rReq.GetSlot() == SID_IMPORT_DIALOG &&pCurWin->IsA( TYPE( ModulWindow) ) ) ) )
+ {
+ pCurWin->ExecuteCommand( rReq );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx
new file mode 100644
index 000000000000..9b5d01636047
--- /dev/null
+++ b/basctl/source/basicide/basidesh.cxx
@@ -0,0 +1,1065 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+// CLOOKS:
+//#define _MENUBTN_HXX
+#define _SPIN_HXX
+#define _PRVWIN_HXX
+//#define _FIELD_HXX ***
+//#define _TAB_HXX ***
+#define _DIALOGS_HXX
+#define _SVRTF_HXX
+#define _ISETBRW_HXX
+#define _VCTRLS_HXX
+#define SI_NOCONTROL
+#define SI_NOSBXCONTROLS
+
+#define ITEMID_SIZE 0
+
+// Falls ohne PCH's:
+#include <ide_pch.hxx>
+
+
+#define _SOLAR__PRIVATE 1
+#include <basic/sbx.hxx>
+#include <svl/hint.hxx>
+#include <tools/diagnose_ex.h>
+#include <basidesh.hrc>
+#include <basidesh.hxx>
+#include <basdoc.hxx>
+#include <basobj.hxx>
+#include <bastypes.hxx>
+#include <basicbox.hxx>
+#include <objdlg.hxx>
+#include <sbxitem.hxx>
+#include <tbxctl.hxx>
+#include <iderdll2.hxx>
+#include <basidectrlr.hxx>
+#include <localizationmgr.hxx>
+
+#define BasicIDEShell
+#define SFX_TYPEMAP
+#include <idetemp.hxx>
+#include <basslots.hxx>
+#include <iderdll.hxx>
+#include <svx/pszctrl.hxx>
+#include <svx/insctrl.hxx>
+#include <svx/srchdlg.hxx>
+#include <svx/lboxctrl.hxx>
+#include <svx/tbcontrl.hxx>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/script/XLibraryContainerPassword.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+
+#include <svx/xmlsecctrl.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+using ::rtl::OUString;
+
+static const rtl::OUString sStandardLibName( rtl::OUString::createFromAscii("Standard") );
+
+typedef ::cppu::WeakImplHelper1< container::XContainerListener > ContainerListenerBASE;
+
+class ContainerListenerImpl : public ContainerListenerBASE
+{
+ BasicIDEShell* mpShell;
+public:
+
+ ContainerListenerImpl( BasicIDEShell* pShell ) : mpShell( pShell ) {}
+
+ ~ContainerListenerImpl()
+ {
+ }
+
+ void addContainerListener( const ScriptDocument& rScriptDocument, const String& aLibName )
+ {
+ try
+ {
+ uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, aLibName, FALSE ), uno::UNO_QUERY );
+ if ( xContainer.is() )
+ {
+ uno::Reference< container::XContainerListener > xContainerListener( this );
+ xContainer->addContainerListener( xContainerListener );
+ }
+ }
+ catch( uno::Exception& ) {}
+ }
+ void removeContainerListener( const ScriptDocument& rScriptDocument, const String& aLibName )
+ {
+ try
+ {
+ uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, aLibName, FALSE ), uno::UNO_QUERY );
+ if ( xContainer.is() )
+ {
+ uno::Reference< container::XContainerListener > xContainerListener( this );
+ xContainer->removeContainerListener( xContainerListener );
+ }
+ }
+ catch( uno::Exception& ) {}
+ }
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const lang::EventObject& ) throw( uno::RuntimeException ) {}
+
+ // XContainerListener
+ virtual void SAL_CALL elementInserted( const container::ContainerEvent& Event ) throw( uno::RuntimeException )
+ {
+ rtl::OUString sModuleName;
+ if( mpShell && ( Event.Accessor >>= sModuleName ) )
+ mpShell->FindBasWin( mpShell->m_aCurDocument, mpShell->m_aCurLibName, sModuleName, TRUE, FALSE );
+ }
+ virtual void SAL_CALL elementReplaced( const container::ContainerEvent& ) throw( com::sun::star::uno::RuntimeException ) { }
+ virtual void SAL_CALL elementRemoved( const container::ContainerEvent& Event ) throw( com::sun::star::uno::RuntimeException )
+ {
+ rtl::OUString sModuleName;
+ if( mpShell && ( Event.Accessor >>= sModuleName ) )
+ {
+ IDEBaseWindow* pWin = mpShell->FindWindow( mpShell->m_aCurDocument, mpShell->m_aCurLibName, sModuleName, BASICIDE_TYPE_MODULE, TRUE );
+ if( pWin )
+ mpShell->RemoveWindow( pWin, TRUE, TRUE );
+ }
+ }
+
+};
+
+TYPEINIT1( BasicIDEShell, SfxViewShell );
+
+SFX_IMPL_NAMED_VIEWFACTORY( BasicIDEShell, "Default" )
+{
+ SFX_VIEW_REGISTRATION( BasicDocShell );
+}
+
+
+// MI: Prinzipiel IDL, aber ich lieber doch nicht?
+// SFX_IMPL_ /*IDL_*/ INTERFACE( BasicIDEShell, SfxViewShell, IDEResId( RID_STR_IDENAME ) )
+SFX_IMPL_INTERFACE( BasicIDEShell, SfxViewShell, IDEResId( RID_STR_IDENAME ) )
+{
+ SFX_CHILDWINDOW_REGISTRATION( SID_SEARCH_DLG );
+ SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_SHOW_PROPERTYBROWSER, BASICIDE_UI_FEATURE_SHOW_BROWSER);
+ SFX_POPUPMENU_REGISTRATION( IDEResId( RID_POPUP_DLGED ) );
+}
+
+
+
+#define IDE_VIEWSHELL_FLAGS SFX_VIEW_CAN_PRINT|SFX_VIEW_NO_NEWWINDOW
+
+
+// Hack for #101048
+static sal_Int32 GnBasicIDEShellCount;
+sal_Int32 getBasicIDEShellCount( void )
+ { return GnBasicIDEShellCount; }
+
+BasicIDEShell::BasicIDEShell( SfxViewFrame* pFrame_, SfxViewShell* /* pOldShell */ ) :
+ SfxViewShell( pFrame_, IDE_VIEWSHELL_FLAGS ),
+ m_aCurDocument( ScriptDocument::getApplicationScriptDocument() ),
+ aHScrollBar( &GetViewFrame()->GetWindow(), WinBits( WB_HSCROLL | WB_DRAG ) ),
+ aVScrollBar( &GetViewFrame()->GetWindow(), WinBits( WB_VSCROLL | WB_DRAG ) ),
+ aScrollBarBox( &GetViewFrame()->GetWindow(), WinBits( WB_SIZEABLE ) ),
+ m_bAppBasicModified( FALSE ),
+ m_aNotifier( *this )
+{
+ m_xLibListener = new ContainerListenerImpl( this );
+ Init();
+ GnBasicIDEShellCount++;
+}
+
+
+
+void BasicIDEShell::Init()
+{
+ TbxControls::RegisterControl( SID_CHOOSE_CONTROLS );
+ SvxPosSizeStatusBarControl::RegisterControl();
+ SvxInsertStatusBarControl::RegisterControl();
+ XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE );
+ SvxSimpleUndoRedoController::RegisterControl( SID_UNDO );
+ SvxSimpleUndoRedoController::RegisterControl( SID_REDO );
+
+ SvxSearchDialogWrapper::RegisterChildWindow( sal_False );
+
+ IDE_DLL()->GetExtraData()->ShellInCriticalSection() = TRUE;
+
+ SetName( String( RTL_CONSTASCII_USTRINGPARAM( "BasicIDE" ) ) );
+ SetHelpId( SVX_INTERFACE_BASIDE_VIEWSH );
+
+ SFX_APP()->EnterBasicCall();
+
+ LibBoxControl::RegisterControl( SID_BASICIDE_LIBSELECTOR );
+ LanguageBoxControl::RegisterControl( SID_BASICIDE_CURRENT_LANG );
+
+ CreateModulWindowLayout();
+
+ GetViewFrame()->GetWindow().SetBackground();
+
+ pCurWin = 0;
+ m_aCurDocument = ScriptDocument::getApplicationScriptDocument();
+ pObjectCatalog = 0;
+ bCreatingWindow = FALSE;
+
+ m_pCurLocalizationMgr = NULL;
+
+ pTabBar = new BasicIDETabBar( &GetViewFrame()->GetWindow() );
+ pTabBar->SetSplitHdl( LINK( this, BasicIDEShell, TabBarSplitHdl ) );
+ bTabBarSplitted = FALSE;
+
+ nCurKey = 100;
+ InitScrollBars();
+ InitTabBar();
+
+ SetCurLib( ScriptDocument::getApplicationScriptDocument(), String::CreateFromAscii( "Standard" ), false, false );
+
+ if ( IDE_DLL() && IDE_DLL()->pShell == NULL )
+ IDE_DLL()->pShell = this;
+
+ IDE_DLL()->GetExtraData()->ShellInCriticalSection() = FALSE;
+
+ // It's enough to create the controller ...
+ // It will be public by using magic :-)
+ new BasicIDEController( this );
+
+ // Force updating the title ! Because it must be set to the controller
+ // it has to be called directly after creating those controller.
+ SetMDITitle ();
+
+ UpdateWindows();
+}
+
+__EXPORT BasicIDEShell::~BasicIDEShell()
+{
+ m_aNotifier.dispose();
+
+ if ( IDE_DLL() && IDE_DLL()->pShell == this )
+ IDE_DLL()->pShell = NULL;
+
+ // Damit bei einem Basic-Fehler beim Speichern die Shell nicht sofort
+ // wieder hoch kommt:
+ IDE_DLL()->GetExtraData()->ShellInCriticalSection() = TRUE;
+
+ SetWindow( 0 );
+ SetCurWindow( 0 );
+
+ // Alle Fenster zerstoeren:
+ IDEBaseWindow* pWin = aIDEWindowTable.First();
+ while ( pWin )
+ {
+ // Kein Store, passiert bereits, wenn die BasicManager zerstoert werden.
+ delete pWin;
+ pWin = aIDEWindowTable.Next();
+ }
+
+ aIDEWindowTable.Clear();
+ delete pTabBar;
+ delete pObjectCatalog;
+ DestroyModulWindowLayout();
+
+ ContainerListenerImpl* pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() );
+ // Destroy all ContainerListeners for Basic Container.
+ if ( pListener )
+ pListener->removeContainerListener( m_aCurDocument, m_aCurLibName );
+
+ // MI: Das gab einen GPF im SDT beim Schliessen da dann der ViewFrame die
+ // ObjSh loslaesst. Es wusste auch keiner mehr wozu das gut war.
+ // GetViewFrame()->GetObjectShell()->Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
+
+ SFX_APP()->LeaveBasicCall();
+ IDE_DLL()->GetExtraData()->ShellInCriticalSection() = FALSE;
+
+ GnBasicIDEShellCount--;
+}
+
+void BasicIDEShell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
+{
+ UpdateWindows();
+}
+
+void BasicIDEShell::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
+{
+ UpdateWindows();
+}
+
+void BasicIDEShell::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
+{
+ StoreAllWindowData();
+}
+
+void BasicIDEShell::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void BasicIDEShell::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
+{
+ StoreAllWindowData();
+}
+
+void BasicIDEShell::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void BasicIDEShell::onDocumentClosed( const ScriptDocument& _rDocument )
+{
+ if ( !_rDocument.isValid() )
+ return;
+
+ bool bSetCurWindow = false;
+ bool bSetCurLib = ( _rDocument == m_aCurDocument );
+
+ // remove all windows which belong to this document
+ for ( ULONG nWin = aIDEWindowTable.Count(); nWin; )
+ {
+ IDEBaseWindow* pWin = aIDEWindowTable.GetObject( --nWin );
+ if ( pWin->IsDocument( _rDocument ) )
+ {
+ if ( pWin->GetStatus() & (BASWIN_RUNNINGBASIC|BASWIN_INRESCHEDULE) )
+ {
+ pWin->AddStatus( BASWIN_TOBEKILLED );
+ pWin->Hide();
+ StarBASIC::Stop();
+ // there's no notify
+ pWin->BasicStopped();
+ }
+ else
+ {
+ pWin->StoreData();
+ if ( pWin == pCurWin )
+ bSetCurWindow = true;
+ RemoveWindow( pWin, TRUE, FALSE );
+ }
+ }
+ }
+
+ // remove lib info
+ BasicIDEData* pData = IDE_DLL()->GetExtraData();
+ if ( pData )
+ pData->GetLibInfos().RemoveInfoFor( _rDocument );
+
+ if ( bSetCurLib )
+ SetCurLib( ScriptDocument::getApplicationScriptDocument(), String::CreateFromAscii( "Standard" ), true, false );
+ else if ( bSetCurWindow )
+ SetCurWindow( FindApplicationWindow(), TRUE );
+}
+
+void BasicIDEShell::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
+{
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR, TRUE, FALSE );
+ SetMDITitle();
+}
+
+void BasicIDEShell::onDocumentModeChanged( const ScriptDocument& _rDocument )
+{
+ for ( ULONG nWin = aIDEWindowTable.Count(); nWin; )
+ {
+ IDEBaseWindow* pWin = aIDEWindowTable.GetObject( --nWin );
+ if ( pWin->IsDocument( _rDocument ) && _rDocument.isDocument() )
+ pWin->SetReadOnly( _rDocument.isReadOnly() );
+ }
+}
+
+void BasicIDEShell::StoreAllWindowData( BOOL bPersistent )
+{
+ for ( ULONG nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ )
+ {
+ IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin );
+ DBG_ASSERT( pWin, "PrepareClose: NULL-Pointer in Table?" );
+ if ( !pWin->IsSuspended() )
+ pWin->StoreData();
+ }
+
+ if ( bPersistent )
+ {
+ SFX_APP()->SaveBasicAndDialogContainer();
+ SetAppBasicModified( FALSE );
+
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ {
+ pBindings->Invalidate( SID_SAVEDOC );
+ pBindings->Update( SID_SAVEDOC );
+ }
+ }
+}
+
+
+USHORT __EXPORT BasicIDEShell::PrepareClose( BOOL bUI, BOOL bForBrowsing )
+{
+ (void)bForBrowsing;
+
+ // da es nach Drucken etc. (DocInfo) modifiziert ist, hier resetten
+ GetViewFrame()->GetObjectShell()->SetModified(FALSE);
+
+ if ( StarBASIC::IsRunning() )
+ {
+ if( bUI )
+ {
+ String aErrorStr( IDEResId( RID_STR_CANNOTCLOSE ) );
+ Window *pParent = &GetViewFrame()->GetWindow();
+ InfoBox( pParent, aErrorStr ).Execute();
+ }
+ return FALSE;
+ }
+ else
+ {
+ // Hier unguenstig, wird zweimal gerufen...
+// StoreAllWindowData();
+
+ BOOL bCanClose = TRUE;
+ for ( ULONG nWin = 0; bCanClose && ( nWin < aIDEWindowTable.Count() ); nWin++ )
+ {
+ IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin );
+ if ( /* !pWin->IsSuspended() && */ !pWin->CanClose() )
+ {
+ if ( m_aCurLibName.Len() && ( pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName ) )
+ SetCurLib( ScriptDocument::getApplicationScriptDocument(), String(), false );
+ SetCurWindow( pWin, TRUE );
+ bCanClose = FALSE;
+ }
+ }
+
+ if ( bCanClose )
+ StoreAllWindowData( FALSE ); // Nicht auf Platte schreiben, das passiert am Ende automatisch
+
+ return bCanClose;
+ }
+}
+
+void BasicIDEShell::InitScrollBars()
+{
+ aVScrollBar.SetLineSize( 300 );
+ aVScrollBar.SetPageSize( 2000 );
+ aHScrollBar.SetLineSize( 300 );
+ aHScrollBar.SetPageSize( 2000 );
+ aHScrollBar.Enable();
+ aVScrollBar.Enable();
+ aVScrollBar.Show();
+ aHScrollBar.Show();
+ aScrollBarBox.Show();
+}
+
+
+
+void BasicIDEShell::InitTabBar()
+{
+ pTabBar->Enable();
+ pTabBar->Show();
+ pTabBar->SetSelectHdl( LINK( this, BasicIDEShell, TabBarHdl ) );
+}
+
+
+Size __EXPORT BasicIDEShell::GetOptimalSizePixel() const
+{
+ return Size( 400, 300 );
+}
+
+
+
+void __EXPORT BasicIDEShell::OuterResizePixel( const Point &rPos, const Size &rSize )
+{
+ // Adjust fliegt irgendwann raus...
+ AdjustPosSizePixel( rPos, rSize );
+}
+
+
+IMPL_LINK_INLINE_START( BasicIDEShell, TabBarSplitHdl, TabBar *, pTBar )
+{
+ (void)pTBar;
+ bTabBarSplitted = TRUE;
+ ArrangeTabBar();
+
+ return 0;
+}
+IMPL_LINK_INLINE_END( BasicIDEShell, TabBarSplitHdl, TabBar *, pTBar )
+
+
+
+IMPL_LINK( BasicIDEShell, TabBarHdl, TabBar *, pCurTabBar )
+{
+ USHORT nCurId = pCurTabBar->GetCurPageId();
+ IDEBaseWindow* pWin = aIDEWindowTable.Get( nCurId );
+ DBG_ASSERT( pWin, "Eintrag in TabBar passt zu keinem Fenster!" );
+ SetCurWindow( pWin );
+
+ return 0;
+}
+
+
+
+BOOL BasicIDEShell::NextPage( BOOL bPrev )
+{
+ BOOL bRet = FALSE;
+ USHORT nPos = pTabBar->GetPagePos( pTabBar->GetCurPageId() );
+
+ if ( bPrev )
+ --nPos;
+ else
+ ++nPos;
+
+ if ( nPos < pTabBar->GetPageCount() )
+ {
+ IDEBaseWindow* pWin = aIDEWindowTable.Get( pTabBar->GetPageId( nPos ) );
+ SetCurWindow( pWin, TRUE );
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+
+
+void BasicIDEShell::ArrangeTabBar()
+{
+ Size aSz( GetViewFrame()->GetWindow().GetOutputSizePixel() );
+ long nBoxPos = aScrollBarBox.GetPosPixel().X() - 1;
+ long nPos = pTabBar->GetSplitSize();
+ if ( nPos <= nBoxPos )
+ {
+ Point aPnt( pTabBar->GetPosPixel() );
+ long nH = aHScrollBar.GetSizePixel().Height();
+ pTabBar->SetPosSizePixel( aPnt, Size( nPos, nH ) );
+ long nScrlStart = aPnt.X() + nPos;
+ aHScrollBar.SetPosSizePixel( Point( nScrlStart, aPnt.Y() ), Size( nBoxPos - nScrlStart + 2, nH ) );
+ aHScrollBar.Update();
+ }
+}
+
+
+
+SfxUndoManager* BasicIDEShell::GetUndoManager()
+{
+ SfxUndoManager* pMgr = NULL;
+ if( pCurWin )
+ pMgr = pCurWin->GetUndoManager();
+
+ return pMgr;
+}
+
+
+
+void BasicIDEShell::ShowObjectDialog( BOOL bShow, BOOL bCreateOrDestroy )
+{
+ if ( bShow )
+ {
+ if ( !pObjectCatalog && bCreateOrDestroy )
+ {
+ pObjectCatalog = new ObjectCatalog( &GetViewFrame()->GetWindow() );
+ // Position wird in BasicIDEData gemerkt und vom Dlg eingestellt
+ if ( pObjectCatalog )
+ {
+ pObjectCatalog->SetCancelHdl( LINK( this, BasicIDEShell, ObjectDialogCancelHdl ) );
+ BasicEntryDescriptor aDesc;
+ IDEBaseWindow* pCurWin_ = GetCurWindow();
+ if ( pCurWin_ )
+ aDesc = pCurWin_->CreateEntryDescriptor();
+ pObjectCatalog->SetCurrentEntry( aDesc );
+ }
+ }
+
+ // Die allerletzten Aenderungen...
+ if ( pCurWin )
+ pCurWin->StoreData();
+
+ if ( pObjectCatalog )
+ {
+ pObjectCatalog->UpdateEntries();
+ pObjectCatalog->Show();
+ }
+ }
+ else if ( pObjectCatalog )
+ {
+ pObjectCatalog->Hide();
+ if ( bCreateOrDestroy )
+ {
+ // Wegen OS/2-Focus-Problem pObjectCatalog vorm delete auf NULL
+ ObjectCatalog* pTemp = pObjectCatalog;
+ pObjectCatalog = 0;
+ delete pTemp;
+ }
+ }
+}
+
+
+
+void __EXPORT BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&,
+ const SfxHint& rHint, const TypeId& )
+{
+ if ( IDE_DLL()->GetShell() )
+ {
+ if ( rHint.IsA( TYPE( SfxSimpleHint ) ) )
+ {
+ switch ( ((SfxSimpleHint&)rHint).GetId() )
+ {
+ case SFX_HINT_DYING:
+ {
+ EndListening( rBC, TRUE /* Alle abmelden */ );
+ if ( pObjectCatalog )
+ pObjectCatalog->UpdateEntries();
+ }
+ break;
+ }
+
+ if ( rHint.IsA( TYPE( SbxHint ) ) )
+ {
+ SbxHint& rSbxHint = (SbxHint&)rHint;
+ ULONG nHintId = rSbxHint.GetId();
+ if ( ( nHintId == SBX_HINT_BASICSTART ) ||
+ ( nHintId == SBX_HINT_BASICSTOP ) )
+ {
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ {
+ pBindings->Invalidate( SID_BASICRUN );
+ pBindings->Update( SID_BASICRUN );
+ pBindings->Invalidate( SID_BASICCOMPILE );
+ pBindings->Update( SID_BASICCOMPILE );
+ pBindings->Invalidate( SID_BASICSTEPOVER );
+ pBindings->Update( SID_BASICSTEPOVER );
+ pBindings->Invalidate( SID_BASICSTEPINTO );
+ pBindings->Update( SID_BASICSTEPINTO );
+ pBindings->Invalidate( SID_BASICSTEPOUT );
+ pBindings->Update( SID_BASICSTEPOUT );
+ pBindings->Invalidate( SID_BASICSTOP );
+ pBindings->Update( SID_BASICSTOP );
+ pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
+ pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT );
+ pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS );
+ pBindings->Update( SID_BASICIDE_MANAGEBRKPNTS );
+ pBindings->Invalidate( SID_BASICIDE_MODULEDLG );
+ pBindings->Update( SID_BASICIDE_MODULEDLG );
+ pBindings->Invalidate( SID_BASICLOAD );
+ pBindings->Update( SID_BASICLOAD );
+ }
+
+ if ( nHintId == SBX_HINT_BASICSTOP )
+ {
+ // Nicht nur bei Error/Break oder explizitem anhalten,
+ // falls durch einen Programmierfehler das Update abgeschaltet ist.
+ BasicIDE::BasicStopped();
+ UpdateModulWindowLayout( true ); // Leer machen...
+ if( m_pCurLocalizationMgr )
+ m_pCurLocalizationMgr->handleBasicStopped();
+ }
+ else if( m_pCurLocalizationMgr )
+ {
+ m_pCurLocalizationMgr->handleBasicStarted();
+ }
+
+ IDEBaseWindow* pWin = aIDEWindowTable.First();
+ while ( pWin )
+ {
+ if ( nHintId == SBX_HINT_BASICSTART )
+ pWin->BasicStarted();
+ else
+ pWin->BasicStopped();
+ pWin = aIDEWindowTable.Next();
+ }
+ }
+ }
+ }
+ }
+}
+
+
+
+void BasicIDEShell::CheckWindows()
+{
+ BOOL bSetCurWindow = FALSE;
+ for ( ULONG nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ )
+ {
+ IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin );
+ if ( pWin->GetStatus() & BASWIN_TOBEKILLED )
+ {
+ pWin->StoreData();
+ if ( pWin == pCurWin )
+ bSetCurWindow = TRUE;
+ RemoveWindow( pWin, TRUE, FALSE );
+ nWin--;
+ }
+ }
+ if ( bSetCurWindow )
+ SetCurWindow( FindApplicationWindow(), TRUE );
+}
+
+
+
+void BasicIDEShell::RemoveWindows( const ScriptDocument& rDocument, const String& rLibName, BOOL bDestroy )
+{
+ BOOL bChangeCurWindow = pCurWin ? FALSE : TRUE;
+ for ( ULONG nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ )
+ {
+ IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin );
+ if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName )
+ {
+ if ( pWin == pCurWin )
+ bChangeCurWindow = TRUE;
+ pWin->StoreData();
+ RemoveWindow( pWin, bDestroy, FALSE );
+ nWin--;
+ }
+ }
+ if ( bChangeCurWindow )
+ SetCurWindow( FindApplicationWindow(), TRUE );
+}
+
+
+
+void BasicIDEShell::UpdateWindows()
+{
+ // Alle Fenster, die nicht angezeigt werden duerfen, entfernen
+ BOOL bChangeCurWindow = pCurWin ? FALSE : TRUE;
+ if ( m_aCurLibName.Len() )
+ {
+ for ( ULONG nWin = 0; nWin < aIDEWindowTable.Count(); nWin++ )
+ {
+ IDEBaseWindow* pWin = aIDEWindowTable.GetObject( nWin );
+ if ( !pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName )
+ {
+ if ( pWin == pCurWin )
+ bChangeCurWindow = TRUE;
+ pWin->StoreData();
+ // Die Abfrage auf RUNNING verhindert den Absturz, wenn in Reschedule.
+ // Fenster bleibt erstmal stehen, spaeter sowieso mal umstellen,
+ // dass Fenster nur als Hidden markiert werden und nicht
+ // geloescht.
+ if ( !(pWin->GetStatus() & ( BASWIN_TOBEKILLED | BASWIN_RUNNINGBASIC | BASWIN_SUSPENDED ) ) )
+ {
+ RemoveWindow( pWin, FALSE, FALSE );
+ nWin--;
+ }
+ }
+ }
+ }
+
+ if ( bCreatingWindow )
+ return;
+
+ IDEBaseWindow* pNextActiveWindow = 0;
+
+ // Alle anzuzeigenden Fenster anzeigen
+ ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::AllWithApplication ) );
+ for ( ScriptDocuments::const_iterator doc = aDocuments.begin();
+ doc != aDocuments.end();
+ ++doc
+ )
+ {
+ StartListening( *doc->getBasicManager(), TRUE /* Nur einmal anmelden */ );
+
+ // libraries
+ Sequence< ::rtl::OUString > aLibNames( doc->getLibraryNames() );
+ sal_Int32 nLibCount = aLibNames.getLength();
+ const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
+
+ for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+ {
+ String aLibName = pLibNames[ i ];
+
+ if ( !m_aCurLibName.Len() || ( *doc == m_aCurDocument && aLibName == m_aCurLibName ) )
+ {
+ // check, if library is password protected and not verified
+ BOOL bProtected = FALSE;
+ Reference< script::XLibraryContainer > xModLibContainer( doc->getLibraryContainer( E_SCRIPTS ) );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
+ {
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
+ {
+ bProtected = TRUE;
+ }
+ }
+
+ if ( !bProtected )
+ {
+ LibInfoItem* pLibInfoItem = 0;
+ BasicIDEData* pData = IDE_DLL()->GetExtraData();
+ if ( pData )
+ pLibInfoItem = pData->GetLibInfos().GetInfo( LibInfoKey( *doc, aLibName ) );
+
+ // modules
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
+ {
+ StarBASIC* pLib = doc->getBasicManager()->GetLib( aLibName );
+ if ( pLib )
+ ImplStartListening( pLib );
+
+ try
+ {
+ Sequence< ::rtl::OUString > aModNames( doc->getObjectNames( E_SCRIPTS, aLibName ) );
+ sal_Int32 nModCount = aModNames.getLength();
+ const ::rtl::OUString* pModNames = aModNames.getConstArray();
+
+ for ( sal_Int32 j = 0 ; j < nModCount ; j++ )
+ {
+ String aModName = pModNames[ j ];
+ ModulWindow* pWin = FindBasWin( *doc, aLibName, aModName, FALSE );
+ if ( !pWin )
+ pWin = CreateBasWin( *doc, aLibName, aModName );
+ if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aModName &&
+ pLibInfoItem->GetCurrentType() == BASICIDE_TYPE_MODULE )
+ {
+ pNextActiveWindow = (IDEBaseWindow*)pWin;
+ }
+ }
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ // dialogs
+ Reference< script::XLibraryContainer > xDlgLibContainer( doc->getLibraryContainer( E_DIALOGS ) );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
+ {
+ try
+ {
+ Sequence< ::rtl::OUString > aDlgNames = doc->getObjectNames( E_DIALOGS, aLibName );
+ sal_Int32 nDlgCount = aDlgNames.getLength();
+ const ::rtl::OUString* pDlgNames = aDlgNames.getConstArray();
+
+ for ( sal_Int32 j = 0 ; j < nDlgCount ; j++ )
+ {
+ String aDlgName = pDlgNames[ j ];
+ // this find only looks for non-suspended windows;
+ // suspended windows are handled in CreateDlgWin
+ DialogWindow* pWin = FindDlgWin( *doc, aLibName, aDlgName, FALSE );
+ if ( !pWin )
+ pWin = CreateDlgWin( *doc, aLibName, aDlgName );
+ if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aDlgName &&
+ pLibInfoItem->GetCurrentType() == BASICIDE_TYPE_DIALOG )
+ {
+ pNextActiveWindow = (IDEBaseWindow*)pWin;
+ }
+ }
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if ( bChangeCurWindow )
+ {
+ if ( !pNextActiveWindow )
+ pNextActiveWindow = FindApplicationWindow();
+ SetCurWindow( pNextActiveWindow, TRUE );
+ }
+}
+
+void BasicIDEShell::RemoveWindow( IDEBaseWindow* pWindow_, BOOL bDestroy, BOOL bAllowChangeCurWindow )
+{
+ DBG_ASSERT( pWindow_, "Kann keinen NULL-Pointer loeschen!" );
+ ULONG nKey = aIDEWindowTable.GetKey( pWindow_ );
+ pTabBar->RemovePage( (USHORT)nKey );
+ aIDEWindowTable.Remove( nKey );
+ if ( pWindow_ == pCurWin )
+ {
+ if ( bAllowChangeCurWindow )
+ SetCurWindow( FindApplicationWindow(), TRUE );
+ else
+ SetCurWindow( NULL, FALSE );
+ }
+ if ( bDestroy )
+ {
+ if ( !( pWindow_->GetStatus() & BASWIN_INRESCHEDULE ) )
+ {
+ delete pWindow_;
+ }
+ else
+ {
+ pWindow_->AddStatus( BASWIN_TOBEKILLED );
+ pWindow_->Hide();
+ // In normal mode stop basic in windows to be deleted
+ // In VBA stop basic only if the running script is trying to delete
+ // its parent module
+ bool bStop = true;
+ if ( pWindow_->GetDocument().isInVBAMode() )
+ {
+ SbModule* pMod = StarBASIC::GetActiveModule();
+ if ( !pMod || ( pMod && ( pMod->GetName() != pWindow_->GetName() ) ) )
+ bStop = false;
+ }
+ if ( bStop )
+ {
+ StarBASIC::Stop();
+ // Es kommt kein Notify...
+ pWindow_->BasicStopped();
+ }
+ aIDEWindowTable.Insert( nKey, pWindow_ ); // wieder einhaegen
+ }
+ }
+ else
+ {
+ pWindow_->Hide();
+ pWindow_->AddStatus( BASWIN_SUSPENDED );
+ pWindow_->Deactivating();
+ aIDEWindowTable.Insert( nKey, pWindow_ ); // wieder einhaegen
+ }
+
+}
+
+
+
+USHORT BasicIDEShell::InsertWindowInTable( IDEBaseWindow* pNewWin )
+{
+ // Eigentlich prueffen,
+ nCurKey++;
+ aIDEWindowTable.Insert( nCurKey, pNewWin );
+ return nCurKey;
+}
+
+
+
+void BasicIDEShell::InvalidateBasicIDESlots()
+{
+ // Nur die, die eine optische Auswirkung haben...
+
+ if ( IDE_DLL()->GetShell() )
+ {
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ {
+ pBindings->Invalidate( SID_UNDO );
+ pBindings->Invalidate( SID_REDO );
+ pBindings->Invalidate( SID_SAVEDOC );
+ pBindings->Invalidate( SID_SIGNATURE );
+ pBindings->Invalidate( SID_BASICIDE_CHOOSEMACRO );
+ pBindings->Invalidate( SID_BASICIDE_MODULEDLG );
+ pBindings->Invalidate( SID_BASICIDE_OBJCAT );
+ pBindings->Invalidate( SID_BASICSTOP );
+ pBindings->Invalidate( SID_BASICRUN );
+ pBindings->Invalidate( SID_BASICCOMPILE );
+ pBindings->Invalidate( SID_BASICLOAD );
+ pBindings->Invalidate( SID_BASICSAVEAS );
+ pBindings->Invalidate( SID_BASICIDE_MATCHGROUP );
+ pBindings->Invalidate( SID_BASICSTEPINTO );
+ pBindings->Invalidate( SID_BASICSTEPOVER );
+ pBindings->Invalidate( SID_BASICSTEPOUT );
+ pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
+ pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS );
+ pBindings->Invalidate( SID_BASICIDE_ADDWATCH );
+ pBindings->Invalidate( SID_BASICIDE_REMOVEWATCH );
+ pBindings->Invalidate( SID_CHOOSE_CONTROLS );
+ pBindings->Invalidate( SID_PRINTDOC );
+ pBindings->Invalidate( SID_PRINTDOCDIRECT );
+ pBindings->Invalidate( SID_SETUPPRINTER );
+ pBindings->Invalidate( SID_DIALOG_TESTMODE );
+
+ pBindings->Invalidate( SID_DOC_MODIFIED );
+ pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
+ pBindings->Invalidate( SID_BASICIDE_STAT_POS );
+ pBindings->Invalidate( SID_ATTR_INSERT );
+ pBindings->Invalidate( SID_ATTR_SIZE );
+ }
+ }
+}
+
+void BasicIDEShell::EnableScrollbars( BOOL bEnable )
+{
+ if ( bEnable )
+ {
+ aHScrollBar.Enable();
+ aVScrollBar.Enable();
+ }
+ else
+ {
+ aHScrollBar.Disable();
+ aVScrollBar.Disable();
+ }
+}
+
+void BasicIDEShell::SetCurLib( const ScriptDocument& rDocument, String aLibName, bool bUpdateWindows, bool bCheck )
+{
+ if ( !bCheck || ( rDocument != m_aCurDocument || aLibName != m_aCurLibName ) )
+ {
+ ContainerListenerImpl* pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() );
+
+ if ( pListener )
+ pListener->removeContainerListener( m_aCurDocument, m_aCurLibName );
+
+ m_aCurDocument = rDocument;
+
+ pListener->addContainerListener( m_aCurDocument, aLibName );
+
+ m_aCurLibName = aLibName;
+
+ if ( bUpdateWindows )
+ UpdateWindows();
+
+ SetMDITitle();
+
+ SetCurLibForLocalization( rDocument, aLibName );
+
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ {
+ pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR );
+ pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
+ pBindings->Invalidate( SID_BASICIDE_MANAGE_LANG );
+ }
+ }
+}
+
+void BasicIDEShell::SetCurLibForLocalization( const ScriptDocument& rDocument, String aLibName )
+{
+ // Create LocalizationMgr
+ delete m_pCurLocalizationMgr;
+ Reference< resource::XStringResourceManager > xStringResourceManager;
+ try
+ {
+ if( aLibName.Len() )
+ {
+ Reference< container::XNameContainer > xDialogLib( rDocument.getLibrary( E_DIALOGS, aLibName, TRUE ) );
+ xStringResourceManager = LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
+ }
+ }
+ catch ( container::NoSuchElementException& )
+ {}
+ m_pCurLocalizationMgr = new LocalizationMgr
+ ( this, rDocument, aLibName, xStringResourceManager );
+
+ m_pCurLocalizationMgr->handleTranslationbar();
+}
+
+void BasicIDEShell::ImplStartListening( StarBASIC* pBasic )
+{
+ StartListening( pBasic->GetBroadcaster(), TRUE /* Nur einmal anmelden */ );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basidesh.src b/basctl/source/basicide/basidesh.src
new file mode 100644
index 000000000000..556211f690af
--- /dev/null
+++ b/basctl/source/basicide/basidesh.src
@@ -0,0 +1,747 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <baside2.hrc>
+#include <helpid.hrc>
+#ifndef _GLOBLMN_HRC
+#include <svx/globlmn.hrc>
+#endif
+#include "dlgresid.hrc"
+
+#define MASKCOLOR MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; };
+
+String RID_STR_IDENAME
+{
+ Text = "BasicIDE" ;
+};
+String RID_STR_FILTER_ALLFILES
+{
+ Text [ en-US ] = "<All>" ;
+};
+String RID_STR_NOMODULE
+{
+ Text [ en-US ] = "< No Module >" ;
+};
+String RID_STR_WRONGPASSWORD
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Fehlerhaftes Paßwort. : Fehlerhaftes Pa˜wort. */
+ Text [ en-US ] = "Incorrect Password" ;
+};
+String RID_STR_OPEN
+{
+ Text [ en-US ] = "Load" ;
+};
+String RID_STR_SAVE
+{
+ Text [ en-US ] = "Save" ;
+};
+String RID_STR_SOURCETOBIG
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Der Quelltext ist zu groß und kann weder gespeichert noch compiliert werden.\nLöschen Sie einige Kommentare oder übertragen Sie einige Methoden in ein anderes Modul. : Der Quelltext ist zu gro˜ und kann weder gespeichert noch compiliert werden.\nL÷schen Sie einige Kommentare oder ³bertragen Sie einige Methoden in ein anderes Modul. */
+ Text [ en-US ] = "The source text is too large and can be neither compiled nor saved.\nDelete some of the comments or transfer some methods into another module." ;
+};
+String RID_STR_ERROROPENSTORAGE
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Fehler beim Öffnen der Datei : Fehler beim Íffnen der Datei */
+ Text [ en-US ] = "Error opening file" ;
+};
+String RID_STR_ERROROPENLIB
+{
+ Text [ en-US ] = "Error loading library" ;
+};
+String RID_STR_NOLIBINSTORAGE
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Die Datei enthält keine BASIC-Bibliotheken : Die Datei enthõlt keine BASIC-Bibliotheken */
+ Text [ en-US ] = "The file does not contain any BASIC libraries" ;
+};
+String RID_STR_BADSBXNAME
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Ungültiger Bezeichner : Ung³ltiger Bezeichner */
+ Text [ en-US ] = "Invalid Name" ;
+};
+String RID_STR_LIBNAMETOLONG
+{
+ Text [ en-US ] = "A library name can have up to 30 characters.";
+};
+String RID_STR_ERRORCHOOSEMACRO
+{
+ Text [ en-US ] = "Macros from other documents are not accessible.";
+};
+String RID_STR_LIBISREADONLY
+{
+ Text [ en-US ] = "This library is read-only.";
+};
+String RID_STR_REPLACELIB
+{
+ Text [ en-US ] = "'XX' cannot be replaced.";
+};
+String RID_STR_IMPORTNOTPOSSIBLE
+{
+ Text [ en-US ] = "'XX' cannot be added.";
+};
+String RID_STR_NOIMPORT
+{
+ Text [ en-US ] = "'XX' was not added.";
+};
+String RID_STR_ENTERPASSWORD
+{
+ Text [ en-US ] = "Enter password for 'XX'";
+};
+String RID_STR_SBXNAMEALLREADYUSED
+{
+ Text [ en-US ] = "Name already exists" ;
+};
+String RID_STR_SIGNED
+{
+ Text [ en-US ] = "(Signed)" ;
+};
+String RID_STR_SBXNAMEALLREADYUSED2
+{
+ Text [ en-US ] = "Object with same name already exists" ;
+};
+String RID_STR_FILEEXISTS
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Die Datei 'XX' existiert schon : Die Datei ''XX'' existiert schon */
+ Text [ en-US ] = "The 'XX' file already exists" ;
+};
+String RID_STR_CANNOTRUNMACRO
+{
+ Text [ en-US ] = "For security reasons, you cannot run this macro.\n\nFor more information, check the security settings." ;
+};
+String RID_STR_COMPILEERROR
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Übersetzungs-Fehler: : šbersetzungs-Fehler: */
+ Text [ en-US ] = "Compile Error: " ;
+};
+String RID_STR_RUNTIMEERROR
+{
+ Text [ en-US ] = "Runtime Error: #" ;
+};
+String RID_STR_SEARCHNOTFOUND
+{
+ Text [ en-US ] = "Search key not found" ;
+};
+String RID_STR_SEARCHFROMSTART
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Es wurde bis zum letzten Modul gesucht. Möchten Sie die Suche beim ersten Modul fortsetzen? : Es wurde bis zum letzten Modul gesucht. M÷chten Sie die Suche beim ersten Modul fortsetzen? */
+ Text [ en-US ] = "Search to last module complete. Continue at first module?" ;
+};
+String RID_STR_SEARCHREPLACES
+{
+ Text [ en-US ] = "Search key replaced XX times" ;
+};
+String RID_STR_COULDNTREAD
+{
+ Text [ en-US ] = "The file could not be read" ;
+};
+String RID_STR_COULDNTWRITE
+{
+ Text [ en-US ] = "The file could not be saved" ;
+};
+String RID_STR_CANNOTCHANGENAMESTDLIB
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Der Name der Standard-Bibliothek kann nicht geändert werden : Der Name der Standard-Bibliothek kann nicht geõndert werden */
+ Text [ en-US ] = "The name of the default library cannot be changed." ;
+};
+String RID_STR_CANNOTCHANGENAMEREFLIB
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Der Name einer referenzierten Bibliothek kann nicht geändert werden : Der Name einer referenzierten Bibliothek kann nicht geõndert werden */
+ Text [ en-US ] = "The name of a referenced library cannot be changed." ;
+};
+String RID_STR_CANNOTUNLOADSTDLIB
+{
+ Text [ en-US ] = "The default library cannot be deactivated" ;
+};
+String RID_STR_GENERATESOURCE
+{
+ Text [ en-US ] = "Generating source" ;
+};
+String RID_STR_FILENAME
+{
+ Text [ en-US ] = "File name:" ;
+};
+String RID_STR_APPENDLIBS
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Bibliotheken hinzufügen : Bibliotheken hinzuf³gen */
+ Text [ en-US ] = "Import Libraries" ;
+};
+String RID_STR_QUERYDELMACRO
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Möchten Sie das Makro XX löschen ? : M÷chten Sie das Makro XX l÷schen ? */
+ Text [ en-US ] = "Do you want to delete the macro XX?" ;
+};
+String RID_STR_QUERYDELDIALOG
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Möchten Sie den Dialog XX löschen ? : M÷chten Sie den Dialog XX l÷schen ? */
+ Text [ en-US ] = "Do you want to delete the XX dialog?" ;
+};
+String RID_STR_QUERYDELLIB
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Möchten Sie die Bibliothek XX löschen ? : M÷chten Sie die Bibliothek XX l÷schen ? */
+ Text [ en-US ] = "Do you want to delete the XX library?" ;
+};
+String RID_STR_QUERYDELLIBREF
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Möchten Sie die Referenz auf die Bibliothek XX löschen ? : M÷chten Sie die Referenz auf die Bibliothek XX l÷schen ? */
+ Text [ en-US ] = "Do you want to delete the reference to the XX library?" ;
+};
+String RID_STR_QUERYDELMODULE
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Möchten Sie das Modul XX löschen ? : M÷chten Sie das Modul XX l÷schen ? */
+ Text [ en-US ] = "Do you want to delete the XX module?" ;
+};
+String RID_STR_OBJNOTFOUND
+{
+ Text [ en-US ] = "Object or method not found" ;
+};
+String RID_STR_BASIC
+{
+ Text [ en-US ] = "BASIC" ;
+};
+String RID_STR_LINE
+{
+ // Abkuerzung fuer 'Zeile'
+ Text [ en-US ] = "Ln" ;
+};
+String RID_STR_COLUMN
+{
+ // Abkuerzung fuer 'Spalte'
+ Text [ en-US ] = "Col" ;
+};
+String RID_STR_DOC
+{
+ Text [ en-US ] = "Document" ;
+};
+String RID_BASICIDE_OBJECTBAR
+{
+ Text [ en-US ] = "Macro Bar" ;
+};
+String RID_STR_CANNOTCLOSE
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Das Fenster kann nicht geschlossen werden,\nwährend das BASIC-Programm läuft. : Das Fenster kann nicht geschlossen werden,\nwõhrend das BASIC-Programm lõuft. */
+ Text [ en-US ] = "The window cannot be closed while BASIC is running." ;
+};
+String RID_STR_REPLACESTDLIB
+{
+ Text [ en-US ] = "The default library cannot be replaced." ;
+};
+String RID_STR_REFNOTPOSSIBLE
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Referenz auf 'XX' nicht möglich. : Referenz auf ''XX'' nicht möglich. */
+ /* ### ACHTUNG: Neuer Text in Resource? Referenz auf 'XX' nicht möglich. : Referenz auf 'XX' nicht m÷glich. */
+ Text [ en-US ] = "Reference to 'XX' not possible." ;
+};
+String RID_STR_WATCHNAME
+{
+ Text [ en-US ] = "Watch" ;
+};
+String RID_STR_WATCHVARIABLE
+{
+ Text [ en-US ] = "Variable" ;
+};
+String RID_STR_WATCHVALUE
+{
+ Text [ en-US ] = "Value" ;
+};
+String RID_STR_WATCHTYPE
+{
+ Text [ en-US ] = "Type" ;
+};
+String RID_STR_STACKNAME
+{
+ Text [ en-US ] = "Call Stack" ;
+};
+String RID_STR_INITIDE
+{
+ Text [ en-US ] = "BASIC Initialization" ;
+};
+String RID_STR_STDMODULENAME
+{
+ Text [ en-US ] = "Module" ;
+};
+String RID_STR_STDDIALOGNAME
+{
+ Text [ en-US ] = "Dialog" ;
+};
+String RID_STR_STDLIBNAME
+{
+ Text [ en-US ] = "Library" ;
+};
+String RID_STR_NEWLIB
+{
+ Text [ en-US ] = "New Library" ;
+};
+String RID_STR_NEWMOD
+{
+ Text [ en-US ] = "New Module" ;
+};
+String RID_STR_NEWDLG
+{
+ Text [ en-US ] = "New Dialog" ;
+};
+String RID_STR_ALL
+{
+ Text [ en-US ] = "All" ;
+};
+String RID_STR_PAGE
+{
+ Text [ en-US ] = "Page" ;
+};
+String RID_STR_MACRONAMEREQ
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Es muß ein Name angegeben werden. : Es mu˜ ein Name angegeben werden. */
+ Text [ en-US ] = "A name must be entered." ;
+};
+String RID_STR_WILLSTOPPRG
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Sie müssen nach dieser Änderung Ihr Programm neu starten.\nForfahren? : Sie m³ssen nach dieser Žnderung Ihr Programm neu starten.\nForfahren? */
+ Text [ en-US ] = "You will have to restart the program after this edit.\nContinue?" ;
+};
+String RID_STR_SEARCHALLMODULES
+{
+ Text [ en-US ] = "Do you want to replace the text in all active modules?" ;
+};
+Edit RID_EDT_WATCHEDIT
+{
+ HelpId = HID_BASICIDE_WATCHWINDOW_EDIT ;
+ Border = TRUE ;
+ SvLook = TRUE ;
+ Size = MAP_APPFONT ( 80 , 12 ) ;
+};
+ImageButton RID_IMGBTN_REMOVEWATCH
+{
+ HelpId = HID_BASICIDE_REMOVEWATCH ;
+ SmallStyle = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "baswatr.bmp" ; };
+ MASKCOLOR
+ };
+ QuickHelpText [ en-US ] = "Remove Watch" ;
+};
+Image RID_IMG_REMOVEWATCH_HC
+{
+ ImageBitmap = Bitmap { File = "baswatr_h.bmp" ; };
+ MASKCOLOR
+};
+ImageButton RID_IMGBTN_GOTOCALL
+{
+ HelpId = HID_BASICIDE_GOTOALL ;
+ SmallStyle = TRUE ;
+ ButtonImage = Image { ImageBitmap = Bitmap { File = "basgocl.bmp" ; }; } ;
+};
+String RID_STR_REMOVEWATCH
+{
+ Text [ en-US ] = "Watch:" ;
+};
+String RID_STR_STACK
+{
+ Text [ en-US ] = "Calls: " ;
+};
+String RID_STR_USERMACROS
+{
+ Text [ en-US ] = "My Macros" ;
+};
+String RID_STR_USERDIALOGS
+{
+ Text [ en-US ] = "My Dialogs" ;
+};
+String RID_STR_USERMACROSDIALOGS
+{
+ Text [ en-US ] = "My Macros & Dialogs" ;
+};
+String RID_STR_SHAREMACROS
+{
+ Text [ en-US ] = "%PRODUCTNAME Macros" ;
+};
+String RID_STR_SHAREDIALOGS
+{
+ Text [ en-US ] = "%PRODUCTNAME Dialogs" ;
+};
+String RID_STR_SHAREMACROSDIALOGS
+{
+ Text [ en-US ] = "%PRODUCTNAME Macros & Dialogs" ;
+};
+Menu RID_POPUP_BRKPROPS
+{
+ Text [ en-US ] = "Properties" ;
+ DefaultItemId = RID_BRKPROPS ;
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = RID_ACTIV ;
+ HelpId = HID_BASICIDE_ACTIV ;
+ Text [ en-US ] = "Active" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = RID_BRKPROPS ;
+ HelpId = HID_BASICIDE_BRKPROPS ;
+ Text [ en-US ] = "Properties..." ;
+ /* ### ACHTUNG: Neuer Text in Resource? Einstellungen für den Haltepunkt : Einstellungen f³r den Haltepunkt */
+ };
+ };
+};
+Menu RID_POPUP_BRKDLG
+{
+ Text [ en-US ] = "Manage Breakpoints" ;
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = RID_BRKDLG ;
+ HelpId = HID_BASICIDE_BRKDLG ;
+ Text [ en-US ] = "Manage Breakpoints..." ;
+ /* ### ACHTUNG: Neuer Text in Resource? Dialog für die Haltepunkte : Dialog f³r die Haltepunkte */
+ };
+ };
+};
+Menu RID_POPUP_TABBAR
+{
+ DefaultItemId = SID_BASICIDE_HIDECURPAGE ;
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = RID_INSERT ;
+ /* ### ACHTUNG: Neuer Text in Resource? Einfügen : Einf³gen */
+ Text [ en-US ] = "Insert" ;
+ Submenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_BASICIDE_NEWMODULE ;
+ HelpId = SID_BASICIDE_NEWMODULE ;
+ Text [ en-US ] = "BASIC Module" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_BASICIDE_NEWDIALOG ;
+ HelpId = SID_BASICIDE_NEWDIALOG ;
+ Text [ en-US ] = "BASIC Dialog" ;
+ };
+ };
+ };
+ /* ### ACHTUNG: Neuer Text in Resource? Modul oder Dialog einfügen : Modul oder Dialog einf³gen */
+ };
+ MenuItem
+ {
+ Identifier = SID_BASICIDE_DELETECURRENT ;
+ HelpId = SID_BASICIDE_DELETECURRENT ;
+ /* ### ACHTUNG: Neuer Text in Resource? Löschen : L÷schen */
+ Text [ en-US ] = "Delete" ;
+ /* ### ACHTUNG: Neuer Text in Resource? Modul oder Dialog löschen : Modul oder Dialog l÷schen */
+ };
+ MenuItem
+ {
+ Identifier = SID_BASICIDE_RENAMECURRENT ;
+ HelpId = SID_BASICIDE_RENAMECURRENT ;
+ Text [ en-US ] = "Rename" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_BASICIDE_HIDECURPAGE ;
+ HelpId = SID_BASICIDE_HIDECURPAGE ;
+ Text [ en-US ] = "Hide" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = SID_BASICIDE_MODULEDLG ;
+ HelpId = SID_BASICIDE_MODULEDLG ;
+ Text [ en-US ] = "Modules..." ;
+ };
+ };
+};
+Menu RID_POPUP_DLGED
+{
+ DefaultItemId = SID_SHOW_PROPERTYBROWSER ;
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_SHOW_PROPERTYBROWSER ;
+ HelpId = SID_SHOW_PROPERTYBROWSER ;
+ Text [ en-US ] = "Properties...";
+ };
+ };
+};
+ImageList RID_IMGLST_LAYOUT
+{
+ Prefix = "im";
+ MASKCOLOR
+ IdList =
+ {
+ IMGID_BRKENABLED ;
+ IMGID_BRKDISABLED ;
+ IMGID_STEPMARKER ;
+ IMGID_ERRORMARKER ;
+ };
+};
+ImageList RID_IMGLST_LAYOUT_HC
+{
+ Prefix = "imh";
+ MASKCOLOR
+ IdList =
+ {
+ IMGID_BRKENABLED ;
+ IMGID_BRKDISABLED ;
+ IMGID_STEPMARKER ;
+ IMGID_ERRORMARKER ;
+ };
+};
+Image RID_IMG_LOCKED
+{
+ ImageBitmap = Bitmap { File = "locked.bmp" ; };
+ MASKCOLOR
+};
+Image RID_IMG_LOCKED_HC
+{
+ ImageBitmap = Bitmap { File = "locked_h.bmp" ; };
+ MASKCOLOR
+};
+Image RID_IMG_INSTALLATION
+{
+ ImageBitmap = Bitmap { File = "harddisk_16.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_INSTALLATION_HC
+{
+ ImageBitmap = Bitmap { File = "harddisk_16_h.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_DOCUMENT
+{
+ ImageBitmap = Bitmap { File = "im30826.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_DOCUMENT_HC
+{
+ ImageBitmap = Bitmap { File = "imh30826.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_MODLIB
+{
+ ImageBitmap = Bitmap { File = "im30820.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_MODLIB_HC
+{
+ ImageBitmap = Bitmap { File = "imh30820.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_MODLIBNOTLOADED
+{
+ ImageBitmap = Bitmap { File = "im30827.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_MODLIBNOTLOADED_HC
+{
+ ImageBitmap = Bitmap { File = "imh30827.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_MODULE
+{
+ ImageBitmap = Bitmap { File = "im30821.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_MODULE_HC
+{
+ ImageBitmap = Bitmap { File = "imh30821.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_MACRO
+{
+ ImageBitmap = Bitmap { File = "im30822.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_MACRO_HC
+{
+ ImageBitmap = Bitmap { File = "imh30822.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_DLGLIB
+{
+ ImageBitmap = Bitmap { File = "dialogfolder_16.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_DLGLIB_HC
+{
+ ImageBitmap = Bitmap { File = "dialogfolder_16_h.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_DLGLIBNOTLOADED
+{
+ ImageBitmap = Bitmap { File = "dialogfoldernot_16.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_DLGLIBNOTLOADED_HC
+{
+ ImageBitmap = Bitmap { File = "dialogfoldernot_16_h.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_DIALOG
+{
+ ImageBitmap = Bitmap { File = "im30823.png"; };
+ MASKCOLOR
+};
+Image RID_IMG_DIALOG_HC
+{
+ ImageBitmap = Bitmap { File = "imh30823.png"; };
+ MASKCOLOR
+};
+String RID_STR_QUERYREPLACEMACRO
+{
+ Text [ en-US ] = "Do you want to overwrite the XX macro?" ;
+};
+String RID_STR_TRANSLATION_NOTLOCALIZED
+{
+ Text [ en-US ] = "<Not localized>" ;
+};
+String RID_STR_TRANSLATION_DEFAULT
+{
+ Text [ en-US ] = "[Default Language]" ;
+};
+String RID_STR_DOCUMENT_OBJECTS
+{
+ Text [ en-US ] = "Document Objects" ;
+};
+String RID_STR_USERFORMS
+{
+ Text [ en-US ] = "Forms" ;
+};
+String RID_STR_NORMAL_MODULES
+{
+ Text [ en-US ] = "Modules" ;
+};
+String RID_STR_CLASS_MODULES
+{
+ Text [ en-US ] = "Class Modules" ;
+};
+
+
+String RID_STR_DLGIMP_CLASH_RENAME
+{
+ Text [ en-US ] = "Rename" ;
+};
+
+String RID_STR_DLGIMP_CLASH_REPLACE
+{
+ Text [ en-US ] = "Replace" ;
+};
+
+String RID_STR_DLGIMP_CLASH_TITLE
+{
+ Text [ en-US ] = "Dialog Import - Name already used" ;
+};
+
+String RID_STR_DLGIMP_CLASH_TEXT
+{
+ Text [ en-US ] = "The library already contains a dialog with the name:\n\n$(ARG1)\n\nRename dialog to keep current dialog or replace existing dialog.\n " ;
+};
+
+String RID_STR_DLGIMP_MISMATCH_ADD
+{
+ Text [ en-US ] = "Add" ;
+};
+
+String RID_STR_DLGIMP_MISMATCH_OMIT
+{
+ Text [ en-US ] = "Omit" ;
+};
+
+String RID_STR_DLGIMP_MISMATCH_TITLE
+{
+ Text [ en-US ] = "Dialog Import - Language Mismatch" ;
+};
+
+String RID_STR_DLGIMP_MISMATCH_TEXT
+{
+ Text [ en-US ] = "The dialog to be imported supports other languages than the target library.\n\nAdd these languages to the library to keep additional language resources provided by the dialog or omit them to stay with the current library languages.\n\nNote: For languages not supported by the dialog the resources of the dialog's default language will be used.\n " ;
+};
+
+
+#define MN_EDIT 20
+#define MN_VIEW 21
+#define MN_EXTRA 22
+#define MN_WIN 30
+#define MN_HELP 31
+#define MN_TEMPLATES 11
+
+#define MN_PLEDIT 20
+#define MN_PLVIEW 21
+#define MN_PLEXTRA 22
+#define MN_PLWIN 30
+#define MN_PLHELP 31
+#define MN_PLTEMPLATES 11
+
+
+/*
+
+The application menu bar resource has become obsolete. You can now find the menu bar definition at:
+<project>/basicide/menubar/menubar.xml.
+
+*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx
new file mode 100644
index 000000000000..a5b441cdb1ab
--- /dev/null
+++ b/basctl/source/basicide/basobj2.cxx
@@ -0,0 +1,416 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include <ide_pch.hxx>
+
+#include <vector>
+#include <algorithm>
+#include <basic/sbx.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/document/XScriptInvocationContext.hpp>
+#include <basobj.hxx>
+#include <iderdll.hxx>
+#include <iderdll2.hxx>
+#include <iderid.hxx>
+#include <macrodlg.hxx>
+#include <moduldlg.hxx>
+#include <basidesh.hxx>
+#include <basidesh.hrc>
+#include <baside2.hxx>
+#include <basicmod.hxx>
+#include <basdoc.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+
+
+//----------------------------------------------------------------------------
+
+extern "C" {
+ SAL_DLLPUBLIC_EXPORT rtl_uString* basicide_choose_macro( void* pOnlyInDocument_AsXModel, BOOL bChooseOnly, rtl_uString* pMacroDesc )
+ {
+ ::rtl::OUString aMacroDesc( pMacroDesc );
+ Reference< frame::XModel > aDocument( static_cast< frame::XModel* >( pOnlyInDocument_AsXModel ) );
+ ::rtl::OUString aScriptURL = BasicIDE::ChooseMacro( aDocument, bChooseOnly, aMacroDesc );
+ rtl_uString* pScriptURL = aScriptURL.pData;
+ rtl_uString_acquire( pScriptURL );
+
+ return pScriptURL;
+ }
+ SAL_DLLPUBLIC_EXPORT void basicide_macro_organizer( INT16 nTabId )
+ {
+ OSL_TRACE("in basicide_macro_organizer");
+ BasicIDE::Organize( nTabId );
+ }
+}
+
+namespace BasicIDE
+{
+//----------------------------------------------------------------------------
+
+void Organize( INT16 tabId )
+{
+ BasicIDEDLL::Init();
+
+ BasicEntryDescriptor aDesc;
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if ( pIDEShell )
+ {
+ IDEBaseWindow* pCurWin = pIDEShell->GetCurWindow();
+ if ( pCurWin )
+ aDesc = pCurWin->CreateEntryDescriptor();
+ }
+
+ Window* pParent = Application::GetDefDialogParent();
+ OrganizeDialog* pDlg = new OrganizeDialog( pParent, tabId, aDesc );
+ pDlg->Execute();
+ delete pDlg;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL IsValidSbxName( const String& rName )
+{
+ for ( USHORT nChar = 0; nChar < rName.Len(); nChar++ )
+ {
+ BOOL bValid = ( ( rName.GetChar(nChar) >= 'A' && rName.GetChar(nChar) <= 'Z' ) ||
+ ( rName.GetChar(nChar) >= 'a' && rName.GetChar(nChar) <= 'z' ) ||
+ ( rName.GetChar(nChar) >= '0' && rName.GetChar(nChar) <= '9' && nChar ) ||
+ ( rName.GetChar(nChar) == '_' ) );
+ if ( !bValid )
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static BOOL StringCompareLessThan( const String& rStr1, const String& rStr2 )
+{
+ return (rStr1.CompareIgnoreCaseToAscii( rStr2 ) == COMPARE_LESS);
+}
+
+//----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > GetMergedLibraryNames( const Reference< script::XLibraryContainer >& xModLibContainer, const Reference< script::XLibraryContainer >& xDlgLibContainer )
+{
+ // create a sorted list of module library names
+ ::std::vector<String> aModLibList;
+ if ( xModLibContainer.is() )
+ {
+ Sequence< ::rtl::OUString > aModLibNames = xModLibContainer->getElementNames();
+ sal_Int32 nModLibCount = aModLibNames.getLength();
+ const ::rtl::OUString* pModLibNames = aModLibNames.getConstArray();
+ for ( sal_Int32 i = 0 ; i < nModLibCount ; i++ )
+ aModLibList.push_back( pModLibNames[ i ] );
+ ::std::sort( aModLibList.begin() , aModLibList.end() , StringCompareLessThan );
+ }
+
+ // create a sorted list of dialog library names
+ ::std::vector<String> aDlgLibList;
+ if ( xDlgLibContainer.is() )
+ {
+ Sequence< ::rtl::OUString > aDlgLibNames = xDlgLibContainer->getElementNames();
+ sal_Int32 nDlgLibCount = aDlgLibNames.getLength();
+ const ::rtl::OUString* pDlgLibNames = aDlgLibNames.getConstArray();
+ for ( sal_Int32 i = 0 ; i < nDlgLibCount ; i++ )
+ aDlgLibList.push_back( pDlgLibNames[ i ] );
+ ::std::sort( aDlgLibList.begin() , aDlgLibList.end() , StringCompareLessThan );
+ }
+
+ // merge both lists
+ ::std::vector<String> aLibList( aModLibList.size() + aDlgLibList.size() );
+ ::std::merge( aModLibList.begin(), aModLibList.end(), aDlgLibList.begin(), aDlgLibList.end(), aLibList.begin(), StringCompareLessThan );
+ ::std::vector<String>::iterator aIterEnd = ::std::unique( aLibList.begin(), aLibList.end() ); // move unique elements to the front
+ aLibList.erase( aIterEnd, aLibList.end() ); // remove duplicates
+
+ // copy to sequence
+ sal_Int32 nLibCount = aLibList.size();
+ Sequence< ::rtl::OUString > aSeqLibNames( nLibCount );
+ for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+ aSeqLibNames.getArray()[ i ] = aLibList[ i ];
+
+ return aSeqLibNames;
+}
+
+//----------------------------------------------------------------------------
+
+bool RenameModule( Window* pErrorParent, const ScriptDocument& rDocument, const String& rLibName, const String& rOldName, const String& rNewName )
+{
+ if ( !rDocument.hasModule( rLibName, rOldName ) )
+ {
+ OSL_ENSURE( false, "BasicIDE::RenameModule: old module name is invalid!" );
+ return false;
+ }
+
+ if ( rDocument.hasModule( rLibName, rNewName ) )
+ {
+ ErrorBox aError( pErrorParent, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) );
+ aError.Execute();
+ return false;
+ }
+
+ // #i74440
+ if ( rNewName.Len() == 0 )
+ {
+ ErrorBox aError( pErrorParent, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_BADSBXNAME ) ) );
+ aError.Execute();
+ return false;
+ }
+
+ if ( !rDocument.renameModule( rLibName, rOldName, rNewName ) )
+ return false;
+
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if ( pIDEShell )
+ {
+ IDEBaseWindow* pWin = pIDEShell->FindWindow( rDocument, rLibName, rNewName, BASICIDE_TYPE_MODULE, TRUE );
+ if ( pWin )
+ {
+ // set new name in window
+ pWin->SetName( rNewName );
+
+ // set new module in module window
+ ModulWindow* pModWin = (ModulWindow*)pWin;
+ pModWin->SetSbModule( (SbModule*)pModWin->GetBasic()->FindModule( rNewName ) );
+
+ // update tabwriter
+ USHORT nId = (USHORT)(pIDEShell->GetIDEWindowTable()).GetKey( pWin );
+ DBG_ASSERT( nId, "No entry in Tabbar!" );
+ if ( nId )
+ {
+ BasicIDETabBar* pTabBar = (BasicIDETabBar*)pIDEShell->GetTabBar();
+ pTabBar->SetPageText( nId, rNewName );
+ pTabBar->Sort();
+ pTabBar->MakeVisible( pTabBar->GetCurPageId() );
+ }
+ }
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+::rtl::OUString ChooseMacro( const uno::Reference< frame::XModel >& rxLimitToDocument, BOOL bChooseOnly, const ::rtl::OUString& rMacroDesc )
+{
+ (void)rMacroDesc;
+
+ BasicIDEDLL::Init();
+
+ IDE_DLL()->GetExtraData()->ChoosingMacro() = TRUE;
+ SFX_APP()->EnterBasicCall();
+
+ String aScriptURL;
+ BOOL bError = FALSE;
+ SbMethod* pMethod = NULL;
+
+ MacroChooser* pChooser = new MacroChooser( NULL, TRUE );
+ if ( bChooseOnly || !SvtModuleOptions().IsBasicIDE() )
+ pChooser->SetMode( MACROCHOOSER_CHOOSEONLY );
+
+ if ( !bChooseOnly && rxLimitToDocument.is() )
+ // Hack!
+ pChooser->SetMode( MACROCHOOSER_RECORDING );
+
+ short nRetValue = pChooser->Execute();
+
+ IDE_DLL()->GetExtraData()->ChoosingMacro() = FALSE;
+
+ switch ( nRetValue )
+ {
+ case MACRO_OK_RUN:
+ {
+ pMethod = pChooser->GetMacro();
+ if ( !pMethod && pChooser->GetMode() == MACROCHOOSER_RECORDING )
+ pMethod = pChooser->CreateMacro();
+
+ if ( pMethod )
+ {
+ SbModule* pModule = pMethod->GetModule();
+ DBG_ASSERT(pModule, "BasicIDE::ChooseMacro: No Module found!");
+ if ( pModule )
+ {
+ StarBASIC* pBasic = (StarBASIC*)pModule->GetParent();
+ DBG_ASSERT(pBasic, "BasicIDE::ChooseMacro: No Basic found!");
+ if ( pBasic )
+ {
+ BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
+ DBG_ASSERT(pBasMgr, "BasicIDE::ChooseMacro: No BasicManager found!");
+ if ( pBasMgr )
+ {
+ // name
+ String aName;
+ aName += pBasic->GetName();
+ aName += '.';
+ aName += pModule->GetName();
+ aName += '.';
+ aName += pMethod->GetName();
+
+ // language
+ String aLanguage = String::CreateFromAscii("Basic");
+
+ // location
+ String aLocation;
+ ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
+ if ( aDocument.isDocument() )
+ {
+ // document basic
+ aLocation = String::CreateFromAscii("document");
+
+ if ( rxLimitToDocument.is() )
+ {
+ uno::Reference< frame::XModel > xLimitToDocument( rxLimitToDocument );
+
+ uno::Reference< document::XEmbeddedScripts > xScripts( rxLimitToDocument, UNO_QUERY );
+ if ( !xScripts.is() )
+ { // the document itself does not support embedding scripts
+ uno::Reference< document::XScriptInvocationContext > xContext( rxLimitToDocument, UNO_QUERY );
+ if ( xContext.is() )
+ xScripts = xContext->getScriptContainer();
+ if ( xScripts.is() )
+ { // but it is able to refer to a document which actually does support this
+ xLimitToDocument.set( xScripts, UNO_QUERY );
+ if ( !xLimitToDocument.is() )
+ {
+ OSL_ENSURE( false, "BasicIDE::ChooseMacro: a script container which is no document!?" );
+ xLimitToDocument = rxLimitToDocument;
+ }
+ }
+ }
+
+ if ( xLimitToDocument != aDocument.getDocument() )
+ {
+ // error
+ bError = TRUE;
+ ErrorBox( NULL, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_ERRORCHOOSEMACRO ) ) ).Execute();
+ }
+ }
+ }
+ else
+ {
+ // application basic
+ aLocation = String::CreateFromAscii("application");
+ }
+
+ // script URL
+ if ( !bError )
+ {
+ aScriptURL = String::CreateFromAscii("vnd.sun.star.script:");
+ aScriptURL += aName;
+ aScriptURL += String::CreateFromAscii("?language=");
+ aScriptURL += aLanguage;
+ aScriptURL += String::CreateFromAscii("&location=");
+ aScriptURL += aLocation;
+ }
+ }
+ }
+ }
+ }
+
+ if ( pMethod && !rxLimitToDocument.is() )
+ {
+ pMethod->AddRef(); // festhalten, bis Event abgearbeitet.
+ Application::PostUserEvent( LINK( IDE_DLL()->GetExtraData(), BasicIDEData, ExecuteMacroEvent ), pMethod );
+ }
+ }
+ break;
+ }
+
+ delete pChooser;
+
+ SFX_APP()->LeaveBasicCall();
+
+ return ::rtl::OUString( aScriptURL );
+}
+
+//----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > GetMethodNames( const ScriptDocument& rDocument, const String& rLibName, const String& rModName )
+ throw(NoSuchElementException )
+{
+ Sequence< ::rtl::OUString > aSeqMethods;
+
+ // get module
+ ::rtl::OUString aOUSource;
+ if ( rDocument.getModule( rLibName, rModName, aOUSource ) )
+ {
+ SbModuleRef xModule = new SbModule( rModName );
+ xModule->SetSource32( aOUSource );
+ USHORT nCount = xModule->GetMethods()->Count();
+ USHORT nRealCount = nCount;
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( i );
+ if( pMethod->IsHidden() )
+ --nRealCount;
+ }
+ aSeqMethods.realloc( nRealCount );
+
+ USHORT iTarget = 0;
+ for ( USHORT i = 0 ; i < nCount; ++i )
+ {
+ SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( i );
+ if( pMethod->IsHidden() )
+ continue;
+ DBG_ASSERT( pMethod, "Method not found! (NULL)" );
+ aSeqMethods.getArray()[ iTarget++ ] = pMethod->GetName();
+ }
+ }
+
+ return aSeqMethods;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL HasMethod( const ScriptDocument& rDocument, const String& rLibName, const String& rModName, const String& rMethName )
+{
+ BOOL bHasMethod = FALSE;
+
+ ::rtl::OUString aOUSource;
+ if ( rDocument.hasModule( rLibName, rModName ) && rDocument.getModule( rLibName, rModName, aOUSource ) )
+ {
+ SbModuleRef xModule = new SbModule( rModName );
+ xModule->SetSource32( aOUSource );
+ SbxArray* pMethods = xModule->GetMethods();
+ if ( pMethods )
+ {
+ SbMethod* pMethod = (SbMethod*)pMethods->Find( rMethName, SbxCLASS_METHOD );
+ if ( pMethod && !pMethod->IsHidden() )
+ bHasMethod = TRUE;
+ }
+ }
+
+ return bHasMethod;
+}
+} //namespace BasicIDE
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx
new file mode 100644
index 000000000000..35c4eafbebf1
--- /dev/null
+++ b/basctl/source/basicide/basobj3.cxx
@@ -0,0 +1,529 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include <ide_pch.hxx>
+
+#include <vector>
+#include <algorithm>
+#include <basic/sbx.hxx>
+#include <unotools/moduleoptions.hxx>
+
+#include <iderdll.hxx>
+#include <iderdll2.hxx>
+#include <basobj.hxx>
+#include <basidesh.hxx>
+#include <objdlg.hxx>
+#include <bastypes.hxx>
+#include <basdoc.hxx>
+#include <basidesh.hrc>
+
+#include <baside2.hxx>
+#include <baside3.hxx>
+#include <basicmod.hxx>
+#include <localizationmgr.hxx>
+#include "dlged.hxx"
+#include <dlgeddef.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/script/XLibraryContainerPassword.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <xmlscript/xmldlg_imexp.hxx>
+#include <rtl/uri.hxx>
+#include <osl/process.h>
+#include <osl/file.hxx>
+
+using namespace comphelper;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+
+
+//----------------------------------------------------------------------------
+
+extern "C" {
+ SAL_DLLPUBLIC_EXPORT long basicide_handle_basic_error( void* pPtr )
+ {
+ return BasicIDE::HandleBasicError( (StarBASIC*)pPtr );
+ }
+}
+
+namespace BasicIDE
+{
+//----------------------------------------------------------------------------
+
+SbMethod* CreateMacro( SbModule* pModule, const String& rMacroName )
+{
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
+ }
+
+ if ( pModule->GetMethods()->Find( rMacroName, SbxCLASS_METHOD ) )
+ return 0;
+
+ String aMacroName( rMacroName );
+ if ( aMacroName.Len() == 0 )
+ {
+ if ( !pModule->GetMethods()->Count() )
+ aMacroName = String( RTL_CONSTASCII_USTRINGPARAM( "Main" ) );
+ else
+ {
+ BOOL bValid = FALSE;
+ String aStdMacroText( RTL_CONSTASCII_USTRINGPARAM( "Macro" ) );
+ //String aStdMacroText( IDEResId( RID_STR_STDMACRONAME ) );
+ USHORT nMacro = 1;
+ while ( !bValid )
+ {
+ aMacroName = aStdMacroText;
+ aMacroName += String::CreateFromInt32( nMacro );
+ // Pruefen, ob vorhanden...
+ bValid = pModule->GetMethods()->Find( aMacroName, SbxCLASS_METHOD ) ? FALSE : TRUE;
+ nMacro++;
+ }
+ }
+ }
+
+ ::rtl::OUString aOUSource( pModule->GetSource32() );
+
+ // Nicht zu viele Leerzeilen erzeugen...
+ sal_Int32 nSourceLen = aOUSource.getLength();
+ if ( nSourceLen > 2 )
+ {
+ const sal_Unicode* pStr = aOUSource.getStr();
+ if ( pStr[ nSourceLen - 1 ] != LINE_SEP )
+ aOUSource += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\n\n" ) );
+ else if ( pStr[ nSourceLen - 2 ] != LINE_SEP )
+ aOUSource += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\n" ) );
+ else if ( pStr[ nSourceLen - 3 ] == LINE_SEP )
+ aOUSource = aOUSource.copy( 0, nSourceLen-1 );
+ }
+
+ ::rtl::OUString aSubStr;
+ aSubStr = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Sub " ) );
+ aSubStr += aMacroName;
+ aSubStr += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\n\nEnd Sub" ) );
+
+ aOUSource += aSubStr;
+
+ // update module in library
+ ScriptDocument aDocument( ScriptDocument::NoDocument );
+ SbxObject* pParent = pModule->GetParent();
+ StarBASIC* pBasic = PTR_CAST(StarBASIC,pParent);
+ DBG_ASSERT(pBasic, "BasicIDE::CreateMacro: No Basic found!");
+ if ( pBasic )
+ {
+ BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
+ DBG_ASSERT(pBasMgr, "BasicIDE::CreateMacro: No BasicManager found!");
+ if ( pBasMgr )
+ {
+ aDocument = ScriptDocument::getDocumentForBasicManager( pBasMgr );
+ OSL_ENSURE( aDocument.isValid(), "BasicIDE::CreateMacro: no document for the given BasicManager!" );
+ if ( aDocument.isValid() )
+ {
+ String aLibName = pBasic->GetName();
+ String aModName = pModule->GetName();
+ OSL_VERIFY( aDocument.updateModule( aLibName, aModName, aOUSource ) );
+ }
+ }
+ }
+
+ SbMethod* pMethod = (SbMethod*)pModule->GetMethods()->Find( aMacroName, SbxCLASS_METHOD );
+
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_UPDATEALLMODULESOURCES );
+ }
+
+ if ( aDocument.isAlive() )
+ BasicIDE::MarkDocumentModified( aDocument );
+
+ return pMethod;
+}
+
+//----------------------------------------------------------------------------
+
+bool RenameDialog( Window* pErrorParent, const ScriptDocument& rDocument, const String& rLibName, const String& rOldName, const String& rNewName )
+ throw(ElementExistException, NoSuchElementException)
+{
+ if ( !rDocument.hasDialog( rLibName, rOldName ) )
+ {
+ OSL_ENSURE( false, "BasicIDE::RenameDialog: old module name is invalid!" );
+ return false;
+ }
+
+ if ( rDocument.hasDialog( rLibName, rNewName ) )
+ {
+ ErrorBox aError( pErrorParent, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) );
+ aError.Execute();
+ return false;
+ }
+
+ // #i74440
+ if ( rNewName.Len() == 0 )
+ {
+ ErrorBox aError( pErrorParent, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_BADSBXNAME ) ) );
+ aError.Execute();
+ return false;
+ }
+
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ IDEBaseWindow* pWin = pIDEShell ? pIDEShell->FindWindow( rDocument, rLibName, rOldName, BASICIDE_TYPE_DIALOG, FALSE ) : NULL;
+ Reference< XNameContainer > xExistingDialog;
+ if ( pWin )
+ xExistingDialog = ((DialogWindow*)pWin)->GetEditor()->GetDialog();
+
+ if ( xExistingDialog.is() )
+ LocalizationMgr::renameStringResourceIDs( rDocument, rLibName, rNewName, xExistingDialog );
+
+ if ( !rDocument.renameDialog( rLibName, rOldName, rNewName, xExistingDialog ) )
+ return false;
+
+ if ( pWin )
+ {
+ // set new name in window
+ pWin->SetName( rNewName );
+
+ // update property browser
+ ((DialogWindow*)pWin)->UpdateBrowser();
+
+ // update tabwriter
+ USHORT nId = (USHORT)(pIDEShell->GetIDEWindowTable()).GetKey( pWin );
+ DBG_ASSERT( nId, "No entry in Tabbar!" );
+ if ( nId )
+ {
+ BasicIDETabBar* pTabBar = (BasicIDETabBar*)pIDEShell->GetTabBar();
+ pTabBar->SetPageText( nId, rNewName );
+ pTabBar->Sort();
+ pTabBar->MakeVisible( pTabBar->GetCurPageId() );
+ }
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+bool RemoveDialog( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName )
+{
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if ( pIDEShell )
+ {
+ DialogWindow* pDlgWin = pIDEShell->FindDlgWin( rDocument, rLibName, rDlgName, FALSE );
+ if( pDlgWin )
+ {
+ Reference< container::XNameContainer > xDialogModel = pDlgWin->GetDialog();
+ LocalizationMgr::removeResourceForDialog( rDocument, rLibName, rDlgName, xDialogModel );
+ }
+ }
+
+ return rDocument.removeDialog( rLibName, rDlgName );
+}
+
+//----------------------------------------------------------------------------
+
+StarBASIC* FindBasic( const SbxVariable* pVar )
+{
+ const SbxVariable* pSbx = pVar;
+ while ( pSbx && !pSbx->ISA( StarBASIC ) )
+ pSbx = pSbx->GetParent();
+
+ DBG_ASSERT( !pSbx || pSbx->ISA( StarBASIC ), "Find Basic: Kein Basic!" );
+ return (StarBASIC*)pSbx;
+}
+
+//----------------------------------------------------------------------------
+
+BasicManager* FindBasicManager( StarBASIC* pLib )
+{
+ ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::AllWithApplication ) );
+ for ( ScriptDocuments::const_iterator doc = aDocuments.begin();
+ doc != aDocuments.end();
+ ++doc
+ )
+ {
+ BasicManager* pBasicMgr = doc->getBasicManager();
+ OSL_ENSURE( pBasicMgr, "BasicIDE::FindBasicManager: no basic manager for the document!" );
+ if ( !pBasicMgr )
+ continue;
+
+ Sequence< ::rtl::OUString > aLibNames( doc->getLibraryNames() );
+ sal_Int32 nLibCount = aLibNames.getLength();
+ const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
+
+ for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+ {
+ StarBASIC* pL = pBasicMgr->GetLib( pLibNames[ i ] );
+ if ( pL == pLib )
+ return pBasicMgr;
+ }
+ }
+ return NULL;
+}
+
+//----------------------------------------------------------------------------
+
+void MarkDocumentModified( const ScriptDocument& rDocument )
+{
+ // Muss ja nicht aus einem Document kommen...
+ if ( rDocument.isApplication() )
+ {
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if ( pIDEShell )
+ pIDEShell->SetAppBasicModified();
+ }
+ else
+ {
+ rDocument.setDocumentModified();
+ }
+
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ {
+ pBindings->Invalidate( SID_SIGNATURE );
+ pBindings->Invalidate( SID_SAVEDOC );
+ pBindings->Update( SID_SAVEDOC );
+ }
+
+ // Objectcatalog updaten...
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ ObjectCatalog* pObjCatalog = pIDEShell ? pIDEShell->GetObjectCatalog() : 0;
+ if ( pObjCatalog )
+ pObjCatalog->UpdateEntries();
+}
+
+//----------------------------------------------------------------------------
+
+void RunMethod( SbMethod* pMethod )
+{
+ SbxValues aRes;
+ aRes.eType = SbxVOID;
+ pMethod->Get( aRes );
+}
+
+//----------------------------------------------------------------------------
+
+void StopBasic()
+{
+ StarBASIC::Stop();
+ BasicIDEShell* pShell = IDE_DLL()->GetShell();
+ if ( pShell )
+ {
+ IDEWindowTable& rWindows = pShell->GetIDEWindowTable();
+ IDEBaseWindow* pWin = rWindows.First();
+ while ( pWin )
+ {
+ // BasicStopped von Hand rufen, da das Stop-Notify ggf. sonst nicht
+ // durchkommen kann.
+ pWin->BasicStopped();
+ pWin = rWindows.Next();
+ }
+ }
+ BasicIDE::BasicStopped();
+}
+
+//----------------------------------------------------------------------------
+
+void BasicStopped( BOOL* pbAppWindowDisabled,
+ BOOL* pbDispatcherLocked, USHORT* pnWaitCount,
+ SfxUInt16Item** ppSWActionCount, SfxUInt16Item** ppSWLockViewCount )
+{
+ // Nach einem Error oder dem expliziten abbrechen des Basics muessen
+ // ggf. einige Locks entfernt werden...
+
+ if ( pbAppWindowDisabled )
+ *pbAppWindowDisabled = FALSE;
+ if ( pbDispatcherLocked )
+ *pbDispatcherLocked = FALSE;
+ if ( pnWaitCount )
+ *pnWaitCount = 0;
+ if ( ppSWActionCount )
+ *ppSWActionCount = 0;
+ if ( ppSWLockViewCount )
+ *ppSWLockViewCount = 0;
+
+ // AppWait ?
+ USHORT nWait = 0;
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if( pIDEShell )
+ {
+ while ( pIDEShell->GetViewFrame()->GetWindow().IsWait() )
+ {
+ pIDEShell->GetViewFrame()->GetWindow().LeaveWait();
+ nWait++;
+ }
+ if ( pnWaitCount )
+ *pnWaitCount = nWait;
+ }
+
+ /*
+ // Interactive = FALSE ?
+ if ( SFX_APP()->IsDispatcherLocked() )
+ {
+ SFX_APP()->LockDispatcher( FALSE );
+ if ( pbDispatcherLocked )
+ *pbDispatcherLocked = TRUE;
+ } */
+
+ Window* pDefParent = Application::GetDefDialogParent();
+ if ( pDefParent && !pDefParent->IsEnabled() )
+ {
+ pDefParent->Enable( TRUE );
+ if ( pbAppWindowDisabled )
+ *pbAppWindowDisabled = TRUE;
+ }
+
+}
+
+//----------------------------------------------------------------------------
+
+void InvalidateDebuggerSlots()
+{
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ {
+ pBindings->Invalidate( SID_BASICSTOP );
+ pBindings->Update( SID_BASICSTOP );
+ pBindings->Invalidate( SID_BASICRUN );
+ pBindings->Update( SID_BASICRUN );
+ pBindings->Invalidate( SID_BASICCOMPILE );
+ pBindings->Update( SID_BASICCOMPILE );
+ pBindings->Invalidate( SID_BASICSTEPOVER );
+ pBindings->Update( SID_BASICSTEPOVER );
+ pBindings->Invalidate( SID_BASICSTEPINTO );
+ pBindings->Update( SID_BASICSTEPINTO );
+ pBindings->Invalidate( SID_BASICSTEPOUT );
+ pBindings->Update( SID_BASICSTEPOUT );
+ pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
+ pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT );
+ pBindings->Invalidate( SID_BASICIDE_STAT_POS );
+ pBindings->Update( SID_BASICIDE_STAT_POS );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+long HandleBasicError( StarBASIC* pBasic )
+{
+ BasicIDEDLL::Init();
+ BasicIDE::BasicStopped();
+
+ // no error output during macro choosing
+ if ( IDE_DLL()->GetExtraData()->ChoosingMacro() )
+ return 1;
+ if ( IDE_DLL()->GetExtraData()->ShellInCriticalSection() )
+ return 2;
+
+ long nRet = 0;
+ BasicIDEShell* pIDEShell = 0;
+ if ( SvtModuleOptions().IsBasicIDE() )
+ {
+ BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
+ if ( pBasMgr )
+ {
+ BOOL bProtected = FALSE;
+ ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
+ OSL_ENSURE( aDocument.isValid(), "BasicIDE::HandleBasicError: no document for the given BasicManager!" );
+ if ( aDocument.isValid() )
+ {
+ ::rtl::OUString aOULibName( pBasic->GetName() );
+ Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
+ {
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
+ {
+ bProtected = TRUE;
+ }
+ }
+ }
+
+ if ( !bProtected )
+ {
+ pIDEShell = IDE_DLL()->GetShell();
+ if ( !pIDEShell )
+ {
+ SfxAllItemSet aArgs( SFX_APP()->GetPool() );
+ SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs );
+ SFX_APP()->ExecuteSlot( aRequest );
+ pIDEShell = IDE_DLL()->GetShell();
+ }
+ }
+ }
+ }
+
+ if ( pIDEShell )
+ nRet = pIDEShell->CallBasicErrorHdl( pBasic );
+ else
+ ErrorHandler::HandleError( StarBASIC::GetErrorCode() );
+
+ return nRet;
+}
+
+//----------------------------------------------------------------------------
+
+SfxBindings* GetBindingsPtr()
+{
+ SfxBindings* pBindings = NULL;
+
+ SfxViewFrame* pFrame = NULL;
+ BasicIDEDLL* pIDEDLL = IDE_DLL();
+ if ( pIDEDLL && pIDEDLL->GetShell() )
+ {
+ pFrame = pIDEDLL->GetShell()->GetViewFrame();
+ }
+ else
+ {
+ SfxViewFrame* pView = SfxViewFrame::GetFirst();
+ while ( pView )
+ {
+ SfxObjectShell* pObjShell = pView->GetObjectShell();
+ if ( pObjShell && pObjShell->ISA( BasicDocShell ) )
+ {
+ pFrame = pView;
+ break;
+ }
+ pView = SfxViewFrame::GetNext( *pView );
+ }
+ }
+ if ( pFrame != NULL )
+ pBindings = &pFrame->GetBindings();
+
+ return pBindings;
+}
+
+} //namespace BasicIDE
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
new file mode 100644
index 000000000000..4fb2679cbc9f
--- /dev/null
+++ b/basctl/source/basicide/bastype2.cxx
@@ -0,0 +1,903 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include <memory>
+
+#include "vcl/bitmap.hxx"
+
+#include <ide_pch.hxx>
+
+
+#include <basidesh.hrc>
+#include <bastypes.hxx>
+#include <bastype2.hxx>
+#include <basobj.hxx>
+#include <baside2.hrc>
+#include <iderid.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
+#include <basic/sbx.hxx>
+#include <svtools/imagemgr.hxx>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/script/XLibraryContainerPassword.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <map>
+#include <com/sun/star/script/ModuleType.hpp>
+#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+
+void ModuleInfoHelper::getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName )
+{
+ try
+ {
+ uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY );
+ if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) )
+ {
+ script::ModuleInfo aModuleInfo = xVBAModuleInfo->getModuleInfo( rModName );
+ uno::Any aObject( aModuleInfo.ModuleObject );
+ uno::Reference< lang::XServiceInfo > xServiceInfo( aObject, uno::UNO_QUERY );
+ if( xServiceInfo.is() && xServiceInfo->supportsService( rtl::OUString::createFromAscii( "ooo.vba.excel.Worksheet" ) ) )
+ {
+ uno::Reference< container::XNamed > xNamed( aObject, uno::UNO_QUERY );
+ if( xNamed.is() )
+ rObjName = xNamed->getName();
+ }
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+sal_Int32 ModuleInfoHelper::getModuleType( const uno::Reference< container::XNameContainer >& rLib, const String& rModName )
+{
+ sal_Int32 nType = script::ModuleType::NORMAL;
+ uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY );
+ if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) )
+ {
+ script::ModuleInfo aModuleInfo = xVBAModuleInfo->getModuleInfo( rModName );
+ nType = aModuleInfo.ModuleType;
+ }
+ return nType;
+}
+
+BasicEntry::~BasicEntry()
+{
+}
+
+BasicDocumentEntry::BasicDocumentEntry( const ScriptDocument& rDocument, LibraryLocation eLocation, BasicEntryType eType )
+ :BasicEntry( eType )
+ ,m_aDocument( rDocument )
+ ,m_eLocation( eLocation )
+{
+ OSL_ENSURE( m_aDocument.isValid(), "BasicDocumentEntry::BasicDocumentEntry: illegal document!" );
+}
+
+BasicDocumentEntry::~BasicDocumentEntry()
+{
+}
+
+BasicLibEntry::BasicLibEntry( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, BasicEntryType eType )
+ :BasicDocumentEntry( rDocument, eLocation, eType )
+ ,m_aLibName( rLibName )
+{
+}
+
+BasicLibEntry::~BasicLibEntry()
+{
+}
+
+BasicEntryDescriptor::BasicEntryDescriptor()
+ :m_aDocument( ScriptDocument::getApplicationScriptDocument() )
+ ,m_eLocation( LIBRARY_LOCATION_UNKNOWN )
+ ,m_eType( OBJ_TYPE_UNKNOWN )
+{
+}
+
+BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, BasicEntryType eType )
+ :m_aDocument( rDocument )
+ ,m_eLocation( eLocation )
+ ,m_aLibName( rLibName )
+ ,m_aLibSubName( rLibSubName )
+ ,m_aName( rName )
+ ,m_eType( eType )
+{
+ OSL_ENSURE( m_aDocument.isValid(), "BasicEntryDescriptor::BasicEntryDescriptor: invalid document!" );
+}
+
+BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, const String& rMethodName, BasicEntryType eType )
+ :m_aDocument( rDocument )
+ ,m_eLocation( eLocation )
+ ,m_aLibName( rLibName )
+ ,m_aLibSubName( rLibSubName )
+ ,m_aName( rName )
+ ,m_aMethodName( rMethodName )
+ ,m_eType( eType )
+{
+ OSL_ENSURE( m_aDocument.isValid(), "BasicEntryDescriptor::BasicEntryDescriptor: invalid document!" );
+}
+
+BasicEntryDescriptor::~BasicEntryDescriptor()
+{
+}
+
+BasicEntryDescriptor::BasicEntryDescriptor( const BasicEntryDescriptor& rDesc )
+ :m_aDocument( rDesc.m_aDocument )
+ ,m_eLocation( rDesc.m_eLocation )
+ ,m_aLibName( rDesc.m_aLibName )
+ ,m_aLibSubName( rDesc.m_aLibSubName )
+ ,m_aName( rDesc.m_aName )
+ ,m_aMethodName( rDesc.m_aMethodName )
+ ,m_eType( rDesc.m_eType )
+{
+}
+
+BasicEntryDescriptor& BasicEntryDescriptor::operator=( const BasicEntryDescriptor& rDesc )
+{
+ m_aDocument = rDesc.m_aDocument;
+ m_eLocation = rDesc.m_eLocation;
+ m_aLibName = rDesc.m_aLibName;
+ m_aLibSubName = rDesc.m_aLibSubName;
+ m_aName = rDesc.m_aName;
+ m_aMethodName = rDesc.m_aMethodName;
+ m_eType = rDesc.m_eType;
+
+ return *this;
+}
+
+bool BasicEntryDescriptor::operator==( const BasicEntryDescriptor& rDesc ) const
+{
+ return m_aDocument == rDesc.m_aDocument &&
+ m_eLocation == rDesc.m_eLocation &&
+ m_aLibName == rDesc.m_aLibName &&
+ m_aLibSubName == rDesc.m_aLibSubName &&
+ m_aName == rDesc.m_aName &&
+ m_aMethodName == rDesc.m_aMethodName &&
+ m_eType == rDesc.m_eType;
+}
+
+BasicTreeListBox::BasicTreeListBox( Window* pParent, const ResId& rRes ) :
+ SvTreeListBox( pParent, IDEResId( sal::static_int_cast<USHORT>( rRes.GetId() ) ) ),
+ m_aNotifier( *this )
+{
+ SetNodeDefaultImages();
+ SetSelectionMode( SINGLE_SELECTION );
+ nMode = 0xFF; // Alles
+}
+
+
+
+BasicTreeListBox::~BasicTreeListBox()
+{
+ m_aNotifier.dispose();
+
+ // UserDaten zerstoeren
+ SvLBoxEntry* pEntry = First();
+ while ( pEntry )
+ {
+ delete (BasicEntry*)pEntry->GetUserData();
+ pEntry = Next( pEntry );
+ }
+}
+
+void BasicTreeListBox::ScanEntry( const ScriptDocument& rDocument, LibraryLocation eLocation )
+{
+ OSL_ENSURE( rDocument.isAlive(), "BasicTreeListBox::ScanEntry: illegal document!" );
+ if ( !rDocument.isAlive() )
+ return;
+
+ // can be called multiple times for updating!
+
+ // eigentlich prueffen, ob Basic bereits im Baum ?!
+ SetUpdateMode( FALSE );
+
+ // level 1: BasicManager (application, document, ...)
+ SvLBoxEntry* pDocumentRootEntry = FindRootEntry( rDocument, eLocation );
+ if ( pDocumentRootEntry && IsExpanded( pDocumentRootEntry ) )
+ ImpCreateLibEntries( pDocumentRootEntry, rDocument, eLocation );
+ if ( !pDocumentRootEntry )
+ {
+ String aRootName( GetRootEntryName( rDocument, eLocation ) );
+ Image aImage;
+ Image aImageHC;
+ GetRootEntryBitmaps( rDocument, aImage, aImageHC );
+ pDocumentRootEntry = AddEntry(
+ aRootName,
+ aImage,
+ aImageHC,
+ 0, true,
+ std::auto_ptr< BasicEntry >( new BasicDocumentEntry( rDocument, eLocation ) ) );
+ }
+
+ SetUpdateMode( TRUE );
+}
+
+void BasicTreeListBox::ImpCreateLibEntries( SvLBoxEntry* pDocumentRootEntry, const ScriptDocument& rDocument, LibraryLocation eLocation )
+{
+ // get a sorted list of library names
+ Sequence< ::rtl::OUString > aLibNames( rDocument.getLibraryNames() );
+ sal_Int32 nLibCount = aLibNames.getLength();
+ const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
+
+ for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+ {
+ String aLibName = pLibNames[ i ];
+
+ if ( eLocation == rDocument.getLibraryLocation( aLibName ) )
+ {
+ // check, if the module library is loaded
+ BOOL bModLibLoaded = FALSE;
+ ::rtl::OUString aOULibName( aLibName );
+ Reference< script::XLibraryContainer > xModLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryLoaded( aOULibName ) )
+ bModLibLoaded = TRUE;
+
+ // check, if the dialog library is loaded
+ BOOL bDlgLibLoaded = FALSE;
+ Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_DIALOGS ) );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryLoaded( aOULibName ) )
+ bDlgLibLoaded = TRUE;
+
+ BOOL bLoaded = bModLibLoaded || bDlgLibLoaded;
+
+ // if only one of the libraries is loaded, load also the other
+ if ( bLoaded )
+ {
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
+ xModLibContainer->loadLibrary( aOULibName );
+
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
+ xDlgLibContainer->loadLibrary( aOULibName );
+ }
+
+ // create tree list box entry
+ USHORT nId, nIdHC;
+ if ( ( nMode & BROWSEMODE_DIALOGS ) && !( nMode & BROWSEMODE_MODULES ) )
+ {
+ nId = bLoaded ? RID_IMG_DLGLIB : RID_IMG_DLGLIBNOTLOADED;
+ nIdHC = bLoaded ? RID_IMG_DLGLIB_HC : RID_IMG_DLGLIBNOTLOADED_HC;
+ }
+ else
+ {
+ nId = bLoaded ? RID_IMG_MODLIB : RID_IMG_MODLIBNOTLOADED;
+ nIdHC = bLoaded ? RID_IMG_MODLIB_HC : RID_IMG_MODLIBNOTLOADED_HC;
+ }
+ SvLBoxEntry* pLibRootEntry = FindEntry( pDocumentRootEntry, aLibName, OBJ_TYPE_LIBRARY );
+ if ( pLibRootEntry )
+ {
+ SetEntryBitmaps( pLibRootEntry, Image( IDEResId( nId ) ), Image( IDEResId( nIdHC ) ) );
+ if ( IsExpanded( pLibRootEntry ) )
+ ImpCreateLibSubEntries( pLibRootEntry, rDocument, aLibName );
+ }
+ else
+ {
+ pLibRootEntry = AddEntry(
+ aLibName,
+ Image( IDEResId( nId ) ),
+ Image( IDEResId( nIdHC ) ),
+ pDocumentRootEntry, true,
+ std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_LIBRARY ) ) );
+ }
+ }
+ }
+}
+
+void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName )
+{
+ ::rtl::OUString aOULibName( rLibName );
+
+ // modules
+ if ( nMode & BROWSEMODE_MODULES )
+ {
+ Reference< script::XLibraryContainer > xModLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) );
+
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ try
+ {
+ if( rDocument.isInVBAMode() )
+ ImpCreateLibSubEntriesInVBAMode( pLibRootEntry, rDocument, rLibName );
+ else
+ {
+ // get a sorted list of module names
+ Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
+ sal_Int32 nModCount = aModNames.getLength();
+ const ::rtl::OUString* pModNames = aModNames.getConstArray();
+
+ for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
+ {
+ String aModName = pModNames[ i ];
+ SvLBoxEntry* pModuleEntry = FindEntry( pLibRootEntry, aModName, OBJ_TYPE_MODULE );
+ if ( !pModuleEntry )
+ pModuleEntry = AddEntry(
+ aModName,
+ Image( IDEResId( RID_IMG_MODULE ) ),
+ Image( IDEResId( RID_IMG_MODULE_HC ) ),
+ pLibRootEntry, false,
+ std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
+
+ // methods
+ if ( nMode & BROWSEMODE_SUBS )
+ {
+ Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( rDocument, rLibName, aModName );
+ sal_Int32 nCount = aNames.getLength();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+
+ for ( sal_Int32 j = 0 ; j < nCount ; j++ )
+ {
+ String aName = pNames[ j ];
+ SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD );
+ if ( !pEntry )
+ pEntry = AddEntry(
+ aName,
+ Image( IDEResId( RID_IMG_MACRO ) ),
+ Image( IDEResId( RID_IMG_MACRO_HC ) ),
+ pModuleEntry, false,
+ std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_METHOD ) ) );
+ }
+ }
+ }
+ }
+ }
+ catch ( const container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ // dialogs
+ if ( nMode & BROWSEMODE_DIALOGS )
+ {
+ Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) );
+
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ try
+ {
+ // get a sorted list of dialog names
+ Sequence< ::rtl::OUString > aDlgNames( rDocument.getObjectNames( E_DIALOGS, rLibName ) );
+ sal_Int32 nDlgCount = aDlgNames.getLength();
+ const ::rtl::OUString* pDlgNames = aDlgNames.getConstArray();
+
+ for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
+ {
+ String aDlgName = pDlgNames[ i ];
+ SvLBoxEntry* pDialogEntry = FindEntry( pLibRootEntry, aDlgName, OBJ_TYPE_DIALOG );
+ if ( !pDialogEntry )
+ pDialogEntry = AddEntry(
+ aDlgName,
+ Image( IDEResId( RID_IMG_DIALOG ) ),
+ Image( IDEResId( RID_IMG_DIALOG_HC ) ),
+ pLibRootEntry, false,
+ std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_DIALOG ) ) );
+ }
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+}
+
+void BasicTreeListBox::ImpCreateLibSubEntriesInVBAMode( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName )
+{
+
+ ::std::vector< std::pair< BasicEntryType, ::rtl::OUString > > aEntries;
+ aEntries.push_back( ::std::make_pair( OBJ_TYPE_DOCUMENT_OBJECTS, String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) );
+ aEntries.push_back( ::std::make_pair( OBJ_TYPE_USERFORMS, String( IDEResId( RID_STR_USERFORMS ) ) ) );
+ aEntries.push_back( ::std::make_pair( OBJ_TYPE_NORMAL_MODULES, String( IDEResId( RID_STR_NORMAL_MODULES ) ) ) );
+ aEntries.push_back( ::std::make_pair( OBJ_TYPE_CLASS_MODULES, String( IDEResId( RID_STR_CLASS_MODULES ) ) ) );
+
+ ::std::vector< std::pair< BasicEntryType, ::rtl::OUString > >::iterator iter;
+ for( iter = aEntries.begin(); iter != aEntries.end(); ++iter )
+ {
+ BasicEntryType eType = iter->first;
+ ::rtl::OUString aEntryName = iter->second;
+ SvLBoxEntry* pLibSubRootEntry = FindEntry( pLibRootEntry, aEntryName, eType );
+ if( pLibSubRootEntry )
+ {
+ SetEntryBitmaps( pLibSubRootEntry, Image( IDEResId( RID_IMG_MODLIB ) ), Image( IDEResId( RID_IMG_MODLIB_HC ) ) );
+ if ( IsExpanded( pLibSubRootEntry ) )
+ ImpCreateLibSubSubEntriesInVBAMode( pLibSubRootEntry, rDocument, rLibName );
+ }
+ else
+ {
+ pLibSubRootEntry = AddEntry(
+ aEntryName,
+ Image( IDEResId( RID_IMG_MODLIB ) ),
+ Image( IDEResId( RID_IMG_MODLIB_HC ) ),
+ pLibRootEntry, true,
+ std::auto_ptr< BasicEntry >( new BasicEntry( eType ) ) );
+ }
+ }
+}
+
+void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubRootEntry, const ScriptDocument& rDocument, const String& rLibName )
+{
+ uno::Reference< container::XNameContainer > xLib = rDocument.getOrCreateLibrary( E_SCRIPTS, rLibName );
+ if( !xLib.is() )
+ return;
+
+ try
+ {
+ // get a sorted list of module names
+ Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
+ sal_Int32 nModCount = aModNames.getLength();
+ const ::rtl::OUString* pModNames = aModNames.getConstArray();
+
+ BasicEntryDescriptor aDesc( GetEntryDescriptor( pLibSubRootEntry ) );
+ BasicEntryType eCurrentType( aDesc.GetType() );
+
+ for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
+ {
+ String aModName = pModNames[ i ];
+ BasicEntryType eType = OBJ_TYPE_UNKNOWN;
+ switch( ModuleInfoHelper::getModuleType( xLib, aModName ) )
+ {
+ case script::ModuleType::DOCUMENT:
+ eType = OBJ_TYPE_DOCUMENT_OBJECTS;
+ break;
+ case script::ModuleType::FORM:
+ eType = OBJ_TYPE_USERFORMS;
+ break;
+ case script::ModuleType::NORMAL:
+ eType = OBJ_TYPE_NORMAL_MODULES;
+ break;
+ case script::ModuleType::CLASS:
+ eType = OBJ_TYPE_CLASS_MODULES;
+ break;
+ }
+ if( eType != eCurrentType )
+ continue;
+
+ // display a nice friendly name in the ObjectModule tab,
+ // combining the objectname and module name, e.g. Sheet1 ( Financials )
+ String aEntryName( aModName );
+ if( eType == OBJ_TYPE_DOCUMENT_OBJECTS )
+ {
+ String sObjName;
+ ModuleInfoHelper::getObjectName( xLib, aModName, sObjName );
+ if( sObjName.Len() )
+ {
+ aEntryName.AppendAscii(" (").Append(sObjName).AppendAscii(")");
+ }
+ }
+ SvLBoxEntry* pModuleEntry = FindEntry( pLibSubRootEntry, aEntryName, OBJ_TYPE_MODULE );
+ if ( !pModuleEntry )
+ pModuleEntry = AddEntry(
+ aEntryName,
+ Image( IDEResId( RID_IMG_MODULE ) ),
+ Image( IDEResId( RID_IMG_MODULE_HC ) ),
+ pLibSubRootEntry, false,
+ std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
+
+ // methods
+ if ( nMode & BROWSEMODE_SUBS )
+ {
+ Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( rDocument, rLibName, aModName );
+ sal_Int32 nCount = aNames.getLength();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+
+ for ( sal_Int32 j = 0 ; j < nCount ; j++ )
+ {
+ String aName = pNames[ j ];
+ SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD );
+ if ( !pEntry )
+ pEntry = AddEntry(
+ aName,
+ Image( IDEResId( RID_IMG_MACRO ) ),
+ Image( IDEResId( RID_IMG_MACRO_HC ) ),
+ pModuleEntry, false,
+ std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_METHOD ) ) );
+ }
+ }
+ }
+ }
+ catch ( const container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+SvLBoxEntry* BasicTreeListBox::ImpFindEntry( SvLBoxEntry* pParent, const String& rText )
+{
+ ULONG nRootPos = 0;
+ SvLBoxEntry* pEntry = pParent ? FirstChild( pParent ) : GetEntry( nRootPos );
+ while ( pEntry )
+ {
+ if ( GetEntryText( pEntry ) == rText )
+ return pEntry;
+
+ pEntry = pParent ? NextSibling( pEntry ) : GetEntry( ++nRootPos );
+ }
+ return 0;
+}
+
+void BasicTreeListBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
+{
+ UpdateEntries();
+}
+
+void BasicTreeListBox::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
+{
+ UpdateEntries();
+}
+
+void BasicTreeListBox::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void BasicTreeListBox::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void BasicTreeListBox::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void BasicTreeListBox::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ )
+{
+ UpdateEntries();
+}
+
+void BasicTreeListBox::onDocumentClosed( const ScriptDocument& /*_rDocument*/ )
+{
+ UpdateEntries();
+}
+
+void BasicTreeListBox::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void BasicTreeListBox::onDocumentModeChanged( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void BasicTreeListBox::UpdateEntries()
+{
+ BasicEntryDescriptor aCurDesc( GetEntryDescriptor( FirstSelected() ) );
+
+ // Erstmal die vorhandenen Eintraege auf existens pruefen:
+ SvLBoxEntry* pLastValid = 0;
+ SvLBoxEntry* pEntry = First();
+ while ( pEntry )
+ {
+ if ( IsValidEntry( pEntry ) )
+ pLastValid = pEntry;
+ else
+ {
+ delete (BasicEntry*)pEntry->GetUserData();
+ GetModel()->Remove( pEntry );
+ }
+ pEntry = pLastValid ? Next( pLastValid ) : First();
+ }
+
+ // Jetzt ueber die Basics rennen und in die Zweige eintragen
+ ScanAllEntries();
+
+ SetCurrentEntry( aCurDesc );
+}
+
+SvLBoxEntry* __EXPORT BasicTreeListBox::CloneEntry( SvLBoxEntry* pSource )
+{
+ SvLBoxEntry* pNew = SvTreeListBox::CloneEntry( pSource );
+ BasicEntry* pUser = (BasicEntry*)pSource->GetUserData();
+
+ DBG_ASSERT( pUser, "User-Daten?!" );
+ DBG_ASSERT( pUser->GetType() != OBJ_TYPE_DOCUMENT, "BasicTreeListBox::CloneEntry: document?!" );
+
+ BasicEntry* pNewUser = new BasicEntry( *pUser );
+ pNew->SetUserData( pNewUser );
+ return pNew;
+}
+
+SvLBoxEntry* BasicTreeListBox::FindEntry( SvLBoxEntry* pParent, const String& rText, BasicEntryType eType )
+{
+ ULONG nRootPos = 0;
+ SvLBoxEntry* pEntry = pParent ? FirstChild( pParent ) : GetEntry( nRootPos );
+ while ( pEntry )
+ {
+ BasicEntry* pBasicEntry = (BasicEntry*)pEntry->GetUserData();
+ DBG_ASSERT( pBasicEntry, "FindEntry: Kein BasicEntry ?!" );
+ if ( ( pBasicEntry->GetType() == eType ) && ( GetEntryText( pEntry ) == rText ) )
+ return pEntry;
+
+ pEntry = pParent ? NextSibling( pEntry ) : GetEntry( ++nRootPos );
+ }
+ return 0;
+}
+
+long BasicTreeListBox::ExpandingHdl()
+{
+ // Expanding oder Collaps?
+ BOOL bOK = TRUE;
+ if ( GetModel()->GetDepth( GetHdlEntry() ) == 1 )
+ {
+ SvLBoxEntry* pCurEntry = GetCurEntry();
+ BasicEntryDescriptor aDesc( GetEntryDescriptor( pCurEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ OSL_ENSURE( aDocument.isAlive(), "BasicTreeListBox::ExpandingHdl: no document, or document is dead!" );
+ if ( aDocument.isAlive() )
+ {
+ String aLibName( aDesc.GetLibName() );
+ String aLibSubName( aDesc.GetLibSubName() );
+ String aName( aDesc.GetName() );
+ String aMethodName( aDesc.GetMethodName() );
+
+ if ( aLibName.Len() && !aLibSubName.Len() && !aName.Len() && !aMethodName.Len() )
+ {
+ // check password, if library is password protected and not verified
+ ::rtl::OUString aOULibName( aLibName );
+ Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
+ {
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
+ {
+ String aPassword;
+ bOK = QueryPassword( xModLibContainer, aLibName, aPassword );
+ }
+ }
+ }
+ }
+ }
+ return bOK;
+}
+
+BOOL BasicTreeListBox::IsEntryProtected( SvLBoxEntry* pEntry )
+{
+ BOOL bProtected = FALSE;
+ if ( pEntry && ( GetModel()->GetDepth( pEntry ) == 1 ) )
+ {
+ BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ OSL_ENSURE( aDocument.isAlive(), "BasicTreeListBox::IsEntryProtected: no document, or document is dead!" );
+ if ( aDocument.isAlive() )
+ {
+ ::rtl::OUString aOULibName( aDesc.GetLibName() );
+ Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
+ {
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
+ {
+ bProtected = TRUE;
+ }
+ }
+ }
+ }
+ return bProtected;
+}
+
+SvLBoxEntry* BasicTreeListBox::AddEntry(
+ const String& rText, const Image& rImage, const Image& rImageHC,
+ SvLBoxEntry* pParent, bool bChildrenOnDemand, std::auto_ptr< BasicEntry > aUserData )
+{
+ SvLBoxEntry* p = InsertEntry(
+ rText, rImage, rImage, pParent, bChildrenOnDemand, LIST_APPEND,
+ aUserData.release() ); // XXX possible leak
+ SetExpandedEntryBmp( p, rImageHC, BMP_COLOR_HIGHCONTRAST );
+ SetCollapsedEntryBmp( p, rImageHC, BMP_COLOR_HIGHCONTRAST );
+ return p;
+}
+
+void BasicTreeListBox::SetEntryBitmaps( SvLBoxEntry * pEntry, const Image& rImage, const Image& rImageHC )
+{
+ SetExpandedEntryBmp( pEntry, rImage, BMP_COLOR_NORMAL );
+ SetCollapsedEntryBmp( pEntry, rImage, BMP_COLOR_NORMAL );
+ SetExpandedEntryBmp( pEntry, rImageHC, BMP_COLOR_HIGHCONTRAST );
+ SetCollapsedEntryBmp( pEntry, rImageHC, BMP_COLOR_HIGHCONTRAST );
+}
+
+LibraryType BasicTreeListBox::GetLibraryType() const
+{
+ LibraryType eType = LIBRARY_TYPE_ALL;
+ if ( ( nMode & BROWSEMODE_MODULES ) && !( nMode & BROWSEMODE_DIALOGS ) )
+ eType = LIBRARY_TYPE_MODULE;
+ else if ( !( nMode & BROWSEMODE_MODULES ) && ( nMode & BROWSEMODE_DIALOGS ) )
+ eType = LIBRARY_TYPE_DIALOG;
+ return eType;
+}
+
+String BasicTreeListBox::GetRootEntryName( const ScriptDocument& rDocument, LibraryLocation eLocation ) const
+{
+ return rDocument.getTitle( eLocation, GetLibraryType() );
+}
+
+void BasicTreeListBox::GetRootEntryBitmaps( const ScriptDocument& rDocument, Image& rImage, Image& rImageHC )
+{
+ OSL_ENSURE( rDocument.isValid(), "BasicTreeListBox::GetRootEntryBitmaps: illegal document!" );
+ if ( !rDocument.isValid() )
+ return;
+
+ if ( rDocument.isDocument() )
+ {
+ ::rtl::OUString sFactoryURL;
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ Reference< ::com::sun::star::frame::XModuleManager > xModuleManager;
+ if ( aContext.createComponent( "com.sun.star.frame.ModuleManager", xModuleManager ) )
+ {
+ try
+ {
+ ::rtl::OUString sModule( xModuleManager->identify( rDocument.getDocument() ) );
+ Reference< container::XNameAccess > xModuleConfig( xModuleManager, UNO_QUERY );
+ if ( xModuleConfig.is() )
+ {
+ Sequence< beans::PropertyValue > aModuleDescr;
+ xModuleConfig->getByName( sModule ) >>= aModuleDescr;
+ sal_Int32 nCount = aModuleDescr.getLength();
+ const beans::PropertyValue* pModuleDescr = aModuleDescr.getConstArray();
+ for ( sal_Int32 i = 0; i < nCount; ++i )
+ {
+ if ( pModuleDescr[ i ].Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "ooSetupFactoryEmptyDocumentURL" ) ) )
+ {
+ pModuleDescr[ i ].Value >>= sFactoryURL;
+ break;
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ if ( sFactoryURL.getLength() )
+ {
+ rImage = SvFileInformationManager::GetFileImage( INetURLObject( sFactoryURL ),
+ FALSE /* small */,
+ FALSE /* normal */ );
+
+ rImageHC = SvFileInformationManager::GetFileImage( INetURLObject( sFactoryURL ),
+ FALSE /* small */,
+ TRUE /* high contrast */ );
+ }
+ else
+ {
+ // default icon
+ rImage = Image( IDEResId( RID_IMG_DOCUMENT ) );
+ rImageHC = Image( IDEResId( RID_IMG_DOCUMENT_HC ) );
+ }
+ }
+ else
+ {
+ rImage = Image( IDEResId( RID_IMG_INSTALLATION ) );
+ rImageHC = Image( IDEResId( RID_IMG_INSTALLATION_HC ) );
+ }
+}
+
+void BasicTreeListBox::SetCurrentEntry( BasicEntryDescriptor& rDesc )
+{
+ SvLBoxEntry* pCurEntry = 0;
+ BasicEntryDescriptor aDesc( rDesc );
+ if ( aDesc.GetType() == OBJ_TYPE_UNKNOWN )
+ {
+ aDesc = BasicEntryDescriptor(
+ ScriptDocument::getApplicationScriptDocument(),
+ LIBRARY_LOCATION_USER, String::CreateFromAscii( "Standard" ),
+ String(), String::CreateFromAscii( "." ), OBJ_TYPE_UNKNOWN );
+ }
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ OSL_ENSURE( aDocument.isValid(), "BasicTreeListBox::SetCurrentEntry: invalid document!" );
+ LibraryLocation eLocation( aDesc.GetLocation() );
+ SvLBoxEntry* pRootEntry = FindRootEntry( aDocument, eLocation );
+ if ( pRootEntry )
+ {
+ pCurEntry = pRootEntry;
+ String aLibName( aDesc.GetLibName() );
+ if ( aLibName.Len() )
+ {
+ Expand( pRootEntry );
+ SvLBoxEntry* pLibEntry = FindEntry( pRootEntry, aLibName, OBJ_TYPE_LIBRARY );
+ if ( pLibEntry )
+ {
+ pCurEntry = pLibEntry;
+ String aLibSubName( aDesc.GetLibSubName() );
+ if( aLibSubName.Len() )
+ {
+ Expand( pLibEntry );
+ SvLBoxEntry* pLibSubEntry = ImpFindEntry( pLibEntry, aLibSubName );
+ if( pLibSubEntry )
+ {
+ pCurEntry = pLibSubEntry;
+ }
+ }
+ String aName( aDesc.GetName() );
+ if ( aName.Len() )
+ {
+ Expand( pCurEntry );
+ BasicEntryType eType = OBJ_TYPE_MODULE;
+ if ( aDesc.GetType() == OBJ_TYPE_DIALOG )
+ eType = OBJ_TYPE_DIALOG;
+ SvLBoxEntry* pEntry = FindEntry( pCurEntry, aName, eType );
+ if ( pEntry )
+ {
+ pCurEntry = pEntry;
+ String aMethodName( aDesc.GetMethodName() );
+ if ( aMethodName.Len() )
+ {
+ Expand( pEntry );
+ SvLBoxEntry* pSubEntry = FindEntry( pEntry, aMethodName, OBJ_TYPE_METHOD );
+ if ( pSubEntry )
+ {
+ pCurEntry = pSubEntry;
+ }
+ else
+ {
+ pSubEntry = FirstChild( pEntry );
+ if ( pSubEntry )
+ pCurEntry = pSubEntry;
+ }
+ }
+ }
+ else
+ {
+ pEntry = FirstChild( pLibEntry );
+ if ( pEntry )
+ pCurEntry = pEntry;
+ }
+ }
+ }
+ else
+ {
+ pLibEntry = FirstChild( pRootEntry );
+ if ( pLibEntry )
+ pCurEntry = pLibEntry;
+ }
+ }
+ }
+ else
+ {
+ pRootEntry = First();
+ if ( pRootEntry )
+ pCurEntry = pRootEntry;
+ }
+
+ SetCurEntry( pCurEntry );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/bastype2.hxx b/basctl/source/basicide/bastype2.hxx
new file mode 100644
index 000000000000..08fb03d1c689
--- /dev/null
+++ b/basctl/source/basicide/bastype2.hxx
@@ -0,0 +1,222 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BASTYPE2_HXX
+#define _BASTYPE2_HXX
+
+#include "doceventnotifier.hxx"
+
+#include <memory>
+#include "tools/solar.h"
+
+#define _SVICNVW_HXX
+#include <svtools/svtreebx.hxx>
+#include <svl/lstner.hxx>
+#include <basic/sbstar.hxx>
+#include <sbxitem.hxx>
+#include "basobj.hxx"
+
+enum BasicEntryType { OBJ_TYPE_UNKNOWN, OBJ_TYPE_DOCUMENT, OBJ_TYPE_LIBRARY, OBJ_TYPE_MODULE, OBJ_TYPE_DIALOG, OBJ_TYPE_METHOD, OBJ_TYPE_DOCUMENT_OBJECTS, OBJ_TYPE_USERFORMS, OBJ_TYPE_NORMAL_MODULES, OBJ_TYPE_CLASS_MODULES };
+
+#define BROWSEMODE_MODULES 0x01
+#define BROWSEMODE_SUBS 0x02
+#define BROWSEMODE_DIALOGS 0x04
+
+class SbMethod;
+class SbxObject;
+class SbModule;
+class SvLBoxEntry;
+class SbxVariable;
+class String;
+
+
+class BasicEntry
+{
+private:
+ BasicEntryType m_eType;
+
+public:
+ BasicEntry( BasicEntryType eType ) { m_eType = eType; }
+ BasicEntry( const BasicEntry& r ) { m_eType = r.m_eType; }
+ virtual ~BasicEntry();
+
+ BasicEntryType GetType() const { return m_eType; }
+};
+
+class BasicDocumentEntry : public BasicEntry
+{
+private:
+ ScriptDocument m_aDocument;
+ LibraryLocation m_eLocation;
+
+public:
+ BasicDocumentEntry( const ScriptDocument& rDocument, LibraryLocation eLocation, BasicEntryType eType = OBJ_TYPE_DOCUMENT );
+ virtual ~BasicDocumentEntry();
+
+ const ScriptDocument&
+ GetDocument() const { return m_aDocument; }
+ LibraryLocation GetLocation() const { return m_eLocation; }
+};
+
+class BasicLibEntry : public BasicDocumentEntry
+{
+private:
+ String m_aLibName;
+
+public:
+ BasicLibEntry( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, BasicEntryType eType = OBJ_TYPE_LIBRARY );
+ virtual ~BasicLibEntry();
+
+ const String& GetLibName() const { return m_aLibName; }
+};
+
+class BasicEntryDescriptor
+{
+ ScriptDocument m_aDocument;
+ LibraryLocation m_eLocation;
+ String m_aLibName;
+ String m_aLibSubName; // for vba entry: Document Objects, Class Modules, Forms and Normal Modules
+ String m_aName;
+ String m_aMethodName;
+ BasicEntryType m_eType;
+
+public:
+ BasicEntryDescriptor();
+ BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, BasicEntryType eType );
+ BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, const String& rMethodName, BasicEntryType eType );
+ virtual ~BasicEntryDescriptor();
+
+ BasicEntryDescriptor( const BasicEntryDescriptor& rDesc );
+ BasicEntryDescriptor& operator=( const BasicEntryDescriptor& rDesc );
+ bool operator==( const BasicEntryDescriptor& rDesc ) const;
+
+ const ScriptDocument&
+ GetDocument() const { return m_aDocument; }
+ void SetDocument( const ScriptDocument& rDocument ) { m_aDocument = rDocument; }
+
+ LibraryLocation GetLocation() const { return m_eLocation; }
+ void SetLocation( LibraryLocation eLocation ) { m_eLocation = eLocation; }
+
+ const String& GetLibName() const { return m_aLibName; }
+ void SetLibName( const String& aLibName ) { m_aLibName = aLibName; }
+
+ const String& GetLibSubName() const { return m_aLibSubName; }
+ void SetLibSubName( const String& aLibSubName ) { m_aLibSubName = aLibSubName; }
+
+ const String& GetName() const { return m_aName; }
+ void SetName( const String& aName ) { m_aName = aName; }
+
+ const String& GetMethodName() const { return m_aMethodName; }
+ void SetMethodName( const String& aMethodName ) { m_aMethodName = aMethodName; }
+
+ BasicEntryType GetType() const { return m_eType; }
+ void SetType( BasicEntryType eType ) { m_eType = eType; }
+};
+
+
+/****************************************
+ Zuordnung von Typen und Pointern in BasicEntrys:
+
+ OBJ_TYPE_DOCUMENT BasicDocumentEntry
+ OBJ_TYPE_LIBRARY BasicEntry
+ OBJ_TYPE_MODULE BasicEntry
+ OBJ_TYPE_DIALOG BasicEntry
+ OBJ_TYPE_METHOD BasicEntry
+
+******************************************/
+
+class BasicTreeListBox :public SvTreeListBox
+ ,public ::basctl::DocumentEventListener
+{
+private:
+ USHORT nMode;
+ ::basctl::DocumentEventNotifier m_aNotifier;
+
+ void SetEntryBitmaps( SvLBoxEntry * pEntry, const Image& rImage, const Image& rImageHC );
+
+protected:
+ virtual void RequestingChilds( SvLBoxEntry* pParent );
+ virtual void ExpandedHdl();
+ virtual SvLBoxEntry* CloneEntry( SvLBoxEntry* pSource );
+ virtual long ExpandingHdl();
+
+ void ImpCreateLibEntries( SvLBoxEntry* pShellRootEntry, const ScriptDocument& rDocument, LibraryLocation eLocation );
+ void ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName );
+ void ImpCreateLibSubEntriesInVBAMode( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName );
+ void ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubRootEntry, const ScriptDocument& rDocument, const String& rLibName );
+ SvLBoxEntry* ImpFindEntry( SvLBoxEntry* pParent, const String& rText );
+
+ // DocumentEventListener
+ virtual void onDocumentCreated( const ScriptDocument& _rDocument );
+ virtual void onDocumentOpened( const ScriptDocument& _rDocument );
+ virtual void onDocumentSave( const ScriptDocument& _rDocument );
+ virtual void onDocumentSaveDone( const ScriptDocument& _rDocument );
+ virtual void onDocumentSaveAs( const ScriptDocument& _rDocument );
+ virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument );
+ virtual void onDocumentClosed( const ScriptDocument& _rDocument );
+ virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument );
+ virtual void onDocumentModeChanged( const ScriptDocument& _rDocument );
+
+public:
+ BasicTreeListBox( Window* pParent, const ResId& rRes );
+ ~BasicTreeListBox();
+
+ void ScanEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
+ void ScanAllEntries();
+ void UpdateEntries();
+
+ BOOL IsEntryProtected( SvLBoxEntry* pEntry );
+
+ void SetMode( USHORT nM ) { nMode = nM; }
+ USHORT GetMode() const { return nMode; }
+
+ SbModule* FindModule( SvLBoxEntry* pEntry );
+ SbxVariable* FindVariable( SvLBoxEntry* pEntry );
+ SvLBoxEntry* FindRootEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
+ SvLBoxEntry* FindEntry( SvLBoxEntry* pParent, const String& rText, BasicEntryType eType );
+
+ BasicEntryDescriptor GetEntryDescriptor( SvLBoxEntry* pEntry );
+
+ USHORT ConvertType( BasicEntryType eType );
+ bool IsValidEntry( SvLBoxEntry* pEntry );
+
+ SvLBoxEntry* AddEntry( const String& rText, const Image& rImage, const Image& rImageHC,
+ SvLBoxEntry* pParent, bool bChildrenOnDemand,
+ std::auto_ptr< BasicEntry > aUserData );
+
+ String GetRootEntryName( const ScriptDocument& rDocument, LibraryLocation eLocation ) const;
+ void GetRootEntryBitmaps( const ScriptDocument& rDocument, Image& rImage, Image& rImageHC );
+
+ void SetCurrentEntry( BasicEntryDescriptor& rDesc );
+
+private:
+ LibraryType GetLibraryType() const;
+};
+
+#endif // _BASTYPE2_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/bastype3.cxx b/basctl/source/basicide/bastype3.cxx
new file mode 100644
index 000000000000..3f114b190587
--- /dev/null
+++ b/basctl/source/basicide/bastype3.cxx
@@ -0,0 +1,509 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include <ide_pch.hxx>
+
+#define _SI_NOSBXCONTROLS
+
+#include <basic/sbx.hxx>
+#include <bastype2.hxx>
+#include <basobj.hxx>
+#include <baside2.hrc>
+#include <iderid.hxx>
+#include <bastypes.hxx>
+#include <basdoc.hxx>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/script/XLibraryContainerPassword.hpp>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+
+
+SV_DECL_VARARR( EntryArray, SvLBoxEntry*, 4, 4 )
+
+SV_IMPL_VARARR( EntryArray, SvLBoxEntry*);
+
+
+void __EXPORT BasicTreeListBox::RequestingChilds( SvLBoxEntry* pEntry )
+{
+ BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ OSL_ENSURE( aDocument.isAlive(), "BasicTreeListBox::RequestingChilds: invalid document!" );
+ if ( !aDocument.isAlive() )
+ return;
+
+ LibraryLocation eLocation( aDesc.GetLocation() );
+ BasicEntryType eType( aDesc.GetType() );
+
+ if ( eType == OBJ_TYPE_DOCUMENT )
+ {
+ ImpCreateLibEntries( pEntry, aDocument, eLocation );
+ }
+ else if ( eType == OBJ_TYPE_LIBRARY )
+ {
+ String aLibName( aDesc.GetLibName() );
+ ::rtl::OUString aOULibName( aLibName );
+
+ // check password
+ BOOL bOK = TRUE;
+ Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
+ {
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
+ {
+ String aPassword;
+ bOK = QueryPassword( xModLibContainer, aLibName, aPassword );
+ }
+ }
+
+ if ( bOK )
+ {
+ // load module library
+ BOOL bModLibLoaded = FALSE;
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
+ {
+ if ( !xModLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ EnterWait();
+ xModLibContainer->loadLibrary( aOULibName );
+ LeaveWait();
+ }
+ bModLibLoaded = xModLibContainer->isLibraryLoaded( aOULibName );
+ }
+
+ // load dialog library
+ BOOL bDlgLibLoaded = FALSE;
+ Reference< script::XLibraryContainer > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) )
+ {
+ if ( !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ EnterWait();
+ xDlgLibContainer->loadLibrary( aOULibName );
+ LeaveWait();
+ }
+ bDlgLibLoaded = xDlgLibContainer->isLibraryLoaded( aOULibName );
+ }
+
+ if ( bModLibLoaded || bDlgLibLoaded )
+ {
+ // create the sub entries
+ ImpCreateLibSubEntries( pEntry, aDocument, aLibName );
+
+ // exchange image
+ bool bDlgMode = ( nMode & BROWSEMODE_DIALOGS ) && !( nMode & BROWSEMODE_MODULES );
+ Image aImage( IDEResId( bDlgMode ? RID_IMG_DLGLIB : RID_IMG_MODLIB ) );
+ Image aImageHC( IDEResId( bDlgMode ? RID_IMG_DLGLIB_HC : RID_IMG_MODLIB_HC ) );
+ SetEntryBitmaps( pEntry, aImage, aImageHC );
+ }
+ else
+ {
+ DBG_ERROR( "BasicTreeListBox::RequestingChilds: Error loading library!" );
+ }
+ }
+ }
+ else if ( eType == OBJ_TYPE_DOCUMENT_OBJECTS
+ || eType == OBJ_TYPE_USERFORMS
+ || eType == OBJ_TYPE_NORMAL_MODULES
+ || eType == OBJ_TYPE_CLASS_MODULES )
+ {
+ String aLibName( aDesc.GetLibName() );
+ ImpCreateLibSubSubEntriesInVBAMode( pEntry, aDocument, aLibName );
+ }
+ else {
+ DBG_ERROR( "BasicTreeListBox::RequestingChilds: Unknown Type!" );
+ }
+}
+
+void __EXPORT BasicTreeListBox::ExpandedHdl()
+{
+ SvLBoxEntry* pEntry = GetHdlEntry();
+ DBG_ASSERT( pEntry, "Was wurde zugeklappt?" );
+ // Die OnDemand erzeugten Childs loeschen,
+ // SubChilds werden automatisch geloescht.
+ if ( !IsExpanded( pEntry ) && pEntry->HasChildsOnDemand() )
+ {
+ SvLBoxEntry* pChild = FirstChild( pEntry );
+ while ( pChild )
+ {
+ GetModel()->Remove( pChild ); // Ruft auch den DTOR
+ pChild = FirstChild( pEntry );
+ }
+ }
+}
+
+void BasicTreeListBox::ScanAllEntries()
+{
+ ScanEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER );
+ ScanEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_SHARE );
+
+ ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::DocumentsSorted ) );
+ for ( ScriptDocuments::const_iterator doc = aDocuments.begin();
+ doc != aDocuments.end();
+ ++doc
+ )
+ {
+ if ( doc->isAlive() )
+ ScanEntry( *doc, LIBRARY_LOCATION_DOCUMENT );
+ }
+}
+
+SbxVariable* BasicTreeListBox::FindVariable( SvLBoxEntry* pEntry )
+{
+ if ( !pEntry )
+ return 0;
+
+ String aLib, aModOrObj, aSubOrPropOrSObj, aPropOrSubInSObj;
+ ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
+ EntryArray aEntries;
+
+ while ( pEntry )
+ {
+ USHORT nDepth = GetModel()->GetDepth( pEntry );
+ switch ( nDepth )
+ {
+ case 4:
+ case 3:
+ case 2:
+ case 1:
+ {
+ aEntries.C40_INSERT( SvLBoxEntry, pEntry, 0 );
+ }
+ break;
+ case 0:
+ {
+ aDocument = ((BasicDocumentEntry*)pEntry->GetUserData())->GetDocument();
+ }
+ break;
+ }
+ pEntry = GetParent( pEntry );
+ }
+
+ SbxVariable* pVar = 0;
+ bool bDocumentObjects = false;
+ if ( aEntries.Count() )
+ {
+ for ( USHORT n = 0; n < aEntries.Count(); n++ )
+ {
+ SvLBoxEntry* pLE = aEntries[n];
+ DBG_ASSERT( pLE, "Entrie im Array nicht gefunden" );
+ BasicEntry* pBE = (BasicEntry*)pLE->GetUserData();
+ DBG_ASSERT( pBE, "Keine Daten im Eintrag gefunden!" );
+ String aName( GetEntryText( pLE ) );
+
+ switch ( pBE->GetType() )
+ {
+ case OBJ_TYPE_LIBRARY:
+ {
+ BasicManager* pBasMgr = aDocument.getBasicManager();
+ if ( pBasMgr )
+ pVar = pBasMgr->GetLib( aName );
+ }
+ break;
+ case OBJ_TYPE_MODULE:
+ {
+ DBG_ASSERT( pVar && pVar->IsA( TYPE(StarBASIC) ), "FindVariable: Ungueltiges Basic" );
+ // extract the module name from the string like "Sheet1 (Example1)"
+ if( bDocumentObjects )
+ {
+ sal_uInt16 nIndex = 0;
+ aName = aName.GetToken( 0, ' ', nIndex );
+ }
+ pVar = ((StarBASIC*)pVar)->FindModule( aName );
+ }
+ break;
+ case OBJ_TYPE_METHOD:
+ {
+ DBG_ASSERT( pVar && ( (pVar->IsA( TYPE(SbModule) )) || (pVar->IsA( TYPE(SbxObject) )) ), "FindVariable: Ungueltiges Modul/Objekt" );
+ pVar = ((SbxObject*)pVar)->GetMethods()->Find( aName, SbxCLASS_METHOD );
+ }
+ break;
+ case OBJ_TYPE_DIALOG:
+ {
+ // sbx dialogs removed
+ }
+ break;
+ case OBJ_TYPE_DOCUMENT_OBJECTS:
+ bDocumentObjects = true;
+ case OBJ_TYPE_USERFORMS:
+ case OBJ_TYPE_NORMAL_MODULES:
+ case OBJ_TYPE_CLASS_MODULES:
+ {
+ // skip, to find the child entry.
+ continue;
+ }
+ default:
+ {
+ DBG_ERROR( "FindVariable: Unbekannter Typ!" );
+ pVar = 0;
+ }
+ break;
+ }
+ if ( !pVar )
+ break;
+ }
+ }
+
+ return pVar;
+}
+
+BasicEntryDescriptor BasicTreeListBox::GetEntryDescriptor( SvLBoxEntry* pEntry )
+{
+ ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
+ LibraryLocation eLocation = LIBRARY_LOCATION_UNKNOWN;
+ String aLibName;
+ String aLibSubName;
+ String aName;
+ String aMethodName;
+ BasicEntryType eType = OBJ_TYPE_UNKNOWN;
+
+ if ( !pEntry )
+ return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aName, aMethodName, eType );
+
+ EntryArray aEntries;
+
+ while ( pEntry )
+ {
+ USHORT nDepth = GetModel()->GetDepth( pEntry );
+ switch ( nDepth )
+ {
+ case 4:
+ case 3:
+ case 2:
+ case 1:
+ {
+ aEntries.C40_INSERT( SvLBoxEntry, pEntry, 0 );
+ }
+ break;
+ case 0:
+ {
+ BasicDocumentEntry* pBasicDocumentEntry = (BasicDocumentEntry*)pEntry->GetUserData();
+ if ( pBasicDocumentEntry )
+ {
+ aDocument = pBasicDocumentEntry->GetDocument();
+ eLocation = pBasicDocumentEntry->GetLocation();
+ eType = OBJ_TYPE_DOCUMENT;
+ }
+ }
+ break;
+ }
+ pEntry = GetParent( pEntry );
+ }
+
+ if ( aEntries.Count() )
+ {
+ for ( USHORT n = 0; n < aEntries.Count(); n++ )
+ {
+ SvLBoxEntry* pLE = aEntries[n];
+ DBG_ASSERT( pLE, "Entrie im Array nicht gefunden" );
+ BasicEntry* pBE = (BasicEntry*)pLE->GetUserData();
+ DBG_ASSERT( pBE, "Keine Daten im Eintrag gefunden!" );
+
+ switch ( pBE->GetType() )
+ {
+ case OBJ_TYPE_LIBRARY:
+ {
+ aLibName = GetEntryText( pLE );
+ eType = pBE->GetType();
+ }
+ break;
+ case OBJ_TYPE_MODULE:
+ {
+ aName = GetEntryText( pLE );
+ eType = pBE->GetType();
+ }
+ break;
+ case OBJ_TYPE_METHOD:
+ {
+ aMethodName = GetEntryText( pLE );
+ eType = pBE->GetType();
+ }
+ break;
+ case OBJ_TYPE_DIALOG:
+ {
+ aName = GetEntryText( pLE );
+ eType = pBE->GetType();
+ }
+ break;
+ case OBJ_TYPE_DOCUMENT_OBJECTS:
+ case OBJ_TYPE_USERFORMS:
+ case OBJ_TYPE_NORMAL_MODULES:
+ case OBJ_TYPE_CLASS_MODULES:
+ {
+ aLibSubName = GetEntryText( pLE );
+ eType = pBE->GetType();
+ }
+ break;
+ default:
+ {
+ DBG_ERROR( "GetEntryDescriptor: Unbekannter Typ!" );
+ eType = OBJ_TYPE_UNKNOWN;
+ }
+ break;
+ }
+
+ if ( eType == OBJ_TYPE_UNKNOWN )
+ break;
+ }
+ }
+
+ return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aName, aMethodName, eType );
+}
+
+USHORT BasicTreeListBox::ConvertType( BasicEntryType eType )
+{
+ USHORT nType = OBJ_TYPE_UNKNOWN;
+
+ switch ( eType )
+ {
+ case OBJ_TYPE_DOCUMENT:
+ {
+ nType = BASICIDE_TYPE_SHELL;
+ }
+ break;
+ case OBJ_TYPE_LIBRARY:
+ {
+ nType = BASICIDE_TYPE_LIBRARY;
+ }
+ break;
+ case OBJ_TYPE_MODULE:
+ {
+ nType = BASICIDE_TYPE_MODULE;
+ }
+ break;
+ case OBJ_TYPE_DIALOG:
+ {
+ nType = BASICIDE_TYPE_DIALOG;
+ }
+ break;
+ case OBJ_TYPE_METHOD:
+ {
+ nType = BASICIDE_TYPE_METHOD;
+ }
+ break;
+ default: ;
+ }
+
+ return nType;
+}
+
+bool BasicTreeListBox::IsValidEntry( SvLBoxEntry* pEntry )
+{
+ bool bIsValid = false;
+
+ BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ LibraryLocation eLocation( aDesc.GetLocation() );
+ String aLibName( aDesc.GetLibName() );
+ String aName( aDesc.GetName() );
+ String aMethodName( aDesc.GetMethodName() );
+ BasicEntryType eType( aDesc.GetType() );
+
+ switch ( eType )
+ {
+ case OBJ_TYPE_DOCUMENT:
+ {
+ bIsValid = aDocument.isAlive()
+ && ( aDocument.isApplication()
+ || GetRootEntryName( aDocument, eLocation ) == GetEntryText( pEntry )
+ );
+ }
+ break;
+ case OBJ_TYPE_LIBRARY:
+ {
+ bIsValid = aDocument.hasLibrary( E_SCRIPTS, aLibName ) || aDocument.hasLibrary( E_DIALOGS, aLibName );
+ }
+ break;
+ case OBJ_TYPE_MODULE:
+ {
+ bIsValid = aDocument.hasModule( aLibName, aName );
+ }
+ break;
+ case OBJ_TYPE_DIALOG:
+ {
+ bIsValid = aDocument.hasDialog( aLibName, aName );
+ }
+ break;
+ case OBJ_TYPE_METHOD:
+ {
+ bIsValid = BasicIDE::HasMethod( aDocument, aLibName, aName, aMethodName );
+ }
+ break;
+ case OBJ_TYPE_DOCUMENT_OBJECTS:
+ case OBJ_TYPE_USERFORMS:
+ case OBJ_TYPE_NORMAL_MODULES:
+ case OBJ_TYPE_CLASS_MODULES:
+ {
+ bIsValid = true;
+ }
+ break;
+ default: ;
+ }
+
+ return bIsValid;
+}
+
+SbModule* BasicTreeListBox::FindModule( SvLBoxEntry* pEntry )
+{
+ SbxVariable* pVar = FindVariable( pEntry );
+ if ( pVar && pVar->IsA( TYPE(SbModule ) ) )
+ return (SbModule*)pVar;
+ return 0;
+}
+
+SvLBoxEntry* BasicTreeListBox::FindRootEntry( const ScriptDocument& rDocument, LibraryLocation eLocation )
+{
+ OSL_ENSURE( rDocument.isValid(), "BasicTreeListBox::FindRootEntry: invalid document!" );
+ ULONG nRootPos = 0;
+ SvLBoxEntry* pRootEntry = GetEntry( nRootPos );
+ while ( pRootEntry )
+ {
+ DBG_ASSERT( (((BasicEntry*)pRootEntry->GetUserData())->GetType() == OBJ_TYPE_DOCUMENT ), "Kein Shelleintrag?" );
+ BasicDocumentEntry* pBasicDocumentEntry = (BasicDocumentEntry*)pRootEntry->GetUserData();
+ if ( pBasicDocumentEntry && ( pBasicDocumentEntry->GetDocument() == rDocument ) && pBasicDocumentEntry->GetLocation() == eLocation )
+ return pRootEntry;
+ pRootEntry = GetEntry( ++nRootPos );
+ }
+ return 0;
+}
+
+String CreateMgrAndLibStr( const String& rMgrName, const String& rLibName )
+{
+ String aName( '[' );
+ aName += rMgrName;
+ aName += String( RTL_CONSTASCII_USTRINGPARAM( "]." ) );
+ aName += rLibName;
+ return aName;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/bastype3.hxx b/basctl/source/basicide/bastype3.hxx
new file mode 100644
index 000000000000..bc27eaa6cf90
--- /dev/null
+++ b/basctl/source/basicide/bastype3.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BASTYPE3_HXX
+#define _BASTYPE3_HXX
+
+#include <svheader.hxx>
+
+#include <svtools/svmedit.hxx>
+
+#include <iderid.hxx>
+
+class EditorWindow;
+
+#ifndef NO_SPECIALEDIT
+
+class ExtendedEdit : public Edit
+{
+private:
+ Accelerator aAcc;
+ Link aAccHdl;
+ Link aGotFocusHdl;
+ Link aLoseFocusHdl;
+
+protected:
+ DECL_LINK( EditAccHdl, Accelerator * );
+ DECL_LINK( ImplGetFocusHdl, Control* );
+ DECL_LINK( ImplLoseFocusHdl, Control* );
+
+public:
+ ExtendedEdit( Window* pParent, IDEResId nRes );
+
+ void SetAccHdl( const Link& rLink ) { aAccHdl = rLink; }
+ void SetLoseFocusHdl( const Link& rLink ) { aLoseFocusHdl = rLink; }
+ void SetGotFocusHdl( const Link& rLink ) { aGotFocusHdl = rLink; }
+ Accelerator& GetAccelerator() { return aAcc; }
+};
+
+#endif //NO_SPECIALEDIT
+
+#endif // _BASTYPE3_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/bastype4.hxx b/basctl/source/basicide/bastype4.hxx
new file mode 100644
index 000000000000..a65b286db99d
--- /dev/null
+++ b/basctl/source/basicide/bastype4.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BASTYPE4_HXX
+#define _BASTYPE4_HXX
+
+
+#include <svtools/tabbar.hxx>
+
+class EditEngine;
+class EditView;
+
+class ExtendedTabBar : public TabBar
+{
+ EditEngine* pEditEngine;
+ EditView* pEditView;
+ BOOL bIsInKeyInput;
+#if _SOLAR__PRIVATE
+ void ImpCheckEditEngine( BOOL bKeepNewText );
+#endif
+protected:
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void LoseFocus();
+ virtual void KeyInput( const KeyEvent& rKEvent );
+ virtual void Paint( const Rectangle& );
+
+ virtual BOOL StartRenamingTab( USHORT nCurId );
+ virtual BOOL AllowRenamingTab( USHORT nCurId, const String& rNewName );
+ virtual void TabRenamed( USHORT nCurId, const String& rNewName );
+
+public:
+ ExtendedTabBar( Window* pParent, WinBits nStyle );
+ ~ExtendedTabBar();
+
+ void RenameSelectedTab();
+ BOOL IsInEditMode() const { return pEditEngine ? TRUE : FALSE; }
+ void StopEditMode( BOOL bKeepCurText = FALSE );
+};
+
+#endif //_BASTYPE4_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx
new file mode 100644
index 000000000000..5faaf7988313
--- /dev/null
+++ b/basctl/source/basicide/bastypes.cxx
@@ -0,0 +1,1022 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include <vector>
+#include <algorithm>
+
+#include <ide_pch.hxx>
+
+
+#include <basic/sbx.hxx>
+#include <helpid.hrc>
+#include <basidesh.hrc>
+#include <bastypes.hxx>
+#include <bastype2.hxx>
+#include <baside2.hxx> // Leider brauche ich teilweise pModulWindow...
+#include <baside3.hxx>
+#include <baside2.hrc>
+#include <svtools/textview.hxx>
+#include <svtools/texteng.hxx>
+#include <basobj.hxx>
+#include <sbxitem.hxx>
+#include <iderdll.hxx>
+
+#include <sfx2/passwd.hxx>
+
+#include <com/sun/star/script/XLibraryContainer2.hpp>
+#include <com/sun/star/script/XLibraryContainerPassword.hpp>
+#include <com/sun/star/script/ModuleType.hpp>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+
+
+DBG_NAME( IDEBaseWindow )
+
+const char* pRegName = "BasicIDETabBar";
+
+TYPEINIT0( IDEBaseWindow )
+TYPEINIT1( SbxItem, SfxPoolItem );
+
+IDEBaseWindow::IDEBaseWindow( Window* pParent, const ScriptDocument& rDocument, String aLibName, String aName )
+ :Window( pParent, WinBits( WB_3DLOOK ) )
+ ,m_aDocument( rDocument )
+ ,m_aLibName( aLibName )
+ ,m_aName( aName )
+{
+ DBG_CTOR( IDEBaseWindow, 0 );
+ pShellHScrollBar = 0;
+ pShellVScrollBar = 0;
+ nStatus = 0;
+}
+
+
+
+__EXPORT IDEBaseWindow::~IDEBaseWindow()
+{
+ DBG_DTOR( IDEBaseWindow, 0 );
+ if ( pShellVScrollBar )
+ pShellVScrollBar->SetScrollHdl( Link() );
+ if ( pShellHScrollBar )
+ pShellHScrollBar->SetScrollHdl( Link() );
+}
+
+
+
+void IDEBaseWindow::Init()
+{
+ DBG_CHKTHIS( IDEBaseWindow, 0 );
+ if ( pShellVScrollBar )
+ pShellVScrollBar->SetScrollHdl( LINK( this, IDEBaseWindow, ScrollHdl ) );
+ if ( pShellHScrollBar )
+ pShellHScrollBar->SetScrollHdl( LINK( this, IDEBaseWindow, ScrollHdl ) );
+ DoInit(); // virtuell...
+}
+
+
+
+void __EXPORT IDEBaseWindow::DoInit()
+{
+}
+
+
+
+void IDEBaseWindow::GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll )
+{
+ DBG_CHKTHIS( IDEBaseWindow, 0 );
+ pShellHScrollBar = pHScroll;
+ pShellVScrollBar = pVScroll;
+// Init(); // macht kein Sinn, fuehrt zu flackern, fuehr zu Fehlern...
+}
+
+
+
+IMPL_LINK_INLINE_START( IDEBaseWindow, ScrollHdl, ScrollBar *, pCurScrollBar )
+{
+ DBG_CHKTHIS( IDEBaseWindow, 0 );
+ DoScroll( pCurScrollBar );
+ return 0;
+}
+IMPL_LINK_INLINE_END( IDEBaseWindow, ScrollHdl, ScrollBar *, pCurScrollBar )
+
+
+
+void __EXPORT IDEBaseWindow::ExecuteCommand( SfxRequest& )
+{
+ DBG_CHKTHIS( IDEBaseWindow, 0 );
+}
+
+
+
+void __EXPORT IDEBaseWindow::GetState( SfxItemSet& )
+{
+ DBG_CHKTHIS( IDEBaseWindow, 0 );
+}
+
+
+long IDEBaseWindow::Notify( NotifyEvent& rNEvt )
+{
+ long nDone = 0;
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ KeyEvent aKEvt = *rNEvt.GetKeyEvent();
+ KeyCode aCode = aKEvt.GetKeyCode();
+ USHORT nCode = aCode.GetCode();
+
+ switch ( nCode )
+ {
+ case KEY_PAGEUP:
+ case KEY_PAGEDOWN:
+ {
+ if ( aCode.IsMod1() )
+ {
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if ( pIDEShell )
+ pIDEShell->NextPage( nCode == KEY_PAGEUP );
+
+ nDone = 1;
+ }
+ }
+ break;
+ }
+ }
+
+ return nDone ? nDone : Window::Notify( rNEvt );
+}
+
+
+void __EXPORT IDEBaseWindow::DoScroll( ScrollBar* )
+{
+ DBG_CHKTHIS( IDEBaseWindow, 0 );
+}
+
+
+void __EXPORT IDEBaseWindow::StoreData()
+{
+}
+
+BOOL __EXPORT IDEBaseWindow::CanClose()
+{
+ return TRUE;
+}
+
+BOOL __EXPORT IDEBaseWindow::AllowUndo()
+{
+ return TRUE;
+}
+
+
+
+void __EXPORT IDEBaseWindow::UpdateData()
+{
+}
+
+
+String __EXPORT IDEBaseWindow::GetTitle()
+{
+ return String();
+}
+
+
+
+String IDEBaseWindow::CreateQualifiedName()
+{
+ String aName;
+ if ( m_aLibName.Len() )
+ {
+ LibraryLocation eLocation = m_aDocument.getLibraryLocation( m_aLibName );
+ aName = m_aDocument.getTitle( eLocation );
+ aName += '.';
+ aName += m_aLibName;
+ aName += '.';
+ aName += GetTitle();
+ }
+
+ return aName;
+}
+
+void IDEBaseWindow::SetReadOnly( BOOL )
+{
+}
+
+BOOL IDEBaseWindow::IsReadOnly()
+{
+ return FALSE;
+}
+
+void __EXPORT IDEBaseWindow::BasicStarted()
+{
+}
+
+void __EXPORT IDEBaseWindow::BasicStopped()
+{
+}
+
+BOOL __EXPORT IDEBaseWindow::IsModified()
+{
+ return TRUE;
+}
+
+BOOL __EXPORT IDEBaseWindow::IsPasteAllowed()
+{
+ return FALSE;
+}
+
+Window* __EXPORT IDEBaseWindow::GetLayoutWindow()
+{
+ return this;
+}
+
+SfxUndoManager* __EXPORT IDEBaseWindow::GetUndoManager()
+{
+ return NULL;
+}
+
+BreakPointList::BreakPointList()
+{}
+
+BreakPointList::BreakPointList(BreakPointList const & rList):
+ BreakPL( sal::static_int_cast<USHORT>( rList.Count() ))
+{
+ for (ULONG i = 0; i < rList.Count(); ++i)
+ Insert(new BreakPoint(*rList.GetObject(i)), i);
+}
+
+BreakPointList::~BreakPointList()
+{
+ reset();
+}
+
+void BreakPointList::reset()
+{
+ while (Count() > 0)
+ delete Remove(Count() - 1);
+}
+
+void BreakPointList::transfer(BreakPointList & rList)
+{
+ reset();
+ for (ULONG i = 0; i < rList.Count(); ++i)
+ Insert(rList.GetObject(i), i);
+ rList.Clear();
+}
+
+void BreakPointList::InsertSorted( BreakPoint* pNewBrk )
+{
+ BreakPoint* pBrk = First();
+ while ( pBrk )
+ {
+ if ( pNewBrk->nLine <= pBrk->nLine )
+ {
+ DBG_ASSERT( ( pBrk->nLine != pNewBrk->nLine ) || pNewBrk->bTemp, "BreakPoint existiert schon!" );
+ Insert( pNewBrk );
+ return;
+ }
+ pBrk = Next();
+ }
+ // Keine Einfuegeposition gefunden => LIST_APPEND
+ Insert( pNewBrk, LIST_APPEND );
+}
+
+void BreakPointList::SetBreakPointsInBasic( SbModule* pModule )
+{
+ pModule->ClearAllBP();
+
+ BreakPoint* pBrk = First();
+ while ( pBrk )
+ {
+ if ( pBrk->bEnabled )
+ pModule->SetBP( (USHORT)pBrk->nLine );
+ pBrk = Next();
+ }
+}
+
+BreakPoint* BreakPointList::FindBreakPoint( ULONG nLine )
+{
+ BreakPoint* pBrk = First();
+ while ( pBrk )
+ {
+ if ( pBrk->nLine == nLine )
+ return pBrk;
+
+ pBrk = Next();
+ }
+
+ return (BreakPoint*)0;
+}
+
+
+
+void BreakPointList::AdjustBreakPoints( ULONG nLine, BOOL bInserted )
+{
+ BreakPoint* pBrk = First();
+ while ( pBrk )
+ {
+ BOOL bDelBrk = FALSE;
+ if ( pBrk->nLine == nLine )
+ {
+ if ( bInserted )
+ pBrk->nLine++;
+ else
+ bDelBrk = TRUE;
+ }
+ else if ( pBrk->nLine > nLine )
+ {
+ if ( bInserted )
+ pBrk->nLine++;
+ else
+ pBrk->nLine--;
+ }
+
+ if ( bDelBrk )
+ {
+ ULONG n = GetCurPos();
+ delete Remove( pBrk );
+ pBrk = Seek( n );
+ }
+ else
+ {
+ pBrk = Next();
+ }
+ }
+}
+
+void BreakPointList::ResetHitCount()
+{
+ BreakPoint* pBrk = First();
+ while ( pBrk )
+ {
+ pBrk->nHitCount = 0;
+ pBrk = Next();
+ }
+}
+
+void IDEBaseWindow::Deactivating()
+{
+}
+
+USHORT __EXPORT IDEBaseWindow::GetSearchOptions()
+{
+ return 0;
+}
+
+
+BasicDockingWindow::BasicDockingWindow( Window* pParent ) :
+ DockingWindow( pParent, WB_BORDER | WB_3DLOOK | WB_DOCKABLE | WB_MOVEABLE |
+ WB_SIZEABLE | WB_ROLLABLE |
+ WB_DOCKABLE | WB_CLIPCHILDREN )
+{
+}
+
+
+
+BOOL __EXPORT BasicDockingWindow::Docking( const Point& rPos, Rectangle& rRect )
+{
+ ModulWindowLayout* pLayout = (ModulWindowLayout*)GetParent();
+ Rectangle aTmpRec( rRect );
+ BOOL bDock = IsDockingPrevented() ? FALSE : pLayout->IsToBeDocked( this, rPos, aTmpRec );
+ if ( bDock )
+ {
+ rRect.SetSize( aTmpRec.GetSize() );
+ }
+ else // Alte Groesse einstellen
+ {
+ if ( !aFloatingPosAndSize.IsEmpty() )
+ rRect.SetSize( aFloatingPosAndSize.GetSize() );
+ }
+ return !bDock; // bFloat
+}
+
+
+
+void __EXPORT BasicDockingWindow::EndDocking( const Rectangle& rRect, BOOL bFloatMode )
+{
+ if ( bFloatMode )
+ DockingWindow::EndDocking( rRect, bFloatMode );
+ else
+ {
+ SetFloatingMode( FALSE );
+ ModulWindowLayout* pLayout = (ModulWindowLayout*)GetParent();
+ pLayout->DockaWindow( this );
+ }
+}
+
+
+
+void __EXPORT BasicDockingWindow::ToggleFloatingMode()
+{
+ ModulWindowLayout* pLayout = (ModulWindowLayout*)GetParent();
+ if ( IsFloatingMode() )
+ {
+ if ( !aFloatingPosAndSize.IsEmpty() )
+ SetPosSizePixel( GetParent()->ScreenToOutputPixel( aFloatingPosAndSize.TopLeft() ),
+ aFloatingPosAndSize.GetSize() );
+ }
+ pLayout->DockaWindow( this );
+}
+
+
+
+BOOL __EXPORT BasicDockingWindow::PrepareToggleFloatingMode()
+{
+ if ( IsFloatingMode() )
+ {
+ // Position und Groesse auf dem Desktop merken...
+ aFloatingPosAndSize.SetPos( GetParent()->OutputToScreenPixel( GetPosPixel() ) );
+ aFloatingPosAndSize.SetSize( GetSizePixel() );
+ }
+ return TRUE;
+}
+
+
+
+void __EXPORT BasicDockingWindow::StartDocking()
+{
+ // Position und Groesse auf dem Desktop merken...
+ if ( IsFloatingMode() )
+ {
+ aFloatingPosAndSize.SetPos( GetParent()->OutputToScreenPixel( GetPosPixel() ) );
+ aFloatingPosAndSize.SetSize( GetSizePixel() );
+ }
+}
+
+
+
+ExtendedEdit::ExtendedEdit( Window* pParent, IDEResId nRes ) :
+ Edit( pParent, nRes )
+{
+ aAcc.SetSelectHdl( LINK( this, ExtendedEdit, EditAccHdl ) );
+ Control::SetGetFocusHdl( LINK( this, ExtendedEdit, ImplGetFocusHdl ) );
+ Control::SetLoseFocusHdl( LINK( this, ExtendedEdit, ImplLoseFocusHdl ) );
+}
+
+IMPL_LINK( ExtendedEdit, ImplGetFocusHdl, Control*, EMPTYARG )
+{
+ Application::InsertAccel( &aAcc );
+ aLoseFocusHdl.Call( this );
+ return 0;
+}
+
+
+IMPL_LINK( ExtendedEdit, ImplLoseFocusHdl, Control*, EMPTYARG )
+{
+ Application::RemoveAccel( &aAcc );
+ return 0;
+}
+
+
+IMPL_LINK_INLINE_START( ExtendedEdit, EditAccHdl, Accelerator *, pAcc )
+{
+ aAccHdl.Call( pAcc );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ExtendedEdit, EditAccHdl, Accelerator *, pAcc )
+
+
+
+struct TabBarDDInfo
+{
+ ULONG npTabBar;
+ USHORT nPage;
+
+ TabBarDDInfo() { npTabBar = 0; nPage = 0; }
+ TabBarDDInfo( ULONG _npTabBar, USHORT _nPage ) { npTabBar = _npTabBar; nPage = _nPage; }
+};
+
+
+BasicIDETabBar::BasicIDETabBar( Window* pParent ) :
+ TabBar( pParent, WinBits( WB_3DLOOK | WB_SCROLL | WB_BORDER | WB_SIZEABLE | WB_DRAG ) )
+{
+ EnableEditMode( TRUE );
+
+ SetHelpId( HID_BASICIDE_TABBAR );
+}
+
+void __EXPORT BasicIDETabBar::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if ( rMEvt.IsLeft() && ( rMEvt.GetClicks() == 2 ) && !IsInEditMode() )
+ {
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_MODULEDLG );
+ }
+ }
+ else
+ {
+ TabBar::MouseButtonDown( rMEvt );
+ }
+}
+
+void __EXPORT BasicIDETabBar::Command( const CommandEvent& rCEvt )
+{
+ if ( ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) && !IsInEditMode() )
+ {
+ Point aPos( rCEvt.IsMouseEvent() ? rCEvt.GetMousePosPixel() : Point(1,1) );
+ if ( rCEvt.IsMouseEvent() ) // Richtige Tab selektieren
+ {
+ Point aP = PixelToLogic( aPos );
+ MouseEvent aMouseEvent( aP, 1, MOUSE_SIMPLECLICK, MOUSE_LEFT );
+ TabBar::MouseButtonDown( aMouseEvent );
+ }
+
+ PopupMenu aPopup( IDEResId( RID_POPUP_TABBAR ) );
+ if ( GetPageCount() == 0 )
+ {
+ aPopup.EnableItem( SID_BASICIDE_DELETECURRENT, FALSE );
+ aPopup.EnableItem( SID_BASICIDE_RENAMECURRENT, FALSE );
+ aPopup.EnableItem( SID_BASICIDE_HIDECURPAGE, FALSE );
+ }
+
+ if ( StarBASIC::IsRunning() )
+ {
+ aPopup.EnableItem(SID_BASICIDE_DELETECURRENT, false);
+ aPopup.EnableItem( SID_BASICIDE_RENAMECURRENT, false);
+ aPopup.EnableItem(SID_BASICIDE_MODULEDLG, false);
+ }
+
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if ( pIDEShell )
+ {
+ ScriptDocument aDocument( pIDEShell->GetCurDocument() );
+ ::rtl::OUString aOULibName( pIDEShell->GetCurLibName() );
+ Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) )
+ {
+ aPopup.EnableItem( aPopup.GetItemId( 0 ), FALSE );
+ aPopup.EnableItem( SID_BASICIDE_DELETECURRENT, FALSE );
+ aPopup.EnableItem( SID_BASICIDE_RENAMECURRENT, FALSE );
+ aPopup.RemoveDisabledEntries();
+ }
+ if ( aDocument.isInVBAMode() )
+ {
+ // disable to delete or remove object modules in IDE
+ BasicManager* pBasMgr = aDocument.getBasicManager();
+ if ( pBasMgr )
+ {
+ StarBASIC* pBasic = pBasMgr->GetLib( aOULibName );
+ if( pBasic )
+ {
+ IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable();
+ IDEBaseWindow* pWin = aIDEWindowTable.Get( GetCurPageId() );
+ if( pWin && pWin->ISA( ModulWindow ) )
+ {
+ SbModule* pActiveModule = (SbModule*)pBasic->FindModule( pWin->GetName() );
+ if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::DOCUMENT ) )
+ {
+ aPopup.EnableItem( SID_BASICIDE_DELETECURRENT, FALSE );
+ aPopup.EnableItem( SID_BASICIDE_RENAMECURRENT, FALSE );
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if ( pDispatcher )
+ pDispatcher->Execute( aPopup.Execute( this, aPos ) );
+ }
+}
+
+long BasicIDETabBar::AllowRenaming()
+{
+ BOOL bValid = BasicIDE::IsValidSbxName( GetEditText() );
+
+ if ( !bValid )
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_BADSBXNAME ) ) ).Execute();
+
+ return bValid ? TABBAR_RENAMING_YES : TABBAR_RENAMING_NO;
+}
+
+
+void __EXPORT BasicIDETabBar::EndRenaming()
+{
+ if ( !IsEditModeCanceled() )
+ {
+ SfxUInt16Item aID( SID_BASICIDE_ARG_TABID, GetEditPageId() );
+ SfxStringItem aNewName( SID_BASICIDE_ARG_MODULENAME, GetEditText() );
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_NAMECHANGEDONTAB,
+ SFX_CALLMODE_SYNCHRON, &aID, &aNewName, 0L );
+ }
+ }
+}
+
+
+void BasicIDETabBar::Sort()
+{
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if ( pIDEShell )
+ {
+ IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable();
+ TabBarSortHelper aTabBarSortHelper;
+ ::std::vector<TabBarSortHelper> aModuleList;
+ ::std::vector<TabBarSortHelper> aDialogList;
+ USHORT nPageCount = GetPageCount();
+ USHORT i;
+
+ // create module and dialog lists for sorting
+ for ( i = 0; i < nPageCount; i++)
+ {
+ USHORT nId = GetPageId( i );
+ aTabBarSortHelper.nPageId = nId;
+ aTabBarSortHelper.aPageText = GetPageText( nId );
+ IDEBaseWindow* pWin = aIDEWindowTable.Get( nId );
+
+ if ( pWin->IsA( TYPE( ModulWindow ) ) )
+ {
+ aModuleList.push_back( aTabBarSortHelper );
+ }
+ else if ( pWin->IsA( TYPE( DialogWindow ) ) )
+ {
+ aDialogList.push_back( aTabBarSortHelper );
+ }
+ }
+
+ // sort module and dialog lists by page text
+ ::std::sort( aModuleList.begin() , aModuleList.end() );
+ ::std::sort( aDialogList.begin() , aDialogList.end() );
+
+
+ USHORT nModules = sal::static_int_cast<USHORT>( aModuleList.size() );
+ USHORT nDialogs = sal::static_int_cast<USHORT>( aDialogList.size() );
+
+ // move module pages to new positions
+ for (i = 0; i < nModules; i++)
+ {
+ MovePage( aModuleList[i].nPageId , i );
+ }
+
+ // move dialog pages to new positions
+ for (i = 0; i < nDialogs; i++)
+ {
+ MovePage( aDialogList[i].nPageId , nModules + i );
+ }
+ }
+}
+
+void CutLines( ::rtl::OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, BOOL bEraseTrailingEmptyLines )
+{
+ sal_Int32 nStartPos = 0;
+ sal_Int32 nEndPos = 0;
+ sal_Int32 nLine = 0;
+ while ( nLine < nStartLine )
+ {
+ nStartPos = searchEOL( rStr, nStartPos );
+ if( nStartPos == -1 )
+ break;
+ nStartPos++; // nicht das \n.
+ nLine++;
+ }
+
+ DBG_ASSERTWARNING( nStartPos != -1, "CutLines: Startzeile nicht gefunden!" );
+
+ if ( nStartPos != -1 )
+ {
+ nEndPos = nStartPos;
+ for ( sal_Int32 i = 0; i < nLines; i++ )
+ nEndPos = searchEOL( rStr, nEndPos+1 );
+
+ if ( nEndPos == -1 ) // kann bei letzter Zeile passieren
+ nEndPos = rStr.getLength();
+ else
+ nEndPos++;
+
+ ::rtl::OUString aEndStr = rStr.copy( nEndPos );
+ rStr = rStr.copy( 0, nStartPos );
+ rStr += aEndStr;
+ }
+ if ( bEraseTrailingEmptyLines )
+ {
+ sal_Int32 n = nStartPos;
+ sal_Int32 nLen = rStr.getLength();
+ while ( ( n < nLen ) && ( rStr.getStr()[ n ] == LINE_SEP ||
+ rStr.getStr()[ n ] == LINE_SEP_CR ) )
+ {
+ n++;
+ }
+
+ if ( n > nStartPos )
+ {
+ ::rtl::OUString aEndStr = rStr.copy( n );
+ rStr = rStr.copy( 0, nStartPos );
+ rStr += aEndStr;
+ }
+ }
+}
+
+ULONG CalcLineCount( SvStream& rStream )
+{
+ ULONG nLFs = 0;
+ ULONG nCRs = 0;
+ char c;
+
+ rStream.Seek( 0 );
+ rStream >> c;
+ while ( !rStream.IsEof() )
+ {
+ if ( c == '\n' )
+ nLFs++;
+ else if ( c == '\r' )
+ nCRs++;
+ rStream >> c;
+ }
+
+ rStream.Seek( 0 );
+ if ( nLFs > nCRs )
+ return nLFs;
+ return nCRs;
+}
+
+LibInfoKey::LibInfoKey( const ScriptDocument& rDocument, const String& rLibName )
+ :m_aDocument( rDocument )
+ ,m_aLibName( rLibName )
+{
+}
+
+LibInfoKey::~LibInfoKey()
+{
+}
+
+LibInfoKey::LibInfoKey( const LibInfoKey& rKey )
+ :m_aDocument( rKey.m_aDocument )
+ ,m_aLibName( rKey.m_aLibName )
+{
+}
+
+LibInfoKey& LibInfoKey::operator=( const LibInfoKey& rKey )
+{
+ m_aDocument = rKey.m_aDocument;
+ m_aLibName = rKey.m_aLibName;
+ return *this;
+}
+
+bool LibInfoKey::operator==( const LibInfoKey& rKey ) const
+{
+ bool bRet = false;
+ if ( m_aDocument == rKey.m_aDocument && m_aLibName == rKey.m_aLibName )
+ bRet = true;
+ return bRet;
+}
+
+LibInfoItem::LibInfoItem( const ScriptDocument& rDocument, const String& rLibName, const String& rCurrentName, USHORT nCurrentType )
+ :m_aDocument( rDocument )
+ ,m_aLibName( rLibName )
+ ,m_aCurrentName( rCurrentName )
+ ,m_nCurrentType( nCurrentType )
+{
+}
+
+LibInfoItem::~LibInfoItem()
+{
+}
+
+LibInfoItem::LibInfoItem( const LibInfoItem& rItem )
+ :m_aDocument( rItem.m_aDocument )
+ ,m_aLibName( rItem.m_aLibName )
+ ,m_aCurrentName( rItem.m_aCurrentName )
+ ,m_nCurrentType( rItem.m_nCurrentType )
+{
+}
+
+LibInfoItem& LibInfoItem::operator=( const LibInfoItem& rItem )
+{
+ m_aDocument = rItem.m_aDocument;
+ m_aLibName = rItem.m_aLibName;
+ m_aCurrentName = rItem.m_aCurrentName;
+ m_nCurrentType = rItem.m_nCurrentType;
+
+ return *this;
+}
+
+LibInfos::LibInfos()
+{
+}
+
+LibInfos::~LibInfos()
+{
+ LibInfoMap::iterator end = m_aLibInfoMap.end();
+ for ( LibInfoMap::iterator it = m_aLibInfoMap.begin(); it != end; ++it )
+ delete it->second;
+ m_aLibInfoMap.clear();
+}
+
+void LibInfos::InsertInfo( LibInfoItem* pItem )
+{
+ LibInfoKey aKey( pItem->GetDocument(), pItem->GetLibName() );
+ LibInfoMap::iterator it = m_aLibInfoMap.find( aKey );
+ if ( it != m_aLibInfoMap.end() )
+ {
+ LibInfoItem* pI = it->second;
+ m_aLibInfoMap.erase( it );
+ delete pI;
+ }
+ m_aLibInfoMap.insert( LibInfoMap::value_type( aKey, pItem ) );
+}
+
+void LibInfos::RemoveInfoFor( const ScriptDocument& _rDocument )
+{
+ for ( LibInfoMap::iterator it = m_aLibInfoMap.begin();
+ it != m_aLibInfoMap.end();
+ )
+ {
+ if ( it->first.GetDocument() != _rDocument )
+ {
+ ++it;
+ continue;
+ }
+
+ LibInfoItem* pItem = it->second;
+
+ LibInfoMap::iterator next_it = it; ++next_it;
+ m_aLibInfoMap.erase( it );
+ it = next_it;
+
+ delete pItem;
+ }
+}
+
+LibInfoItem* LibInfos::GetInfo( const LibInfoKey& rKey )
+{
+ LibInfoItem* pItem = 0;
+ LibInfoMap::iterator it = m_aLibInfoMap.find( rKey );
+ if ( it != m_aLibInfoMap.end() )
+ pItem = it->second;
+ return pItem;
+}
+
+SbxItem::SbxItem(USHORT nWhich_, const ScriptDocument& rDocument, const String& aLibName, const String& aName, USHORT nType )
+ :SfxPoolItem( nWhich_ )
+ ,m_aDocument(rDocument)
+ ,m_aLibName(aLibName)
+ ,m_aName(aName)
+ ,m_nType(nType)
+{
+}
+
+SbxItem::SbxItem(USHORT nWhich_, const ScriptDocument& rDocument, const String& aLibName, const String& aName, const String& aMethodName, USHORT nType )
+ :SfxPoolItem( nWhich_ )
+ ,m_aDocument(rDocument)
+ ,m_aLibName(aLibName)
+ ,m_aName(aName)
+ ,m_aMethodName(aMethodName)
+ ,m_nType(nType)
+{
+}
+
+SbxItem::SbxItem(const SbxItem& rCopy)
+ :SfxPoolItem( rCopy )
+ ,m_aDocument( rCopy.m_aDocument )
+{
+ m_aLibName = rCopy.m_aLibName;
+ m_aName = rCopy.m_aName;
+ m_aMethodName = rCopy.m_aMethodName;
+ m_nType = rCopy.m_nType;
+}
+
+int SbxItem::operator==( const SfxPoolItem& rCmp) const
+{
+ DBG_ASSERT( rCmp.ISA( SbxItem ), "==: Kein SbxItem!" );
+ return ( SfxPoolItem::operator==( rCmp ) && ( m_aDocument == ((const SbxItem&)rCmp).m_aDocument )
+ && ( m_aLibName == ((const SbxItem&)rCmp).m_aLibName )
+ && ( m_aName == ((const SbxItem&)rCmp).m_aName )
+ && ( m_aMethodName == ((const SbxItem&)rCmp).m_aMethodName )
+ && ( m_nType == ((const SbxItem&)rCmp).m_nType ) );
+}
+
+SfxPoolItem *SbxItem::Clone( SfxItemPool* ) const
+{
+ return new SbxItem(*this);
+}
+
+BOOL QueryDel( const String& rName, const ResId& rId, Window* pParent )
+{
+ String aQuery( rId );
+ String aName( rName );
+ aName += '\'';
+ aName.Insert( '\'', 0 );
+ aQuery.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), aName );
+ QueryBox aQueryBox( pParent, WB_YES_NO | WB_DEF_YES, aQuery );
+ if ( aQueryBox.Execute() == RET_YES )
+ return TRUE;
+ return FALSE;
+}
+
+BOOL QueryDelMacro( const String& rName, Window* pParent )
+{
+ return QueryDel( rName, IDEResId( RID_STR_QUERYDELMACRO ), pParent );
+}
+
+BOOL QueryReplaceMacro( const String& rName, Window* pParent )
+{
+ return QueryDel( rName, IDEResId( RID_STR_QUERYREPLACEMACRO ), pParent );
+}
+
+BOOL QueryDelDialog( const String& rName, Window* pParent )
+{
+ return QueryDel( rName, IDEResId( RID_STR_QUERYDELDIALOG ), pParent );
+}
+
+BOOL QueryDelLib( const String& rName, BOOL bRef, Window* pParent )
+{
+ return QueryDel( rName, IDEResId( bRef ? RID_STR_QUERYDELLIBREF : RID_STR_QUERYDELLIB ), pParent );
+}
+
+BOOL QueryDelModule( const String& rName, Window* pParent )
+{
+ return QueryDel( rName, IDEResId( RID_STR_QUERYDELMODULE ), pParent );
+}
+
+BOOL QueryPassword( const Reference< script::XLibraryContainer >& xLibContainer, const String& rLibName, String& rPassword, BOOL bRepeat, BOOL bNewTitle )
+{
+ BOOL bOK = FALSE;
+ USHORT nRet = 0;
+
+ do
+ {
+ // password dialog
+ SfxPasswordDialog* pDlg = new SfxPasswordDialog( Application::GetDefDialogParent() );
+ pDlg->SetMinLen( 1 );
+
+ // set new title
+ if ( bNewTitle )
+ {
+ String aTitle( IDEResId( RID_STR_ENTERPASSWORD ) );
+ aTitle.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), rLibName );
+ pDlg->SetText( aTitle );
+ }
+
+ // execute dialog
+ nRet = pDlg->Execute();
+
+ // verify password
+ if ( nRet == RET_OK )
+ {
+ ::rtl::OUString aOULibName( rLibName );
+ if ( xLibContainer.is() && xLibContainer->hasByName( aOULibName ) )
+ {
+ Reference< script::XLibraryContainerPassword > xPasswd( xLibContainer, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
+ {
+ rPassword = pDlg->GetPassword();
+ ::rtl::OUString aOUPassword( rPassword );
+ bOK = xPasswd->verifyLibraryPassword( aOULibName, aOUPassword );
+
+ if ( !bOK )
+ {
+ ErrorBox aErrorBox( Application::GetDefDialogParent(), WB_OK, String( IDEResId( RID_STR_WRONGPASSWORD ) ) );
+ aErrorBox.Execute();
+ }
+ }
+ }
+ }
+
+ delete pDlg;
+ }
+ while ( bRepeat && !bOK && nRet == RET_OK );
+
+ return bOK;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/brkdlg.cxx b/basctl/source/basicide/brkdlg.cxx
new file mode 100644
index 000000000000..34a1f8f62c94
--- /dev/null
+++ b/basctl/source/basicide/brkdlg.cxx
@@ -0,0 +1,282 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include <limits>
+
+#include <vcl/sound.hxx>
+
+// #define ITEMID_SEARCH SID_SEARCH_ITEM
+#define _SVX_NOIDERESIDS
+#include <brkdlg.hxx>
+#include <brkdlg.hrc>
+#include <basidesh.hxx>
+#include <basidesh.hrc>
+#include <iderdll.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+
+// FIXME Why does BreakPointDialog allow only USHORT for break-point line
+// numbers, whereas BreakPoint supports ULONG?
+
+bool lcl_ParseText( String aText, USHORT& rLineNr )
+{
+ // aText should look like "# n" where
+ // n > 0 && n < std::numeric_limits< USHORT >::max().
+ // All spaces are ignored, so there can even be spaces within the
+ // number n. (Maybe it would be better to ignore all whitespace instead
+ // of just spaces.)
+ aText.EraseAllChars(' ');
+ sal_Unicode cFirst = aText.GetChar(0);
+ if (cFirst != '#' && !(cFirst >= '0' && cFirst <= '9'))
+ return false;
+ if (cFirst == '#')
+ aText.Erase(0, 1);
+ // XXX Assumes that USHORT is contained within sal_Int32:
+ sal_Int32 n = aText.ToInt32();
+ if (n <= 0 || n > std::numeric_limits< USHORT >::max())
+ return false;
+ rLineNr = static_cast< USHORT >(n);
+ return true;
+}
+
+BreakPointDialog::BreakPointDialog( Window* pParent, BreakPointList& rBrkPntList ) :
+ ModalDialog( pParent, IDEResId( RID_BASICIDE_BREAKPOINTDLG ) ),
+ aComboBox( this, IDEResId( RID_CB_BRKPOINTS ) ),
+ aOKButton( this, IDEResId( RID_PB_OK ) ),
+ aCancelButton( this, IDEResId( RID_PB_CANCEL ) ),
+ aNewButton( this, IDEResId( RID_PB_NEW ) ),
+ aDelButton( this, IDEResId( RID_PB_DEL ) ),
+ aCheckBox( this, IDEResId( RID_CHKB_ACTIVE ) ),
+ aBrkText( this, IDEResId( RID_FT_BRKPOINTS ) ),
+ aPassText( this, IDEResId( RID_FT_PASS ) ),
+ aNumericField( this, IDEResId( RID_FLD_PASS ) ),
+ m_rOriginalBreakPointList(rBrkPntList),
+ m_aModifiedBreakPointList(rBrkPntList)
+{
+ FreeResource();
+
+ aComboBox.SetUpdateMode( FALSE );
+ BreakPoint* pBrk = m_aModifiedBreakPointList.First();
+ BreakPoint* pFirstBrk = pBrk;
+ while ( pBrk )
+ {
+ String aEntryStr( RTL_CONSTASCII_USTRINGPARAM( "# " ) );
+ aEntryStr += String::CreateFromInt32( pBrk->nLine );
+ aComboBox.InsertEntry( aEntryStr, COMBOBOX_APPEND );
+ pBrk = m_aModifiedBreakPointList.Next();
+ }
+ aComboBox.SetUpdateMode( TRUE );
+
+ aOKButton.SetClickHdl( LINK( this, BreakPointDialog, ButtonHdl ) );
+ aNewButton.SetClickHdl( LINK( this, BreakPointDialog, ButtonHdl ) );
+ aDelButton.SetClickHdl( LINK( this, BreakPointDialog, ButtonHdl ) );
+// aShowButton.SetClickHdl( LINK( this, BreakPointDialog, ButtonHdl ) );
+
+ aCheckBox.SetClickHdl( LINK( this, BreakPointDialog, CheckBoxHdl ) );
+ aComboBox.SetSelectHdl( LINK( this, BreakPointDialog, ComboBoxHighlightHdl ) );
+ aComboBox.SetModifyHdl( LINK( this, BreakPointDialog, EditModifyHdl ) );
+ aComboBox.GrabFocus();
+
+ aNumericField.SetMin( 0 );
+ aNumericField.SetMax( 0x7FFFFFFF );
+ aNumericField.SetSpinSize( 1 );
+ aNumericField.SetStrictFormat( TRUE );
+ aNumericField.SetModifyHdl( LINK( this, BreakPointDialog, EditModifyHdl ) );
+
+ aComboBox.SetText( aComboBox.GetEntry( 0 ) );
+ UpdateFields( pFirstBrk );
+
+ CheckButtons();
+}
+
+void BreakPointDialog::SetCurrentBreakPoint( BreakPoint* pBrk )
+{
+ String aStr( RTL_CONSTASCII_USTRINGPARAM( "# " ) );
+ aStr += String::CreateFromInt32( pBrk->nLine );
+ aComboBox.SetText( aStr );
+ UpdateFields( pBrk );
+}
+
+void BreakPointDialog::CheckButtons()
+{
+ // "New" button is enabled if the combo box edit contains a valid line
+ // number that is not already present in the combo box list; otherwise
+ // "OK" and "Delete" buttons are enabled:
+ USHORT nLine;
+ if (lcl_ParseText(aComboBox.GetText(), nLine)
+ && m_aModifiedBreakPointList.FindBreakPoint(nLine) == 0)
+ {
+ aNewButton.Enable();
+ aOKButton.Disable();
+ aDelButton.Disable();
+ }
+ else
+ {
+ aNewButton.Disable();
+ aOKButton.Enable();
+ aDelButton.Enable();
+ }
+}
+
+IMPL_LINK_INLINE_START( BreakPointDialog, CheckBoxHdl, CheckBox *, pChkBx )
+{
+ BreakPoint* pBrk = GetSelectedBreakPoint();
+ if ( pBrk )
+ pBrk->bEnabled = pChkBx->IsChecked();
+
+ return 0;
+}
+IMPL_LINK_INLINE_END( BreakPointDialog, CheckBoxHdl, CheckBox *, pChkBx )
+
+
+
+IMPL_LINK( BreakPointDialog, ComboBoxHighlightHdl, ComboBox *, pBox )
+{
+ aNewButton.Disable();
+ aOKButton.Enable();
+ aDelButton.Enable();
+
+ USHORT nEntry = pBox->GetEntryPos( pBox->GetText() );
+ BreakPoint* pBrk = m_aModifiedBreakPointList.GetObject( nEntry );
+ DBG_ASSERT( pBrk, "Kein passender Breakpoint zur Liste ?" );
+ UpdateFields( pBrk );
+
+ return 0;
+}
+
+
+
+IMPL_LINK( BreakPointDialog, EditModifyHdl, Edit *, pEdit )
+{
+ if ( pEdit == &aComboBox )
+ CheckButtons();
+ else if ( pEdit == &aNumericField )
+ {
+ BreakPoint* pBrk = GetSelectedBreakPoint();
+ if ( pBrk )
+ pBrk->nStopAfter = pEdit->GetText().ToInt32();
+ }
+ return 0;
+}
+
+
+
+IMPL_LINK( BreakPointDialog, ButtonHdl, Button *, pButton )
+{
+ if ( pButton == &aOKButton )
+ {
+ m_rOriginalBreakPointList.transfer(m_aModifiedBreakPointList);
+ EndDialog( 1 );
+ }
+ else if ( pButton == &aNewButton )
+ {
+ // Checkbox beruecksichtigen!
+ String aText( aComboBox.GetText() );
+ USHORT nLine;
+ BOOL bValid = lcl_ParseText( aText, nLine );
+ if ( bValid )
+ {
+ BreakPoint* pBrk = new BreakPoint( nLine );
+ pBrk->bEnabled = aCheckBox.IsChecked();
+ pBrk->nStopAfter = (ULONG) aNumericField.GetValue();
+ m_aModifiedBreakPointList.InsertSorted( pBrk );
+ String aEntryStr( RTL_CONSTASCII_USTRINGPARAM( "# " ) );
+ aEntryStr += String::CreateFromInt32( pBrk->nLine );
+ aComboBox.InsertEntry( aEntryStr, COMBOBOX_APPEND );
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_BRKPNTSCHANGED );
+ }
+ }
+ else
+ {
+ aComboBox.SetText( aText );
+ aComboBox.GrabFocus();
+ Sound::Beep();
+ }
+ CheckButtons();
+ }
+ else if ( pButton == &aDelButton )
+ {
+ USHORT nEntry = aComboBox.GetEntryPos( aComboBox.GetText() );
+ BreakPoint* pBrk = m_aModifiedBreakPointList.GetObject( nEntry );
+ if ( pBrk )
+ {
+ delete m_aModifiedBreakPointList.Remove( pBrk );
+ aComboBox.RemoveEntry( nEntry );
+ if ( nEntry && !( nEntry < aComboBox.GetEntryCount() ) )
+ nEntry--;
+ aComboBox.SetText( aComboBox.GetEntry( nEntry ) );
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_BRKPNTSCHANGED );
+ }
+ }
+ CheckButtons();
+ }
+// else if ( pButton == &aShowButton )
+// {
+// ;
+// }
+
+ return 0;
+}
+
+
+
+void BreakPointDialog::UpdateFields( BreakPoint* pBrk )
+{
+ if ( pBrk )
+ {
+ aCheckBox.Check( pBrk->bEnabled );
+ aNumericField.SetValue( pBrk->nStopAfter );
+ }
+}
+
+
+
+BreakPoint* BreakPointDialog::GetSelectedBreakPoint()
+{
+ USHORT nEntry = aComboBox.GetEntryPos( aComboBox.GetText() );
+ BreakPoint* pBrk = m_aModifiedBreakPointList.GetObject( nEntry );
+ return pBrk;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/brkdlg.hrc b/basctl/source/basicide/brkdlg.hrc
new file mode 100644
index 000000000000..921990d35e6c
--- /dev/null
+++ b/basctl/source/basicide/brkdlg.hrc
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BRKDLG_HRC
+#define _BRKDLG_HRC
+
+#include <svl/solar.hrc>
+
+#define RID_BASICIDE_BREAKPOINTDLG ( RID_BASICIDE_START + 80 )
+
+#define RID_CB_BRKPOINTS 2
+#define RID_PB_OK 3
+#define RID_PB_CANCEL 4
+#define RID_PB_NEW 5
+#define RID_PB_DEL 6
+#define RID_CHKB_ACTIVE 7
+#define RID_FT_PASS 8
+#define RID_FT_BRKPOINTS 9
+#define RID_FLD_PASS 10
+
+#endif // _BRKDLG_HRC
+
diff --git a/basctl/source/basicide/brkdlg.hxx b/basctl/source/basicide/brkdlg.hxx
new file mode 100644
index 000000000000..04777bb70518
--- /dev/null
+++ b/basctl/source/basicide/brkdlg.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BRKDLG_HXX
+#define _BRKDLG_HXX
+
+#include <svheader.hxx>
+#include <bastypes.hxx>
+#include <vcl/dialog.hxx>
+
+#include <vcl/button.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+
+class BreakPointDialog : public ModalDialog
+{
+private:
+ ComboBox aComboBox;
+ OKButton aOKButton;
+ CancelButton aCancelButton;
+ PushButton aNewButton;
+ PushButton aDelButton;
+// PushButton aShowButton;
+ CheckBox aCheckBox;
+ FixedText aBrkText;
+ FixedText aPassText;
+ NumericField aNumericField;
+
+ BreakPointList & m_rOriginalBreakPointList;
+ BreakPointList m_aModifiedBreakPointList;
+
+protected:
+ void CheckButtons();
+ DECL_LINK( CheckBoxHdl, CheckBox * );
+ DECL_LINK( ComboBoxHighlightHdl, ComboBox * );
+ DECL_LINK( EditModifyHdl, Edit * );
+ DECL_LINK( ButtonHdl, Button * );
+ void UpdateFields( BreakPoint* pBrk );
+ BreakPoint* GetSelectedBreakPoint();
+
+
+public:
+ BreakPointDialog( Window* pParent, BreakPointList& rBrkList );
+
+ void SetCurrentBreakPoint( BreakPoint* pBrk );
+};
+
+#endif // _BRKDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/brkdlg.src b/basctl/source/basicide/brkdlg.src
new file mode 100644
index 000000000000..00fd8fbf8968
--- /dev/null
+++ b/basctl/source/basicide/brkdlg.src
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "helpid.hrc"
+#include <brkdlg.hrc>
+ModalDialog RID_BASICIDE_BREAKPOINTDLG
+{
+ // HelpId = HID_BASICIDE_BRKPNTS ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 178 , 116 ) ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+ ComboBox RID_CB_BRKPOINTS
+ {
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 110 , 70 ) ;
+ TabStop = TRUE ;
+ };
+ OKButton RID_PB_OK
+ {
+ Pos = MAP_APPFONT ( 122 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton RID_PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 122 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton RID_PB_NEW
+ {
+ Pos = MAP_APPFONT ( 122 , 57 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "New" ;
+ };
+ PushButton RID_PB_DEL
+ {
+ Pos = MAP_APPFONT ( 122 , 74 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Löschen : L÷schen */
+ TabStop = TRUE ;
+ Text [ en-US ] = "Delete" ;
+ };
+ CheckBox RID_CHKB_ACTIVE
+ {
+ Pos = MAP_APPFONT ( 6 , 87 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Active" ;
+ };
+ FixedText RID_FT_PASS
+ {
+ Pos = MAP_APPFONT ( 6 , 102 ) ;
+ Size = MAP_APPFONT ( 75 , 10 ) ;
+ Text [ en-US ] = "Pass Count:" ;
+ };
+ FixedText RID_FT_BRKPOINTS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 110, 10 ) ;
+ Text [ en-US ] = "Breakpoints" ;
+ };
+ NumericField RID_FLD_PASS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 81 , 100 ) ;
+ Size = MAP_APPFONT ( 35 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Manage Breakpoints" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/basctl/source/basicide/doceventnotifier.cxx b/basctl/source/basicide/doceventnotifier.cxx
new file mode 100644
index 000000000000..a47c269f2c3d
--- /dev/null
+++ b/basctl/source/basicide/doceventnotifier.cxx
@@ -0,0 +1,280 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include "doceventnotifier.hxx"
+#include "scriptdocument.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/document/XEventBroadcaster.hpp>
+/** === end UNO includes === **/
+
+#include <vcl/svapp.hxx>
+
+#include <tools/diagnose_ex.h>
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <osl/mutex.hxx>
+#include <sal/macros.h>
+
+#include <cppuhelper/compbase1.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+//........................................................................
+namespace basctl
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::document::XEventBroadcaster;
+ using ::com::sun::star::document::XEventListener;
+ using ::com::sun::star::document::EventObject;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::uno::UNO_QUERY;
+ /** === end UNO using === **/
+ namespace csslang = ::com::sun::star::lang;
+
+ //====================================================================
+ //= DocumentEventNotifier_Impl
+ //====================================================================
+ typedef ::cppu::WeakComponentImplHelper1 < XEventListener
+ > DocumentEventNotifier_Impl_Base;
+
+ enum ListenerAction
+ {
+ RegisterListener,
+ RemoveListener
+ };
+
+ /** impl class for DocumentEventNotifier
+ */
+ class DocumentEventNotifier_Impl :public ::boost::noncopyable
+ ,public ::cppu::BaseMutex
+ ,public DocumentEventNotifier_Impl_Base
+ {
+ public:
+ DocumentEventNotifier_Impl( DocumentEventListener& _rListener, const Reference< XModel >& _rxDocument );
+
+ // document::XEventListener
+ virtual void SAL_CALL notifyEvent( const EventObject& Event ) throw (RuntimeException);
+
+ // lang::XEventListener
+ virtual void SAL_CALL disposing( const csslang::EventObject& Event ) throw (RuntimeException);
+
+ // ComponentHelper
+ virtual void SAL_CALL disposing();
+
+ protected:
+ ~DocumentEventNotifier_Impl();
+
+ private:
+ /// determines whether the instance is already disposed
+ bool impl_isDisposed_nothrow() const { return m_pListener == NULL; }
+
+ /// disposes the instance
+ void impl_dispose_nothrow();
+
+ /// registers or revokes the instance as listener at the global event broadcaster
+ void impl_listenerAction_nothrow( ListenerAction _eAction );
+
+ private:
+ DocumentEventListener* m_pListener;
+ Reference< XModel > m_xModel;
+ };
+
+ //--------------------------------------------------------------------
+ DocumentEventNotifier_Impl::DocumentEventNotifier_Impl( DocumentEventListener& _rListener, const Reference< XModel >& _rxDocument )
+ :DocumentEventNotifier_Impl_Base( m_aMutex )
+ ,m_pListener( &_rListener )
+ ,m_xModel( _rxDocument )
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ impl_listenerAction_nothrow( RegisterListener );
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ DocumentEventNotifier_Impl::~DocumentEventNotifier_Impl()
+ {
+ if ( !impl_isDisposed_nothrow() )
+ {
+ acquire();
+ dispose();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DocumentEventNotifier_Impl::notifyEvent( const EventObject& _rEvent ) throw (RuntimeException)
+ {
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ OSL_PRECOND( !impl_isDisposed_nothrow(), "DocumentEventNotifier_Impl::notifyEvent: disposed, but still getting events?" );
+ if ( impl_isDisposed_nothrow() )
+ return;
+
+ Reference< XModel > xDocument( _rEvent.Source, UNO_QUERY );
+ OSL_ENSURE( xDocument.is(), "DocumentEventNotifier_Impl::notifyEvent: illegal source document!" );
+ if ( !xDocument.is() )
+ return;
+
+ struct EventEntry
+ {
+ const sal_Char* pEventName;
+ void (DocumentEventListener::*listenerMethod)( const ScriptDocument& _rDocument );
+ };
+ EventEntry aEvents[] = {
+ { "OnNew", &DocumentEventListener::onDocumentCreated },
+ { "OnLoad", &DocumentEventListener::onDocumentOpened },
+ { "OnSave", &DocumentEventListener::onDocumentSave },
+ { "OnSaveDone", &DocumentEventListener::onDocumentSaveDone },
+ { "OnSaveAs", &DocumentEventListener::onDocumentSaveAs },
+ { "OnSaveAsDone", &DocumentEventListener::onDocumentSaveAsDone },
+ { "OnUnload", &DocumentEventListener::onDocumentClosed },
+ { "OnTitleChanged", &DocumentEventListener::onDocumentTitleChanged },
+ { "OnModeChanged", &DocumentEventListener::onDocumentModeChanged }
+ };
+
+ for ( size_t i=0; i < SAL_N_ELEMENTS( aEvents ); ++i )
+ {
+ if ( !_rEvent.EventName.equalsAscii( aEvents[i].pEventName ) )
+ continue;
+
+ ScriptDocument aDocument( xDocument );
+ {
+ // the listener implementations usually require the SolarMutex, so lock it here.
+ // But ensure the proper order of locking the solar and the own mutex
+ aGuard.clear();
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard2( m_aMutex );
+
+ if ( impl_isDisposed_nothrow() )
+ // somebody took the chance to dispose us -> bail out
+ return;
+
+ (m_pListener->*aEvents[i].listenerMethod)( aDocument );
+ }
+ break;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DocumentEventNotifier_Impl::disposing( const csslang::EventObject& /*Event*/ ) throw (RuntimeException)
+ {
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !impl_isDisposed_nothrow() )
+ impl_dispose_nothrow();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DocumentEventNotifier_Impl::disposing()
+ {
+ impl_listenerAction_nothrow( RemoveListener );
+ impl_dispose_nothrow();
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier_Impl::impl_dispose_nothrow()
+ {
+ m_pListener = NULL;
+ m_xModel.clear();
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier_Impl::impl_listenerAction_nothrow( ListenerAction _eAction )
+ {
+ try
+ {
+ Reference< XEventBroadcaster > xBroadcaster;
+ if ( m_xModel.is() )
+ xBroadcaster.set( m_xModel, UNO_QUERY_THROW );
+ else
+ {
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ xBroadcaster.set(
+ aContext.createComponent( "com.sun.star.frame.GlobalEventBroadcaster" ),
+ UNO_QUERY_THROW );
+ }
+
+ void ( SAL_CALL XEventBroadcaster::*listenerAction )( const Reference< XEventListener >& ) =
+ ( _eAction == RegisterListener ) ? &XEventBroadcaster::addEventListener : &XEventBroadcaster::removeEventListener;
+ (xBroadcaster.get()->*listenerAction)( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //====================================================================
+ //= DocumentEventNotifier
+ //====================================================================
+ //--------------------------------------------------------------------
+ DocumentEventNotifier::DocumentEventNotifier( DocumentEventListener& _rListener, const Reference< XModel >& _rxDocument )
+ :m_pImpl( new DocumentEventNotifier_Impl( _rListener, _rxDocument ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DocumentEventNotifier::DocumentEventNotifier( DocumentEventListener& _rListener )
+ :m_pImpl( new DocumentEventNotifier_Impl( _rListener, Reference< XModel >() ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DocumentEventNotifier::~DocumentEventNotifier()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEventNotifier::dispose()
+ {
+ m_pImpl->dispose();
+ }
+
+ //====================================================================
+ //= DocumentEventListener
+ //====================================================================
+ DocumentEventListener::~DocumentEventListener()
+ {
+ }
+
+//........................................................................
+} // namespace basctl
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/docsignature.cxx b/basctl/source/basicide/docsignature.cxx
new file mode 100644
index 000000000000..19cf14004612
--- /dev/null
+++ b/basctl/source/basicide/docsignature.cxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include "docsignature.hxx"
+#include "scriptdocument.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <sfx2/objsh.hxx>
+#include <sfx2/signaturestate.hxx>
+
+//........................................................................
+namespace basctl
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::frame::XModel;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= DocumentSignature_Data
+ //====================================================================
+ struct DocumentSignature_Data
+ {
+ SfxObjectShell* pShell;
+
+ DocumentSignature_Data() : pShell( NULL ) { }
+ };
+
+ //====================================================================
+ //= DocumentSignature
+ //====================================================================
+ //--------------------------------------------------------------------
+ DocumentSignature::DocumentSignature( const ScriptDocument& _rDocument )
+ :m_pData( new DocumentSignature_Data )
+ {
+ if ( _rDocument.isDocument() )
+ {
+ Reference< XModel > xDocument( _rDocument.getDocument() );
+ // find object shell for document
+ SfxObjectShell* pShell = SfxObjectShell::GetFirst();
+ while ( pShell )
+ {
+ if ( pShell->GetModel() == xDocument )
+ break;
+ pShell = SfxObjectShell::GetNext( *pShell );
+ }
+ m_pData->pShell = pShell;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ DocumentSignature::~DocumentSignature()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool DocumentSignature::supportsSignatures() const
+ {
+ return ( m_pData->pShell != NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentSignature::signScriptingContent() const
+ {
+ OSL_PRECOND( supportsSignatures(), "DocumentSignature::signScriptingContent: signatures not supported by this document!" );
+ if ( m_pData->pShell )
+ m_pData->pShell->SignScriptingContent();
+ }
+
+ //--------------------------------------------------------------------
+ sal_uInt16 DocumentSignature::getScriptingSignatureState() const
+ {
+ if ( m_pData->pShell )
+ return m_pData->pShell->GetScriptingSignatureState();
+ return SIGNATURESTATE_NOSIGNATURES;
+ }
+
+//........................................................................
+} // namespace basctl
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/documentenumeration.cxx b/basctl/source/basicide/documentenumeration.cxx
new file mode 100644
index 000000000000..e9cfa14b1ee0
--- /dev/null
+++ b/basctl/source/basicide/documentenumeration.cxx
@@ -0,0 +1,206 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include "documentenumeration.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+
+#include <comphelper/stl_types.hxx>
+
+//........................................................................
+namespace basctl { namespace docs {
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::frame::XDesktop;
+ using ::com::sun::star::container::XEnumerationAccess;
+ using ::com::sun::star::container::XEnumeration;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::frame::XFramesSupplier;
+ using ::com::sun::star::frame::XFrames;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::frame::XModel2;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::frame::XFrame;
+ /** === end UNO using === **/
+ namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag;
+
+ //====================================================================
+ //= DocumentEnumeration_Data
+ //====================================================================
+ struct DocumentEnumeration_Data
+ {
+ ::comphelper::ComponentContext aContext;
+ const IDocumentDescriptorFilter* pFilter;
+
+ DocumentEnumeration_Data( const ::comphelper::ComponentContext& _rContext, const IDocumentDescriptorFilter* _pFilter )
+ :aContext( _rContext )
+ ,pFilter( _pFilter )
+ {
+ }
+ };
+
+ //====================================================================
+ //= DocumentEnumeration
+ //====================================================================
+ //--------------------------------------------------------------------
+ DocumentEnumeration::DocumentEnumeration( const ::comphelper::ComponentContext& _rContext, const IDocumentDescriptorFilter* _pFilter )
+ :m_pData( new DocumentEnumeration_Data( _rContext, _pFilter ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DocumentEnumeration::~DocumentEnumeration()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ //................................................................
+ void lcl_getDocumentControllers_nothrow( DocumentDescriptor& _io_rDocDesc )
+ {
+ OSL_PRECOND( _io_rDocDesc.xModel.is(), "lcl_getDocumentControllers_nothrow: illegal model!" );
+
+ _io_rDocDesc.aControllers.clear();
+ try
+ {
+ Reference< XModel2 > xModel2( _io_rDocDesc.xModel, UNO_QUERY );
+ if ( xModel2.is() )
+ {
+ Reference< XEnumeration > xEnum( xModel2->getControllers(), UNO_SET_THROW );
+ while ( xEnum->hasMoreElements() )
+ {
+ Reference< XController > xController( xEnum->nextElement(), UNO_QUERY_THROW );
+ _io_rDocDesc.aControllers.push_back( xController );
+ }
+ }
+ else if ( _io_rDocDesc.xModel.is() )
+ _io_rDocDesc.aControllers.push_back( _io_rDocDesc.xModel->getCurrentController() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //................................................................
+ void lcl_getDocuments_nothrow( const Sequence< Reference< XFrame > >& _rFrames, Documents& _out_rDocuments,
+ const IDocumentDescriptorFilter* _pFilter )
+ {
+ // ensure we don't encounter some models multiple times
+ ::std::set< Reference< XModel >, ::comphelper::OInterfaceCompare< XModel > > aEncounteredModels;
+
+ for ( const Reference< XFrame >* pFrame = _rFrames.getConstArray();
+ pFrame != _rFrames.getConstArray() + _rFrames.getLength();
+ ++pFrame
+ )
+ {
+ try
+ {
+ OSL_ENSURE( pFrame->is(), "lcl_getDocuments_nothrow: illegal frame!" );
+ if ( !pFrame->is() )
+ continue;
+ Reference< XController > xController( (*pFrame)->getController() );
+ if ( !xController.is() )
+ continue;
+
+ Reference< XModel > xModel( xController->getModel() );
+ if ( !xModel.is() )
+ // though it's legal for a controller to not have a model, we're not interested in
+ // those
+ continue;
+
+ if ( aEncounteredModels.find( xModel ) != aEncounteredModels.end() )
+ // there might be multiple frames for the same model
+ // handle it only once
+ continue;
+ aEncounteredModels.insert( xModel );
+
+ // create a DocumentDescriptor
+ DocumentDescriptor aDescriptor;
+ aDescriptor.xModel = xModel;
+ lcl_getDocumentControllers_nothrow( aDescriptor );
+
+ // consult filter, if there is one
+ if ( _pFilter && !_pFilter->includeDocument( aDescriptor ) )
+ continue;
+
+ _out_rDocuments.push_back( aDescriptor );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void DocumentEnumeration::getDocuments( Documents& _out_rDocuments ) const
+ {
+ _out_rDocuments.clear();
+
+ try
+ {
+ const Reference< XDesktop > xDesktop( m_pData->aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW );
+ const Reference< XFramesSupplier > xSuppFrames( xDesktop, UNO_QUERY_THROW );
+ const Reference< XFrames > xFrames( xSuppFrames->getFrames(), UNO_SET_THROW );
+ const Sequence< Reference< XFrame > > aFrames( xFrames->queryFrames( FrameSearchFlag::ALL ) );
+
+ lcl_getDocuments_nothrow( aFrames, _out_rDocuments, m_pData->pFilter );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+//........................................................................
+} } // namespace basctl::docs
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/documentenumeration.hxx b/basctl/source/basicide/documentenumeration.hxx
new file mode 100644
index 000000000000..6778c676c15c
--- /dev/null
+++ b/basctl/source/basicide/documentenumeration.hxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef BASCTL_DOCUMENTENUMERATION_HXX
+#define BASCTL_DOCUMENTENUMERATION_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XController.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+
+#include <memory>
+#include <vector>
+
+//........................................................................
+namespace basctl { namespace docs {
+//........................................................................
+
+ typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > Model;
+ typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > > Controllers;
+
+ struct DocumentDescriptor
+ {
+ Model xModel;
+ Controllers aControllers;
+ };
+
+ typedef ::std::vector< DocumentDescriptor > Documents;
+
+ //====================================================================
+ //= IDocumentDescriptorFilter
+ //====================================================================
+ /// allows pre-filtering when enumerating document descriptors
+ class SAL_NO_VTABLE IDocumentDescriptorFilter
+ {
+ public:
+ virtual bool includeDocument( const DocumentDescriptor& _rDocument ) const = 0;
+ };
+
+ //====================================================================
+ //= DocumentEnumeration
+ //====================================================================
+ struct DocumentEnumeration_Data;
+ /** is a helper class for enumerating documents in OOo
+
+ If you need a list of all open documents in OOo, this is little bit of
+ a hassle: You need to iterate though all components at the desktop, which
+ might or might not be documents.
+
+ Additionally, you need to examine the existing documents' frames
+ for sub frames, which might contain sub documents (e.g. embedded objects
+ edited out-place).
+
+ DocumentEnumeration relieves you from this hassle.
+ */
+ class DocumentEnumeration
+ {
+ public:
+ DocumentEnumeration( const ::comphelper::ComponentContext& _rContext, const IDocumentDescriptorFilter* _pFilter = NULL );
+ ~DocumentEnumeration();
+
+ /** retrieves a list of all currently known documents in the application
+
+ @param _out_rDocuments
+ output parameter taking the collected document information
+ @
+ */
+ void getDocuments(
+ Documents& _out_rDocuments
+ ) const;
+
+ private:
+ ::std::auto_ptr< DocumentEnumeration_Data > m_pData;
+ };
+
+//........................................................................
+} } // namespace basctl::docs
+//........................................................................
+
+#endif // BASCTL_DOCUMENTENUMERATION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/ide_pch.cxx b/basctl/source/basicide/ide_pch.cxx
new file mode 100644
index 000000000000..44937011dc2f
--- /dev/null
+++ b/basctl/source/basicide/ide_pch.cxx
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+#include <ide_pch.hxx>
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/ide_pch.hxx b/basctl/source/basicide/ide_pch.hxx
new file mode 100644
index 000000000000..d30218e73c50
--- /dev/null
+++ b/basctl/source/basicide/ide_pch.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <svheader.hxx>
+
+#define ITEMID_SEARCH 0
+#define ITEMID_SIZE 0
+
+#include <vcl/wrkwin.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/menu.hxx>
+
+#include <svl/svarray.hxx>
+#include <svl/itemset.hxx>
+#include <svl/aeitem.hxx>
+#include <svl/stritem.hxx>
+#include <svl/whiter.hxx>
+#include <svl/intitem.hxx>
+#include <svl/srchitem.hxx>
+
+#define _BASIC_TEXTPORTIONS
+#include <basic/sbdef.hxx>
+#include <basic/sbstar.hxx>
+#include <basic/sbmeth.hxx>
+#include <basic/sbmod.hxx>
+#include <basic/basmgr.hxx>
+
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/event.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/childwin.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/genlink.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/minfitem.hxx>
+#include <sfx2/dinfdlg.hxx>
+#include <sfx2/docfac.hxx>
+#include <sfx2/progress.hxx>
+#include <editeng/sizeitem.hxx>
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/iderdll.cxx b/basctl/source/basicide/iderdll.cxx
new file mode 100644
index 000000000000..dd06ff421860
--- /dev/null
+++ b/basctl/source/basicide/iderdll.cxx
@@ -0,0 +1,232 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include <ide_pch.hxx>
+
+
+#include <svheader.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/genlink.hxx>
+
+
+#include <svl/solar.hrc>
+#include <iderdll.hxx>
+#include <iderdll2.hxx>
+#include <iderid.hxx>
+#include <svx/svxids.hrc>
+#include <basidesh.hxx>
+#include <basidesh.hrc>
+#include <basobj.hxx>
+#include <bastypes.hxx>
+#include <basdoc.hxx>
+#include <basicmod.hxx>
+#include <propbrw.hxx>
+
+
+#define ITEMID_SEARCH 0
+#include <svl/srchitem.hxx>
+#include <com/sun/star/script/XLibraryContainerPassword.hpp>
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+static BasicIDEDLL* pBasicIDEDLL = 0;
+
+BasicIDEDLL* BasicIDEDLL::GetDLL()
+{
+ return pBasicIDEDLL;
+}
+
+IDEResId::IDEResId( USHORT nId ):
+ ResId( nId, *(*(BasicIDEModule**)GetAppData(SHL_IDE))->GetResMgr() )
+{
+}
+
+BasicIDEDLL::BasicIDEDLL()
+{
+ pBasicIDEDLL = this;
+ pShell = 0;
+ pExtraData = 0;
+
+ GetExtraData(); // damit GlobalErrorHdl gesetzt wird.
+}
+
+BasicIDEDLL::~BasicIDEDLL()
+{
+ delete pExtraData;
+ *(BasicIDEDLL**)GetAppData(SHL_IDE) = NULL;
+}
+
+void BasicIDEDLL::Init()
+{
+ if ( pBasicIDEDLL )
+ return;
+
+ SfxObjectFactory* pFact = &BasicDocShell::Factory();
+ (void)pFact;
+
+ ByteString aResMgrName( "basctl" );
+ ResMgr* pMgr = ResMgr::CreateResMgr(
+ aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
+
+ BASIC_MOD() = new BasicIDEModule( pMgr, &BasicDocShell::Factory() );
+
+ new BasicIDEDLL;
+ SfxModule* pMod = BASIC_MOD();
+
+ SfxObjectFactory& rFactory = BasicDocShell::Factory();
+ rFactory.SetDocumentServiceName( String::CreateFromAscii( "com.sun.star.script.BasicIDE" ) );
+
+ BasicDocShell::RegisterInterface( pMod );
+ BasicIDEShell::RegisterFactory( SVX_INTERFACE_BASIDE_VIEWSH );
+ BasicIDEShell::RegisterInterface( pMod );
+
+ PropBrwMgr::RegisterChildWindow();
+}
+
+/*************************************************************************
+|*
+|* Deinitialisierung
+|*
+\************************************************************************/
+void BasicIDEDLL::Exit()
+{
+ // the BasicIDEModule must be destroyed
+ BasicIDEModule** ppShlPtr = (BasicIDEModule**) GetAppData(SHL_IDE);
+ delete (*ppShlPtr);
+ (*ppShlPtr) = NULL;
+ DELETEZ( pBasicIDEDLL );
+}
+
+BasicIDEData* BasicIDEDLL::GetExtraData()
+{
+ if ( !pExtraData )
+ pExtraData = new BasicIDEData;
+ return pExtraData;
+}
+
+BasicIDEData::BasicIDEData() : aObjCatPos( INVPOSITION, INVPOSITION )
+{
+ nBasicDialogCount = 0;
+ bChoosingMacro = FALSE;
+ bShellInCriticalSection = FALSE;
+ pSearchItem = new SvxSearchItem( SID_SEARCH_ITEM );
+
+ StarBASIC::SetGlobalBreakHdl( LINK( this, BasicIDEData, GlobalBasicBreakHdl ) );
+
+ pAccelerator = 0;
+}
+
+BasicIDEData::~BasicIDEData()
+{
+ // ErrorHdl zuruecksetzen ist zwar sauberer, aber diese Instanz wird
+ // sowieso sehr spaet, nach dem letzten Basic, zerstoert.
+ // Durch den Aufruf werden dann aber wieder AppDaten erzeugt und nicht
+ // mehr zerstoert => MLK's beim Purify
+// StarBASIC::SetGlobalErrorHdl( Link() );
+// StarBASIC::SetGlobalBreakHdl( Link() );
+// StarBASIC::setGlobalStarScriptListener( XEngineListenerRef() );
+
+ delete pSearchItem;
+ //delete pAccelerator;
+}
+
+SvxSearchItem& BasicIDEData::GetSearchItem() const
+{
+ return *pSearchItem;
+}
+
+void BasicIDEData::SetSearchItem( const SvxSearchItem& rItem )
+{
+ delete pSearchItem;
+ pSearchItem = (SvxSearchItem*)rItem.Clone();
+}
+
+IMPL_LINK( BasicIDEData, GlobalBasicBreakHdl, StarBASIC *, pBasic )
+{
+ long nRet = 0;
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if ( pIDEShell )
+ {
+ BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
+ if ( pBasMgr )
+ {
+ // Hier lande ich zweimal, wenn Step into protected Basic
+ // => schlecht, wenn Passwortabfrage 2x, ausserdem sieht man in
+ // dem PasswordDlg nicht, fuer welche Lib...
+ // => An dieser Stelle keine Passwort-Abfrage starten
+ ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
+ OSL_ENSURE( aDocument.isValid(), "BasicIDEData::GlobalBasicBreakHdl: no document for the basic manager!" );
+ if ( aDocument.isValid() )
+ {
+ ::rtl::OUString aOULibName( pBasic->GetName() );
+ Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
+ {
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
+ {
+ // Ein Step-Out muesste mich aus den geschuetzten Bereich befoerdern...
+ nRet = SbDEBUG_STEPOUT;
+ }
+ else
+ {
+ nRet = pIDEShell->CallBasicBreakHdl( pBasic );
+ }
+ }
+ }
+ }
+ }
+
+ return nRet;
+}
+
+IMPL_LINK( BasicIDEData, ExecuteMacroEvent, void *, pData )
+{
+ if ( pData )
+ {
+ SFX_APP()->EnterBasicCall();
+ SbMethod* pMethod = (SbMethod*)pData;
+
+ // Ist es eine StarScript-Methode? Am Parent erkennen
+ DBG_ASSERT( pMethod->GetParent()->GetFlags() & SBX_EXTSEARCH, "Kein EXTSEARCH!" );
+ BasicIDE::RunMethod( pMethod );
+ pMethod->ReleaseRef(); // muss vorher inkrementiert worden sein!
+ SFX_APP()->LeaveBasicCall();
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/iderdll2.hxx b/basctl/source/basicide/iderdll2.hxx
new file mode 100644
index 000000000000..e79c11721ed6
--- /dev/null
+++ b/basctl/source/basicide/iderdll2.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _IDERDLL2_HXX
+#define _IDERDLL2_HXX
+
+class StarBASIC;
+class SvxSearchItem;
+class Accelerator;
+
+#include <tools/string.hxx>
+#include <tools/gen.hxx>
+#include <tools/link.hxx>
+
+#include <bastypes.hxx>
+#include <bastype2.hxx>
+
+#define INVPOSITION 0x7fff
+
+class BasicIDEData
+{
+private:
+ Accelerator* pAccelerator;
+ SvxSearchItem* pSearchItem;
+
+ LibInfos aLibInfos;
+
+ BasicEntryDescriptor m_aLastEntryDesc;
+
+ Point aObjCatPos;
+ Size aObjCatSize;
+
+ String aAddLibPath;
+ String aAddLibFilter;
+
+ USHORT nBasicDialogCount;
+
+ BOOL OLD_bRelMacroRecording;
+ BOOL bChoosingMacro;
+ BOOL bShellInCriticalSection;
+
+protected:
+ DECL_LINK( GlobalBasicBreakHdl, StarBASIC * );
+
+public:
+ BasicIDEData();
+ ~BasicIDEData();
+
+ LibInfos& GetLibInfos() { return aLibInfos; }
+
+ BasicEntryDescriptor& GetLastEntryDescriptor() { return m_aLastEntryDesc; }
+ void SetLastEntryDescriptor( BasicEntryDescriptor& rDesc ) { m_aLastEntryDesc = rDesc; }
+
+ BOOL& ChoosingMacro() { return bChoosingMacro; }
+ BOOL& ShellInCriticalSection() { return bShellInCriticalSection; }
+
+ USHORT GetBasicDialogCount() const { return nBasicDialogCount; }
+ void IncBasicDialogCount() { nBasicDialogCount++; }
+ void DecBasicDialogCount() { nBasicDialogCount--; }
+
+ SvxSearchItem& GetSearchItem() const;
+ void SetSearchItem( const SvxSearchItem& rItem );
+
+ void SetObjectCatalogPos( const Point& rPnt )
+ { aObjCatPos = rPnt; }
+ const Point& GetObjectCatalogPos() const
+ { return aObjCatPos; }
+
+ void SetObjectCatalogSize( const Size& rSize )
+ { aObjCatSize = rSize; }
+ const Size& GetObjectCatalogSize() const
+ { return aObjCatSize; }
+
+ const String& GetAddLibPath() const { return aAddLibPath; }
+ void SetAddLibPath( const String& rPath ) { aAddLibPath = rPath; }
+
+ const String& GetAddLibFilter() const { return aAddLibFilter; }
+ void SetAddLibFilter( const String& rFilter ) { aAddLibFilter = rFilter; }
+
+ DECL_LINK( ExecuteMacroEvent, void * );
+};
+
+
+#endif //_IDERDLL2_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/idetemp.hxx b/basctl/source/basicide/idetemp.hxx
new file mode 100644
index 000000000000..7700d94f0748
--- /dev/null
+++ b/basctl/source/basicide/idetemp.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _IDETEMP_HXX
+#define _IDETEMP_HXX
+
+
+enum SvxChooseControlEnum
+{
+ SVX_SNAP_PUSHBUTTON,
+ SVX_SNAP_CHECKBOX,
+ SVX_SNAP_RADIOBUTTON,
+ SVX_SNAP_SPINBUTTON,
+ SVX_SNAP_FIXEDTEXT,
+ SVX_SNAP_GROUPBOX,
+ SVX_SNAP_LISTBOX,
+ SVX_SNAP_COMBOBOX,
+ SVX_SNAP_EDIT,
+ SVX_SNAP_HSCROLLBAR,
+ SVX_SNAP_VSCROLLBAR,
+ SVX_SNAP_PREVIEW,
+ SVX_SNAP_SELECT,
+ SVX_SNAP_URLBUTTON,
+ SVX_SNAP_NOTHING,
+ SVX_SNAP_IMAGECONTROL,
+ SVX_SNAP_PROGRESSBAR,
+ SVX_SNAP_HFIXEDLINE,
+ SVX_SNAP_VFIXEDLINE,
+ SVX_SNAP_DATEFIELD,
+ SVX_SNAP_TIMEFIELD,
+ SVX_SNAP_NUMERICFIELD,
+ SVX_SNAP_CURRENCYFIELD,
+ SVX_SNAP_FORMATTEDFIELD,
+ SVX_SNAP_PATTERNFIELD,
+ SVX_SNAP_FILECONTROL,
+ SVX_SNAP_TREECONTROL
+};
+
+#define SvxChooseControlItem SfxAllEnumItem
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/localizationmgr.cxx b/basctl/source/basicide/localizationmgr.cxx
new file mode 100644
index 000000000000..bd0259fe0637
--- /dev/null
+++ b/basctl/source/basicide/localizationmgr.cxx
@@ -0,0 +1,1228 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_basctl.hxx"
+#include <ide_pch.hxx>
+
+#include <basidesh.hxx>
+#include <baside3.hxx>
+#include <basobj.hxx>
+#include <iderdll.hxx>
+#include "dlged.hxx"
+
+#include <localizationmgr.hxx>
+#include <com/sun/star/resource/XStringResourceSupplier.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::resource;
+
+static ::rtl::OUString aDot = ::rtl::OUString::createFromAscii( "." );
+static ::rtl::OUString aEsc = ::rtl::OUString::createFromAscii( "&" );
+static ::rtl::OUString aSemi = ::rtl::OUString::createFromAscii( ";" );
+
+
+LocalizationMgr::LocalizationMgr( BasicIDEShell* pIDEShell,
+ const ScriptDocument& rDocument, String aLibName,
+ const Reference< XStringResourceManager >& xStringResourceManager )
+ : m_xStringResourceManager( xStringResourceManager )
+ , m_pIDEShell( pIDEShell )
+ , m_aDocument( rDocument )
+ , m_aLibName( aLibName )
+{
+}
+
+bool LocalizationMgr::isLibraryLocalized( void )
+{
+ bool bRet = false;
+ if( m_xStringResourceManager.is() )
+ {
+ Sequence< Locale > aLocaleSeq = m_xStringResourceManager->getLocales();
+ bRet = ( aLocaleSeq.getLength() > 0 );
+ }
+ return bRet;
+}
+
+void LocalizationMgr::handleTranslationbar( void )
+{
+ static ::rtl::OUString aLayoutManagerName = ::rtl::OUString::createFromAscii( "LayoutManager" );
+ static ::rtl::OUString aToolBarResName =
+ ::rtl::OUString::createFromAscii( "private:resource/toolbar/translationbar" );
+
+ Reference< beans::XPropertySet > xFrameProps
+ ( m_pIDEShell->GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
+ if ( xFrameProps.is() )
+ {
+ Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
+ uno::Any a = xFrameProps->getPropertyValue( aLayoutManagerName );
+ a >>= xLayoutManager;
+ if ( xLayoutManager.is() )
+ {
+ if ( !isLibraryLocalized() )
+ {
+ xLayoutManager->destroyElement( aToolBarResName );
+ }
+ else
+ {
+ xLayoutManager->createElement( aToolBarResName );
+ xLayoutManager->requestElement( aToolBarResName );
+ }
+ }
+ }
+}
+
+
+//============================================
+// TODO: -> export from toolkit
+
+struct LanguageDependentProp
+{
+ const char* pPropName;
+ sal_Int32 nPropNameLength;
+};
+
+static LanguageDependentProp aLanguageDependentProp[] =
+{
+ { "Text", 4 },
+ { "Label", 5 },
+ { "Title", 5 },
+ { "HelpText", 8 },
+ { "CurrencySymbol", 14 },
+ { "StringItemList", 14 },
+ { 0, 0 }
+};
+
+bool isLanguageDependentProperty( ::rtl::OUString aName )
+{
+ bool bRet = false;
+
+ LanguageDependentProp* pLangDepProp = aLanguageDependentProp;
+ while( pLangDepProp->pPropName != 0 )
+ {
+ if( aName.equalsAsciiL( pLangDepProp->pPropName, pLangDepProp->nPropNameLength ))
+ {
+ bRet = true;
+ break;
+ }
+ pLangDepProp++;
+ }
+ return bRet;
+}
+//============================================
+
+void LocalizationMgr::implEnableDisableResourceForAllLibraryDialogs( HandleResourceMode eMode )
+{
+ Sequence< ::rtl::OUString > aDlgNames = m_aDocument.getObjectNames( E_DIALOGS, m_aLibName );
+ sal_Int32 nDlgCount = aDlgNames.getLength();
+ const ::rtl::OUString* pDlgNames = aDlgNames.getConstArray();
+
+ Reference< XStringResourceResolver > xDummyStringResolver;
+ for( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
+ {
+ String aDlgName = pDlgNames[ i ];
+ DialogWindow* pWin = m_pIDEShell->FindDlgWin( m_aDocument, m_aLibName, aDlgName, FALSE );
+ if( pWin && pWin->IsA( TYPE( DialogWindow ) ) )
+ {
+ DialogWindow* pDialogWin = static_cast< DialogWindow* >( pWin );
+ Reference< container::XNameContainer > xDialog = pDialogWin->GetDialog();
+ if( xDialog.is() )
+ {
+ // Handle dialog itself as control
+ Any aDialogCtrl;
+ aDialogCtrl <<= xDialog;
+ implHandleControlResourceProperties( aDialogCtrl, aDlgName,
+ ::rtl::OUString(), m_xStringResourceManager, xDummyStringResolver, eMode );
+
+ // Handle all controls
+ Sequence< ::rtl::OUString > aNames = xDialog->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+ for( sal_Int32 j = 0 ; j < nCtrls ; ++j )
+ {
+ ::rtl::OUString aCtrlName( pNames[j] );
+ Any aCtrl = xDialog->getByName( aCtrlName );
+ implHandleControlResourceProperties( aCtrl, aDlgName,
+ aCtrlName, m_xStringResourceManager, xDummyStringResolver, eMode );
+ }
+ }
+ }
+ }
+}
+
+
+::rtl::OUString implCreatePureResourceId
+ ( const ::rtl::OUString& aDialogName, const ::rtl::OUString& aCtrlName,
+ const ::rtl::OUString& aPropName,
+ Reference< XStringResourceManager > xStringResourceManager )
+{
+ sal_Int32 nUniqueId = xStringResourceManager->getUniqueNumericId();
+ ::rtl::OUString aPureIdStr = ::rtl::OUString::valueOf( nUniqueId );
+ aPureIdStr += aDot;
+ aPureIdStr += aDialogName;
+ aPureIdStr += aDot;
+ if( aCtrlName.getLength() )
+ {
+ aPureIdStr += aCtrlName;
+ aPureIdStr += aDot;
+ }
+ aPureIdStr += aPropName;
+ return aPureIdStr;
+}
+
+extern bool localesAreEqual( const ::com::sun::star::lang::Locale& rLocaleLeft,
+ const ::com::sun::star::lang::Locale& rLocaleRight );
+
+// Works on xStringResourceManager's current language for SET_IDS/RESET_IDS,
+// anyway only one language should exist when calling this method then,
+// either the first one for mode SET_IDS or the last one for mode RESET_IDS
+sal_Int32 LocalizationMgr::implHandleControlResourceProperties
+ ( Any aControlAny, const ::rtl::OUString& aDialogName, const ::rtl::OUString& aCtrlName,
+ Reference< XStringResourceManager > xStringResourceManager,
+ Reference< XStringResourceResolver > xSourceStringResolver, HandleResourceMode eMode )
+{
+ sal_Int32 nChangedCount = 0;
+
+ Reference< XPropertySet > xPropertySet;
+ aControlAny >>= xPropertySet;
+ if( xPropertySet.is() )
+ {
+ Sequence< Locale > aLocaleSeq = xStringResourceManager->getLocales();
+ sal_Int32 nLocaleCount = aLocaleSeq.getLength();
+ if( nLocaleCount == 0 )
+ return 0;
+
+ Reference< XPropertySetInfo > xPropertySetInfo = xPropertySet->getPropertySetInfo();
+ if( xPropertySetInfo.is() )
+ {
+ // get sequence of control properties
+ Sequence< Property > aPropSeq = xPropertySetInfo->getProperties();
+ const Property* pProps = aPropSeq.getConstArray();
+ sal_Int32 nCtrlProps = aPropSeq.getLength();
+
+ // create a map of tab indices and control names, sorted by tab index
+ for( sal_Int32 j = 0 ; j < nCtrlProps ; ++j )
+ {
+ const Property& rProp = pProps[j];
+ ::rtl::OUString aPropName = rProp.Name;
+ TypeClass eType = rProp.Type.getTypeClass();
+ bool bLanguageDependentProperty =
+ (eType == TypeClass_STRING || eType == TypeClass_SEQUENCE)
+ && isLanguageDependentProperty( aPropName );
+ if( !bLanguageDependentProperty )
+ continue;
+
+ if( eType == TypeClass_STRING )
+ {
+ Any aPropAny = xPropertySet->getPropertyValue( aPropName );
+ ::rtl::OUString aPropStr;
+ aPropAny >>= aPropStr;
+
+ // Replace string by id, add id+string to StringResource
+ if( eMode == SET_IDS )
+ {
+ bool bEscAlreadyExisting = (aPropStr.getLength() && aPropStr.getStr()[0] == '&' );
+ if( bEscAlreadyExisting )
+ continue;
+
+ ::rtl::OUString aPureIdStr = implCreatePureResourceId
+ ( aDialogName, aCtrlName, aPropName, xStringResourceManager );
+
+ // Set Id for all locales
+ const Locale* pLocales = aLocaleSeq.getConstArray();
+ for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
+ {
+ const Locale& rLocale = pLocales[ i ];
+ xStringResourceManager->setStringForLocale( aPureIdStr, aPropStr, rLocale );
+ }
+
+ ::rtl::OUString aPropIdStr = aEsc;
+ aPropIdStr += aPureIdStr;
+ // TODO?: Change here and in toolkit
+ //aPropIdStr += aSemi;
+ (void)aSemi;
+ aPropAny <<= aPropIdStr;
+ xPropertySet->setPropertyValue( aPropName, aPropAny );
+ }
+ // Replace id by string from StringResource
+ else if( eMode == RESET_IDS )
+ {
+ if( aPropStr.getLength() > 1 )
+ {
+ ::rtl::OUString aPureIdStr = aPropStr.copy( 1 );
+ ::rtl::OUString aNewPropStr = aPropStr;
+ try
+ {
+ aNewPropStr = xStringResourceManager->resolveString( aPureIdStr );
+ }
+ catch(MissingResourceException&)
+ {
+ }
+ aPropAny <<= aNewPropStr;
+ xPropertySet->setPropertyValue( aPropName, aPropAny );
+ }
+ }
+ // Remove Id for all locales
+ else if( eMode == REMOVE_IDS_FROM_RESOURCE )
+ {
+ if( aPropStr.getLength() > 1 )
+ {
+ ::rtl::OUString aPureIdStr = aPropStr.copy( 1 );
+
+ const Locale* pLocales = aLocaleSeq.getConstArray();
+ for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
+ {
+ const Locale& rLocale = pLocales[ i ];
+ try
+ {
+ xStringResourceManager->removeIdForLocale( aPureIdStr, rLocale );
+ }
+ catch(MissingResourceException&)
+ {
+ }
+ }
+ }
+ }
+ // Rename resource id
+ else if( eMode == RENAME_DIALOG_IDS || eMode == RENAME_CONTROL_IDS )
+ {
+ ::rtl::OUString aSourceIdStr = aPropStr;
+ ::rtl::OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
+
+ ::rtl::OUString aPureIdStr = implCreatePureResourceId
+ ( aDialogName, aCtrlName, aPropName, xStringResourceManager );
+
+ // Set new Id and remove old one for all locales
+ const Locale* pLocales = aLocaleSeq.getConstArray();
+ for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
+ {
+ const Locale& rLocale = pLocales[ i ];
+ ::rtl::OUString aResStr;
+ try
+ {
+ aResStr = xStringResourceManager->resolveStringForLocale
+ ( aPureSourceIdStr, rLocale );
+ xStringResourceManager->removeIdForLocale( aPureSourceIdStr, rLocale );
+ xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale );
+ }
+ catch(MissingResourceException&)
+ {}
+ }
+
+ ::rtl::OUString aPropIdStr = aEsc;
+ aPropIdStr += aPureIdStr;
+ // TODO?: Change here and in toolkit
+ //aPropIdStr += aSemi;
+ (void)aSemi;
+ aPropAny <<= aPropIdStr;
+ xPropertySet->setPropertyValue( aPropName, aPropAny );
+ }
+ // Replace string by string from source StringResourceResolver
+ else if( eMode == MOVE_RESOURCES && xSourceStringResolver.is() )
+ {
+ ::rtl::OUString aSourceIdStr = aPropStr;
+ ::rtl::OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
+
+ ::rtl::OUString aPureIdStr = implCreatePureResourceId
+ ( aDialogName, aCtrlName, aPropName, xStringResourceManager );
+
+ const Locale& rDefaultLocale = xSourceStringResolver->getDefaultLocale();
+
+ // Set Id for all locales
+ const Locale* pLocales = aLocaleSeq.getConstArray();
+ for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
+ {
+ const Locale& rLocale = pLocales[ i ];
+ ::rtl::OUString aResStr;
+ try
+ {
+ aResStr = xSourceStringResolver->resolveStringForLocale
+ ( aPureSourceIdStr, rLocale );
+ }
+ catch(MissingResourceException&)
+ {
+ aResStr = xSourceStringResolver->resolveStringForLocale
+ ( aPureSourceIdStr, rDefaultLocale );
+ }
+ xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale );
+ }
+
+ ::rtl::OUString aPropIdStr = aEsc;
+ aPropIdStr += aPureIdStr;
+ // TODO?: Change here and in toolkit
+ //aPropIdStr += aSemi;
+ (void)aSemi;
+ aPropAny <<= aPropIdStr;
+ xPropertySet->setPropertyValue( aPropName, aPropAny );
+ }
+ // Copy string from source to target resource
+ else if( eMode == COPY_RESOURCES && xSourceStringResolver.is() )
+ {
+ ::rtl::OUString aSourceIdStr = aPropStr;
+ ::rtl::OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
+
+ const Locale& rDefaultLocale = xSourceStringResolver->getDefaultLocale();
+
+ // Copy Id for all locales
+ const Locale* pLocales = aLocaleSeq.getConstArray();
+ for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
+ {
+ const Locale& rLocale = pLocales[ i ];
+ ::rtl::OUString aResStr;
+ try
+ {
+ aResStr = xSourceStringResolver->resolveStringForLocale
+ ( aPureSourceIdStr, rLocale );
+ }
+ catch(MissingResourceException&)
+ {
+ aResStr = xSourceStringResolver->resolveStringForLocale
+ ( aPureSourceIdStr, rDefaultLocale );
+ }
+ xStringResourceManager->setStringForLocale( aPureSourceIdStr, aResStr, rLocale );
+ }
+ }
+ nChangedCount++;
+ }
+
+ // Listbox / Combobox
+ else if( eType == TypeClass_SEQUENCE )
+ {
+ Any aPropAny = xPropertySet->getPropertyValue( aPropName );
+ Sequence< ::rtl::OUString > aPropStrings;
+ aPropAny >>= aPropStrings;
+
+ const ::rtl::OUString* pPropStrings = aPropStrings.getConstArray();
+ sal_Int32 nPropStringCount = aPropStrings.getLength();
+ if( nPropStringCount == 0 )
+ continue;
+
+ // Replace string by id, add id+string to StringResource
+ if( eMode == SET_IDS )
+ {
+ Sequence< ::rtl::OUString > aIdStrings;
+ aIdStrings.realloc( nPropStringCount );
+ ::rtl::OUString* pIdStrings = aIdStrings.getArray();
+
+ ::rtl::OUString aIdStrBase = aDot;
+ aIdStrBase += aCtrlName;
+ aIdStrBase += aDot;
+ aIdStrBase += aPropName;
+
+ const Locale* pLocales = aLocaleSeq.getConstArray();
+ sal_Int32 i;
+ for ( i = 0; i < nPropStringCount; ++i )
+ {
+ ::rtl::OUString aPropStr = pPropStrings[i];
+ bool bEscAlreadyExisting = (aPropStr.getLength() && aPropStr.getStr()[0] == '&' );
+ if( bEscAlreadyExisting )
+ {
+ pIdStrings[i] = aPropStr;
+ continue;
+ }
+
+ sal_Int32 nUniqueId = xStringResourceManager->getUniqueNumericId();
+ ::rtl::OUString aPureIdStr = ::rtl::OUString::valueOf( nUniqueId );
+ aPureIdStr += aIdStrBase;
+
+ // Set Id for all locales
+ for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
+ {
+ const Locale& rLocale = pLocales[ iLocale ];
+ xStringResourceManager->setStringForLocale( aPureIdStr, aPropStr, rLocale );
+ }
+
+ ::rtl::OUString aPropIdStr = aEsc;
+ aPropIdStr += aPureIdStr;
+ pIdStrings[i] = aPropIdStr;
+ }
+ aPropAny <<= aIdStrings;
+ xPropertySet->setPropertyValue( aPropName, aPropAny );
+ }
+ // Replace id by string from StringResource
+ else if( eMode == RESET_IDS )
+ {
+ Sequence< ::rtl::OUString > aNewPropStrings;
+ aNewPropStrings.realloc( nPropStringCount );
+ ::rtl::OUString* pNewPropStrings = aNewPropStrings.getArray();
+
+ sal_Int32 i;
+ for ( i = 0; i < nPropStringCount; ++i )
+ {
+ ::rtl::OUString aIdStr = pPropStrings[i];
+ ::rtl::OUString aNewPropStr = aIdStr;
+ if( aIdStr.getLength() > 1 )
+ {
+ ::rtl::OUString aPureIdStr = aIdStr.copy( 1 );
+ try
+ {
+ aNewPropStr = xStringResourceManager->resolveString( aPureIdStr );
+ }
+ catch(MissingResourceException&)
+ {
+ }
+ }
+ pNewPropStrings[i] = aNewPropStr;
+ }
+ aPropAny <<= aNewPropStrings;
+ xPropertySet->setPropertyValue( aPropName, aPropAny );
+ }
+ // Remove Id for all locales
+ else if( eMode == REMOVE_IDS_FROM_RESOURCE )
+ {
+ Sequence< ::rtl::OUString > aNewPropStrings;
+ aNewPropStrings.realloc( nPropStringCount );
+
+ const Locale* pLocales = aLocaleSeq.getConstArray();
+ sal_Int32 i;
+ for ( i = 0; i < nPropStringCount; ++i )
+ {
+ ::rtl::OUString aIdStr = pPropStrings[i];
+ if( aIdStr.getLength() > 1 )
+ {
+ ::rtl::OUString aPureIdStr = aIdStr.copy( 1 );
+
+ for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
+ {
+ const Locale& rLocale = pLocales[iLocale];
+ try
+ {
+ xStringResourceManager->removeIdForLocale( aPureIdStr, rLocale );
+ }
+ catch(MissingResourceException&)
+ {
+ }
+ }
+ }
+ }
+ }
+ // Rename resource id
+ else if( eMode == RENAME_CONTROL_IDS )
+ {
+ Sequence< ::rtl::OUString > aIdStrings;
+ aIdStrings.realloc( nPropStringCount );
+ ::rtl::OUString* pIdStrings = aIdStrings.getArray();
+
+ ::rtl::OUString aIdStrBase = aDot;
+ aIdStrBase += aCtrlName;
+ aIdStrBase += aDot;
+ aIdStrBase += aPropName;
+
+ const Locale* pLocales = aLocaleSeq.getConstArray();
+ sal_Int32 i;
+ for ( i = 0; i < nPropStringCount; ++i )
+ {
+ ::rtl::OUString aSourceIdStr = pPropStrings[i];
+ ::rtl::OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
+
+ sal_Int32 nUniqueId = xStringResourceManager->getUniqueNumericId();
+ ::rtl::OUString aPureIdStr = ::rtl::OUString::valueOf( nUniqueId );
+ aPureIdStr += aIdStrBase;
+
+ // Set Id for all locales
+ for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
+ {
+ const Locale& rLocale = pLocales[ iLocale ];
+
+ ::rtl::OUString aResStr;
+ try
+ {
+ aResStr = xStringResourceManager->resolveStringForLocale
+ ( aPureSourceIdStr, rLocale );
+ xStringResourceManager->removeIdForLocale( aPureSourceIdStr, rLocale );
+ xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale );
+ }
+ catch(MissingResourceException&)
+ {}
+ }
+
+ ::rtl::OUString aPropIdStr = aEsc;
+ aPropIdStr += aPureIdStr;
+ pIdStrings[i] = aPropIdStr;
+ }
+ aPropAny <<= aIdStrings;
+ xPropertySet->setPropertyValue( aPropName, aPropAny );
+ }
+ // Replace string by string from source StringResourceResolver
+ else if( eMode == MOVE_RESOURCES && xSourceStringResolver.is() )
+ {
+ Sequence< ::rtl::OUString > aIdStrings;
+ aIdStrings.realloc( nPropStringCount );
+ ::rtl::OUString* pIdStrings = aIdStrings.getArray();
+
+ ::rtl::OUString aIdStrBase = aDot;
+ aIdStrBase += aCtrlName;
+ aIdStrBase += aDot;
+ aIdStrBase += aPropName;
+
+ const Locale& rDefaultLocale = xSourceStringResolver->getDefaultLocale();
+
+ const Locale* pLocales = aLocaleSeq.getConstArray();
+ sal_Int32 i;
+ for ( i = 0; i < nPropStringCount; ++i )
+ {
+ ::rtl::OUString aSourceIdStr = pPropStrings[i];
+ ::rtl::OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
+
+ sal_Int32 nUniqueId = xStringResourceManager->getUniqueNumericId();
+ ::rtl::OUString aPureIdStr = ::rtl::OUString::valueOf( nUniqueId );
+ aPureIdStr += aIdStrBase;
+
+ // Set Id for all locales
+ for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
+ {
+ const Locale& rLocale = pLocales[ iLocale ];
+
+ ::rtl::OUString aResStr;
+ try
+ {
+ aResStr = xSourceStringResolver->resolveStringForLocale
+ ( aPureSourceIdStr, rLocale );
+ }
+ catch(MissingResourceException&)
+ {
+ aResStr = xSourceStringResolver->resolveStringForLocale
+ ( aPureSourceIdStr, rDefaultLocale );
+ }
+ xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale );
+ }
+
+ ::rtl::OUString aPropIdStr = aEsc;
+ aPropIdStr += aPureIdStr;
+ pIdStrings[i] = aPropIdStr;
+ }
+ aPropAny <<= aIdStrings;
+ xPropertySet->setPropertyValue( aPropName, aPropAny );
+ }
+ // Copy string from source to target resource
+ else if( eMode == COPY_RESOURCES && xSourceStringResolver.is() )
+ {
+ const Locale& rDefaultLocale = xSourceStringResolver->getDefaultLocale();
+
+ const Locale* pLocales = aLocaleSeq.getConstArray();
+ sal_Int32 i;
+ for ( i = 0; i < nPropStringCount; ++i )
+ {
+ ::rtl::OUString aSourceIdStr = pPropStrings[i];
+ ::rtl::OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
+
+ // Set Id for all locales
+ for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
+ {
+ const Locale& rLocale = pLocales[ iLocale ];
+
+ ::rtl::OUString aResStr;
+ try
+ {
+ aResStr = xSourceStringResolver->resolveStringForLocale
+ ( aPureSourceIdStr, rLocale );
+ }
+ catch(MissingResourceException&)
+ {
+ aResStr = xSourceStringResolver->resolveStringForLocale
+ ( aPureSourceIdStr, rDefaultLocale );
+ }
+ xStringResourceManager->setStringForLocale( aPureSourceIdStr, aResStr, rLocale );
+ }
+ }
+ }
+ nChangedCount++;
+ }
+ }
+ }
+ }
+ return nChangedCount;
+}
+
+/*
+void TEST_simulateDialogAddRemoveLocale( bool bAdd )
+{
+ Sequence< Locale > aLocaleSeq( 1 );
+ Locale* pLocales = aLocaleSeq.getArray();
+
+ ::com::sun::star::lang::Locale aLocale_en;
+ aLocale_en.Language = ::rtl::OUString::createFromAscii( "en" );
+ aLocale_en.Country = ::rtl::OUString::createFromAscii( "US" );
+
+ ::com::sun::star::lang::Locale aLocale_de;
+ aLocale_de.Language = ::rtl::OUString::createFromAscii( "de" );
+ aLocale_de.Country = ::rtl::OUString::createFromAscii( "DE" );
+
+ ::com::sun::star::lang::Locale aLocale_fr;
+ aLocale_fr.Language = ::rtl::OUString::createFromAscii( "fr" );
+ aLocale_fr.Country = ::rtl::OUString::createFromAscii( "FR" );
+
+ int n = 0;
+ if( n == 0 )
+ pLocales[0] = aLocale_en;
+ else if( n == 1 )
+ pLocales[0] = aLocale_de;
+ else if( n == 2 )
+ pLocales[0] = aLocale_fr;
+
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ LocalizationMgr* pMgr = pIDEShell->GetCurLocalizationMgr();
+ if( bAdd )
+ pMgr->handleAddLocales( aLocaleSeq );
+ else
+ pMgr->handleRemoveLocales( aLocaleSeq );
+}
+
+void TEST_simulateDialogAddLocale( void )
+{
+ TEST_simulateDialogAddRemoveLocale( true );
+}
+
+void TEST_simulateDialogRemoveLocale( void )
+{
+ TEST_simulateDialogAddRemoveLocale( false );
+}
+*/
+
+void LocalizationMgr::handleAddLocales( Sequence< Locale > aLocaleSeq )
+{
+ const Locale* pLocales = aLocaleSeq.getConstArray();
+ sal_Int32 nLocaleCount = aLocaleSeq.getLength();
+
+ if( isLibraryLocalized() )
+ {
+ for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
+ {
+ const Locale& rLocale = pLocales[ i ];
+ m_xStringResourceManager->newLocale( rLocale );
+ }
+ }
+ else
+ {
+ DBG_ASSERT( nLocaleCount==1, "LocalizationMgr::handleAddLocales(): Only one first locale allowed" );
+
+ const Locale& rLocale = pLocales[ 0 ];
+ m_xStringResourceManager->newLocale( rLocale );
+ enableResourceForAllLibraryDialogs();
+ }
+
+ BasicIDE::MarkDocumentModified( m_aDocument );
+
+ // update locale toolbar
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
+
+ handleTranslationbar();
+}
+
+
+void LocalizationMgr::handleRemoveLocales( Sequence< Locale > aLocaleSeq )
+{
+ const Locale* pLocales = aLocaleSeq.getConstArray();
+ sal_Int32 nLocaleCount = aLocaleSeq.getLength();
+ bool bConsistant = true;
+ bool bModified = false;
+
+ for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
+ {
+ const Locale& rLocale = pLocales[ i ];
+ bool bRemove = true;
+
+ // Check if last locale
+ Sequence< Locale > aResLocaleSeq = m_xStringResourceManager->getLocales();
+ if( aResLocaleSeq.getLength() == 1 )
+ {
+ const Locale& rLastResLocale = aResLocaleSeq.getConstArray()[ 0 ];
+ if( localesAreEqual( rLocale, rLastResLocale ) )
+ {
+ disableResourceForAllLibraryDialogs();
+ }
+ else
+ {
+ // Inconsistancy, keep last locale
+ bConsistant = false;
+ bRemove = false;
+ }
+ }
+
+ if( bRemove )
+ {
+ try
+ {
+ m_xStringResourceManager->removeLocale( rLocale );
+ bModified = true;
+ }
+ catch(IllegalArgumentException&)
+ {
+ bConsistant = false;
+ }
+ }
+ }
+ if( bModified )
+ {
+ BasicIDE::MarkDocumentModified( m_aDocument );
+
+ // update slots
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ {
+ pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
+ pBindings->Invalidate( SID_BASICIDE_MANAGE_LANG );
+ }
+
+ handleTranslationbar();
+ }
+
+ DBG_ASSERT( bConsistant,
+ "LocalizationMgr::handleRemoveLocales(): sequence contains unsupported locales" );
+}
+
+void LocalizationMgr::handleSetDefaultLocale( Locale aLocale )
+{
+ if( m_xStringResourceManager.is() )
+ {
+ try
+ {
+ m_xStringResourceManager->setDefaultLocale( aLocale );
+ }
+ catch(IllegalArgumentException&)
+ {
+ DBG_ERROR( "LocalizationMgr::handleSetDefaultLocale: Invalid locale" );
+ }
+
+ // update locale toolbar
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
+ }
+}
+
+void LocalizationMgr::handleSetCurrentLocale( ::com::sun::star::lang::Locale aLocale )
+{
+ if( m_xStringResourceManager.is() )
+ {
+ try
+ {
+ m_xStringResourceManager->setCurrentLocale( aLocale, false );
+ }
+ catch(IllegalArgumentException&)
+ {
+ DBG_ERROR( "LocalizationMgr::handleSetCurrentLocale: Invalid locale" );
+ }
+
+ // update locale toolbar
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
+
+ IDEBaseWindow* pCurWin = m_pIDEShell->GetCurWindow();
+ if ( pCurWin && !pCurWin->IsSuspended() && pCurWin->IsA( TYPE( DialogWindow ) ) )
+ {
+ DialogWindow* pDlgWin = (DialogWindow*)pCurWin;
+ DlgEditor* pWinEditor = pDlgWin->GetEditor();
+ if( pWinEditor )
+ pWinEditor->UpdatePropertyBrowserDelayed();
+ }
+ }
+}
+
+void LocalizationMgr::handleBasicStarted( void )
+{
+ if( m_xStringResourceManager.is() )
+ m_aLocaleBeforeBasicStart = m_xStringResourceManager->getCurrentLocale();
+}
+
+void LocalizationMgr::handleBasicStopped( void )
+{
+ try
+ {
+ if( m_xStringResourceManager.is() )
+ m_xStringResourceManager->setCurrentLocale( m_aLocaleBeforeBasicStart, true );
+ }
+ catch(IllegalArgumentException&)
+ {
+ }
+}
+
+
+DialogWindow* FindDialogWindowForEditor( DlgEditor* pEditor )
+{
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable();
+ IDEBaseWindow* pWin = aIDEWindowTable.First();
+ DialogWindow* pFoundDlgWin = NULL;
+ while( pWin )
+ {
+ if ( !pWin->IsSuspended() && pWin->IsA( TYPE( DialogWindow ) ) )
+ {
+ DialogWindow* pDlgWin = (DialogWindow*)pWin;
+ DlgEditor* pWinEditor = pDlgWin->GetEditor();
+ if( pWinEditor == pEditor )
+ {
+ pFoundDlgWin = pDlgWin;
+ break;
+ }
+ }
+ pWin = aIDEWindowTable.Next();
+ }
+ return pFoundDlgWin;
+}
+
+
+void LocalizationMgr::setControlResourceIDsForNewEditorObject( DlgEditor* pEditor,
+ Any aControlAny, const ::rtl::OUString& aCtrlName )
+{
+ // Get library for DlgEditor
+ DialogWindow* pDlgWin = FindDialogWindowForEditor( pEditor );
+ if( !pDlgWin )
+ return;
+ ScriptDocument aDocument( pDlgWin->GetDocument() );
+ DBG_ASSERT( aDocument.isValid(), "LocalizationMgr::setControlResourceIDsForNewEditorObject: invalid document!" );
+ if ( !aDocument.isValid() )
+ return;
+ const String& rLibName = pDlgWin->GetLibName();
+ Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, rLibName, TRUE ) );
+ Reference< XStringResourceManager > xStringResourceManager =
+ LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
+
+ // Set resource property
+ if( !xStringResourceManager.is() || xStringResourceManager->getLocales().getLength() == 0 )
+ return;
+
+ ::rtl::OUString aDialogName = pDlgWin->GetName();
+ Reference< XStringResourceResolver > xDummyStringResolver;
+ sal_Int32 nChangedCount = implHandleControlResourceProperties
+ ( aControlAny, aDialogName, aCtrlName, xStringResourceManager,
+ xDummyStringResolver, SET_IDS );
+
+ if( nChangedCount )
+ BasicIDE::MarkDocumentModified( aDocument );
+}
+
+void LocalizationMgr::renameControlResourceIDsForEditorObject( DlgEditor* pEditor,
+ ::com::sun::star::uno::Any aControlAny, const ::rtl::OUString& aNewCtrlName )
+{
+ // Get library for DlgEditor
+ DialogWindow* pDlgWin = FindDialogWindowForEditor( pEditor );
+ if( !pDlgWin )
+ return;
+ ScriptDocument aDocument( pDlgWin->GetDocument() );
+ DBG_ASSERT( aDocument.isValid(), "LocalizationMgr::renameControlResourceIDsForEditorObject: invalid document!" );
+ if ( !aDocument.isValid() )
+ return;
+ const String& rLibName = pDlgWin->GetLibName();
+ Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, rLibName, TRUE ) );
+ Reference< XStringResourceManager > xStringResourceManager =
+ LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
+
+ // Set resource property
+ if( !xStringResourceManager.is() || xStringResourceManager->getLocales().getLength() == 0 )
+ return;
+
+ ::rtl::OUString aDialogName = pDlgWin->GetName();
+ Reference< XStringResourceResolver > xDummyStringResolver;
+ implHandleControlResourceProperties
+ ( aControlAny, aDialogName, aNewCtrlName, xStringResourceManager,
+ xDummyStringResolver, RENAME_CONTROL_IDS );
+}
+
+
+void LocalizationMgr::deleteControlResourceIDsForDeletedEditorObject( DlgEditor* pEditor,
+ Any aControlAny, const ::rtl::OUString& aCtrlName )
+{
+ // Get library for DlgEditor
+ DialogWindow* pDlgWin = FindDialogWindowForEditor( pEditor );
+ if( !pDlgWin )
+ return;
+ ScriptDocument aDocument( pDlgWin->GetDocument() );
+ DBG_ASSERT( aDocument.isValid(), "LocalizationMgr::deleteControlResourceIDsForDeletedEditorObject: invalid document!" );
+ if ( !aDocument.isValid() )
+ return;
+ const String& rLibName = pDlgWin->GetLibName();
+ Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, rLibName, TRUE ) );
+ Reference< XStringResourceManager > xStringResourceManager =
+ LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
+
+ ::rtl::OUString aDialogName = pDlgWin->GetName();
+ Reference< XStringResourceResolver > xDummyStringResolver;
+ sal_Int32 nChangedCount = implHandleControlResourceProperties
+ ( aControlAny, aDialogName, aCtrlName, xStringResourceManager,
+ xDummyStringResolver, REMOVE_IDS_FROM_RESOURCE );
+
+ if( nChangedCount )
+ BasicIDE::MarkDocumentModified( aDocument );
+}
+
+void LocalizationMgr::setStringResourceAtDialog( const ScriptDocument& rDocument, const String& aLibName,
+ const String& aDlgName, Reference< container::XNameContainer > xDialogModel )
+{
+ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAscii( "ResourceResolver" );
+
+ // Get library
+ Reference< container::XNameContainer > xDialogLib( rDocument.getLibrary( E_DIALOGS, aLibName, TRUE ) );
+ Reference< XStringResourceManager > xStringResourceManager =
+ LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
+
+ // Set resource property
+ if( xStringResourceManager.is() )
+ {
+ // Not very elegant as dialog may or may not be localized yet
+ // TODO: Find better place, where dialog is created
+ if( xStringResourceManager->getLocales().getLength() > 0 )
+ {
+ Any aDialogCtrl;
+ aDialogCtrl <<= xDialogModel;
+ Reference< XStringResourceResolver > xDummyStringResolver;
+ implHandleControlResourceProperties( aDialogCtrl, aDlgName,
+ ::rtl::OUString(), xStringResourceManager,
+ xDummyStringResolver, SET_IDS );
+ }
+
+ Reference< beans::XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY );
+ Any aStringResourceManagerAny;
+ aStringResourceManagerAny <<= xStringResourceManager;
+ xDlgPSet->setPropertyValue( aResourceResolverPropName, aStringResourceManagerAny );
+ }
+}
+
+void LocalizationMgr::renameStringResourceIDs( const ScriptDocument& rDocument, const String& aLibName,
+ const String& aDlgName, Reference< container::XNameContainer > xDialogModel )
+{
+ // Get library
+ Reference< container::XNameContainer > xDialogLib( rDocument.getLibrary( E_DIALOGS, aLibName, TRUE ) );
+ Reference< XStringResourceManager > xStringResourceManager =
+ LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
+ if( !xStringResourceManager.is() )
+ return;
+
+ Any aDialogCtrl;
+ aDialogCtrl <<= xDialogModel;
+ Reference< XStringResourceResolver > xDummyStringResolver;
+ implHandleControlResourceProperties( aDialogCtrl, aDlgName,
+ ::rtl::OUString(), xStringResourceManager,
+ xDummyStringResolver, RENAME_DIALOG_IDS );
+
+ // Handle all controls
+ Sequence< ::rtl::OUString > aNames = xDialogModel->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+ for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
+ {
+ ::rtl::OUString aCtrlName( pNames[i] );
+ Any aCtrl = xDialogModel->getByName( aCtrlName );
+ implHandleControlResourceProperties( aCtrl, aDlgName,
+ aCtrlName, xStringResourceManager,
+ xDummyStringResolver, RENAME_DIALOG_IDS );
+ }
+}
+
+void LocalizationMgr::removeResourceForDialog( const ScriptDocument& rDocument, const String& aLibName,
+ const String& aDlgName, Reference< container::XNameContainer > xDialogModel )
+{
+ // Get library
+ Reference< container::XNameContainer > xDialogLib( rDocument.getLibrary( E_DIALOGS, aLibName, TRUE ) );
+ Reference< XStringResourceManager > xStringResourceManager =
+ LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
+ if( !xStringResourceManager.is() )
+ return;
+
+ Any aDialogCtrl;
+ aDialogCtrl <<= xDialogModel;
+ Reference< XStringResourceResolver > xDummyStringResolver;
+ implHandleControlResourceProperties( aDialogCtrl, aDlgName,
+ ::rtl::OUString(), xStringResourceManager,
+ xDummyStringResolver, REMOVE_IDS_FROM_RESOURCE );
+
+ // Handle all controls
+ Sequence< ::rtl::OUString > aNames = xDialogModel->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+ for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
+ {
+ ::rtl::OUString aCtrlName( pNames[i] );
+ Any aCtrl = xDialogModel->getByName( aCtrlName );
+ implHandleControlResourceProperties( aCtrl, aDlgName,
+ aCtrlName, xStringResourceManager,
+ xDummyStringResolver, REMOVE_IDS_FROM_RESOURCE );
+ }
+}
+
+void LocalizationMgr::resetResourceForDialog( Reference< container::XNameContainer > xDialogModel,
+ Reference< XStringResourceManager > xStringResourceManager )
+{
+ if( !xStringResourceManager.is() )
+ return;
+
+ // Dialog as control
+ ::rtl::OUString aDummyName;
+ Any aDialogCtrl;
+ aDialogCtrl <<= xDialogModel;
+ Reference< XStringResourceResolver > xDummyStringResolver;
+ implHandleControlResourceProperties( aDialogCtrl, aDummyName,
+ aDummyName, xStringResourceManager, xDummyStringResolver, RESET_IDS );
+
+ // Handle all controls
+ Sequence< ::rtl::OUString > aNames = xDialogModel->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+ for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
+ {
+ ::rtl::OUString aCtrlName( pNames[i] );
+ Any aCtrl = xDialogModel->getByName( aCtrlName );
+ implHandleControlResourceProperties( aCtrl, aDummyName,
+ aCtrlName, xStringResourceManager, xDummyStringResolver, RESET_IDS );
+ }
+}
+
+void LocalizationMgr::setResourceIDsForDialog( Reference< container::XNameContainer > xDialogModel,
+ Reference< XStringResourceManager > xStringResourceManager )
+{
+ if( !xStringResourceManager.is() )
+ return;
+
+ // Dialog as control
+ ::rtl::OUString aDummyName;
+ Any aDialogCtrl;
+ aDialogCtrl <<= xDialogModel;
+ Reference< XStringResourceResolver > xDummyStringResolver;
+ implHandleControlResourceProperties( aDialogCtrl, aDummyName,
+ aDummyName, xStringResourceManager, xDummyStringResolver, SET_IDS );
+
+ // Handle all controls
+ Sequence< ::rtl::OUString > aNames = xDialogModel->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+ for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
+ {
+ ::rtl::OUString aCtrlName( pNames[i] );
+ Any aCtrl = xDialogModel->getByName( aCtrlName );
+ implHandleControlResourceProperties( aCtrl, aDummyName,
+ aCtrlName, xStringResourceManager, xDummyStringResolver, SET_IDS );
+ }
+}
+
+void LocalizationMgr::copyResourcesForPastedEditorObject( DlgEditor* pEditor,
+ Any aControlAny, const ::rtl::OUString& aCtrlName,
+ Reference< XStringResourceResolver > xSourceStringResolver )
+{
+ // Get library for DlgEditor
+ DialogWindow* pDlgWin = FindDialogWindowForEditor( pEditor );
+ if( !pDlgWin )
+ return;
+ ScriptDocument aDocument( pDlgWin->GetDocument() );
+ DBG_ASSERT( aDocument.isValid(), "LocalizationMgr::copyResourcesForPastedEditorObject: invalid document!" );
+ if ( !aDocument.isValid() )
+ return;
+ const String& rLibName = pDlgWin->GetLibName();
+ Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, rLibName, TRUE ) );
+ Reference< XStringResourceManager > xStringResourceManager =
+ LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
+
+ // Set resource property
+ if( !xStringResourceManager.is() || xStringResourceManager->getLocales().getLength() == 0 )
+ return;
+
+ ::rtl::OUString aDialogName = pDlgWin->GetName();
+ implHandleControlResourceProperties
+ ( aControlAny, aDialogName, aCtrlName, xStringResourceManager,
+ xSourceStringResolver, MOVE_RESOURCES );
+}
+
+void LocalizationMgr::copyResourceForDroppedDialog( Reference< container::XNameContainer > xDialogModel,
+ const ::rtl::OUString& aDialogName, Reference< XStringResourceManager > xStringResourceManager,
+ Reference< XStringResourceResolver > xSourceStringResolver )
+{
+ if( !xStringResourceManager.is() )
+ return;
+
+ // Dialog as control
+ ::rtl::OUString aDummyName;
+ Any aDialogCtrl;
+ aDialogCtrl <<= xDialogModel;
+ implHandleControlResourceProperties( aDialogCtrl, aDialogName,
+ aDummyName, xStringResourceManager, xSourceStringResolver, MOVE_RESOURCES );
+
+ // Handle all controls
+ Sequence< ::rtl::OUString > aNames = xDialogModel->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+ for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
+ {
+ ::rtl::OUString aCtrlName( pNames[i] );
+ Any aCtrl = xDialogModel->getByName( aCtrlName );
+ implHandleControlResourceProperties( aCtrl, aDialogName,
+ aCtrlName, xStringResourceManager, xSourceStringResolver, MOVE_RESOURCES );
+ }
+}
+
+void LocalizationMgr::copyResourceForDialog(
+ const Reference< container::XNameContainer >& xDialogModel,
+ const Reference< XStringResourceResolver >& xSourceStringResolver,
+ const Reference< XStringResourceManager >& xTargetStringResourceManager )
+{
+ if( !xDialogModel.is() || !xSourceStringResolver.is() || !xTargetStringResourceManager.is() )
+ return;
+
+ ::rtl::OUString aDummyName;
+ Any aDialogCtrl;
+ aDialogCtrl <<= xDialogModel;
+ implHandleControlResourceProperties
+ ( aDialogCtrl, aDummyName, aDummyName, xTargetStringResourceManager,
+ xSourceStringResolver, COPY_RESOURCES );
+
+ // Handle all controls
+ Sequence< ::rtl::OUString > aNames = xDialogModel->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+ for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
+ {
+ ::rtl::OUString aCtrlName( pNames[i] );
+ Any aCtrl = xDialogModel->getByName( aCtrlName );
+ implHandleControlResourceProperties( aCtrl, aDummyName, aDummyName,
+ xTargetStringResourceManager, xSourceStringResolver, COPY_RESOURCES );
+ }
+}
+
+Reference< XStringResourceManager > LocalizationMgr::getStringResourceFromDialogLibrary
+ ( Reference< container::XNameContainer > xDialogLib )
+{
+ Reference< XStringResourceManager > xStringResourceManager;
+ if( xDialogLib.is() )
+ {
+ Reference< resource::XStringResourceSupplier > xStringResourceSupplier( xDialogLib, UNO_QUERY );
+ if( xStringResourceSupplier.is() )
+ {
+ Reference< resource::XStringResourceResolver >
+ xStringResourceResolver = xStringResourceSupplier->getStringResource();
+
+ xStringResourceManager =
+ Reference< resource::XStringResourceManager >( xStringResourceResolver, UNO_QUERY );
+ }
+ }
+ return xStringResourceManager;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
new file mode 100644
index 000000000000..e3f21bba669a
--- /dev/null
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -0,0 +1,923 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include <memory>
+
+#include <ide_pch.hxx>
+
+
+#include <macrodlg.hxx>
+#include <macrodlg.hrc>
+#include <basidesh.hrc>
+#include <basidesh.hxx>
+#include <baside2.hrc> // ID's fuer Imagese
+#include <basobj.hxx>
+#include <baside3.hxx>
+
+#include <iderdll.hxx>
+#include <iderdll2.hxx>
+#include <iderid.hxx>
+
+#include <moduldlg.hxx>
+#include <basic/sbx.hxx>
+
+#include <bastypes.hxx>
+#include <sbxitem.hxx>
+#include <sfx2/minfitem.hxx>
+
+#include <com/sun/star/script/XLibraryContainer2.hpp>
+#include <com/sun/star/document/MacroExecMode.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+DECLARE_LIST( MacroList, SbMethod* )
+
+MacroChooser::MacroChooser( Window* pParnt, BOOL bCreateEntries ) :
+ SfxModalDialog( pParnt, IDEResId( RID_MACROCHOOSER ) ),
+ aMacroNameTxt( this, IDEResId( RID_TXT_MACRONAME ) ),
+ aMacroNameEdit( this, IDEResId( RID_ED_MACRONAME ) ),
+ aMacroFromTxT( this, IDEResId( RID_TXT_MACROFROM ) ),
+ aMacrosSaveInTxt( this, IDEResId( RID_TXT_SAVEMACRO ) ),
+ aBasicBox( this, IDEResId( RID_CTRL_LIB ) ),
+ aMacrosInTxt( this, IDEResId( RID_TXT_MACROSIN ) ),
+ aMacroBox( this, IDEResId( RID_CTRL_MACRO ) ),
+ aRunButton( this, IDEResId( RID_PB_RUN ) ),
+ aCloseButton( this, IDEResId( RID_PB_CLOSE ) ),
+ aAssignButton( this, IDEResId( RID_PB_ASSIGN ) ),
+ aEditButton( this, IDEResId( RID_PB_EDIT ) ),
+ aNewDelButton( this, IDEResId( RID_PB_DEL ) ),
+ aOrganizeButton( this, IDEResId( RID_PB_ORG ) ),
+ aHelpButton( this, IDEResId( RID_PB_HELP ) ),
+ aNewLibButton( this, IDEResId( RID_PB_NEWLIB ) ),
+ aNewModButton( this, IDEResId( RID_PB_NEWMOD ) )
+{
+ FreeResource();
+
+ nMode = MACROCHOOSER_ALL;
+ bNewDelIsDel = TRUE;
+
+ // Der Sfx fragt den BasicManager nicht, ob modified
+ // => Speichern anschmeissen, wenn Aenderung, aber kein Sprung in
+ // die BasicIDE.
+ bForceStoreBasic = FALSE;
+
+ aMacrosInTxtBaseStr = aMacrosInTxt.GetText();
+
+ aMacroBox.SetSelectionMode( SINGLE_SELECTION );
+ aMacroBox.SetHighlightRange(); // ueber ganze Breite selektieren
+
+ aRunButton.SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
+ aCloseButton.SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
+ aAssignButton.SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
+ aEditButton.SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
+ aNewDelButton.SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
+ aOrganizeButton.SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
+
+ // Buttons only for MACROCHOOSER_RECORDING
+ aNewLibButton.SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
+ aNewModButton.SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
+ aNewLibButton.Hide(); // default
+ aNewModButton.Hide(); // default
+ aMacrosSaveInTxt.Hide(); // default
+
+ aMacrosInTxt.SetStyle( WB_NOMULTILINE | WB_PATHELLIPSIS );
+
+ aMacroNameEdit.SetModifyHdl( LINK( this, MacroChooser, EditModifyHdl ) );
+
+ aBasicBox.SetSelectHdl( LINK( this, MacroChooser, BasicSelectHdl ) );
+
+ aMacroBox.SetDoubleClickHdl( LINK( this, MacroChooser, MacroDoubleClickHdl ) );
+ aMacroBox.SetSelectHdl( LINK( this, MacroChooser, MacroSelectHdl ) );
+
+ aBasicBox.SetMode( BROWSEMODE_MODULES );
+ aBasicBox.SetWindowBits( WB_HASLINES | WB_HASLINESATROOT |
+ WB_HASBUTTONS | WB_HASBUTTONSATROOT |
+ WB_HSCROLL );
+
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
+ }
+
+ if ( bCreateEntries )
+ aBasicBox.ScanAllEntries();
+}
+
+MacroChooser::~MacroChooser()
+{
+ if ( bForceStoreBasic )
+ SFX_APP()->SaveBasicAndDialogContainer();
+}
+
+void MacroChooser::StoreMacroDescription()
+{
+ BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( aBasicBox.FirstSelected() ) );
+ String aMethodName;
+ SvLBoxEntry* pEntry = aMacroBox.FirstSelected();
+ if ( pEntry )
+ aMethodName = aMacroBox.GetEntryText( pEntry );
+ else
+ aMethodName = aMacroNameEdit.GetText();
+ if ( aMethodName.Len() )
+ {
+ aDesc.SetMethodName( aMethodName );
+ aDesc.SetType( OBJ_TYPE_METHOD );
+ }
+
+ BasicIDEData* pData = IDE_DLL()->GetExtraData();
+ if ( pData )
+ pData->SetLastEntryDescriptor( aDesc );
+}
+
+void MacroChooser::RestoreMacroDescription()
+{
+ BasicEntryDescriptor aDesc;
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if ( pIDEShell )
+ {
+ IDEBaseWindow* pCurWin = pIDEShell->GetCurWindow();
+ if ( pCurWin )
+ aDesc = pCurWin->CreateEntryDescriptor();
+ }
+ else
+ {
+ BasicIDEData* pData = IDE_DLL()->GetExtraData();
+ if ( pData )
+ aDesc = pData->GetLastEntryDescriptor();
+ }
+
+ aBasicBox.SetCurrentEntry( aDesc );
+
+ String aLastMacro( aDesc.GetMethodName() );
+ if ( aLastMacro.Len() )
+ {
+ // find entry in macro box
+ SvLBoxEntry* pEntry = 0;
+ ULONG nPos = 0;
+ SvLBoxEntry* pE = aMacroBox.GetEntry( nPos );
+ while ( pE )
+ {
+ if ( aMacroBox.GetEntryText( pE ) == aLastMacro )
+ {
+ pEntry = pE;
+ break;
+ }
+ pE = aMacroBox.GetEntry( ++nPos );
+ }
+
+ if ( pEntry )
+ aMacroBox.SetCurEntry( pEntry );
+ else
+ {
+ aMacroNameEdit.SetText( aLastMacro );
+ aMacroNameEdit.SetSelection( Selection( 0, 0 ) );
+ }
+ }
+}
+
+short __EXPORT MacroChooser::Execute()
+{
+ RestoreMacroDescription();
+ aRunButton.GrabFocus();
+
+ // #104198 Check if "wrong" document is active
+ SvLBoxEntry* pSelectedEntry = aBasicBox.GetCurEntry();
+ BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pSelectedEntry ) );
+ const ScriptDocument& rSelectedDoc( aDesc.GetDocument() );
+
+ // App Basic is always ok, so only check if shell was found
+ if( rSelectedDoc.isDocument() && !rSelectedDoc.isActive() )
+ {
+ // Search for the right entry
+ ULONG nRootPos = 0;
+ SvLBoxEntry* pRootEntry = aBasicBox.GetEntry( nRootPos );
+ while( pRootEntry )
+ {
+ BasicEntryDescriptor aCmpDesc( aBasicBox.GetEntryDescriptor( pRootEntry ) );
+ const ScriptDocument& rCmpDoc( aCmpDesc.GetDocument() );
+ if ( rCmpDoc.isDocument() && rCmpDoc.isActive() )
+ {
+ SvLBoxEntry* pEntry = pRootEntry;
+ SvLBoxEntry* pLastValid = pEntry;
+ while ( pEntry )
+ {
+ pLastValid = pEntry;
+ pEntry = aBasicBox.FirstChild( pEntry );
+ }
+ if( pLastValid )
+ aBasicBox.SetCurEntry( pLastValid );
+ }
+ pRootEntry = aBasicBox.GetEntry( ++nRootPos );
+ }
+ }
+
+ CheckButtons();
+ UpdateFields();
+
+ if ( StarBASIC::IsRunning() )
+ aCloseButton.GrabFocus();
+
+ Window* pPrevDlgParent = Application::GetDefDialogParent();
+ Application::SetDefDialogParent( this );
+ short nRet = ModalDialog::Execute();
+ // #57314# Wenn die BasicIDE aktiviert wurde, dann nicht den DefModalDialogParent auf das inaktive Dokument zuruecksetzen.
+ if ( Application::GetDefDialogParent() == this )
+ Application::SetDefDialogParent( pPrevDlgParent );
+ return nRet;
+}
+
+
+void MacroChooser::EnableButton( Button& rButton, BOOL bEnable )
+{
+ if ( bEnable )
+ {
+ if ( nMode == MACROCHOOSER_CHOOSEONLY || nMode == MACROCHOOSER_RECORDING )
+ {
+ // Nur der RunButton kann enabled werden
+ if ( &rButton == &aRunButton )
+ rButton.Enable();
+ else
+ rButton.Disable();
+ }
+ else
+ rButton.Enable();
+ }
+ else
+ rButton.Disable();
+}
+
+
+
+
+SbMethod* MacroChooser::GetMacro()
+{
+ SbMethod* pMethod = 0;
+ SbModule* pModule = aBasicBox.FindModule( aBasicBox.GetCurEntry() );
+ if ( pModule )
+ {
+ SvLBoxEntry* pEntry = aMacroBox.FirstSelected();
+ if ( pEntry )
+ {
+ String aMacroName( aMacroBox.GetEntryText( pEntry ) );
+ pMethod = (SbMethod*)pModule->GetMethods()->Find( aMacroName, SbxCLASS_METHOD );
+ }
+ }
+ return pMethod;
+}
+
+
+
+void MacroChooser::DeleteMacro()
+{
+ SbMethod* pMethod = GetMacro();
+ DBG_ASSERT( pMethod, "DeleteMacro: Kein Macro !" );
+ if ( pMethod && QueryDelMacro( pMethod->GetName(), this ) )
+ {
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
+ }
+
+ // Aktuelles Doc als geaendert markieren:
+ StarBASIC* pBasic = BasicIDE::FindBasic( pMethod );
+ DBG_ASSERT( pBasic, "Basic?!" );
+ BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
+ DBG_ASSERT( pBasMgr, "BasMgr?" );
+ ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
+ if ( aDocument.isDocument() ) // Muss ja nicht aus einem Document kommen...
+ {
+ aDocument.setDocumentModified();
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_SAVEDOC );
+ }
+
+ SbModule* pModule = pMethod->GetModule();
+ DBG_ASSERT( pModule, "DeleteMacro: Kein Modul?!" );
+ ::rtl::OUString aSource( pModule->GetSource32() );
+ USHORT nStart, nEnd;
+ pMethod->GetLineRange( nStart, nEnd );
+ pModule->GetMethods()->Remove( pMethod );
+ CutLines( aSource, nStart-1, nEnd-nStart+1, TRUE );
+ pModule->SetSource32( aSource );
+
+ // update module in library
+ String aLibName = pBasic->GetName();
+ String aModName = pModule->GetName();
+ OSL_VERIFY( aDocument.updateModule( aLibName, aModName, aSource ) );
+
+ SvLBoxEntry* pEntry = aMacroBox.FirstSelected();
+ DBG_ASSERT( pEntry, "DeleteMacro: Entry ?!" );
+ aMacroBox.GetModel()->Remove( pEntry );
+ bForceStoreBasic = TRUE;
+ }
+}
+
+SbMethod* MacroChooser::CreateMacro()
+{
+ SbMethod* pMethod = 0;
+ SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
+ BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ OSL_ENSURE( aDocument.isAlive(), "MacroChooser::CreateMacro: no document!" );
+ if ( !aDocument.isAlive() )
+ return NULL;
+
+ String aLibName( aDesc.GetLibName() );
+
+ if ( !aLibName.Len() )
+ aLibName = String::CreateFromAscii( "Standard" );
+
+ aDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
+
+ ::rtl::OUString aOULibName( aLibName );
+ Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
+ xModLibContainer->loadLibrary( aOULibName );
+ Reference< script::XLibraryContainer > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ) );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
+ xDlgLibContainer->loadLibrary( aOULibName );
+
+ BasicManager* pBasMgr = aDocument.getBasicManager();
+ StarBASIC* pBasic = pBasMgr ? pBasMgr->GetLib( aLibName ) : 0;
+ if ( pBasic )
+ {
+ SbModule* pModule = 0;
+ String aModName( aDesc.GetName() );
+ if ( aModName.Len() )
+ {
+ // extract the module name from the string like "Sheet1 (Example1)"
+ if( aDesc.GetLibSubName().Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) )
+ {
+ sal_uInt16 nIndex = 0;
+ aModName = aModName.GetToken( 0, ' ', nIndex );
+ }
+ pModule = pBasic->FindModule( aModName );
+ }
+ else if ( pBasic->GetModules()->Count() )
+ pModule = (SbModule*)pBasic->GetModules()->Get( 0 );
+
+ if ( !pModule )
+ {
+ pModule = createModImpl( static_cast<Window*>( this ),
+ aDocument, aBasicBox, aLibName, aModName );
+ }
+
+ String aSubName = aMacroNameEdit.GetText();
+ DBG_ASSERT( !pModule || !pModule->GetMethods()->Find( aSubName, SbxCLASS_METHOD ), "Macro existiert schon!" );
+ pMethod = pModule ? BasicIDE::CreateMacro( pModule, aSubName ) : NULL;
+ }
+
+ return pMethod;
+}
+
+void MacroChooser::SaveSetCurEntry( SvTreeListBox& rBox, SvLBoxEntry* pEntry )
+{
+ // Durch das Highlight wird das Edit sonst platt gemacht:
+
+ String aSaveText( aMacroNameEdit.GetText() );
+ Selection aCurSel( aMacroNameEdit.GetSelection() );
+
+ rBox.SetCurEntry( pEntry );
+ aMacroNameEdit.SetText( aSaveText );
+ aMacroNameEdit.SetSelection( aCurSel );
+}
+
+void MacroChooser::CheckButtons()
+{
+ SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
+ BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
+ SvLBoxEntry* pMacroEntry = aMacroBox.FirstSelected();
+ SbMethod* pMethod = GetMacro();
+
+ // check, if corresponding libraries are readonly
+ BOOL bReadOnly = FALSE;
+ USHORT nDepth = pCurEntry ? aBasicBox.GetModel()->GetDepth( pCurEntry ) : 0;
+ if ( nDepth == 1 || nDepth == 2 )
+ {
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ ::rtl::OUString aOULibName( aDesc.GetLibName() );
+ Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) )
+ {
+ bReadOnly = TRUE;
+ }
+ }
+
+ if ( nMode != MACROCHOOSER_RECORDING )
+ {
+ // Run...
+ BOOL bEnable = pMethod ? TRUE : FALSE;
+ if ( ( nMode != MACROCHOOSER_CHOOSEONLY ) && StarBASIC::IsRunning() )
+ bEnable = FALSE;
+ EnableButton( aRunButton, bEnable );
+ }
+
+ // Organisieren immer moeglich ?
+
+ // Assign...
+ EnableButton( aAssignButton, pMethod ? TRUE : FALSE );
+
+ // Edit...
+ EnableButton( aEditButton, pMacroEntry ? TRUE : FALSE );
+
+ // aOrganizeButton
+ EnableButton( aOrganizeButton, !StarBASIC::IsRunning() && ( nMode == MACROCHOOSER_ALL ));
+
+ // aNewDelButton....
+ bool bProtected = aBasicBox.IsEntryProtected( pCurEntry );
+ bool bShare = ( aDesc.GetLocation() == LIBRARY_LOCATION_SHARE );
+ EnableButton( aNewDelButton,
+ !StarBASIC::IsRunning() && ( nMode == MACROCHOOSER_ALL ) && !bProtected && !bReadOnly && !bShare );
+ BOOL bPrev = bNewDelIsDel;
+ bNewDelIsDel = pMethod ? TRUE : FALSE;
+ if ( ( bPrev != bNewDelIsDel ) && ( nMode == MACROCHOOSER_ALL ) )
+ {
+ String aBtnText( bNewDelIsDel ? IDEResId( RID_STR_BTNDEL) : IDEResId( RID_STR_BTNNEW ) );
+ aNewDelButton.SetText( aBtnText );
+ }
+
+ if ( nMode == MACROCHOOSER_RECORDING )
+ {
+ // save button
+ if ( !bProtected && !bReadOnly && !bShare )
+ aRunButton.Enable();
+ else
+ aRunButton.Disable();
+
+ // new library button
+ if ( !bShare )
+ aNewLibButton.Enable();
+ else
+ aNewLibButton.Disable();
+
+ // new module button
+ if ( !bProtected && !bReadOnly && !bShare )
+ aNewModButton.Enable();
+ else
+ aNewModButton.Disable();
+ }
+}
+
+
+
+IMPL_LINK_INLINE_START( MacroChooser, MacroDoubleClickHdl, SvTreeListBox *, EMPTYARG )
+{
+ StoreMacroDescription();
+ if ( nMode == MACROCHOOSER_RECORDING )
+ {
+ SbMethod* pMethod = GetMacro();
+ if ( pMethod && !QueryReplaceMacro( pMethod->GetName(), this ) )
+ return 0;
+ }
+
+ EndDialog( MACRO_OK_RUN );
+ return 0;
+}
+IMPL_LINK_INLINE_END( MacroChooser, MacroDoubleClickHdl, SvTreeListBox *, EMPTYARG )
+
+IMPL_LINK( MacroChooser, MacroSelectHdl, SvTreeListBox *, pBox )
+{
+ // Wird auch gerufen, wenn Deselektiert!
+ // 2 Funktionsaufrufe in jedem SelectHdl, nur weil Olli
+ // keinen separatren DeselctHdl einfuehren wollte:
+ // Also: Feststellen, ob Select oder Deselect:
+ if ( pBox->IsSelected( pBox->GetHdlEntry() ) )
+ {
+ UpdateFields();
+ CheckButtons();
+ }
+ return 0;
+}
+
+IMPL_LINK( MacroChooser, BasicSelectHdl, SvTreeListBox *, pBox )
+{
+ static String aSpaceStr = String::CreateFromAscii(" ");
+
+ // Wird auch gerufen, wenn Deselektiert!
+ // 2 Funktionsaufrufe in jedem SelectHdl, nur weil Olli
+ // keinen separatren DeselctHdl einfuehren wollte:
+ // Also: Feststellen, ob Select oder Deselect:
+ if ( !pBox->IsSelected( pBox->GetHdlEntry() ) )
+ return 0;
+
+ SbModule* pModule = aBasicBox.FindModule( aBasicBox.GetCurEntry() );
+
+ aMacroBox.Clear();
+ if ( pModule )
+ {
+ String aStr = aMacrosInTxtBaseStr;
+ aStr += aSpaceStr;
+ aStr += pModule->GetName();
+
+ aMacrosInTxt.SetText( aStr );
+
+ // Die Macros sollen in der Reihenfolge angezeigt werden,
+ // wie sie im Modul stehen.
+ MacroList aMacros;
+ USHORT nMacroCount = pModule->GetMethods()->Count();
+ USHORT nRealMacroCount = 0;
+ USHORT iMeth;
+ for ( iMeth = 0; iMeth < nMacroCount; iMeth++ )
+ {
+ SbMethod* pMethod = (SbMethod*)pModule->GetMethods()->Get( iMeth );
+ if( pMethod->IsHidden() )
+ continue;
+ ++nRealMacroCount;
+ DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" );
+ ULONG nPos = LIST_APPEND;
+ // Eventuell weiter vorne ?
+ USHORT nStart, nEnd;
+ pMethod->GetLineRange( nStart, nEnd );
+ for ( ULONG n = 0; n < aMacros.Count(); n++ )
+ {
+ USHORT nS, nE;
+ SbMethod* pM = aMacros.GetObject( n );
+ DBG_ASSERT( pM, "Macro nicht in Liste ?!" );
+ pM->GetLineRange( nS, nE );
+ if ( nS > nStart )
+ {
+ nPos = n;
+ break;
+ }
+ }
+ aMacros.Insert( pMethod, nPos );
+ }
+
+ aMacroBox.SetUpdateMode( FALSE );
+ for ( iMeth = 0; iMeth < nRealMacroCount; iMeth++ )
+ aMacroBox.InsertEntry( aMacros.GetObject( iMeth )->GetName() );
+ aMacroBox.SetUpdateMode( TRUE );
+
+ if ( aMacroBox.GetEntryCount() )
+ {
+ SvLBoxEntry* pEntry = aMacroBox.GetEntry( 0 );
+ DBG_ASSERT( pEntry, "Entry ?!" );
+ aMacroBox.SetCurEntry( pEntry );
+ }
+ }
+
+ UpdateFields();
+ CheckButtons();
+ return 0;
+}
+
+
+
+IMPL_LINK( MacroChooser, EditModifyHdl, Edit *, pEdit )
+{
+ (void)pEdit;
+
+ // Das Modul, in dem bei Neu das Macro landet, selektieren,
+ // wenn BasicManager oder Lib selektiert.
+ SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
+ if ( pCurEntry )
+ {
+ USHORT nDepth = aBasicBox.GetModel()->GetDepth( pCurEntry );
+ if ( ( nDepth == 1 ) && ( aBasicBox.IsEntryProtected( pCurEntry ) ) )
+ {
+ // Dann auf die entsprechende Std-Lib stellen...
+ SvLBoxEntry* pManagerEntry = aBasicBox.GetModel()->GetParent( pCurEntry );
+ pCurEntry = aBasicBox.GetModel()->FirstChild( pManagerEntry );
+ }
+ if ( nDepth < 2 )
+ {
+ SvLBoxEntry* pNewEntry = pCurEntry;
+ while ( pCurEntry && ( nDepth < 2 ) )
+ {
+ pCurEntry = aBasicBox.FirstChild( pCurEntry );
+ if ( pCurEntry )
+ {
+ pNewEntry = pCurEntry;
+ nDepth = aBasicBox.GetModel()->GetDepth( pCurEntry );
+ }
+ }
+ SaveSetCurEntry( aBasicBox, pNewEntry );
+ }
+ if ( aMacroBox.GetEntryCount() )
+ {
+ String aEdtText( aMacroNameEdit.GetText() );
+ BOOL bFound = FALSE;
+ for ( USHORT n = 0; n < aMacroBox.GetEntryCount(); n++ )
+ {
+ SvLBoxEntry* pEntry = aMacroBox.GetEntry( n );
+ DBG_ASSERT( pEntry, "Entry ?!" );
+ if ( aMacroBox.GetEntryText( pEntry ).CompareIgnoreCaseToAscii( aEdtText ) == COMPARE_EQUAL )
+ {
+ SaveSetCurEntry( aMacroBox, pEntry );
+ bFound = TRUE;
+ break;
+ }
+ }
+ if ( !bFound )
+ {
+ SvLBoxEntry* pEntry = aMacroBox.FirstSelected();
+ // Wenn es den Eintrag gibt ->Select ->Desription...
+ if ( pEntry )
+ aMacroBox.Select( pEntry, FALSE );
+ }
+ }
+ }
+
+ CheckButtons();
+ return 0;
+}
+
+
+
+IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton )
+{
+ // ausser bei New/Record wird die Description durch LoseFocus uebernommen.
+ if ( pButton == &aRunButton )
+ {
+ StoreMacroDescription();
+
+ // #116444# check security settings before macro execution
+ if ( nMode == MACROCHOOSER_ALL )
+ {
+ SbMethod* pMethod = GetMacro();
+ SbModule* pModule = pMethod ? pMethod->GetModule() : NULL;
+ StarBASIC* pBasic = pModule ? (StarBASIC*)pModule->GetParent() : NULL;
+ BasicManager* pBasMgr = pBasic ? BasicIDE::FindBasicManager( pBasic ) : NULL;
+ if ( pBasMgr )
+ {
+ ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
+ if ( aDocument.isDocument() && !aDocument.allowMacros() )
+ {
+ WarningBox( this, WB_OK, String( IDEResId( RID_STR_CANNOTRUNMACRO ) ) ).Execute();
+ return 0;
+ }
+ }
+ }
+ else if ( nMode == MACROCHOOSER_RECORDING )
+ {
+ BOOL bValid = BasicIDE::IsValidSbxName( aMacroNameEdit.GetText() );
+ if ( !bValid )
+ {
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_BADSBXNAME ) ) ).Execute();
+ aMacroNameEdit.SetSelection( Selection( 0, aMacroNameEdit.GetText().Len() ) );
+ aMacroNameEdit.GrabFocus();
+ return 0;
+ }
+
+ SbMethod* pMethod = GetMacro();
+ if ( pMethod && !QueryReplaceMacro( pMethod->GetName(), this ) )
+ return 0;
+ }
+
+ EndDialog( MACRO_OK_RUN );
+ }
+ else if ( pButton == &aCloseButton )
+ {
+ StoreMacroDescription();
+ EndDialog( MACRO_CLOSE );
+ }
+ else if ( ( pButton == &aEditButton ) || ( pButton == &aNewDelButton ) )
+ {
+ SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
+ BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ DBG_ASSERT( aDocument.isAlive(), "MacroChooser::ButtonHdl: no document, or document is dead!" );
+ if ( !aDocument.isAlive() )
+ return 0;
+ BasicManager* pBasMgr = aDocument.getBasicManager();
+ String aLib( aDesc.GetLibName() );
+ String aMod( aDesc.GetName() );
+ // extract the module name from the string like "Sheet1 (Example1)"
+ if( aDesc.GetLibSubName().Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) )
+ {
+ sal_uInt16 nIndex = 0;
+ aMod = aMod.GetToken( 0, ' ', nIndex );
+ }
+ String aSub( aDesc.GetMethodName() );
+ SfxMacroInfoItem aInfoItem( SID_BASICIDE_ARG_MACROINFO, pBasMgr, aLib, aMod, aSub, String() );
+ if ( pButton == &aEditButton )
+ {
+ SvLBoxEntry* pEntry = aMacroBox.FirstSelected();
+ if ( pEntry )
+ aInfoItem.SetMethod( aMacroBox.GetEntryText( pEntry ) );
+ StoreMacroDescription();
+ SfxAllItemSet aArgs( SFX_APP()->GetPool() );
+ SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs );
+ SFX_APP()->ExecuteSlot( aRequest );
+
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ pDispatcher->Execute( SID_BASICIDE_EDITMACRO, SFX_CALLMODE_ASYNCHRON, &aInfoItem, 0L );
+ EndDialog( MACRO_EDIT );
+ }
+ else
+ {
+ if ( bNewDelIsDel )
+ {
+ DeleteMacro();
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_UPDATEMODULESOURCE,
+ SFX_CALLMODE_SYNCHRON, &aInfoItem, 0L );
+ }
+ CheckButtons();
+ UpdateFields();
+ //if ( aMacroBox.GetCurEntry() ) // OV-Bug ?
+ // aMacroBox.Select( aMacroBox.GetCurEntry() );
+ }
+ else
+ {
+ BOOL bValid = BasicIDE::IsValidSbxName( aMacroNameEdit.GetText() );
+ if ( !bValid )
+ {
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_BADSBXNAME ) ) ).Execute();
+ aMacroNameEdit.SetSelection( Selection( 0, aMacroNameEdit.GetText().Len() ) );
+ aMacroNameEdit.GrabFocus();
+ return 1;
+ }
+ SbMethod* pMethod = CreateMacro();
+ if ( pMethod )
+ {
+ aInfoItem.SetMethod( pMethod->GetName() );
+ aInfoItem.SetModule( pMethod->GetModule()->GetName() );
+ aInfoItem.SetLib( pMethod->GetModule()->GetParent()->GetName() );
+ SfxAllItemSet aArgs( SFX_APP()->GetPool() );
+ SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs );
+ SFX_APP()->ExecuteSlot( aRequest );
+
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if ( pDispatcher )
+ pDispatcher->Execute( SID_BASICIDE_EDITMACRO, SFX_CALLMODE_ASYNCHRON, &aInfoItem, 0L );
+ StoreMacroDescription();
+ EndDialog( MACRO_NEW );
+ }
+ }
+ }
+ }
+
+ else if ( pButton == &aAssignButton )
+ {
+ SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
+ BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ DBG_ASSERT( aDocument.isAlive(), "MacroChooser::ButtonHdl: no document, or document is dead!" );
+ if ( !aDocument.isAlive() )
+ return 0;
+ BasicManager* pBasMgr = aDocument.getBasicManager();
+ String aLib( aDesc.GetLibName() );
+ String aMod( aDesc.GetName() );
+ String aSub( aMacroNameEdit.GetText() );
+ SbMethod* pMethod = GetMacro();
+ DBG_ASSERT( pBasMgr, "BasMgr?" );
+ DBG_ASSERT( pMethod, "Method?" );
+ String aComment( GetInfo( pMethod ) );
+ SfxMacroInfoItem aItem( SID_MACROINFO, pBasMgr, aLib, aMod, aSub, aComment );
+ SfxAllItemSet Args( SFX_APP()->GetPool() );
+ SfxRequest aRequest( SID_CONFIG, SFX_CALLMODE_SYNCHRON, Args );
+ aRequest.AppendItem( aItem );
+ SFX_APP()->ExecuteSlot( aRequest );
+ }
+ else if ( pButton == &aNewLibButton )
+ {
+ SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
+ BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ createLibImpl( static_cast<Window*>( this ), aDocument, NULL, &aBasicBox );
+ }
+ else if ( pButton == &aNewModButton )
+ {
+ SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
+ BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ String aLibName( aDesc.GetLibName() );
+ String aModName;
+ createModImpl( static_cast<Window*>( this ), aDocument,
+ aBasicBox, aLibName, aModName, true );
+ }
+ else if ( pButton == &aOrganizeButton )
+ {
+ StoreMacroDescription();
+
+ BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( aBasicBox.FirstSelected() ) );
+ OrganizeDialog* pDlg = new OrganizeDialog( this, 0, aDesc );
+ USHORT nRet = pDlg->Execute();
+ delete pDlg;
+
+ if ( nRet ) // Nicht einfach nur geschlossen
+ {
+ EndDialog( MACRO_EDIT );
+ return 0;
+ }
+
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if ( pIDEShell && pIDEShell->IsAppBasicModified() )
+ bForceStoreBasic = TRUE;
+
+ aBasicBox.UpdateEntries();
+ }
+ return 0;
+}
+
+
+
+void MacroChooser::UpdateFields()
+{
+ SvLBoxEntry* pMacroEntry = aMacroBox.GetCurEntry();
+ String aEmptyStr;
+
+ aMacroNameEdit.SetText( aEmptyStr );
+ if ( pMacroEntry )
+ aMacroNameEdit.SetText( aMacroBox.GetEntryText( pMacroEntry ) );
+}
+
+void MacroChooser::SetMode( USHORT nM )
+{
+ nMode = nM;
+ if ( nMode == MACROCHOOSER_ALL )
+ {
+ aRunButton.SetText( String( IDEResId( RID_STR_RUN ) ) );
+ EnableButton( aNewDelButton, TRUE );
+ EnableButton( aOrganizeButton, TRUE );
+ }
+ else if ( nMode == MACROCHOOSER_CHOOSEONLY )
+ {
+ aRunButton.SetText( String( IDEResId( RID_STR_CHOOSE ) ) );
+ EnableButton( aNewDelButton, FALSE );
+ EnableButton( aOrganizeButton, FALSE );
+ }
+ else if ( nMode == MACROCHOOSER_RECORDING )
+ {
+ aRunButton.SetText( String( IDEResId( RID_STR_RECORD ) ) );
+ EnableButton( aNewDelButton, FALSE );
+ EnableButton( aOrganizeButton, FALSE );
+
+ aAssignButton.Hide();
+ aEditButton.Hide();
+ aNewDelButton.Hide();
+ aOrganizeButton.Hide();
+ aMacroFromTxT.Hide();
+
+ aNewLibButton.Show();
+ aNewModButton.Show();
+ aMacrosSaveInTxt.Show();
+
+ Point aHelpPos = aHelpButton.GetPosPixel();
+ Point aHelpPosLogic = PixelToLogic( aHelpPos, MapMode(MAP_APPFONT) );
+ aHelpPosLogic.Y() -= 34;
+ aHelpPos = LogicToPixel( aHelpPosLogic, MapMode(MAP_APPFONT) );
+ aHelpButton.SetPosPixel( aHelpPos );
+ }
+ CheckButtons();
+}
+
+String MacroChooser::GetInfo( SbxVariable* pVar )
+{
+ String aComment;
+ SbxInfoRef xInfo = pVar->GetInfo();
+ if ( xInfo.Is() )
+ aComment = xInfo->GetComment();
+ return aComment;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/macrodlg.hrc b/basctl/source/basicide/macrodlg.hrc
new file mode 100644
index 000000000000..ae96e1b0b92f
--- /dev/null
+++ b/basctl/source/basicide/macrodlg.hrc
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _MACRODLG_HRC
+#define _MACRODLG_HRC
+
+#include <svl/solar.hrc>
+
+#define RID_MACROCHOOSER ( RID_BASICIDE_START + 50 )
+#define RID_STR_BTNDEL ( RID_BASICIDE_START + 51 )
+#define RID_STR_BTNNEW ( RID_BASICIDE_START + 52 )
+#define RID_STR_CHOOSE ( RID_BASICIDE_START + 53 )
+#define RID_STR_RUN ( RID_BASICIDE_START + 54 )
+#define RID_STR_RECORD ( RID_BASICIDE_START + 56 )
+
+#define RID_CTRL_MACRO 1
+#define RID_CTRL_LIB 2
+#define RID_TXT_MACRONAME 3
+#define RID_TXT_MACROFROM 4
+#define RID_ED_MACRONAME 5
+#define RID_TXT_DESCRIPTION 6
+#define RID_PB_RUN 8
+#define RID_PB_CLOSE 9
+#define RID_PB_EDIT 10
+#define RID_PB_ORG 11
+#define RID_PB_DEL 12
+#define RID_PB_ASSIGN 13
+#define RID_PB_HELP 15
+#define RID_ML_DESCRIPTION 16
+#define RID_TXT_MACROSIN 17
+#define RID_TXT_SAVEMACRO 18
+#define RID_PB_NEWLIB 19
+#define RID_PB_NEWMOD 20
+
+#endif // _MACRODLG_HRC
+
diff --git a/basctl/source/basicide/macrodlg.hxx b/basctl/source/basicide/macrodlg.hxx
new file mode 100644
index 000000000000..b6841377833b
--- /dev/null
+++ b/basctl/source/basicide/macrodlg.hxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+//
+#ifndef _MACRODLG_HXX
+#define _MACRODLG_HXX
+
+#include <svheader.hxx>
+
+#include <bastype2.hxx>
+#include <bastype3.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <vcl/fixed.hxx>
+
+#include <vcl/button.hxx>
+
+#define MACRO_CLOSE 10
+#define MACRO_OK_RUN 11
+#define MACRO_NEW 12
+#define MACRO_EDIT 14
+#define MACRO_ORGANIZE 15
+#define MACRO_ASSIGN 16
+
+#define MACROCHOOSER_ALL 1
+#define MACROCHOOSER_CHOOSEONLY 2
+#define MACROCHOOSER_RECORDING 3
+
+class BasicManager;
+
+class MacroChooser : public SfxModalDialog
+{
+private:
+ FixedText aMacroNameTxt;
+ Edit aMacroNameEdit;
+ FixedText aMacroFromTxT;
+ FixedText aMacrosSaveInTxt;
+ BasicTreeListBox aBasicBox;
+ FixedText aMacrosInTxt;
+ String aMacrosInTxtBaseStr;
+ SvTreeListBox aMacroBox;
+
+ PushButton aRunButton;
+ CancelButton aCloseButton;
+ PushButton aAssignButton;
+ PushButton aEditButton;
+ PushButton aNewDelButton;
+ PushButton aOrganizeButton;
+ HelpButton aHelpButton;
+ PushButton aNewLibButton;
+ PushButton aNewModButton;
+
+ BOOL bNewDelIsDel;
+ BOOL bForceStoreBasic;
+
+ USHORT nMode;
+
+ DECL_LINK( MacroSelectHdl, SvTreeListBox * );
+ DECL_LINK( MacroDoubleClickHdl, SvTreeListBox * );
+ DECL_LINK( BasicSelectHdl, SvTreeListBox * );
+ DECL_LINK( EditModifyHdl, Edit * );
+ DECL_LINK( ButtonHdl, Button * );
+
+ void CheckButtons();
+ void SaveSetCurEntry( SvTreeListBox& rBox, SvLBoxEntry* pEntry );
+ void UpdateFields();
+
+ void EnableButton( Button& rButton, BOOL bEnable );
+
+ String GetInfo( SbxVariable* pVar );
+
+ void StoreMacroDescription();
+ void RestoreMacroDescription();
+
+public:
+ MacroChooser( Window* pParent, BOOL bCreateEntries = TRUE );
+ ~MacroChooser();
+
+ SbMethod* GetMacro();
+ void DeleteMacro();
+ SbMethod* CreateMacro();
+
+ virtual short Execute();
+
+ void SetMode( USHORT nMode );
+ USHORT GetMode() const { return nMode; }
+};
+
+#endif // _MACRODLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/macrodlg.src b/basctl/source/basicide/macrodlg.src
new file mode 100644
index 000000000000..5037879802b0
--- /dev/null
+++ b/basctl/source/basicide/macrodlg.src
@@ -0,0 +1,231 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <sfx2/sfx.hrc>
+#include <macrodlg.hrc>
+#include <basidesh.hrc>
+#include <helpid.hrc>
+ModalDialog RID_MACROCHOOSER
+{
+ // HelpId = SID_BASICCHOOSER ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 287 , 165 ) ;
+ Text [ en-US ] = "%PRODUCTNAME Basic Macros" ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+
+ FixedText RID_TXT_MACROSIN
+ {
+ Pos = MAP_APPFONT ( 122 , 30 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ Text [ en-US ] = "Existing macros ~in:";
+ };
+ Control RID_CTRL_MACRO
+ {
+ HelpID = HID_BASICIDE_MACROS ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 122 , 41 ) ;
+ Size = MAP_APPFONT ( 100 , 117 ) ;
+ // Size = MAP_APPFONT ( 100 , 117 ) ;
+ TabStop = TRUE ;
+ };
+ Control RID_CTRL_LIB
+ {
+ HelpID = HID_BASICIDE_LIBS ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 41 ) ;
+ Size = MAP_APPFONT ( 110 , 117 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText RID_TXT_MACRONAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ Text [ en-US ] = "~Macro name" ;
+ };
+ Edit RID_ED_MACRONAME
+ {
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 110 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText RID_TXT_MACROFROM
+ {
+ Pos = MAP_APPFONT ( 6 , 30 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ Text [ en-US ] = "Macro ~from" ;
+ };
+ FixedText RID_TXT_SAVEMACRO
+ {
+ Pos = MAP_APPFONT ( 6 , 30 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ Text [ en-US ] = "Save m~acro in";
+ };
+
+ FixedText RID_TXT_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 6 , 117 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ Text [ en-US ] = "De~scription" ;
+ };
+ PushButton RID_PB_RUN
+ {
+ Pos = MAP_APPFONT ( 231 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE;
+ /* ### ACHTUNG: Neuer Text in Resource? Aus~führen : Aus~f³hren */
+ Text [ en-US ] = "R~un" ;
+ TabStop = TRUE ;
+ };
+ CancelButton RID_PB_CLOSE
+ {
+ Pos = MAP_APPFONT ( 231 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Close";
+ };
+
+ PushButton RID_PB_ASSIGN
+ {
+ Pos = MAP_APPFONT ( 231 , 60 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Assign..." ;
+ TabStop = TRUE ;
+ };
+ PushButton RID_PB_EDIT
+ {
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Pos = MAP_APPFONT ( 231 , 77 ) ;
+ Text [ en-US ] = "~Edit" ;
+ TabStop = TRUE ;
+ };
+ PushButton RID_PB_NEWLIB
+ {
+ Pos = MAP_APPFONT ( 231 , 60 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "New ~Library";
+ };
+ PushButton RID_PB_NEWMOD
+ {
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Pos = MAP_APPFONT ( 231 , 77 ) ;
+ Text [ en-US ] = "New M~odule";
+ };
+ PushButton RID_PB_DEL
+ {
+ Pos = MAP_APPFONT ( 231 , 94 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Löschen... : ~L÷schen... */
+ Text [ en-US ] = "~Delete" ;
+ TabStop = TRUE ;
+ };
+ PushButton RID_PB_ORG
+ {
+ Pos = MAP_APPFONT ( 231 , 114 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Organizer..." ;
+ };
+ HelpButton RID_PB_HELP
+ {
+ Pos = MAP_APPFONT ( 231 , 131 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ MultiLineEdit RID_ML_DESCRIPTION
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 131 ) ;
+ Size = MAP_APPFONT ( 216 , 28 ) ;
+ TabStop = TRUE ;
+ VScroll = TRUE ;
+ IgnoreTab = TRUE ;
+ };
+};
+String RID_STR_STDMACRONAME
+{
+ Text [ en-US ] = "Macro" ;
+};
+String RID_STR_BTNDEL
+{
+ /* ### ACHTUNG: Neuer Text in Resource? ~Löschen... : ~L÷schen... */
+ Text [ en-US ] = "~Delete" ;
+};
+String RID_STR_BTNNEW
+{
+ Text [ en-US ] = "~New" ;
+};
+String RID_STR_CLOSE
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Schließen : Schlie˜en */
+ Text [ en-US ] = "Close" ;
+};
+String RID_STR_CHOOSE
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Auswählen : Auswõhlen */
+ Text [ en-US ] = "Choose" ;
+};
+String RID_STR_RUN
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Ausführen : Ausf³hren */
+ Text [ en-US ] = "Run" ;
+};
+
+String RID_STR_RECORD
+{
+ Text [ en-US ] = "~Save" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/basctl/source/basicide/makefile.mk b/basctl/source/basicide/makefile.mk
new file mode 100644
index 000000000000..b225b987b24b
--- /dev/null
+++ b/basctl/source/basicide/makefile.mk
@@ -0,0 +1,100 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=basctl
+TARGET=basicide
+VISIBILITY_HIDDEN=TRUE
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=ide_pch
+PROJECTPCHSOURCE=ide_pch
+
+# --- Settings -----------------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+.IF "$(basicdebug)" != "" || "$(BASICDEBUG)" != ""
+CDEFS+=-DBASICDEBUG
+.ENDIF
+
+
+# --- Allgemein ----------------------------------------------------------
+
+EXCEPTIONSFILES=$(SLO)$/basicrenderable.obj \
+ $(SLO)$/scriptdocument.obj \
+ $(SLO)$/basicbox.obj \
+ $(SLO)$/basidesh.obj \
+ $(SLO)$/basides1.obj \
+ $(SLO)$/basides2.obj \
+ $(SLO)$/basides3.obj \
+ $(SLO)$/baside2.obj \
+ $(SLO)$/baside3.obj \
+ $(SLO)$/basobj2.obj \
+ $(SLO)$/basobj3.obj \
+ $(SLO)$/bastypes.obj \
+ $(SLO)$/bastype2.obj \
+ $(SLO)$/bastype3.obj \
+ $(SLO)$/iderdll.obj \
+ $(SLO)$/macrodlg.obj \
+ $(SLO)$/moduldlg.obj \
+ $(SLO)$/moduldl2.obj \
+ $(SLO)$/unomodel.obj \
+ $(SLO)$/register.obj \
+ $(SLO)$/basdoc.obj \
+ $(SLO)$/tbxctl.obj \
+ $(SLO)$/basidectrlr.obj \
+ $(SLO)$/localizationmgr.obj \
+ $(SLO)$/doceventnotifier.obj \
+ $(SLO)$/docsignature.obj \
+ $(SLO)$/documentenumeration.obj
+
+SLOFILES = $(EXCEPTIONSFILES) \
+ $(SLO)$/baside2b.obj \
+ $(SLO)$/brkdlg.obj \
+ $(SLO)$/objdlg.obj \
+
+SRS1NAME=$(TARGET)
+SRC1FILES= basidesh.src macrodlg.src moptions.src moduldlg.src objdlg.src brkdlg.src tbxctl.src basicprint.src
+
+.INCLUDE : target.mk
+
+$(INCCOM)$/dllname.hxx: makefile.mk
+.IF "$(GUI)"=="UNX"
+ $(RM) $@
+ echo \#define DLL_NAME \"libbasctl$(DLLPOSTFIX)$(DLLPOST)\" >$@
+.ELSE
+ echo \#define DLL_NAME \"basctl$(DLLPOSTFIX)$(DLLPOST)\" >$@
+.ENDIF
+
+$(SLO)$/basiclib.obj : $(INCCOM)$/dllname.hxx
+
+$(INCCOM)$/basicide.hrc: basidesh.hrc
+ @-$(COPY) basidesh.hrc $@
+
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
new file mode 100644
index 000000000000..b66d6b3510d9
--- /dev/null
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -0,0 +1,1728 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#define GLOBALOVERFLOW
+
+#include <ide_pch.hxx>
+
+#include <svtools/filedlg.hxx>
+
+
+#include <sot/storinfo.hxx>
+
+#include <moduldlg.hrc>
+#include <moduldlg.hxx>
+#include <basidesh.hrc>
+#include <basidesh.hxx>
+#include <bastypes.hxx>
+#include <basobj.hxx>
+#include <baside2.hrc>
+#include <iderdll.hxx>
+#include <iderdll2.hxx>
+#include <svx/passwd.hxx>
+#include <sbxitem.hxx>
+#include <basdoc.hxx>
+#include <ucbhelper/content.hxx>
+#include "rtl/uri.hxx"
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <sot/storage.hxx>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <com/sun/star/script/XLibraryContainer2.hpp>
+#include <com/sun/star/script/XLibraryContainerPassword.hpp>
+#include <com/sun/star/script/XLibraryContainerExport.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include "com/sun/star/ucb/XCommandEnvironment.hpp"
+#include <com/sun/star/ucb/NameClash.hpp>
+#include "com/sun/star/packages/manifest/XManifestWriter.hpp"
+#include <unotools/pathoptions.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/util/VetoException.hpp>
+#include <com/sun/star/script/ModuleSizeExceededRequest.hpp>
+
+using namespace ::comphelper;
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::ui::dialogs;
+
+
+typedef ::cppu::WeakImplHelper1< task::XInteractionHandler > HandlerImpl_BASE;
+
+class DummyInteractionHandler : public HandlerImpl_BASE
+{
+ Reference< task::XInteractionHandler > m_xHandler;
+public:
+ DummyInteractionHandler( const Reference< task::XInteractionHandler >& xHandler ) : m_xHandler( xHandler ){}
+
+ virtual void SAL_CALL handle( const Reference< task::XInteractionRequest >& rRequest ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ if ( m_xHandler.is() )
+ {
+ script::ModuleSizeExceededRequest aModSizeException;
+ if ( rRequest->getRequest() >>= aModSizeException )
+ m_xHandler->handle( rRequest );
+ }
+ }
+};
+
+//----------------------------------------------------------------------------
+// BasicLibUserData
+//----------------------------------------------------------------------------
+class BasicLibUserData
+{
+private:
+ ScriptDocument m_aDocument;
+
+public:
+ BasicLibUserData( const ScriptDocument& rDocument ) : m_aDocument( rDocument ) { }
+ virtual ~BasicLibUserData() {};
+
+ const ScriptDocument&
+ GetDocument() const { return m_aDocument; }
+};
+
+
+//----------------------------------------------------------------------------
+// BasicLibLBoxString
+//----------------------------------------------------------------------------
+
+class BasicLibLBoxString : public SvLBoxString
+{
+public:
+ BasicLibLBoxString( SvLBoxEntry* pEntry, USHORT nFlags, const String& rTxt ) :
+ SvLBoxString( pEntry, nFlags, rTxt ) {}
+
+ virtual void Paint( const Point& rPos, SvLBox& rDev, USHORT nFlags, SvLBoxEntry* pEntry );
+};
+
+//----------------------------------------------------------------------------
+
+void BasicLibLBoxString::Paint( const Point& rPos, SvLBox& rDev, USHORT, SvLBoxEntry* pEntry )
+{
+ // Change text color if library is read only:
+ bool bReadOnly = false;
+ if (pEntry && pEntry->GetUserData())
+ {
+ ScriptDocument aDocument(
+ static_cast< BasicLibUserData * >(pEntry->GetUserData())->
+ GetDocument() );
+
+ rtl::OUString aLibName(
+ static_cast< SvLBoxString * >(pEntry->GetItem(1))->GetText());
+ Reference< script::XLibraryContainer2 > xModLibContainer(
+ aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY);
+ Reference< script::XLibraryContainer2 > xDlgLibContainer(
+ aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY);
+ bReadOnly
+ = (xModLibContainer.is() && xModLibContainer->hasByName(aLibName)
+ && xModLibContainer->isLibraryReadOnly(aLibName))
+ || (xDlgLibContainer.is() && xDlgLibContainer->hasByName(aLibName)
+ && xDlgLibContainer->isLibraryReadOnly(aLibName));
+ }
+ if (bReadOnly)
+ rDev.DrawCtrlText(rPos, GetText(), 0, STRING_LEN, TEXT_DRAW_DISABLE);
+ else
+ rDev.DrawText(rPos, GetText());
+}
+
+
+//----------------------------------------------------------------------------
+// BasicCheckBox
+//----------------------------------------------------------------------------
+
+BasicCheckBox::BasicCheckBox( Window* pParent, const ResId& rResId )
+ :SvTabListBox( pParent, rResId )
+ ,m_aDocument( ScriptDocument::getApplicationScriptDocument() )
+{
+ nMode = LIBMODE_MANAGER;
+ long aTabs_[] = { 1, 12 }; // Mindestens einen braucht die TabPos...
+ // 12 wegen der Checkbox
+ SetTabs( aTabs_ );
+ Init();
+}
+
+//----------------------------------------------------------------------------
+
+__EXPORT BasicCheckBox::~BasicCheckBox()
+{
+ delete pCheckButton;
+
+ // delete user data
+ SvLBoxEntry* pEntry = First();
+ while ( pEntry )
+ {
+ delete (BasicLibUserData*)pEntry->GetUserData();
+ pEntry = Next( pEntry );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void BasicCheckBox::Init()
+{
+ pCheckButton = new SvLBoxButtonData(this);
+
+ if ( nMode == LIBMODE_CHOOSER )
+ EnableCheckButton( pCheckButton );
+ else
+ EnableCheckButton( 0 );
+
+ SetHighlightRange();
+}
+
+//----------------------------------------------------------------------------
+
+void BasicCheckBox::SetMode( USHORT n )
+{
+ nMode = n;
+
+ if ( nMode == LIBMODE_CHOOSER )
+ EnableCheckButton( pCheckButton );
+ else
+ EnableCheckButton( 0 );
+}
+
+//----------------------------------------------------------------------------
+
+SvLBoxEntry* BasicCheckBox::DoInsertEntry( const String& rStr, ULONG nPos )
+{
+ return SvTabListBox::InsertEntryToColumn( rStr, nPos, 0 );
+}
+
+//----------------------------------------------------------------------------
+
+SvLBoxEntry* BasicCheckBox::FindEntry( const String& rName )
+{
+ ULONG nCount = GetEntryCount();
+ for ( ULONG i = 0; i < nCount; i++ )
+ {
+ SvLBoxEntry* pEntry = GetEntry( i );
+ DBG_ASSERT( pEntry, "pEntry?!" );
+ if ( rName.CompareIgnoreCaseToAscii( GetEntryText( pEntry, 0 ) ) == COMPARE_EQUAL )
+ return pEntry;
+ }
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+void BasicCheckBox::CheckEntryPos( ULONG nPos, BOOL bCheck )
+{
+ if ( nPos < GetEntryCount() )
+ {
+ SvLBoxEntry* pEntry = GetEntry( nPos );
+
+ if ( bCheck != GetCheckButtonState( pEntry ) )
+ SetCheckButtonState( pEntry,
+ bCheck
+ ? SvButtonState(SV_BUTTON_CHECKED)
+ : SvButtonState(SV_BUTTON_UNCHECKED) );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL BasicCheckBox::IsChecked( ULONG nPos ) const
+{
+ if ( nPos < GetEntryCount() )
+ return (GetCheckButtonState( GetEntry( nPos ) ) == SV_BUTTON_CHECKED);
+ return FALSE;
+}
+
+//----------------------------------------------------------------------------
+
+void BasicCheckBox::InitEntry( SvLBoxEntry* pEntry, const XubString& rTxt, const Image& rImg1, const Image& rImg2, SvLBoxButtonKind eButtonKind )
+{
+ SvTabListBox::InitEntry( pEntry, rTxt, rImg1, rImg2, eButtonKind );
+
+ if ( nMode == LIBMODE_MANAGER )
+ {
+ // initialize all columns with own string class (column 0 == bitmap)
+ USHORT nCount = pEntry->ItemCount();
+ for ( USHORT nCol = 1; nCol < nCount; ++nCol )
+ {
+ SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nCol );
+ BasicLibLBoxString* pStr = new BasicLibLBoxString( pEntry, 0, pCol->GetText() );
+ pEntry->ReplaceItem( pStr, nCol );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT BasicCheckBox::EditingEntry( SvLBoxEntry* pEntry, Selection& )
+{
+ if ( nMode != LIBMODE_MANAGER )
+ return FALSE;
+
+ DBG_ASSERT( pEntry, "Kein Eintrag?" );
+
+ // check, if Standard library
+ String aLibName = GetEntryText( pEntry, 0 );
+ if ( aLibName.EqualsIgnoreCaseAscii( "Standard" ) )
+ {
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_CANNOTCHANGENAMESTDLIB ) ) ).Execute();
+ return FALSE;
+ }
+
+ // check, if library is readonly
+ ::rtl::OUString aOULibName( aLibName );
+ Reference< script::XLibraryContainer2 > xModLibContainer( m_aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) && !xModLibContainer->isLibraryLink( aOULibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) && !xDlgLibContainer->isLibraryLink( aOULibName ) ) )
+ {
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_LIBISREADONLY ) ) ).Execute();
+ return FALSE;
+ }
+
+ // i24094: Password verification necessary for renaming
+ BOOL bOK = TRUE;
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ // check password
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
+ {
+ String aPassword;
+ Reference< script::XLibraryContainer > xModLibContainer1( xModLibContainer, UNO_QUERY );
+ bOK = QueryPassword( xModLibContainer1, aLibName, aPassword );
+ }
+ if ( !bOK )
+ return FALSE;
+ }
+
+ // TODO: check if library is reference/link
+
+ // Prueffen, ob Referenz...
+ /*
+ USHORT nLib = pBasMgr->GetLibId( GetEntryText( pEntry, 0 ) );
+ DBG_ASSERT( nLib != LIB_NOTFOUND, "LibId ?!" );
+ if ( pBasMgr->IsReference( nLib ) )
+ {
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_CANNOTCHANGENAMEREFLIB ) ) ).Execute();
+ return FALSE;
+ }
+ */
+ return TRUE;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT BasicCheckBox::EditedEntry( SvLBoxEntry* pEntry, const String& rNewText )
+{
+ BOOL bValid = ( rNewText.Len() <= 30 ) && BasicIDE::IsValidSbxName( rNewText );
+ String aCurText( GetEntryText( pEntry, 0 ) );
+ if ( bValid && ( aCurText != rNewText ) )
+ {
+ try
+ {
+ ::rtl::OUString aOUOldName( aCurText );
+ ::rtl::OUString aOUNewName( rNewText );
+
+ Reference< script::XLibraryContainer2 > xModLibContainer( m_aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ if ( xModLibContainer.is() )
+ {
+ xModLibContainer->renameLibrary( aOUOldName, aOUNewName );
+ }
+
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( xDlgLibContainer.is() )
+ {
+ xDlgLibContainer->renameLibrary( aOUOldName, aOUNewName );
+ }
+
+ BasicIDE::MarkDocumentModified( m_aDocument );
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ {
+ pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR );
+ pBindings->Update( SID_BASICIDE_LIBSELECTOR );
+ }
+ }
+ catch ( container::ElementExistException& )
+ {
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_SBXNAMEALLREADYUSED ) ) ).Execute();
+ return FALSE;
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return FALSE;
+ }
+ }
+
+ if ( !bValid )
+ {
+ if ( rNewText.Len() > 30 )
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_LIBNAMETOLONG ) ) ).Execute();
+ else
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_BADSBXNAME ) ) ).Execute();
+ }
+
+ return bValid;
+}
+
+//----------------------------------------------------------------------------
+// NewObjectDialog
+//----------------------------------------------------------------------------
+
+IMPL_LINK(NewObjectDialog, OkButtonHandler, Button *, EMPTYARG)
+{
+ if (BasicIDE::IsValidSbxName(aEdit.GetText()))
+ EndDialog(1);
+ else
+ {
+ ErrorBox(this, WB_OK | WB_DEF_OK,
+ String(IDEResId(RID_STR_BADSBXNAME))).Execute();
+ aEdit.GrabFocus();
+ }
+ return 0;
+}
+
+NewObjectDialog::NewObjectDialog(Window * pParent, USHORT nMode,
+ bool bCheckName)
+ : ModalDialog( pParent, IDEResId( RID_DLG_NEWLIB ) ),
+ aText( this, IDEResId( RID_FT_NEWLIB ) ),
+ aEdit( this, IDEResId( RID_ED_LIBNAME ) ),
+ aOKButton( this, IDEResId( RID_PB_OK ) ),
+ aCancelButton( this, IDEResId( RID_PB_CANCEL ) )
+{
+ FreeResource();
+ aEdit.GrabFocus();
+
+ if ( nMode == NEWOBJECTMODE_LIB )
+ {
+ SetText( String( IDEResId( RID_STR_NEWLIB ) ) );
+ }
+ else if ( nMode == NEWOBJECTMODE_MOD )
+ {
+ SetText( String( IDEResId( RID_STR_NEWMOD ) ) );
+ }
+ else if ( nMode == NEWOBJECTMODE_METH )
+ {
+ SetText( String( IDEResId( RID_STR_NEWMETH ) ) );
+ }
+ else
+ {
+ SetText( String( IDEResId( RID_STR_NEWDLG ) ) );
+ }
+
+ if (bCheckName)
+ aOKButton.SetClickHdl(LINK(this, NewObjectDialog, OkButtonHandler));
+}
+
+//----------------------------------------------------------------------------
+
+NewObjectDialog::~NewObjectDialog()
+{
+}
+
+//----------------------------------------------------------------------------
+// ExportDialog
+//----------------------------------------------------------------------------
+
+IMPL_LINK(ExportDialog, OkButtonHandler, Button *, EMPTYARG)
+{
+ mbExportAsPackage = maExportAsPackageButton.IsChecked();
+ EndDialog(1);
+ return 0;
+}
+
+ExportDialog::ExportDialog( Window * pParent )
+ : ModalDialog( pParent, IDEResId( RID_DLG_EXPORT ) ),
+ maExportAsPackageButton( this, IDEResId( RB_EXPORTASPACKAGE ) ),
+ maExportAsBasicButton( this, IDEResId( RB_EXPORTASBASIC ) ),
+ maOKButton( this, IDEResId( RID_PB_OK ) ),
+ maCancelButton( this, IDEResId( RID_PB_CANCEL ) )
+{
+ FreeResource();
+ maExportAsPackageButton.Check();
+ maOKButton.SetClickHdl(LINK(this, ExportDialog, OkButtonHandler));
+}
+
+//----------------------------------------------------------------------------
+
+ExportDialog::~ExportDialog()
+{
+}
+
+//----------------------------------------------------------------------------
+// LibPage
+//----------------------------------------------------------------------------
+
+LibPage::LibPage( Window * pParent )
+ :TabPage( pParent, IDEResId( RID_TP_LIBS ) )
+ ,aBasicsText( this, IDEResId( RID_STR_BASICS ) )
+ ,aBasicsBox( this, IDEResId( RID_LB_BASICS ) )
+ ,aLibText( this, IDEResId( RID_STR_LIB ) )
+ ,aLibBox( this, IDEResId( RID_TRLBOX ) )
+ ,aEditButton( this, IDEResId( RID_PB_EDIT ) )
+ ,aCloseButton( this, IDEResId( RID_PB_CLOSE ) )
+ ,aPasswordButton( this, IDEResId( RID_PB_PASSWORD ) )
+ ,aExportButton( this, IDEResId( RID_PB_EXPORT ) )
+ ,aNewLibButton( this, IDEResId( RID_PB_NEWLIB ) )
+ ,aInsertLibButton( this, IDEResId( RID_PB_APPEND ) )
+ ,aDelButton( this, IDEResId( RID_PB_DELETE ) )
+ ,m_aCurDocument( ScriptDocument::getApplicationScriptDocument() )
+ ,m_eCurLocation( LIBRARY_LOCATION_UNKNOWN )
+{
+ FreeResource();
+ pTabDlg = 0;
+
+ aEditButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
+ aNewLibButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
+ aPasswordButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
+ aExportButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
+ aInsertLibButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
+ aDelButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
+ aCloseButton.SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
+ aLibBox.SetSelectHdl( LINK( this, LibPage, TreeListHighlightHdl ) );
+
+ aBasicsBox.SetSelectHdl( LINK( this, LibPage, BasicSelectHdl ) );
+
+ aLibBox.SetMode( LIBMODE_MANAGER );
+ aLibBox.EnableInplaceEditing( TRUE );
+ aLibBox.SetWindowBits( WB_HSCROLL );
+ aCloseButton.GrabFocus();
+
+ long aTabs[] = { 2, 30, 120 };
+ aLibBox.SetTabs( aTabs, MAP_PIXEL );
+
+ FillListBox();
+ aBasicsBox.SelectEntryPos( 0 );
+ SetCurLib();
+
+ CheckButtons();
+}
+
+//----------------------------------------------------------------------------
+
+LibPage::~LibPage()
+{
+ USHORT nCount = aBasicsBox.GetEntryCount();
+ for ( USHORT i = 0; i < nCount; ++i )
+ {
+ BasicDocumentEntry* pEntry = (BasicDocumentEntry*)aBasicsBox.GetEntryData( i );
+ delete pEntry;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void LibPage::CheckButtons()
+{
+ SvLBoxEntry* pCur = aLibBox.GetCurEntry();
+ if ( pCur )
+ {
+ String aLibName = aLibBox.GetEntryText( pCur, 0 );
+ ::rtl::OUString aOULibName( aLibName );
+ Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+
+ if ( m_eCurLocation == LIBRARY_LOCATION_SHARE )
+ {
+ aPasswordButton.Disable();
+ aNewLibButton.Disable();
+ aInsertLibButton.Disable();
+ aDelButton.Disable();
+ }
+ else if ( aLibName.EqualsIgnoreCaseAscii( "Standard" ) )
+ {
+ aPasswordButton.Disable();
+ aNewLibButton.Enable();
+ aInsertLibButton.Enable();
+ aExportButton.Disable();
+ aDelButton.Disable();
+ if ( !aLibBox.HasFocus() )
+ aCloseButton.GrabFocus();
+ }
+ else if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) )
+ {
+ aPasswordButton.Disable();
+ aNewLibButton.Enable();
+ aInsertLibButton.Enable();
+ if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) && !xModLibContainer->isLibraryLink( aOULibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) && !xDlgLibContainer->isLibraryLink( aOULibName ) ) )
+ aDelButton.Disable();
+ else
+ aDelButton.Enable();
+ }
+ else
+ {
+ if ( xModLibContainer.is() && !xModLibContainer->hasByName( aOULibName ) )
+ aPasswordButton.Disable();
+ else
+ aPasswordButton.Enable();
+
+ aNewLibButton.Enable();
+ aInsertLibButton.Enable();
+ aExportButton.Enable();
+ aDelButton.Enable();
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void __EXPORT LibPage::ActivatePage()
+{
+ SetCurLib();
+}
+
+//----------------------------------------------------------------------------
+
+
+void __EXPORT LibPage::DeactivatePage()
+{
+}
+
+//----------------------------------------------------------------------------
+
+
+IMPL_LINK_INLINE_START( LibPage, TreeListHighlightHdl, SvTreeListBox *, pBox )
+{
+ if ( pBox->IsSelected( pBox->GetHdlEntry() ) )
+ CheckButtons();
+ return 0;
+}
+IMPL_LINK_INLINE_END( LibPage, TreeListHighlightHdl, SvTreeListBox *, pBox )
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( LibPage, BasicSelectHdl, ListBox *, pBox )
+{
+ (void)pBox;
+ SetCurLib();
+ CheckButtons();
+ return 0;
+}
+IMPL_LINK_INLINE_END( LibPage, BasicSelectHdl, ListBox *, pBox )
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( LibPage, ButtonHdl, Button *, pButton )
+{
+ if ( pButton == &aEditButton )
+ {
+ SfxAllItemSet aArgs( SFX_APP()->GetPool() );
+ SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs );
+ SFX_APP()->ExecuteSlot( aRequest );
+
+ SfxUsrAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( m_aCurDocument.getDocumentOrNull() ) );
+ SvLBoxEntry* pCurEntry = aLibBox.GetCurEntry();
+ DBG_ASSERT( pCurEntry, "Entry?!" );
+ String aLibName( aLibBox.GetEntryText( pCurEntry, 0 ) );
+ SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if ( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_LIBSELECTED,
+ SFX_CALLMODE_ASYNCHRON, &aDocItem, &aLibNameItem, 0L );
+ }
+ EndTabDialog( 1 );
+ return 0;
+ }
+ else if ( pButton == &aNewLibButton )
+ NewLib();
+ else if ( pButton == &aInsertLibButton )
+ InsertLib();
+ else if ( pButton == &aExportButton )
+ Export();
+ else if ( pButton == &aDelButton )
+ DeleteCurrent();
+ else if ( pButton == &aCloseButton )
+ {
+ EndTabDialog( 0 );
+ return 0;
+ }
+ else if ( pButton == &aPasswordButton )
+ {
+ SvLBoxEntry* pCurEntry = aLibBox.GetCurEntry();
+ String aLibName( aLibBox.GetEntryText( pCurEntry, 0 ) );
+ ::rtl::OUString aOULibName( aLibName );
+
+ // load module library (if not loaded)
+ Reference< script::XLibraryContainer > xModLibContainer = m_aCurDocument.getLibraryContainer( E_SCRIPTS );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if ( pIDEShell )
+ pIDEShell->GetViewFrame()->GetWindow().EnterWait();
+ xModLibContainer->loadLibrary( aOULibName );
+ if ( pIDEShell )
+ pIDEShell->GetViewFrame()->GetWindow().LeaveWait();
+ }
+
+ // load dialog library (if not loaded)
+ Reference< script::XLibraryContainer > xDlgLibContainer = m_aCurDocument.getLibraryContainer( E_DIALOGS );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ if ( pIDEShell )
+ pIDEShell->GetViewFrame()->GetWindow().EnterWait();
+ xDlgLibContainer->loadLibrary( aOULibName );
+ if ( pIDEShell )
+ pIDEShell->GetViewFrame()->GetWindow().LeaveWait();
+ }
+
+ // check, if library is password protected
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
+ {
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() )
+ {
+ BOOL bProtected = xPasswd->isLibraryPasswordProtected( aOULibName );
+
+ // change password dialog
+ SvxPasswordDialog* pDlg = new SvxPasswordDialog( this, TRUE, !bProtected );
+ pDlg->SetCheckPasswordHdl( LINK( this, LibPage, CheckPasswordHdl ) );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ BOOL bNewProtected = xPasswd->isLibraryPasswordProtected( aOULibName );
+
+ if ( bNewProtected != bProtected )
+ {
+ ULONG nPos = (ULONG)aLibBox.GetModel()->GetAbsPos( pCurEntry );
+ aLibBox.GetModel()->Remove( pCurEntry );
+ ImpInsertLibEntry( aLibName, nPos );
+ aLibBox.SetCurEntry( aLibBox.GetEntry( nPos ) );
+ }
+
+ BasicIDE::MarkDocumentModified( m_aCurDocument );
+ }
+ delete pDlg;
+ }
+ }
+ }
+ CheckButtons();
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( LibPage, CheckPasswordHdl, SvxPasswordDialog *, pDlg )
+{
+ long nRet = 0;
+
+ SvLBoxEntry* pCurEntry = aLibBox.GetCurEntry();
+ ::rtl::OUString aOULibName( aLibBox.GetEntryText( pCurEntry, 0 ) );
+ Reference< script::XLibraryContainerPassword > xPasswd( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+
+ if ( xPasswd.is() )
+ {
+ try
+ {
+ ::rtl::OUString aOUOldPassword( pDlg->GetOldPassword() );
+ ::rtl::OUString aOUNewPassword( pDlg->GetNewPassword() );
+ xPasswd->changeLibraryPassword( aOULibName, aOUOldPassword, aOUNewPassword );
+ nRet = 1;
+ }
+ catch (...)
+ {
+ }
+ }
+
+ return nRet;
+}
+IMPL_LINK_INLINE_END( LibPage, CheckPasswordHdl, SvxPasswordDialog *, pDlg )
+
+//----------------------------------------------------------------------------
+
+void LibPage::NewLib()
+{
+ createLibImpl( static_cast<Window*>( this ), m_aCurDocument, &aLibBox, NULL);
+}
+
+//----------------------------------------------------------------------------
+
+void LibPage::InsertLib()
+{
+ // file open dialog
+ Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
+ Reference < XFilePicker > xFP;
+ if( xMSF.is() )
+ {
+ Sequence <Any> aServiceType(1);
+ aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
+ xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
+ }
+ xFP->setTitle( String( IDEResId( RID_STR_APPENDLIBS ) ) );
+
+ // filter
+ ::rtl::OUString aTitle = String( IDEResId( RID_STR_BASIC ) );
+ ::rtl::OUString aFilter;
+ aFilter = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.sbl;*.xlc;*.xlb" ) ); // library files
+ aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sdw;*.sxw;*.odt" ) ); // text
+ aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.vor;*.stw;*.ott" ) ); // text template
+ aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sgl;*.sxg;*.odm" ) ); // master document
+ aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.oth" ) ); // html document template
+ aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sdc;*.sxc;*.ods" ) ); // spreadsheet
+ aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.stc;*.ots" ) ); // spreadsheet template
+ aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sda;*.sxd;*.odg" ) ); // drawing
+ aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.std;*.otg" ) ); // drawing template
+ aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sdd;*.sxi;*.odp" ) ); // presentation
+ aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sti;*.otp" ) ); // presentation template
+ aFilter += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";*.sxm;*.odf" ) ); // formula
+ Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
+ xFltMgr->appendFilter( aTitle, aFilter );
+
+ // set display directory and filter
+ String aPath( IDE_DLL()->GetExtraData()->GetAddLibPath() );
+ if ( aPath.Len() )
+ {
+ xFP->setDisplayDirectory( aPath );
+ }
+ else
+ {
+ // macro path from configuration management
+ xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
+ }
+
+ String aLastFilter( IDE_DLL()->GetExtraData()->GetAddLibFilter() );
+ if ( aLastFilter.Len() )
+ {
+ xFltMgr->setCurrentFilter( aLastFilter );
+ }
+ else
+ {
+ xFltMgr->setCurrentFilter( String( IDEResId( RID_STR_BASIC ) ) );
+ }
+
+ if ( xFP->execute() == RET_OK )
+ {
+ IDE_DLL()->GetExtraData()->SetAddLibPath( xFP->getDisplayDirectory() );
+ IDE_DLL()->GetExtraData()->SetAddLibFilter( xFltMgr->getCurrentFilter() );
+
+ // library containers for import
+ Reference< script::XLibraryContainer2 > xModLibContImport;
+ Reference< script::XLibraryContainer2 > xDlgLibContImport;
+
+ // file URLs
+ Sequence< ::rtl::OUString > aFiles = xFP->getFiles();
+ INetURLObject aURLObj( aFiles[0] );
+ INetURLObject aModURLObj( aURLObj );
+ INetURLObject aDlgURLObj( aURLObj );
+
+ String aBase = aURLObj.getBase();
+ String aModBase = String::CreateFromAscii( "script" );
+ String aDlgBase = String::CreateFromAscii( "dialog" );
+
+ if ( aBase == aModBase || aBase == aDlgBase )
+ {
+ aModURLObj.setBase( aModBase );
+ aDlgURLObj.setBase( aDlgBase );
+ }
+
+ if ( xMSF.is() )
+ {
+ Reference< XSimpleFileAccess > xSFA( xMSF->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" ) ) ), UNO_QUERY );
+
+ if ( xSFA.is() )
+ {
+ ::rtl::OUString aModURL( aModURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
+ if ( xSFA->exists( aModURL ) )
+ {
+ Sequence <Any> aSeqModURL(1);
+ aSeqModURL[0] <<= aModURL;
+ xModLibContImport = Reference< script::XLibraryContainer2 >( xMSF->createInstanceWithArguments(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.DocumentScriptLibraryContainer" ) ), aSeqModURL ), UNO_QUERY );
+ }
+
+ ::rtl::OUString aDlgURL( aDlgURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
+ if ( xSFA->exists( aDlgURL ) )
+ {
+ Sequence <Any> aSeqDlgURL(1);
+ aSeqDlgURL[0] <<= aDlgURL;
+ xDlgLibContImport = Reference< script::XLibraryContainer2 >( xMSF->createInstanceWithArguments(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.DocumentDialogLibraryContainer" ) ), aSeqDlgURL ), UNO_QUERY );
+ }
+ }
+ }
+
+ if ( xModLibContImport.is() || xDlgLibContImport.is() )
+ {
+ LibDialog* pLibDlg = 0;
+
+ Reference< script::XLibraryContainer > xModLibContImp( xModLibContImport, UNO_QUERY );
+ Reference< script::XLibraryContainer > xDlgLibContImp( xDlgLibContImport, UNO_QUERY );
+ Sequence< ::rtl::OUString > aLibNames = BasicIDE::GetMergedLibraryNames( xModLibContImp, xDlgLibContImp );
+ sal_Int32 nLibCount = aLibNames.getLength();
+ const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
+ for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+ {
+ // library import dialog
+ if ( !pLibDlg )
+ {
+ pLibDlg = new LibDialog( this );
+ pLibDlg->SetStorageName( aURLObj.getName() );
+ pLibDlg->GetLibBox().SetMode( LIBMODE_CHOOSER );
+ }
+
+ // libbox entries
+ String aLibName( pLibNames[ i ] );
+ String aOULibName( aLibName );
+ if ( !( ( xModLibContImport.is() && xModLibContImport->hasByName( aOULibName ) && xModLibContImport->isLibraryLink( aOULibName ) ) ||
+ ( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aOULibName ) && xDlgLibContImport->isLibraryLink( aOULibName ) ) ) )
+ {
+ SvLBoxEntry* pEntry = pLibDlg->GetLibBox().DoInsertEntry( aLibName );
+ USHORT nPos = (USHORT) pLibDlg->GetLibBox().GetModel()->GetAbsPos( pEntry );
+ pLibDlg->GetLibBox().CheckEntryPos( nPos, TRUE);
+ }
+ }
+
+ if ( !pLibDlg )
+ InfoBox( this, String( IDEResId( RID_STR_NOLIBINSTORAGE ) ) ).Execute();
+ else
+ {
+ BOOL bChanges = FALSE;
+ String aExtension( aURLObj.getExtension() );
+ String aLibExtension( String::CreateFromAscii( "xlb" ) );
+ String aContExtension( String::CreateFromAscii( "xlc" ) );
+
+ // disable reference checkbox for documents and sbls
+ if ( aExtension != aLibExtension && aExtension != aContExtension )
+ pLibDlg->EnableReference( FALSE );
+
+ if ( pLibDlg->Execute() )
+ {
+ ULONG nNewPos = aLibBox.GetEntryCount();
+ BOOL bRemove = FALSE;
+ BOOL bReplace = pLibDlg->IsReplace();
+ BOOL bReference = pLibDlg->IsReference();
+ for ( USHORT nLib = 0; nLib < pLibDlg->GetLibBox().GetEntryCount(); nLib++ )
+ {
+ if ( pLibDlg->GetLibBox().IsChecked( nLib ) )
+ {
+ SvLBoxEntry* pEntry = pLibDlg->GetLibBox().GetEntry( nLib );
+ DBG_ASSERT( pEntry, "Entry?!" );
+ String aLibName( pLibDlg->GetLibBox().GetEntryText( pEntry, 0 ) );
+ ::rtl::OUString aOULibName( aLibName );
+ Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+
+ // check, if the library is already existing
+ if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) ) )
+ {
+ if ( bReplace )
+ {
+ // check, if the library is the Standard library
+ if ( aLibName.EqualsAscii( "Standard" ) )
+ {
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_REPLACESTDLIB ) ) ).Execute();
+ continue;
+ }
+
+ // check, if the library is readonly and not a link
+ if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) && !xModLibContainer->isLibraryLink( aOULibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) && !xDlgLibContainer->isLibraryLink( aOULibName ) ) )
+ {
+ String aErrStr( IDEResId( RID_STR_REPLACELIB ) );
+ aErrStr.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), aLibName );
+ aErrStr += '\n';
+ aErrStr += String( IDEResId( RID_STR_LIBISREADONLY ) );
+ ErrorBox( this, WB_OK | WB_DEF_OK, aErrStr ).Execute();
+ continue;
+ }
+
+ // remove existing libraries
+ bRemove = TRUE;
+ }
+ else
+ {
+ String aErrStr;
+ if ( bReference )
+ aErrStr = String( IDEResId( RID_STR_REFNOTPOSSIBLE ) );
+ else
+ aErrStr = String( IDEResId( RID_STR_IMPORTNOTPOSSIBLE ) );
+ aErrStr.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), aLibName );
+ aErrStr += '\n';
+ aErrStr += String( IDEResId( RID_STR_SBXNAMEALLREADYUSED ) );
+ ErrorBox( this, WB_OK | WB_DEF_OK, aErrStr ).Execute();
+ continue;
+ }
+ }
+
+ // check, if the library is password protected
+ BOOL bOK = FALSE;
+ String aPassword;
+ if ( xModLibContImport.is() && xModLibContImport->hasByName( aOULibName ) )
+ {
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContImport, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) && !bReference )
+ {
+ bOK = QueryPassword( xModLibContImp, aLibName, aPassword, TRUE, TRUE );
+
+ if ( !bOK )
+ {
+ String aErrStr( IDEResId( RID_STR_NOIMPORT ) );
+ aErrStr.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "XX" ) ), aLibName );
+ ErrorBox( this, WB_OK | WB_DEF_OK, aErrStr ).Execute();
+ continue;
+ }
+ }
+ }
+
+ // remove existing libraries
+ if ( bRemove )
+ {
+ // remove listbox entry
+ SvLBoxEntry* pEntry_ = aLibBox.FindEntry( aLibName );
+ if ( pEntry_ )
+ aLibBox.SvTreeListBox::GetModel()->Remove( pEntry_ );
+
+ // remove module library
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
+ xModLibContainer->removeLibrary( aOULibName );
+
+ // remove dialog library
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) )
+ xDlgLibContainer->removeLibrary( aOULibName );
+ }
+
+ // copy module library
+ if ( xModLibContImport.is() && xModLibContImport->hasByName( aOULibName ) && xModLibContainer.is() && !xModLibContainer->hasByName( aOULibName ) )
+ {
+ Reference< container::XNameContainer > xModLib;
+ if ( bReference )
+ {
+ // storage URL
+ INetURLObject aModStorageURLObj( aModURLObj );
+ if ( aExtension == aContExtension )
+ {
+ sal_Int32 nCount = aModStorageURLObj.getSegmentCount();
+ aModStorageURLObj.insertName( aLibName, false, nCount-1 );
+ aModStorageURLObj.setExtension( aLibExtension );
+ aModStorageURLObj.setFinalSlash();
+ }
+ ::rtl::OUString aModStorageURL( aModStorageURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
+
+ // create library link
+ xModLib = Reference< container::XNameContainer >( xModLibContainer->createLibraryLink( aOULibName, aModStorageURL, TRUE ), UNO_QUERY);
+ }
+ else
+ {
+ // create library
+ xModLib = xModLibContainer->createLibrary( aOULibName );
+ if ( xModLib.is() )
+ {
+ // get import library
+ Reference< container::XNameContainer > xModLibImport;
+ Any aElement = xModLibContImport->getByName( aOULibName );
+ aElement >>= xModLibImport;
+
+ if ( xModLibImport.is() )
+ {
+ // load library
+ if ( !xModLibContImport->isLibraryLoaded( aOULibName ) )
+ xModLibContImport->loadLibrary( aOULibName );
+
+ // copy all modules
+ Sequence< ::rtl::OUString > aModNames = xModLibImport->getElementNames();
+ sal_Int32 nModCount = aModNames.getLength();
+ const ::rtl::OUString* pModNames = aModNames.getConstArray();
+ for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
+ {
+ ::rtl::OUString aOUModName( pModNames[ i ] );
+ Any aElement_ = xModLibImport->getByName( aOUModName );
+ xModLib->insertByName( aOUModName, aElement_ );
+ }
+
+ // set password
+ if ( bOK )
+ {
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() )
+ {
+ try
+ {
+ ::rtl::OUString aOUPassword( aPassword );
+ xPasswd->changeLibraryPassword( aOULibName, ::rtl::OUString(), aOUPassword );
+ }
+ catch (...)
+ {
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // copy dialog library
+ if ( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aOULibName ) && xDlgLibContainer.is() && !xDlgLibContainer->hasByName( aOULibName ) )
+ {
+ Reference< container::XNameContainer > xDlgLib;
+ if ( bReference )
+ {
+ // storage URL
+ INetURLObject aDlgStorageURLObj( aDlgURLObj );
+ if ( aExtension == aContExtension )
+ {
+ sal_Int32 nCount = aDlgStorageURLObj.getSegmentCount();
+ aDlgStorageURLObj.insertName( aLibName, false, nCount - 1 );
+ aDlgStorageURLObj.setExtension( aLibExtension );
+ aDlgStorageURLObj.setFinalSlash();
+ }
+ ::rtl::OUString aDlgStorageURL( aDlgStorageURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
+
+ // create library link
+ xDlgLib = Reference< container::XNameContainer >( xDlgLibContainer->createLibraryLink( aOULibName, aDlgStorageURL, TRUE ), UNO_QUERY);
+ }
+ else
+ {
+ // create library
+ xDlgLib = xDlgLibContainer->createLibrary( aOULibName );
+ if ( xDlgLib.is() )
+ {
+ // get import library
+ Reference< container::XNameContainer > xDlgLibImport;
+ Any aElement = xDlgLibContImport->getByName( aOULibName );
+ aElement >>= xDlgLibImport;
+
+ if ( xDlgLibImport.is() )
+ {
+ // load library
+ if ( !xDlgLibContImport->isLibraryLoaded( aOULibName ) )
+ xDlgLibContImport->loadLibrary( aOULibName );
+
+ // copy all dialogs
+ Sequence< ::rtl::OUString > aDlgNames = xDlgLibImport->getElementNames();
+ sal_Int32 nDlgCount = aDlgNames.getLength();
+ const ::rtl::OUString* pDlgNames = aDlgNames.getConstArray();
+ for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
+ {
+ ::rtl::OUString aOUDlgName( pDlgNames[ i ] );
+ Any aElement_ = xDlgLibImport->getByName( aOUDlgName );
+ xDlgLib->insertByName( aOUDlgName, aElement_ );
+ }
+ }
+ }
+ }
+ }
+
+ // insert listbox entry
+ ImpInsertLibEntry( aLibName, aLibBox.GetEntryCount() );
+ bChanges = TRUE;
+ }
+ }
+
+ SvLBoxEntry* pFirstNew = aLibBox.GetEntry( nNewPos );
+ if ( pFirstNew )
+ aLibBox.SetCurEntry( pFirstNew );
+ }
+
+ delete pLibDlg;
+ if ( bChanges )
+ BasicIDE::MarkDocumentModified( m_aCurDocument );
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void LibPage::Export( void )
+{
+ SvLBoxEntry* pCurEntry = aLibBox.GetCurEntry();
+ String aLibName( aLibBox.GetEntryText( pCurEntry, 0 ) );
+
+ // Password verification
+ ::rtl::OUString aOULibName( aLibName );
+ Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ BOOL bOK = TRUE;
+
+ // check password
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
+ {
+ String aPassword;
+ Reference< script::XLibraryContainer > xModLibContainer1( xModLibContainer, UNO_QUERY );
+ bOK = QueryPassword( xModLibContainer1, aLibName, aPassword );
+ }
+ if ( !bOK )
+ return;
+ }
+
+
+ Window* pWin = static_cast<Window*>( this );
+ std::auto_ptr< ExportDialog > xNewDlg( new ExportDialog( pWin ) );
+
+ if ( xNewDlg->Execute() == RET_OK )
+ {
+ try
+ {
+ if( xNewDlg->isExportAsPackage() )
+ ExportAsPackage( aLibName );
+ else
+ ExportAsBasic( aLibName );
+ }
+ catch( util::VetoException& ) // user cancled operation
+ {
+ }
+ }
+}
+
+void LibPage::implExportLib( const String& aLibName, const String& aTargetURL,
+ const Reference< task::XInteractionHandler >& Handler )
+{
+ ::rtl::OUString aOULibName( aLibName );
+ Reference< script::XLibraryContainerExport > xModLibContainerExport
+ ( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ Reference< script::XLibraryContainerExport > xDlgLibContainerExport
+ ( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( xModLibContainerExport.is() )
+ xModLibContainerExport->exportLibrary( aOULibName, aTargetURL, Handler );
+
+ if ( xDlgLibContainerExport.is() )
+ xDlgLibContainerExport->exportLibrary( aOULibName, aTargetURL, Handler );
+}
+
+
+//===========================================================================
+// Implementation XCommandEnvironment
+
+typedef cppu::WeakImplHelper1< XCommandEnvironment > LibCommandEnvironmentHelper;
+
+class OLibCommandEnvironment : public LibCommandEnvironmentHelper
+{
+ Reference< task::XInteractionHandler > mxInteraction;
+
+public:
+ OLibCommandEnvironment( Reference< task::XInteractionHandler > xInteraction )
+ : mxInteraction( xInteraction )
+ {}
+
+ // Methods
+ virtual Reference< task::XInteractionHandler > SAL_CALL getInteractionHandler()
+ throw(RuntimeException);
+ virtual Reference< XProgressHandler > SAL_CALL getProgressHandler()
+ throw(RuntimeException);
+};
+
+Reference< task::XInteractionHandler > OLibCommandEnvironment::getInteractionHandler()
+ throw(RuntimeException)
+{
+ return mxInteraction;
+}
+
+Reference< XProgressHandler > OLibCommandEnvironment::getProgressHandler()
+ throw(RuntimeException)
+{
+ Reference< XProgressHandler > xRet;
+ return xRet;
+}
+
+
+
+void LibPage::ExportAsPackage( const String& aLibName )
+{
+ // file open dialog
+ Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
+ Reference< task::XInteractionHandler > xHandler;
+ Reference< XSimpleFileAccess > xSFA;
+ Reference < XFilePicker > xFP;
+ if( xMSF.is() )
+ {
+ xHandler = Reference< task::XInteractionHandler >( xMSF->createInstance
+ ( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), UNO_QUERY );
+
+ xSFA = Reference< XSimpleFileAccess > ( xMSF->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" ) ) ), UNO_QUERY );
+ if( !xSFA.is() )
+ {
+ DBG_ERROR( "No simpleFileAccess" );
+ return;
+ }
+
+ Sequence <Any> aServiceType(1);
+ aServiceType[0] <<= TemplateDescription::FILESAVE_SIMPLE;
+ xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
+ }
+ xFP->setTitle( String( IDEResId( RID_STR_EXPORTPACKAGE ) ) );
+
+ // filter
+ ::rtl::OUString aTitle = String( IDEResId( RID_STR_PACKAGE_BUNDLE ) );
+ ::rtl::OUString aFilter;
+ aFilter = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.oxt" ) ); // library files
+ Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
+ xFltMgr->appendFilter( aTitle, aFilter );
+
+ // set display directory and filter
+ String aPath( IDE_DLL()->GetExtraData()->GetAddLibPath() );
+ if ( aPath.Len() )
+ {
+ xFP->setDisplayDirectory( aPath );
+ }
+ else
+ {
+ // macro path from configuration management
+ xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
+ }
+ xFltMgr->setCurrentFilter( aTitle );
+
+ if ( xFP->execute() == RET_OK )
+ {
+ IDE_DLL()->GetExtraData()->SetAddLibPath( xFP->getDisplayDirectory() );
+
+ Sequence< ::rtl::OUString > aFiles = xFP->getFiles();
+ INetURLObject aURL( aFiles[0] );
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "oxt" ) ) );
+
+ ::rtl::OUString aPackageURL( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+
+ String aTmpPath = SvtPathOptions().GetTempPath();
+ INetURLObject aInetObj( aTmpPath );
+ aInetObj.insertName( aLibName, sal_True, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
+ OUString aSourcePath = aInetObj.GetMainURL( INetURLObject::NO_DECODE );
+ if( xSFA->exists( aSourcePath ) )
+ xSFA->kill( aSourcePath );
+ Reference< task::XInteractionHandler > xDummyHandler( new DummyInteractionHandler( xHandler ) );
+ implExportLib( aLibName, aTmpPath, xDummyHandler );
+
+ Reference< XCommandEnvironment > xCmdEnv =
+ static_cast<XCommandEnvironment*>( new OLibCommandEnvironment( xHandler ) );
+
+ ::ucbhelper::Content sourceContent( aSourcePath, xCmdEnv );
+
+ ::rtl::OUStringBuffer buf;
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.zip://") );
+ buf.append( ::rtl::Uri::encode( aPackageURL,
+ rtl_UriCharClassRegName,
+ rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8 ) );
+ buf.append( static_cast<sal_Unicode>('/') );
+ OUString destFolder( buf.makeStringAndClear() );
+
+ if( xSFA->exists( aPackageURL ) )
+ xSFA->kill( aPackageURL );
+
+ ::ucbhelper::Content destFolderContent( destFolder, xCmdEnv );
+ destFolderContent.transferContent(
+ sourceContent, ::ucbhelper::InsertOperation_COPY,
+ OUString(), NameClash::OVERWRITE );
+
+ INetURLObject aMetaInfInetObj( aTmpPath );
+ aMetaInfInetObj.insertName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) ),
+ sal_True, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
+ OUString aMetaInfFolder = aMetaInfInetObj.GetMainURL( INetURLObject::NO_DECODE );
+ if( xSFA->exists( aMetaInfFolder ) )
+ xSFA->kill( aMetaInfFolder );
+ xSFA->createFolder( aMetaInfFolder );
+
+ ::std::vector< Sequence<beans::PropertyValue> > manifest;
+ const OUString strMediaType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) );
+ const OUString strFullPath = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FullPath" ) );
+ const OUString strBasicMediaType = ::rtl::OUString
+ ( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.star.basic-library" ) );
+
+ Sequence<beans::PropertyValue> attribs( 2 );
+ beans::PropertyValue * pattribs = attribs.getArray();
+ pattribs[ 0 ].Name = strFullPath;
+ OUString fullPath = aLibName;
+ fullPath += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/") );
+ pattribs[ 0 ].Value <<= fullPath;
+ pattribs[ 1 ].Name = strMediaType;
+ pattribs[ 1 ].Value <<= strBasicMediaType;
+ manifest.push_back( attribs );
+
+ // write into pipe:
+ Reference<packages::manifest::XManifestWriter> xManifestWriter( xMSF->createInstance
+ ( DEFINE_CONST_UNICODE("com.sun.star.packages.manifest.ManifestWriter") ), UNO_QUERY );
+ Reference<io::XOutputStream> xPipe( xMSF->createInstance
+ ( DEFINE_CONST_UNICODE("com.sun.star.io.Pipe") ), UNO_QUERY );
+ xManifestWriter->writeManifestSequence(
+ xPipe, Sequence< Sequence<beans::PropertyValue> >(
+ &manifest[ 0 ], manifest.size() ) );
+
+ aMetaInfInetObj.insertName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "manifest.xml" ) ),
+ sal_True, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
+
+ // write buffered pipe data to content:
+ ::ucbhelper::Content manifestContent( aMetaInfInetObj.GetMainURL( INetURLObject::NO_DECODE ), xCmdEnv );
+ manifestContent.writeStream( Reference<io::XInputStream>( xPipe, UNO_QUERY_THROW ), true );
+
+ ::ucbhelper::Content MetaInfContent( aMetaInfFolder, xCmdEnv );
+ destFolderContent.transferContent(
+ MetaInfContent, ::ucbhelper::InsertOperation_COPY,
+ OUString(), NameClash::OVERWRITE );
+
+ if( xSFA->exists( aSourcePath ) )
+ xSFA->kill( aSourcePath );
+ if( xSFA->exists( aMetaInfFolder ) )
+ xSFA->kill( aMetaInfFolder );
+ }
+}
+
+void LibPage::ExportAsBasic( const String& aLibName )
+{
+ // Folder picker
+ Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
+ Reference< XFolderPicker > xFolderPicker;
+ Reference< task::XInteractionHandler > xHandler;
+ if( xMSF.is() )
+ {
+ xFolderPicker = Reference< XFolderPicker >( xMSF->createInstance(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FolderPicker" ) ) ), UNO_QUERY );
+
+ xHandler = Reference< task::XInteractionHandler >( xMSF->createInstance
+ ( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ), UNO_QUERY );
+ }
+
+ if( xFolderPicker.is() )
+ {
+ xFolderPicker->setTitle( String( IDEResId( RID_STR_EXPORTBASIC ) ) );
+
+ // set display directory and filter
+ String aPath( IDE_DLL()->GetExtraData()->GetAddLibPath() );
+ if( !aPath.Len() )
+ aPath = SvtPathOptions().GetWorkPath();
+
+ // INetURLObject aURL(m_sSavePath, INET_PROT_FILE);
+ xFolderPicker->setDisplayDirectory( aPath );
+ short nRet = xFolderPicker->execute();
+ if( nRet == RET_OK )
+ {
+ String aTargetURL = xFolderPicker->getDirectory();
+ IDE_DLL()->GetExtraData()->SetAddLibPath( aTargetURL );
+
+ Reference< task::XInteractionHandler > xDummyHandler( new DummyInteractionHandler( xHandler ) );
+ implExportLib( aLibName, aTargetURL, xDummyHandler );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void LibPage::DeleteCurrent()
+{
+ SvLBoxEntry* pCurEntry = aLibBox.GetCurEntry();
+ String aLibName( aLibBox.GetEntryText( pCurEntry, 0 ) );
+
+ // check, if library is link
+ BOOL bIsLibraryLink = FALSE;
+ ::rtl::OUString aOULibName( aLibName );
+ Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryLink( aOULibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryLink( aOULibName ) ) )
+ {
+ bIsLibraryLink = TRUE;
+ }
+
+ if ( QueryDelLib( aLibName, bIsLibraryLink, this ) )
+ {
+ // inform BasicIDE
+ SfxUsrAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( m_aCurDocument.getDocumentOrNull() ) );
+ SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_LIBREMOVED,
+ SFX_CALLMODE_SYNCHRON, &aDocItem, &aLibNameItem, 0L );
+ }
+
+ // remove library from module and dialog library containers
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
+ xModLibContainer->removeLibrary( aOULibName );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) )
+ xDlgLibContainer->removeLibrary( aOULibName );
+
+ ((SvLBox&)aLibBox).GetModel()->Remove( pCurEntry );
+ BasicIDE::MarkDocumentModified( m_aCurDocument );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void LibPage::EndTabDialog( USHORT nRet )
+{
+ DBG_ASSERT( pTabDlg, "TabDlg nicht gesetzt!" );
+ if ( pTabDlg )
+ pTabDlg->EndDialog( nRet );
+}
+
+//----------------------------------------------------------------------------
+
+void LibPage::FillListBox()
+{
+ InsertListBoxEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER );
+ InsertListBoxEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_SHARE );
+
+ ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::DocumentsSorted ) );
+ for ( ScriptDocuments::const_iterator doc = aDocuments.begin();
+ doc != aDocuments.end();
+ ++doc
+ )
+ {
+ InsertListBoxEntry( *doc, LIBRARY_LOCATION_DOCUMENT );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void LibPage::InsertListBoxEntry( const ScriptDocument& rDocument, LibraryLocation eLocation )
+{
+ String aEntryText( rDocument.getTitle( eLocation ) );
+ USHORT nPos = aBasicsBox.InsertEntry( aEntryText, LISTBOX_APPEND );
+ aBasicsBox.SetEntryData( nPos, new BasicDocumentEntry( rDocument, eLocation ) );
+}
+
+//----------------------------------------------------------------------------
+
+void LibPage::SetCurLib()
+{
+ USHORT nSelPos = aBasicsBox.GetSelectEntryPos();
+ BasicDocumentEntry* pEntry = (BasicDocumentEntry*)aBasicsBox.GetEntryData( nSelPos );
+ if ( pEntry )
+ {
+ ScriptDocument aDocument( pEntry->GetDocument() );
+ DBG_ASSERT( aDocument.isAlive(), "LibPage::SetCurLib: no document, or document is dead!" );
+ if ( !aDocument.isAlive() )
+ return;
+ LibraryLocation eLocation = pEntry->GetLocation();
+ if ( aDocument != m_aCurDocument || eLocation != m_eCurLocation )
+ {
+ m_aCurDocument = aDocument;
+ m_eCurLocation = eLocation;
+ aLibBox.SetDocument( aDocument );
+ aLibBox.Clear();
+
+ // get a sorted list of library names
+ Sequence< ::rtl::OUString > aLibNames = aDocument.getLibraryNames();
+ sal_Int32 nLibCount = aLibNames.getLength();
+ const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
+
+ for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+ {
+ String aLibName( pLibNames[ i ] );
+ if ( eLocation == aDocument.getLibraryLocation( aLibName ) )
+ ImpInsertLibEntry( aLibName, i );
+ }
+
+ SvLBoxEntry* pEntry_ = aLibBox.FindEntry( String::CreateFromAscii( "Standard" ) );
+ if ( !pEntry_ )
+ pEntry_ = aLibBox.GetEntry( 0 );
+ aLibBox.SetCurEntry( pEntry_ );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+SvLBoxEntry* LibPage::ImpInsertLibEntry( const String& rLibName, ULONG nPos )
+{
+ // check, if library is password protected
+ BOOL bProtected = FALSE;
+ ::rtl::OUString aOULibName( rLibName );
+ Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
+ {
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() )
+ {
+ bProtected = xPasswd->isLibraryPasswordProtected( aOULibName );
+ }
+ }
+
+ SvLBoxEntry* pNewEntry = aLibBox.DoInsertEntry( rLibName, nPos );
+ pNewEntry->SetUserData( new BasicLibUserData( m_aCurDocument ) );
+
+ if (bProtected)
+ {
+ Image aImage(IDEResId(RID_IMG_LOCKED));
+ aLibBox.SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
+ aLibBox.SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
+ aImage = Image(IDEResId(RID_IMG_LOCKED_HC));
+ aLibBox.SetExpandedEntryBmp(pNewEntry, aImage,
+ BMP_COLOR_HIGHCONTRAST);
+ aLibBox.SetCollapsedEntryBmp(pNewEntry, aImage,
+ BMP_COLOR_HIGHCONTRAST);
+ }
+
+ // check, if library is link
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryLink( aOULibName ) )
+ {
+ String aLinkURL = xModLibContainer->getLibraryLinkURL( aOULibName );
+ aLibBox.SetEntryText( aLinkURL, pNewEntry, 1 );
+ }
+
+ return pNewEntry;
+}
+
+//----------------------------------------------------------------------------
+
+// Helper function
+void createLibImpl( Window* pWin, const ScriptDocument& rDocument,
+ BasicCheckBox* pLibBox, BasicTreeListBox* pBasicBox )
+{
+ OSL_ENSURE( rDocument.isAlive(), "createLibImpl: invalid document!" );
+ if ( !rDocument.isAlive() )
+ return;
+
+ // create library name
+ String aLibName;
+ String aLibStdName( String( RTL_CONSTASCII_USTRINGPARAM( "Library" ) ) );
+ //String aLibStdName( IDEResId( RID_STR_STDLIBNAME ) );
+ BOOL bValid = FALSE;
+ USHORT i = 1;
+ while ( !bValid )
+ {
+ aLibName = aLibStdName;
+ aLibName += String::CreateFromInt32( i );
+ if ( !rDocument.hasLibrary( E_SCRIPTS, aLibName ) && !rDocument.hasLibrary( E_DIALOGS, aLibName ) )
+ bValid = TRUE;
+ i++;
+ }
+
+ std::auto_ptr< NewObjectDialog > xNewDlg( new NewObjectDialog( pWin, NEWOBJECTMODE_LIB ) );
+ xNewDlg->SetObjectName( aLibName );
+
+ if ( xNewDlg->Execute() )
+ {
+ if ( xNewDlg->GetObjectName().Len() )
+ aLibName = xNewDlg->GetObjectName();
+
+ if ( aLibName.Len() > 30 )
+ {
+ ErrorBox( pWin, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_LIBNAMETOLONG ) ) ).Execute();
+ }
+ else if ( !BasicIDE::IsValidSbxName( aLibName ) )
+ {
+ ErrorBox( pWin, WB_OK | WB_DEF_OK,
+ String( IDEResId( RID_STR_BADSBXNAME ) ) ).Execute();
+ }
+ else if ( rDocument.hasLibrary( E_SCRIPTS, aLibName ) || rDocument.hasLibrary( E_DIALOGS, aLibName ) )
+ {
+ ErrorBox( pWin, WB_OK | WB_DEF_OK,
+ String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute();
+ }
+ else
+ {
+ try
+ {
+ // create module and dialog library
+ Reference< container::XNameContainer > xModLib( rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName ) );
+ Reference< container::XNameContainer > xDlgLib( rDocument.getOrCreateLibrary( E_DIALOGS, aLibName ) );
+
+ if( pLibBox )
+ {
+ SvLBoxEntry* pEntry = pLibBox->DoInsertEntry( aLibName );
+ pEntry->SetUserData( new BasicLibUserData( rDocument ) );
+ pLibBox->SetCurEntry( pEntry );
+ }
+
+ // create a module
+ String aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
+ ::rtl::OUString sModuleCode;
+ if ( !rDocument.createModule( aLibName, aModName, TRUE, sModuleCode ) )
+ throw Exception();
+
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, BASICIDE_TYPE_MODULE );
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
+ SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
+ }
+
+ if( pBasicBox )
+ {
+ SvLBoxEntry* pEntry = pBasicBox->GetCurEntry();
+ SvLBoxEntry* pRootEntry = NULL;
+ while( pEntry )
+ {
+ pRootEntry = pEntry;
+ pEntry = pBasicBox->GetParent( pEntry );
+ }
+
+ USHORT nMode = pBasicBox->GetMode();
+ bool bDlgMode = ( nMode & BROWSEMODE_DIALOGS ) && !( nMode & BROWSEMODE_MODULES );
+ USHORT nId = bDlgMode ? RID_IMG_DLGLIB : RID_IMG_MODLIB;
+ USHORT nIdHC = bDlgMode ? RID_IMG_DLGLIB_HC : RID_IMG_MODLIB_HC;
+ SvLBoxEntry* pNewLibEntry = pBasicBox->AddEntry(
+ aLibName,
+ Image( IDEResId( nId ) ),
+ Image( IDEResId( nIdHC ) ),
+ pRootEntry, false,
+ std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_LIBRARY ) ) );
+ DBG_ASSERT( pNewLibEntry, "InsertEntry fehlgeschlagen!" );
+
+ if( pNewLibEntry )
+ {
+ SvLBoxEntry* pEntry_ = pBasicBox->AddEntry(
+ aModName,
+ Image( IDEResId( RID_IMG_MODULE ) ),
+ Image( IDEResId( RID_IMG_MODULE_HC ) ),
+ pNewLibEntry, false,
+ std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
+ DBG_ASSERT( pEntry_, "InsertEntry fehlgeschlagen!" );
+ pBasicBox->SetCurEntry( pEntry_ );
+ pBasicBox->Select( pBasicBox->GetCurEntry() ); // OV-Bug?!
+ }
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
new file mode 100644
index 000000000000..fcc2858670d1
--- /dev/null
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -0,0 +1,1068 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include <memory>
+
+#include <ide_pch.hxx>
+
+
+#include <moduldlg.hrc>
+#include <moduldlg.hxx>
+#include <basidesh.hrc>
+#include <basidesh.hxx>
+#include <bastypes.hxx>
+#include <baside3.hxx>
+#include <basobj.hxx>
+#include <baside2.hrc>
+#include <sbxitem.hxx>
+#include <iderdll.hxx>
+
+#include <com/sun/star/io/XInputStreamProvider.hpp>
+#include <com/sun/star/script/XLibraryContainer2.hpp>
+#include <com/sun/star/script/XLibraryContainerPassword.hpp>
+#include <com/sun/star/resource/XStringResourceManager.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/processfactory.hxx>
+#include <xmlscript/xmldlg_imexp.hxx>
+
+#include "localizationmgr.hxx"
+#include <basic/sbx.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::resource;
+
+
+ExtBasicTreeListBox::ExtBasicTreeListBox( Window* pParent, const ResId& rRes )
+ : BasicTreeListBox( pParent, rRes )
+{
+}
+
+
+
+ExtBasicTreeListBox::~ExtBasicTreeListBox()
+{
+}
+
+BOOL __EXPORT ExtBasicTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& )
+{
+ BOOL bRet = FALSE;
+
+ if ( pEntry )
+ {
+ USHORT nDepth = GetModel()->GetDepth( pEntry );
+ if ( nDepth >= 2 )
+ {
+ BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ ::rtl::OUString aOULibName( aDesc.GetLibName() );
+ Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) ) )
+ {
+ // allow editing only for libraries, which are not readonly
+ bRet = TRUE;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+BOOL __EXPORT ExtBasicTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const String& rNewText )
+{
+ BOOL bValid = BasicIDE::IsValidSbxName( rNewText );
+ if ( !bValid )
+ {
+ ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_BADSBXNAME ) ) ).Execute();
+ return FALSE;
+ }
+
+ String aCurText( GetEntryText( pEntry ) );
+ if ( aCurText == rNewText )
+ // nothing to do
+ return TRUE;
+
+ BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ DBG_ASSERT( aDocument.isValid(), "ExtBasicTreeListBox::EditedEntry: no document!" );
+ if ( !aDocument.isValid() )
+ return FALSE;
+ String aLibName( aDesc.GetLibName() );
+ BasicEntryType eType( aDesc.GetType() );
+
+ bool bSuccess = ( eType == OBJ_TYPE_MODULE )
+ ? BasicIDE::RenameModule( this, aDocument, aLibName, aCurText, rNewText )
+ : BasicIDE::RenameDialog( this, aDocument, aLibName, aCurText, rNewText );
+
+ if ( !bSuccess )
+ return FALSE;
+
+ BasicIDE::MarkDocumentModified( aDocument );
+
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, rNewText, ConvertType( eType ) );
+ pDispatcher->Execute( SID_BASICIDE_SBXRENAMED,
+ SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
+ }
+
+ // OV-Bug?!
+ SetEntryText( pEntry, rNewText );
+ SetCurEntry( pEntry );
+ SetCurEntry( pEntry );
+ Select( pEntry, FALSE );
+ Select( pEntry ); // damit Handler gerufen wird => Edit updaten
+
+ return TRUE;
+}
+
+
+DragDropMode __EXPORT ExtBasicTreeListBox::NotifyStartDrag( TransferDataContainer&, SvLBoxEntry* pEntry )
+{
+ DragDropMode nMode_ = SV_DRAGDROP_NONE;
+
+ if ( pEntry )
+ {
+ USHORT nDepth = GetModel()->GetDepth( pEntry );
+ if ( nDepth >= 2 )
+ {
+ nMode_ = SV_DRAGDROP_CTRL_COPY;
+ BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ ::rtl::OUString aOULibName( aDesc.GetLibName() );
+ // allow MOVE mode only for libraries, which are not readonly
+ Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) ) )
+ {
+ // Only allow copy for localized libraries
+ bool bAllowMove = true;
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) )
+ {
+ // Get StringResourceManager
+ Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, aOULibName, TRUE ) );
+ Reference< XStringResourceManager > xSourceMgr =
+ LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
+ if( xSourceMgr.is() )
+ bAllowMove = ( xSourceMgr->getLocales().getLength() == 0 );
+ }
+ if( bAllowMove )
+ nMode_ |= SV_DRAGDROP_CTRL_MOVE;
+ }
+ }
+ }
+
+ return nMode_;
+}
+
+
+BOOL __EXPORT ExtBasicTreeListBox::NotifyAcceptDrop( SvLBoxEntry* pEntry )
+{
+ // don't drop on a BasicManager (nDepth == 0)
+ USHORT nDepth = pEntry ? GetModel()->GetDepth( pEntry ) : 0;
+ BOOL bValid = nDepth ? TRUE : FALSE;
+
+ // don't drop in the same library
+ SvLBoxEntry* pSelected = FirstSelected();
+ if ( ( nDepth == 1 ) && ( pEntry == GetParent( pSelected ) ) )
+ bValid = FALSE;
+ else if ( ( nDepth == 2 ) && ( GetParent( pEntry ) == GetParent( pSelected ) ) )
+ bValid = FALSE;
+
+ // don't drop on a library, which is not loaded, readonly or password protected
+ // or which already has a module/dialog with this name
+ if ( bValid && ( nDepth > 0 ) )
+ {
+ // get source module/dialog name
+ BasicEntryDescriptor aSourceDesc( GetEntryDescriptor( pSelected ) );
+ String aSourceName( aSourceDesc.GetName() );
+ BasicEntryType eSourceType( aSourceDesc.GetType() );
+
+ // get target shell and target library name
+ BasicEntryDescriptor aDestDesc( GetEntryDescriptor( pEntry ) );
+ const ScriptDocument& rDestDoc( aDestDesc.GetDocument() );
+ String aDestLibName( aDestDesc.GetLibName() );
+ ::rtl::OUString aOUDestLibName( aDestLibName );
+
+ // check if module library is not loaded, readonly or password protected
+ Reference< script::XLibraryContainer2 > xModLibContainer( rDestDoc.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOUDestLibName ) )
+ {
+ if ( !xModLibContainer->isLibraryLoaded( aOUDestLibName ) )
+ bValid = FALSE;
+
+ if ( xModLibContainer->isLibraryReadOnly( aOUDestLibName ) )
+ bValid = FALSE;
+
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOUDestLibName ) && !xPasswd->isLibraryPasswordVerified( aOUDestLibName ) )
+ bValid = FALSE;
+ }
+
+ // check if dialog library is not loaded or readonly
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( rDestDoc.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOUDestLibName ) )
+ {
+ if ( !xDlgLibContainer->isLibraryLoaded( aOUDestLibName ) )
+ bValid = FALSE;
+
+ if ( xDlgLibContainer->isLibraryReadOnly( aOUDestLibName ) )
+ bValid = FALSE;
+ }
+
+ // check, if module/dialog with this name is already existing in target library
+ if ( ( eSourceType == OBJ_TYPE_MODULE && rDestDoc.hasModule( aDestLibName, aSourceName ) ) ||
+ ( eSourceType == OBJ_TYPE_DIALOG && rDestDoc.hasDialog( aDestLibName, aSourceName ) ) )
+ {
+ bValid = FALSE;
+ }
+ }
+
+ return bValid;
+}
+
+
+BOOL __EXPORT ExtBasicTreeListBox::NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
+ SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos )
+{
+ return NotifyCopyingMoving( pTarget, pEntry,
+ rpNewParent, rNewChildPos, TRUE );
+}
+
+
+BOOL __EXPORT ExtBasicTreeListBox::NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
+ SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos )
+{
+// return FALSE; // Wie kopiere ich ein SBX ?!
+ return NotifyCopyingMoving( pTarget, pEntry,
+ rpNewParent, rNewChildPos, FALSE );
+}
+
+
+void BasicIDEShell::CopyDialogResources( Reference< io::XInputStreamProvider >& io_xISP,
+ const ScriptDocument& rSourceDoc, const String& rSourceLibName, const ScriptDocument& rDestDoc,
+ const String& rDestLibName, const String& rDlgName )
+{
+ if ( !io_xISP.is() )
+ return;
+
+ // Get StringResourceManager
+ Reference< container::XNameContainer > xSourceDialogLib( rSourceDoc.getLibrary( E_DIALOGS, rSourceLibName, TRUE ) );
+ Reference< XStringResourceManager > xSourceMgr =
+ LocalizationMgr::getStringResourceFromDialogLibrary( xSourceDialogLib );
+ if( !xSourceMgr.is() )
+ return;
+ bool bSourceLocalized = ( xSourceMgr->getLocales().getLength() > 0 );
+
+ Reference< container::XNameContainer > xDestDialogLib( rDestDoc.getLibrary( E_DIALOGS, rDestLibName, TRUE ) );
+ Reference< XStringResourceManager > xDestMgr =
+ LocalizationMgr::getStringResourceFromDialogLibrary( xDestDialogLib );
+ if( !xDestMgr.is() )
+ return;
+ bool bDestLocalized = ( xDestMgr->getLocales().getLength() > 0 );
+
+ if( !bSourceLocalized && !bDestLocalized )
+ return;
+
+ // create dialog model
+ Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
+ Reference< container::XNameContainer > xDialogModel = Reference< container::XNameContainer >( xMSF->createInstance
+ ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY );
+ Reference< io::XInputStream > xInput( io_xISP->createInputStream() );
+ Reference< XComponentContext > xContext;
+ Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
+ OSL_ASSERT( xProps.is() );
+ OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rSourceDoc.isDocument() ? rSourceDoc.getDocument() : Reference< frame::XModel >() );
+
+ if( xDialogModel.is() )
+ {
+ if( bSourceLocalized && bDestLocalized )
+ {
+ Reference< resource::XStringResourceResolver > xSourceStringResolver( xSourceMgr, UNO_QUERY );
+ LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, rDlgName, xDestMgr, xSourceStringResolver );
+ }
+ else if( bSourceLocalized )
+ {
+ LocalizationMgr::resetResourceForDialog( xDialogModel, xSourceMgr );
+ }
+ else if( bDestLocalized )
+ {
+ LocalizationMgr::setResourceIDsForDialog( xDialogModel, xDestMgr );
+ }
+ io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.isDocument() ? rDestDoc.getDocument() : Reference< frame::XModel >() );
+ }
+}
+
+
+BOOL __EXPORT ExtBasicTreeListBox::NotifyCopyingMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
+ SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos, BOOL bMove )
+{
+ (void)pEntry;
+ DBG_ASSERT( pEntry, "Kein Eintrag?" ); // Hier ASS ok, sollte nicht mit
+ DBG_ASSERT( pTarget, "Kein Ziel?" ); // NULL (ganz vorne) erreicht werden
+ USHORT nDepth = GetModel()->GetDepth( pTarget );
+ DBG_ASSERT( nDepth, "Tiefe?" );
+ if ( nDepth == 1 )
+ {
+ // Target = Basic => Modul/Dialog unter das Basic haengen...
+ rpNewParent = pTarget;
+ rNewChildPos = 0;
+ }
+ else if ( nDepth >= 2 )
+ {
+ // Target = Modul/Dialog => Modul/Dialog unter das uebergeordnete Basic haengen...
+ rpNewParent = GetParent( pTarget );
+ rNewChildPos = GetModel()->GetRelPos( pTarget ) + 1;
+ }
+
+ // get target shell and target library name
+ BasicEntryDescriptor aDestDesc( GetEntryDescriptor( rpNewParent ) );
+ const ScriptDocument& rDestDoc( aDestDesc.GetDocument() );
+ String aDestLibName( aDestDesc.GetLibName() );
+
+ // get source shell, library name and module/dialog name
+ BasicEntryDescriptor aSourceDesc( GetEntryDescriptor( FirstSelected() ) );
+ const ScriptDocument rSourceDoc( aSourceDesc.GetDocument() );
+ String aSourceLibName( aSourceDesc.GetLibName() );
+ String aSourceName( aSourceDesc.GetName() );
+ BasicEntryType eType( aSourceDesc.GetType() );
+
+ // get dispatcher
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+
+ if ( bMove ) // move
+ {
+ // remove source module/dialog window
+ if ( rSourceDoc != rDestDoc || aSourceLibName != aDestLibName )
+ {
+ if( pDispatcher )
+ {
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rSourceDoc, aSourceLibName, aSourceName, ConvertType( eType ) );
+ pDispatcher->Execute( SID_BASICIDE_SBXDELETED,
+ SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
+ }
+ }
+
+ try
+ {
+ if ( eType == OBJ_TYPE_MODULE ) // module
+ {
+ // get module
+ ::rtl::OUString aModule;
+ if ( rSourceDoc.getModule( aSourceLibName, aSourceName, aModule ) )
+ {
+ // remove module from source library
+ if ( rSourceDoc.removeModule( aSourceLibName, aSourceName ) )
+ {
+ BasicIDE::MarkDocumentModified( rSourceDoc );
+
+ // insert module into target library
+ if ( rDestDoc.insertModule( aDestLibName, aSourceName, aModule ) )
+ BasicIDE::MarkDocumentModified( rDestDoc );
+ }
+ }
+ }
+ else if ( eType == OBJ_TYPE_DIALOG ) // dialog
+ {
+ // get dialog
+ Reference< io::XInputStreamProvider > xISP;
+ if ( rSourceDoc.getDialog( aSourceLibName, aSourceName, xISP ) )
+ {
+ BasicIDEShell::CopyDialogResources( xISP, rSourceDoc,
+ aSourceLibName, rDestDoc, aDestLibName, aSourceName );
+
+ // remove dialog from source library
+ if ( BasicIDE::RemoveDialog( rSourceDoc, aSourceLibName, aSourceName ) )
+ {
+ BasicIDE::MarkDocumentModified( rSourceDoc );
+
+ // insert dialog into target library
+ if ( rDestDoc.insertDialog( aDestLibName, aSourceName, xISP ) )
+ BasicIDE::MarkDocumentModified( rDestDoc );
+ }
+ }
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ else // copy
+ {
+ try
+ {
+ if ( eType == OBJ_TYPE_MODULE ) // module
+ {
+ // get module
+ ::rtl::OUString aModule;
+ if ( rSourceDoc.getModule( aSourceLibName, aSourceName, aModule ) )
+ {
+ // insert module into target library
+ if ( rDestDoc.insertModule( aDestLibName, aSourceName, aModule ) )
+ BasicIDE::MarkDocumentModified( rDestDoc );
+ }
+ }
+ else if ( eType == OBJ_TYPE_DIALOG ) // dialog
+ {
+ // get dialog
+ Reference< io::XInputStreamProvider > xISP;
+ if ( rSourceDoc.getDialog( aSourceLibName, aSourceName, xISP ) )
+ {
+ BasicIDEShell::CopyDialogResources( xISP, rSourceDoc,
+ aSourceLibName, rDestDoc, aDestLibName, aSourceName );
+
+ // insert dialog into target library
+ if ( rDestDoc.insertDialog( aDestLibName, aSourceName, xISP ) )
+ BasicIDE::MarkDocumentModified( rDestDoc );
+ }
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ // create target module/dialog window
+ if ( rSourceDoc != rDestDoc || aSourceLibName != aDestLibName )
+ {
+ if( pDispatcher )
+ {
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDestDoc, aDestLibName, aSourceName, ConvertType( eType ) );
+ pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
+ SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
+ }
+ }
+
+ return 2; // Aufklappen...
+}
+
+OrganizeDialog::OrganizeDialog( Window* pParent, INT16 tabId, BasicEntryDescriptor& rDesc )
+ :TabDialog( pParent, IDEResId( RID_TD_ORGANIZE ) )
+ ,aTabCtrl( this, IDEResId( RID_TC_ORGANIZE ) )
+ ,m_aCurEntry( rDesc )
+{
+ FreeResource();
+ aTabCtrl.SetActivatePageHdl( LINK( this, OrganizeDialog, ActivatePageHdl ) );
+ if( tabId == 0 )
+ {
+ aTabCtrl.SetCurPageId( RID_TP_MOD );
+ }
+ else if ( tabId == 1 )
+ {
+ aTabCtrl.SetCurPageId( RID_TP_DLG );
+ }
+ else
+ {
+ aTabCtrl.SetCurPageId( RID_TP_LIB );
+ }
+
+ ActivatePageHdl( &aTabCtrl );
+
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
+ }
+}
+
+__EXPORT OrganizeDialog::~OrganizeDialog()
+{
+ for ( USHORT i = 0; i < aTabCtrl.GetPageCount(); i++ )
+ delete aTabCtrl.GetTabPage( aTabCtrl.GetPageId( i ) );
+};
+
+short OrganizeDialog::Execute()
+{
+ Window* pPrevDlgParent = Application::GetDefDialogParent();
+ Application::SetDefDialogParent( this );
+ short nRet = TabDialog::Execute();
+ Application::SetDefDialogParent( pPrevDlgParent );
+ return nRet;
+}
+
+
+IMPL_LINK( OrganizeDialog, ActivatePageHdl, TabControl *, pTabCtrl )
+{
+ USHORT nId = pTabCtrl->GetCurPageId();
+ // Wenn TabPage noch nicht erzeugt wurde, dann erzeugen
+ if ( !pTabCtrl->GetTabPage( nId ) )
+ {
+ TabPage* pNewTabPage = 0;
+ switch ( nId )
+ {
+ case RID_TP_MOD:
+ {
+ pNewTabPage = new ObjectPage( pTabCtrl, IDEResId( RID_TP_MODULS ), BROWSEMODE_MODULES );
+ ((ObjectPage*)pNewTabPage)->SetTabDlg( this );
+ ((ObjectPage*)pNewTabPage)->SetCurrentEntry( m_aCurEntry );
+ }
+ break;
+ case RID_TP_DLG:
+ {
+ pNewTabPage = new ObjectPage( pTabCtrl, IDEResId( RID_TP_DLGS ), BROWSEMODE_DIALOGS );
+ ((ObjectPage*)pNewTabPage)->SetTabDlg( this );
+ ((ObjectPage*)pNewTabPage)->SetCurrentEntry( m_aCurEntry );
+ }
+ break;
+ case RID_TP_LIB:
+ {
+ pNewTabPage = new LibPage( pTabCtrl );
+ ((LibPage*)pNewTabPage)->SetTabDlg( this );
+ }
+ break;
+ default: DBG_ERROR( "PageHdl: Unbekannte ID!" );
+ }
+ DBG_ASSERT( pNewTabPage, "Keine Page!" );
+ pTabCtrl->SetTabPage( nId, pNewTabPage );
+ }
+ return 0;
+}
+
+ObjectPage::ObjectPage( Window * pParent, const ResId& rResId, USHORT nMode ) :
+ TabPage( pParent, rResId ),
+ aLibText( this, IDEResId( RID_STR_LIB ) ),
+ aBasicBox( this, IDEResId( RID_TRLBOX ) ),
+ aEditButton( this, IDEResId( RID_PB_EDIT ) ),
+ aCloseButton( this, IDEResId( RID_PB_CLOSE ) ),
+ aNewModButton( this, IDEResId( RID_PB_NEWMOD ) ),
+ aNewDlgButton( this, IDEResId( RID_PB_NEWDLG ) ),
+ aDelButton( this, IDEResId( RID_PB_DELETE ) )
+{
+ FreeResource();
+ pTabDlg = 0;
+
+ aEditButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
+ aDelButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
+ aCloseButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
+ aBasicBox.SetSelectHdl( LINK( this, ObjectPage, BasicBoxHighlightHdl ) );
+
+ if( nMode & BROWSEMODE_MODULES )
+ {
+ aNewModButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
+ aNewDlgButton.Hide();
+ }
+ else if ( nMode & BROWSEMODE_DIALOGS )
+ {
+ aNewDlgButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
+ aNewModButton.Hide();
+ }
+
+ aBasicBox.SetDragDropMode( SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY );
+ aBasicBox.EnableInplaceEditing( TRUE );
+ aBasicBox.SetMode( nMode );
+ aBasicBox.SetWindowBits( WB_HASLINES | WB_HASLINESATROOT |
+ WB_HASBUTTONS | WB_HASBUTTONSATROOT |
+ WB_HSCROLL );
+ aBasicBox.ScanAllEntries();
+
+ aEditButton.GrabFocus();
+ CheckButtons();
+}
+
+void ObjectPage::SetCurrentEntry( BasicEntryDescriptor& rDesc )
+{
+ aBasicBox.SetCurrentEntry( rDesc );
+}
+
+void __EXPORT ObjectPage::ActivatePage()
+{
+ aBasicBox.UpdateEntries();
+}
+
+void __EXPORT ObjectPage::DeactivatePage()
+{
+}
+
+void ObjectPage::CheckButtons()
+{
+ // enable/disable edit button
+ SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
+ BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ ::rtl::OUString aOULibName( aDesc.GetLibName() );
+ String aLibSubName( aDesc.GetLibSubName() );
+ sal_Bool bVBAEnabled = aDocument.isInVBAMode();
+ USHORT nMode = aBasicBox.GetMode();
+
+ USHORT nDepth = pCurEntry ? aBasicBox.GetModel()->GetDepth( pCurEntry ) : 0;
+ if ( nDepth >= 2 )
+ {
+ if( bVBAEnabled && ( nMode & BROWSEMODE_MODULES ) && ( nDepth == 2 ) )
+ aEditButton.Disable();
+ else
+ aEditButton.Enable();
+ }
+ else
+ aEditButton.Disable();
+
+ // enable/disable new module/dialog buttons
+ LibraryLocation eLocation( aDesc.GetLocation() );
+ BOOL bReadOnly = FALSE;
+ if ( nDepth > 0 )
+ {
+ Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) )
+ {
+ bReadOnly = TRUE;
+ }
+ }
+ if ( bReadOnly || eLocation == LIBRARY_LOCATION_SHARE )
+ {
+ aNewModButton.Disable();
+ aNewDlgButton.Disable();
+ }
+ else
+ {
+ aNewModButton.Enable();
+ aNewDlgButton.Enable();
+ }
+
+ // enable/disable delete button
+ if ( nDepth >= 2 && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE )
+ {
+ if( bVBAEnabled && ( nMode & BROWSEMODE_MODULES ) && ( ( nDepth == 2 ) || aLibSubName.Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) ) )
+ aDelButton.Disable();
+ else
+ aDelButton.Enable();
+ }
+ else
+ aDelButton.Disable();
+}
+
+IMPL_LINK( ObjectPage, BasicBoxHighlightHdl, BasicTreeListBox *, pBox )
+{
+ if ( !pBox->IsSelected( pBox->GetHdlEntry() ) )
+ return 0;
+
+ CheckButtons();
+ return 0;
+}
+
+IMPL_LINK( ObjectPage, ButtonHdl, Button *, pButton )
+{
+ if ( pButton == &aEditButton )
+ {
+ SfxAllItemSet aArgs( SFX_APP()->GetPool() );
+ SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs );
+ SFX_APP()->ExecuteSlot( aRequest );
+
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
+ DBG_ASSERT( pCurEntry, "Entry?!" );
+ if ( aBasicBox.GetModel()->GetDepth( pCurEntry ) >= 2 )
+ {
+ BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
+ if ( pDispatcher )
+ {
+ String aModName( aDesc.GetName() );
+ // extract the module name from the string like "Sheet1 (Example1)"
+ if( aDesc.GetLibSubName().Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) )
+ {
+ sal_uInt16 nIndex = 0;
+ aModName = aModName.GetToken( 0, ' ', nIndex );
+ }
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(),
+ aModName, aBasicBox.ConvertType( aDesc.GetType() ) );
+ pDispatcher->Execute( SID_BASICIDE_SHOWSBX, SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
+ }
+ }
+ else // Nur Lib selektiert
+ {
+ DBG_ASSERT( aBasicBox.GetModel()->GetDepth( pCurEntry ) == 1, "Kein LibEntry?!" );
+ ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
+ SvLBoxEntry* pParentEntry = aBasicBox.GetParent( pCurEntry );
+ if ( pParentEntry )
+ {
+ BasicDocumentEntry* pBasicDocumentEntry = (BasicDocumentEntry*)pParentEntry->GetUserData();
+ if ( pBasicDocumentEntry )
+ aDocument = pBasicDocumentEntry->GetDocument();
+ }
+ SfxUsrAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( aDocument.getDocumentOrNull() ) );
+ String aLibName( aBasicBox.GetEntryText( pCurEntry ) );
+ SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
+ if ( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_LIBSELECTED, SFX_CALLMODE_ASYNCHRON, &aDocItem, &aLibNameItem, 0L );
+ }
+ }
+ EndTabDialog( 1 );
+ }
+ else if ( pButton == &aNewModButton )
+ NewModule();
+ else if ( pButton == &aNewDlgButton )
+ NewDialog();
+ else if ( pButton == &aDelButton )
+ DeleteCurrent();
+ else if ( pButton == &aCloseButton )
+ EndTabDialog( 0 );
+
+ return 0;
+}
+
+bool ObjectPage::GetSelection( ScriptDocument& rDocument, String& rLibName )
+{
+ bool bRet = false;
+
+ SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
+ BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
+ rDocument = aDesc.GetDocument();
+ rLibName = aDesc.GetLibName();
+ if ( !rLibName.Len() )
+ rLibName = String::CreateFromAscii( "Standard" );
+
+ DBG_ASSERT( rDocument.isAlive(), "ObjectPage::GetSelection: no or dead ScriptDocument in the selection!" );
+ if ( !rDocument.isAlive() )
+ return false;
+
+ // check if the module library is loaded
+ BOOL bOK = TRUE;
+ ::rtl::OUString aOULibName( rLibName );
+ Reference< script::XLibraryContainer > xModLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) );
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ // check password
+ Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
+ if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
+ {
+ String aPassword;
+ bOK = QueryPassword( xModLibContainer, rLibName, aPassword );
+ }
+
+ // load library
+ if ( bOK )
+ xModLibContainer->loadLibrary( aOULibName );
+ }
+
+ // check if the dialog library is loaded
+ Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_DIALOGS ) );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ // load library
+ if ( bOK )
+ xDlgLibContainer->loadLibrary( aOULibName );
+ }
+
+ if ( bOK )
+ bRet = true;
+
+ return bRet;
+}
+
+void ObjectPage::NewModule()
+{
+ ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
+ String aLibName;
+
+ if ( GetSelection( aDocument, aLibName ) )
+ {
+ String aModName;
+ createModImpl( static_cast<Window*>( this ), aDocument,
+ aBasicBox, aLibName, aModName, true );
+ }
+}
+
+void ObjectPage::NewDialog()
+{
+ ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
+ String aLibName;
+
+ if ( GetSelection( aDocument, aLibName ) )
+ {
+ aDocument.getOrCreateLibrary( E_DIALOGS, aLibName );
+
+ std::auto_ptr< NewObjectDialog > xNewDlg(
+ new NewObjectDialog(this, NEWOBJECTMODE_DLG, true));
+ xNewDlg->SetObjectName( aDocument.createObjectName( E_DIALOGS, aLibName ) );
+
+ if (xNewDlg->Execute() != 0)
+ {
+ String aDlgName( xNewDlg->GetObjectName() );
+ if (aDlgName.Len() == 0)
+ aDlgName = aDocument.createObjectName( E_DIALOGS, aLibName);
+
+ if ( aDocument.hasDialog( aLibName, aDlgName ) )
+ {
+ ErrorBox( this, WB_OK | WB_DEF_OK,
+ String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute();
+ }
+ else
+ {
+ Reference< io::XInputStreamProvider > xISP;
+ if ( !aDocument.createDialog( aLibName, aDlgName, xISP ) )
+ return;
+
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aDlgName, BASICIDE_TYPE_DIALOG );
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
+ SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
+ }
+ LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
+ SvLBoxEntry* pRootEntry = aBasicBox.FindRootEntry( aDocument, eLocation );
+ if ( pRootEntry )
+ {
+ if ( !aBasicBox.IsExpanded( pRootEntry ) )
+ aBasicBox.Expand( pRootEntry );
+ SvLBoxEntry* pLibEntry = aBasicBox.FindEntry( pRootEntry, aLibName, OBJ_TYPE_LIBRARY );
+ DBG_ASSERT( pLibEntry, "Libeintrag nicht gefunden!" );
+ if ( pLibEntry )
+ {
+ if ( !aBasicBox.IsExpanded( pLibEntry ) )
+ aBasicBox.Expand( pLibEntry );
+ SvLBoxEntry* pEntry = aBasicBox.FindEntry( pLibEntry, aDlgName, OBJ_TYPE_DIALOG );
+ if ( !pEntry )
+ {
+ pEntry = aBasicBox.AddEntry(
+ aDlgName,
+ Image( IDEResId( RID_IMG_DIALOG ) ),
+ Image( IDEResId( RID_IMG_DIALOG_HC ) ),
+ pLibEntry, false,
+ std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_DIALOG ) ) );
+ DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" );
+ }
+ aBasicBox.SetCurEntry( pEntry );
+ aBasicBox.Select( aBasicBox.GetCurEntry() ); // OV-Bug?!
+ }
+ }
+ }
+ }
+ }
+}
+
+void ObjectPage::DeleteCurrent()
+{
+ SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
+ DBG_ASSERT( pCurEntry, "Kein aktueller Eintrag!" );
+ BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
+ ScriptDocument aDocument( aDesc.GetDocument() );
+ DBG_ASSERT( aDocument.isAlive(), "ObjectPage::DeleteCurrent: no document!" );
+ if ( !aDocument.isAlive() )
+ return;
+ String aLibName( aDesc.GetLibName() );
+ String aName( aDesc.GetName() );
+ BasicEntryType eType( aDesc.GetType() );
+
+ if ( ( eType == OBJ_TYPE_MODULE && QueryDelModule( aName, this ) ) ||
+ ( eType == OBJ_TYPE_DIALOG && QueryDelDialog( aName, this ) ) )
+ {
+ aBasicBox.GetModel()->Remove( pCurEntry );
+ if ( aBasicBox.GetCurEntry() ) // OV-Bug ?
+ aBasicBox.Select( aBasicBox.GetCurEntry() );
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aName, aBasicBox.ConvertType( eType ) );
+ pDispatcher->Execute( SID_BASICIDE_SBXDELETED,
+ SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
+ }
+
+ try
+ {
+ bool bSuccess = false;
+ if ( eType == OBJ_TYPE_MODULE )
+ bSuccess = aDocument.removeModule( aLibName, aName );
+ else if ( eType == OBJ_TYPE_DIALOG )
+ bSuccess = BasicIDE::RemoveDialog( aDocument, aLibName, aName );
+
+ if ( bSuccess )
+ BasicIDE::MarkDocumentModified( aDocument );
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+
+
+
+void ObjectPage::EndTabDialog( USHORT nRet )
+{
+ DBG_ASSERT( pTabDlg, "TabDlg nicht gesetzt!" );
+ if ( pTabDlg )
+ pTabDlg->EndDialog( nRet );
+}
+
+
+LibDialog::LibDialog( Window* pParent )
+ : ModalDialog( pParent, IDEResId( RID_DLG_LIBS ) ),
+ aOKButton( this, IDEResId( RID_PB_OK ) ),
+ aCancelButton( this, IDEResId( RID_PB_CANCEL ) ),
+ aStorageName( this, IDEResId( RID_FT_STORAGENAME ) ),
+ aLibBox( this, IDEResId( RID_CTRL_LIBS ) ),
+ aFixedLine( this, IDEResId( RID_FL_OPTIONS ) ),
+ aReferenceBox( this, IDEResId( RID_CB_REF ) ),
+ aReplaceBox( this, IDEResId( RID_CB_REPL ) )
+{
+ SetText( String( IDEResId( RID_STR_APPENDLIBS ) ) );
+ FreeResource();
+}
+
+
+LibDialog::~LibDialog()
+{
+}
+
+void LibDialog::SetStorageName( const String& rName )
+{
+ String aName( IDEResId( RID_STR_FILENAME ) );
+ aName += rName;
+ aStorageName.SetText( aName );
+}
+
+// Helper function
+SbModule* createModImpl( Window* pWin, const ScriptDocument& rDocument,
+ BasicTreeListBox& rBasicBox, const String& rLibName, String aModName, bool bMain )
+{
+ OSL_ENSURE( rDocument.isAlive(), "createModImpl: invalid document!" );
+ if ( !rDocument.isAlive() )
+ return NULL;
+
+ SbModule* pModule = NULL;
+
+ String aLibName( rLibName );
+ if ( !aLibName.Len() )
+ aLibName = String::CreateFromAscii( "Standard" );
+ rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
+ if ( !aModName.Len() )
+ aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
+
+ std::auto_ptr< NewObjectDialog > xNewDlg(
+ new NewObjectDialog( pWin, NEWOBJECTMODE_MOD, true ) );
+ xNewDlg->SetObjectName( aModName );
+
+ if (xNewDlg->Execute() != 0)
+ {
+ if ( xNewDlg->GetObjectName().Len() )
+ aModName = xNewDlg->GetObjectName();
+
+ try
+ {
+ ::rtl::OUString sModuleCode;
+ // the module has existed
+ if( rDocument.hasModule( aLibName, aModName ) )
+ return NULL;
+ rDocument.createModule( aLibName, aModName, bMain, sModuleCode );
+ BasicManager* pBasMgr = rDocument.getBasicManager();
+ StarBASIC* pBasic = pBasMgr? pBasMgr->GetLib( aLibName ) : 0;
+ if ( pBasic )
+ pModule = pBasic->FindModule( aModName );
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, BASICIDE_TYPE_MODULE );
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
+ SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
+ }
+ LibraryLocation eLocation = rDocument.getLibraryLocation( aLibName );
+ SvLBoxEntry* pRootEntry = rBasicBox.FindRootEntry( rDocument, eLocation );
+ if ( pRootEntry )
+ {
+ if ( !rBasicBox.IsExpanded( pRootEntry ) )
+ rBasicBox.Expand( pRootEntry );
+ SvLBoxEntry* pLibEntry = rBasicBox.FindEntry( pRootEntry, aLibName, OBJ_TYPE_LIBRARY );
+ DBG_ASSERT( pLibEntry, "Libeintrag nicht gefunden!" );
+ if ( pLibEntry )
+ {
+ if ( !rBasicBox.IsExpanded( pLibEntry ) )
+ rBasicBox.Expand( pLibEntry );
+ SvLBoxEntry* pSubRootEntry = pLibEntry;
+ if( pBasic && rDocument.isInVBAMode() )
+ {
+ // add the new module in the "Modules" entry
+ SvLBoxEntry* pLibSubEntry = rBasicBox.FindEntry( pLibEntry, String( IDEResId( RID_STR_NORMAL_MODULES ) ) , OBJ_TYPE_NORMAL_MODULES );
+ if( pLibSubEntry )
+ {
+ if( !rBasicBox.IsExpanded( pLibSubEntry ) )
+ rBasicBox.Expand( pLibSubEntry );
+ pSubRootEntry = pLibSubEntry;
+ }
+ }
+
+ SvLBoxEntry* pEntry = rBasicBox.FindEntry( pSubRootEntry, aModName, OBJ_TYPE_MODULE );
+ if ( !pEntry )
+ {
+ pEntry = rBasicBox.AddEntry(
+ aModName,
+ Image( IDEResId( RID_IMG_MODULE ) ),
+ Image( IDEResId( RID_IMG_MODULE_HC ) ),
+ pSubRootEntry, false,
+ std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
+ DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" );
+ }
+ rBasicBox.SetCurEntry( pEntry );
+ rBasicBox.Select( rBasicBox.GetCurEntry() ); // OV-Bug?!
+ }
+ }
+ }
+ catch ( container::ElementExistException& )
+ {
+ ErrorBox( pWin, WB_OK | WB_DEF_OK,
+ String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute();
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return pModule;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/moduldlg.hrc b/basctl/source/basicide/moduldlg.hrc
new file mode 100644
index 000000000000..1eed98e0bdca
--- /dev/null
+++ b/basctl/source/basicide/moduldlg.hrc
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _MODULDLG_HRC
+#define _MODULDLG_HRC
+
+#include <svl/solar.hrc>
+
+#define RID_STR_LIB 1
+#define RID_TRLBOX 2
+// free
+#define RID_PB_EDIT 4
+#define RID_PB_CLOSE 5
+#define RID_PB_NEWMOD 6
+#define RID_PB_NEWDLG 7
+#define RID_PB_DELETE 8
+#define RID_PB_NEWLIB 9
+#define RID_PB_APPEND 10
+#define RID_PB_PASSWORD 11
+#define RID_LB_BASICS 12
+#define RID_STR_BASICS 13
+
+#define RID_PB_EXPORT 14
+#define RID_PB_EXPORT_PACKAGE 15
+
+#define RID_TP_MOD 20
+#define RID_TP_LIB 21
+#define RID_TP_DLG 22
+
+#define RID_TC_ORGANIZE 30
+
+#define RID_PB_OK 31
+#define RID_PB_CANCEL 32
+#define RID_CTRL_LIBS 33
+#define RID_FL_OPTIONS 34
+#define RID_CB_REF 35
+#define RID_CB_REPL 36
+#define RID_FT_STORAGENAME 38
+
+#define RID_FT_NEWLIB 40
+#define RID_ED_LIBNAME 41
+#define RB_EXPORTASPACKAGE 42
+#define RB_EXPORTASBASIC 43
+
+#endif // _MODULDLG_HRC
diff --git a/basctl/source/basicide/moduldlg.hxx b/basctl/source/basicide/moduldlg.hxx
new file mode 100644
index 000000000000..552c638e8daa
--- /dev/null
+++ b/basctl/source/basicide/moduldlg.hxx
@@ -0,0 +1,277 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _MODULDLG_HXX
+#define _MODULDLG_HXX
+
+#include <svheader.hxx>
+
+#include <bastype2.hxx>
+#include <vcl/dialog.hxx>
+
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <svtools/svtabbx.hxx>
+#include <vcl/tabdlg.hxx>
+#include <vcl/tabpage.hxx>
+#include "com/sun/star/task/XInteractionHandler.hpp"
+
+#include <vcl/tabctrl.hxx>
+#include <vcl/lstbox.hxx>
+
+class StarBASIC;
+
+
+#define NEWOBJECTMODE_LIB 1
+#define NEWOBJECTMODE_MOD 2
+#define NEWOBJECTMODE_DLG 3
+#define NEWOBJECTMODE_METH 4
+
+class NewObjectDialog : public ModalDialog
+{
+private:
+ FixedText aText;
+ Edit aEdit;
+ OKButton aOKButton;
+ CancelButton aCancelButton;
+
+ DECL_LINK(OkButtonHandler, Button *);
+
+public:
+ NewObjectDialog(Window * pParent, USHORT nMode, bool bCheckName = false);
+ ~NewObjectDialog();
+
+ String GetObjectName() const { return aEdit.GetText(); }
+ void SetObjectName( const String& rName ) { aEdit.SetText( rName ); aEdit.SetSelection( Selection( 0, rName.Len() ) );}
+};
+
+class ExportDialog : public ModalDialog
+{
+private:
+ RadioButton maExportAsPackageButton;
+ RadioButton maExportAsBasicButton;
+ OKButton maOKButton;
+ CancelButton maCancelButton;
+
+ sal_Bool mbExportAsPackage;
+
+ DECL_LINK(OkButtonHandler, Button *);
+
+public:
+ ExportDialog( Window * pParent );
+ ~ExportDialog();
+
+ sal_Bool isExportAsPackage( void ) { return mbExportAsPackage; }
+};
+
+
+class ExtBasicTreeListBox : public BasicTreeListBox
+{
+protected:
+ virtual BOOL EditingEntry( SvLBoxEntry* pEntry, Selection& rSel );
+ virtual BOOL EditedEntry( SvLBoxEntry* pEntry, const String& rNewText );
+
+ virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData, SvLBoxEntry* pEntry );
+ virtual BOOL NotifyAcceptDrop( SvLBoxEntry* pEntry );
+
+ virtual BOOL NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
+ SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos );
+ virtual BOOL NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
+ SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos );
+ BOOL NotifyCopyingMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
+ SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos, BOOL bMove );
+
+public:
+ ExtBasicTreeListBox( Window* pParent, const ResId& rRes );
+ ~ExtBasicTreeListBox();
+};
+
+#define LIBMODE_CHOOSER 1
+#define LIBMODE_MANAGER 2
+
+class BasicCheckBox : public SvTabListBox
+{
+private:
+ USHORT nMode;
+ SvLBoxButtonData* pCheckButton;
+ ScriptDocument m_aDocument;
+ void Init();
+
+public:
+ BasicCheckBox( Window* pParent, const ResId& rResId );
+ ~BasicCheckBox();
+
+ SvLBoxEntry* DoInsertEntry( const String& rStr, ULONG nPos = LISTBOX_APPEND );
+ SvLBoxEntry* FindEntry( const String& rName );
+
+ void CheckEntryPos( ULONG nPos, BOOL bCheck = TRUE );
+ BOOL IsChecked( ULONG nPos ) const;
+
+ virtual void InitEntry( SvLBoxEntry*, const XubString&, const Image&, const Image&, SvLBoxButtonKind eButtonKind );
+ virtual BOOL EditingEntry( SvLBoxEntry* pEntry, Selection& rSel );
+ virtual BOOL EditedEntry( SvLBoxEntry* pEntry, const String& rNewText );
+
+ void SetDocument( const ScriptDocument& rDocument ) { m_aDocument = rDocument; }
+
+ void SetMode( USHORT n );
+ USHORT GetMode() const { return nMode; }
+};
+
+class LibDialog: public ModalDialog
+{
+private:
+ OKButton aOKButton;
+ CancelButton aCancelButton;
+ FixedText aStorageName;
+ BasicCheckBox aLibBox;
+ FixedLine aFixedLine;
+ CheckBox aReferenceBox;
+ CheckBox aReplaceBox;
+
+public:
+ LibDialog( Window* pParent );
+ ~LibDialog();
+
+ void SetStorageName( const String& rName );
+
+ BasicCheckBox& GetLibBox() { return aLibBox; }
+ BOOL IsReference() const { return aReferenceBox.IsChecked(); }
+ BOOL IsReplace() const { return aReplaceBox.IsChecked(); }
+
+ void EnableReference( BOOL b ) { aReferenceBox.Enable( b ); }
+ void EnableReplace( BOOL b ) { aReplaceBox.Enable( b ); }
+};
+
+
+class OrganizeDialog : public TabDialog
+{
+private:
+ TabControl aTabCtrl;
+ BasicEntryDescriptor m_aCurEntry;
+
+public:
+ OrganizeDialog( Window* pParent, INT16 tabId, BasicEntryDescriptor& rDesc );
+ ~OrganizeDialog();
+
+ virtual short Execute();
+
+ DECL_LINK( ActivatePageHdl, TabControl * );
+};
+
+class ObjectPage: public TabPage
+{
+protected:
+ FixedText aLibText;
+ ExtBasicTreeListBox aBasicBox;
+ PushButton aEditButton;
+ CancelButton aCloseButton;
+ PushButton aNewModButton;
+ PushButton aNewDlgButton;
+ PushButton aDelButton;
+
+ DECL_LINK( BasicBoxHighlightHdl, BasicTreeListBox * );
+ DECL_LINK( ButtonHdl, Button * );
+ void CheckButtons();
+ bool GetSelection( ScriptDocument& rDocument, String& rLibName );
+ void DeleteCurrent();
+ void NewModule();
+ void NewDialog();
+ void EndTabDialog( USHORT nRet );
+
+ TabDialog* pTabDlg;
+
+ virtual void ActivatePage();
+ virtual void DeactivatePage();
+
+public:
+ ObjectPage( Window* pParent, const ResId& rResId, USHORT nMode );
+
+ void SetCurrentEntry( BasicEntryDescriptor& rDesc );
+ void SetTabDlg( TabDialog* p ) { pTabDlg = p;}
+};
+
+
+class SvxPasswordDialog;
+
+class LibPage: public TabPage
+{
+protected:
+ FixedText aBasicsText;
+ ListBox aBasicsBox;
+ FixedText aLibText;
+ BasicCheckBox aLibBox;
+ PushButton aEditButton;
+ CancelButton aCloseButton;
+ PushButton aPasswordButton;
+ PushButton aExportButton;
+ PushButton aNewLibButton;
+ PushButton aInsertLibButton;
+ PushButton aDelButton;
+
+ ScriptDocument m_aCurDocument;
+ LibraryLocation m_eCurLocation;
+
+ DECL_LINK( TreeListHighlightHdl, SvTreeListBox * );
+ DECL_LINK( BasicSelectHdl, ListBox * );
+ DECL_LINK( ButtonHdl, Button * );
+ DECL_LINK( CheckPasswordHdl, SvxPasswordDialog * );
+ void CheckButtons();
+ void DeleteCurrent();
+ void NewLib();
+ void InsertLib();
+ void implExportLib( const String& aLibName, const String& aTargetURL,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler );
+ void Export();
+ void ExportAsPackage( const String& aLibName );
+ void ExportAsBasic( const String& aLibName );
+ void EndTabDialog( USHORT nRet );
+ void FillListBox();
+ void InsertListBoxEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
+ void SetCurLib();
+ SvLBoxEntry* ImpInsertLibEntry( const String& rLibName, ULONG nPos );
+ virtual void ActivatePage();
+ virtual void DeactivatePage();
+
+ TabDialog* pTabDlg;
+
+public:
+ LibPage( Window* pParent );
+ virtual ~LibPage();
+
+ void SetTabDlg( TabDialog* p ) { pTabDlg = p;}
+};
+
+// Helper functions
+SbModule* createModImpl( Window* pWin, const ScriptDocument& rDocument,
+ BasicTreeListBox& rBasicBox, const String& rLibName, String aModName, bool bMain = false );
+void createLibImpl( Window* pWin, const ScriptDocument& rDocument,
+ BasicCheckBox* pLibBox, BasicTreeListBox* pBasicBox );
+
+#endif // _MODULDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/moduldlg.src b/basctl/source/basicide/moduldlg.src
new file mode 100644
index 000000000000..a6ac943f29d0
--- /dev/null
+++ b/basctl/source/basicide/moduldlg.src
@@ -0,0 +1,411 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "helpid.hrc"
+#include <moduldlg.hrc>
+#include <basidesh.hrc>
+TabDialog RID_TD_ORGANIZE
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ /* ### ACHTUNG: Neuer Text in Resource? Makros verwalten : Verwalten */
+ /* ### ACHTUNG: Neuer Text in Resource? Makros verwalten : Verwalten */
+ Text[ en-US ] = "%PRODUCTNAME Basic Macro Organizer";
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ // Da Cancel-Button auf TabPage, nicht auf Dialog!
+ TabControl RID_TC_ORGANIZE
+ {
+ // HelpID = HID_BASICIDE_ORG_TC;
+ OutputSize = TRUE ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = RID_TP_MOD ;
+ Text [ en-US ] = "Modules" ;
+ };
+ PageItem
+ {
+ Identifier = RID_TP_DLG ;
+ Text [ en-US ] = "Dialogs" ;
+ };
+ PageItem
+ {
+ Identifier = RID_TP_LIB ;
+ Text [ en-US ] = "Libraries" ;
+ };
+ };
+ };
+};
+TabPage RID_TP_MODULS
+{
+ // HelpId = HID_BASICIDE_MODULS ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 210 , 140 ) ;
+ FixedText RID_STR_LIB
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
+ Text [ en-US ] = "M~odule" ;
+ };
+ Control RID_TRLBOX
+ {
+ HelpId = HID_BASICIDE_MODULES_TREE ;
+ Pos = MAP_APPFONT ( 6 , 17 ) ;
+ Size = MAP_APPFONT ( 130 , 117 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ PushButton RID_PB_EDIT
+ {
+ Text [ en-US ] = "~Edit";
+ Pos = MAP_APPFONT ( 144 , 6 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton RID_PB_CLOSE
+ {
+ Text [ en-US ] = "Close";
+ Pos = MAP_APPFONT ( 144 , 23 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton RID_PB_NEWMOD
+ {
+ Pos = MAP_APPFONT ( 144 , 103 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~New..." ;
+ TabStop = TRUE ;
+ };
+ PushButton RID_PB_NEWDLG
+ {
+ Pos = MAP_APPFONT ( 144 , 103 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~New..." ;
+ TabStop = TRUE ;
+ };
+ PushButton RID_PB_DELETE
+ {
+ Pos = MAP_APPFONT ( 144 , 120 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Löschen... : ~L÷schen... */
+ Text [ en-US ] = "~Delete" ;
+ TabStop = TRUE ;
+ };
+};
+TabPage RID_TP_DLGS
+{
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 210 , 140 ) ;
+ FixedText RID_STR_LIB
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
+ Text [ en-US ] = "Dialog" ;
+ };
+ Control RID_TRLBOX
+ {
+ HelpId = HID_BASICIDE_MODULES_TREE ;
+ Pos = MAP_APPFONT ( 6 , 17 ) ;
+ Size = MAP_APPFONT ( 130 , 117 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ PushButton RID_PB_EDIT
+ {
+ Text [ en-US ] = "~Edit";
+ Pos = MAP_APPFONT ( 144 , 6 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton RID_PB_CLOSE
+ {
+ Text[ en-US ] = "Close";
+ Pos = MAP_APPFONT ( 144 , 23 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton RID_PB_NEWMOD
+ {
+ Pos = MAP_APPFONT ( 144 , 103 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~New..." ;
+ TabStop = TRUE ;
+ };
+ PushButton RID_PB_NEWDLG
+ {
+ Pos = MAP_APPFONT ( 144 , 103 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~New..." ;
+ TabStop = TRUE ;
+ };
+ PushButton RID_PB_DELETE
+ {
+ Pos = MAP_APPFONT ( 144 , 120 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Löschen... : ~L÷schen... */
+ Text [ en-US ] = "~Delete" ;
+ TabStop = TRUE ;
+ };
+};
+TabPage RID_TP_LIBS
+{
+ // HelpId = HID_BASICIDE_LIBS_TP ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 210 , 140 ) ;
+ FixedText RID_STR_BASICS
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
+ Text [ en-US ] = "L~ocation";
+ };
+ ListBox RID_LB_BASICS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 17 ) ;
+ Size = MAP_APPFONT ( 130 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ FixedText RID_STR_LIB
+ {
+ Pos = MAP_APPFONT ( 6 , 36 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
+ Text [ en-US ] = "~Library" ;
+ };
+ Control RID_TRLBOX
+ {
+ HelpID = HID_BASICIDE_LIBS_TREE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 47 ) ;
+ Size = MAP_APPFONT ( 130 , 87 ) ;
+ TabStop = TRUE ;
+ };
+
+ PushButton RID_PB_EDIT
+ {
+ Text [ en-US ] = "~Edit";
+ Pos = MAP_APPFONT ( 144 , 6 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton RID_PB_CLOSE
+ {
+ Text [ en-US ] = "Close";
+ Pos = MAP_APPFONT ( 144 , 23 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Schließen : Schlie˜en */
+ TabStop = TRUE ;
+ };
+ PushButton RID_PB_PASSWORD
+ {
+ Pos = MAP_APPFONT ( 144 , 43 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~Password..." ;
+ TabStop = TRUE ;
+ };
+
+ PushButton RID_PB_NEWLIB
+ {
+ Pos = MAP_APPFONT ( 144 , 69 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~New..." ;
+ TabStop = TRUE ;
+ };
+ PushButton RID_PB_APPEND
+ {
+ Pos = MAP_APPFONT ( 144 , 86 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Hin~zufügen... : Hin~zuf³gen... */
+ Text [ en-US ] = "~Import..." ;
+ };
+ PushButton RID_PB_EXPORT
+ {
+ Pos = MAP_APPFONT ( 144 , 103 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "E~xport..." ;
+ TabStop = TRUE ;
+ };
+ PushButton RID_PB_DELETE
+ {
+ Pos = MAP_APPFONT ( 144 , 120 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Löschen... : ~L÷schen... */
+ Text [ en-US ] = "~Delete" ;
+ TabStop = TRUE ;
+ };
+};
+ModalDialog RID_DLG_LIBS
+{
+ // HelpId = HID_BASICIDE_LIBS_DLG ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 168 , 132 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ OKButton RID_PB_OK
+ {
+ Pos = MAP_APPFONT ( 112 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton RID_PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 112 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText RID_FT_STORAGENAME
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ };
+ Control RID_CTRL_LIBS
+ {
+ HelpID = HID_BASICIDE_LIBSDLG_TREE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 19 ) ;
+ Size = MAP_APPFONT ( 100 , 67 ) ;
+ TabStop = TRUE ;
+ };
+ FixedLine RID_FL_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 89 ) ;
+ Size = MAP_APPFONT ( 156 , 8 ) ;
+ Text [ en-US ] = "Options" ;
+ };
+ CheckBox RID_CB_REF
+ {
+ Pos = MAP_APPFONT ( 12 , 100 ) ;
+ Size = MAP_APPFONT ( 146 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Insert as reference (read-only)" ;
+ };
+ CheckBox RID_CB_REPL
+ {
+ Pos = MAP_APPFONT ( 12 , 113 ) ;
+ Size = MAP_APPFONT ( 146 , 10 ) ;
+ Text [ en-US ] = "Replace existing libraries" ;
+ };
+};
+ModalDialog RID_DLG_NEWLIB
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 160 , 55 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ OKButton RID_PB_OK
+ {
+ Pos = MAP_APPFONT ( 104 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton RID_PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 104 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText RID_FT_NEWLIB
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ Text [ en-US ] = "~Name:" ;
+ };
+ Edit RID_ED_LIBNAME
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 19 ) ;
+ Size = MAP_APPFONT ( 92 , 12 ) ;
+ TabStop = TRUE ;
+ };
+};
+
+ModalDialog RID_DLG_EXPORT
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 115 , 55 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text [ en-US ] = "Export Basic library";
+ OKButton RID_PB_OK
+ {
+ Pos = MAP_APPFONT ( 6 , 35 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton RID_PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 59 , 35 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+
+ RadioButton RB_EXPORTASPACKAGE
+ {
+ Pos = MAP_APPFONT( 6, 6 );
+ Size = MAP_APPFONT( 103, 10 );
+ Group = TRUE;
+ Text [ en-US ] = "Export as ~extension";
+ TabStop = TRUE ;
+ };
+ RadioButton RB_EXPORTASBASIC
+ {
+ Pos = MAP_APPFONT( 6, 19 );
+ Size = MAP_APPFONT( 103, 10 );
+ //Group = TRUE;
+ Text [ en-US ] = "Export as BASIC library";
+ };
+};
+
+String RID_STR_EXPORTPACKAGE
+{
+ Text [ en-US ] = "Export library as extension";
+};
+
+String RID_STR_EXPORTBASIC
+{
+ Text [ en-US ] = "Export as BASIC library";
+};
+
+String RID_STR_PACKAGE_BUNDLE
+{
+ Text [ en-US ] = "Extension";
+};
+
diff --git a/basctl/source/basicide/moptions.hrc b/basctl/source/basicide/moptions.hrc
new file mode 100644
index 000000000000..2636a39a8484
--- /dev/null
+++ b/basctl/source/basicide/moptions.hrc
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _MOPTIONS_HRC
+#define _MOPTIONS_HRC
+
+#include <svl/solar.hrc>
+
+#define RID_MACROOPTIONS ( RID_BASICIDE_START + 55 )
+
+#define RID_FT_SBXNAME 2
+#define RID_PB_OK 3
+#define RID_PB_CANCEL 4
+#define RID_PB_HELP 5
+#define RID_FT_DESCR 6
+#define RID_ME_DESCR 7
+#define RID_FL_HELP 8
+#define RID_FT_HELPID 9
+#define RID_NF_HELPID 10
+#define RID_FT_HELPNAME 11
+#define RID_ED_HELPNAME 12
+
+#endif // _MOPTIONS_HRC
+
diff --git a/basctl/source/basicide/moptions.src b/basctl/source/basicide/moptions.src
new file mode 100644
index 000000000000..ef1be222095c
--- /dev/null
+++ b/basctl/source/basicide/moptions.src
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "helpid.hrc"
+#include <moptions.hrc>
+ModalDialog RID_MACROOPTIONS
+{
+ // HelpId = HID_MACRO_OPTIONS ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 224 , 121 ) ;
+ Text [ en-US ] = "Description" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ FixedText RID_FT_SBXNAME
+ {
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 150 , 10 ) ;
+ };
+ OKButton RID_PB_OK
+ {
+ Pos = MAP_APPFONT ( 168 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton RID_PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 168 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton RID_PB_HELP
+ {
+ Pos = MAP_APPFONT ( 168 , 53 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText RID_FT_DESCR
+ {
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 19 ) ;
+ Size = MAP_APPFONT ( 69 , 10 ) ;
+ Text [ en-US ] = "Description" ;
+ };
+ MultiLineEdit RID_ME_DESCR
+ {
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 32 ) ;
+ Size = MAP_APPFONT ( 154 , 36 ) ;
+ TabStop = TRUE ;
+ VScroll = TRUE ;
+ IgnoreTab = TRUE ;
+ };
+ FixedLine RID_FL_HELP
+ {
+ Pos = MAP_APPFONT ( 6 , 73 ) ;
+ Size = MAP_APPFONT ( 212 , 8 ) ;
+ Text [ en-US ] = "Help information" ;
+ };
+ FixedText RID_FT_HELPID
+ {
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 9 , 83 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ Text [ en-US ] = "Help ID" ;
+ };
+ NumericField RID_NF_HELPID
+ {
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 95 , 83 ) ;
+ Size = MAP_APPFONT ( 120 , 12 ) ;
+ TabStop = TRUE ;
+ Minimum = 0 ;
+ Maximum = 0xFFFFFFFF ;
+ };
+ FixedText RID_FT_HELPNAME
+ {
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 9 , 99 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ Text [ en-US ] = "Help file name" ;
+ };
+ Edit RID_ED_HELPNAME
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 95 , 99 ) ;
+ Size = MAP_APPFONT ( 120 , 12 ) ;
+ TabStop = TRUE ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/basctl/source/basicide/objdlg.cxx b/basctl/source/basicide/objdlg.cxx
new file mode 100644
index 000000000000..f3998287a2b8
--- /dev/null
+++ b/basctl/source/basicide/objdlg.cxx
@@ -0,0 +1,303 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include <ide_pch.hxx>
+
+
+#include <basic/sbx.hxx>
+#include <vcl/cmdevt.hxx>
+#include <vcl/taskpanelist.hxx>
+#include <vcl/sound.hxx>
+#include <objdlg.hrc>
+#include <objdlg.hxx>
+#include <bastypes.hxx>
+#include <basidesh.hrc>
+#include <basidesh.hxx>
+#include <iderdll.hxx>
+#include <iderdll2.hxx>
+#include <sbxitem.hxx>
+
+
+ObjectTreeListBox::ObjectTreeListBox( Window* pParent, const ResId& rRes )
+ : BasicTreeListBox( pParent, rRes )
+{
+}
+
+ObjectTreeListBox::~ObjectTreeListBox()
+{
+}
+
+void ObjectTreeListBox::Command( const CommandEvent& )
+{
+}
+
+void ObjectTreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ BasicTreeListBox::MouseButtonDown( rMEvt );
+
+ if ( rMEvt.IsLeft() && ( rMEvt.GetClicks() == 2 ) )
+ {
+ BasicEntryDescriptor aDesc( GetEntryDescriptor( GetCurEntry() ) );
+
+ if ( aDesc.GetType() == OBJ_TYPE_METHOD )
+ {
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), aDesc.GetName(),
+ aDesc.GetMethodName(), ConvertType( aDesc.GetType() ) );
+ pDispatcher->Execute( SID_BASICIDE_SHOWSBX,
+ SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
+ }
+ }
+ }
+}
+
+
+
+ObjectCatalog::ObjectCatalog( Window * pParent )
+ :FloatingWindow( pParent, IDEResId( RID_BASICIDE_OBJCAT ) )
+ ,aMacroTreeList( this, IDEResId( RID_TLB_MACROS ) )
+ ,aToolBox(this, IDEResId(RID_TB_TOOLBOX), IDEResId(RID_IMGLST_TB_HC))
+ ,aMacroDescr( this, IDEResId( RID_FT_MACRODESCR ) )
+{
+ FreeResource();
+
+ aToolBox.SetOutStyle( TOOLBOX_STYLE_FLAT );
+ aToolBox.SetSizePixel( aToolBox.CalcWindowSizePixel() );
+ aToolBox.SetSelectHdl( LINK( this, ObjectCatalog, ToolBoxHdl ) );
+
+ aMacroTreeList.SetWindowBits( WB_HASLINES | WB_HASLINESATROOT |
+ WB_HASBUTTONS | WB_HASBUTTONSATROOT |
+ WB_HSCROLL );
+
+ aMacroTreeList.SetSelectHdl( LINK( this, ObjectCatalog, TreeListHighlightHdl ) );
+
+ aMacroTreeList.ScanAllEntries();
+ CheckButtons();
+
+ Point aPos = IDE_DLL()->GetExtraData()->GetObjectCatalogPos();
+ Size aSize = IDE_DLL()->GetExtraData()->GetObjectCatalogSize();
+ if ( aPos.X() == INVPOSITION )
+ {
+ // Zentriert nach AppWin:
+ Window* pWin = GetParent();
+ aPos = pWin->OutputToScreenPixel( Point( 0, 0 ) );
+ Size aAppWinSz = pWin->GetSizePixel();
+ Size aDlgWinSz = GetSizePixel();
+ aPos.X() += aAppWinSz.Width() / 2;
+ aPos.X() -= aDlgWinSz.Width() / 2;
+ aPos.Y() += aAppWinSz.Height() / 2;
+ aPos.Y() -= aDlgWinSz.Height() / 2;
+ }
+ SetPosPixel( aPos );
+ if ( aSize.Width() )
+ SetOutputSizePixel( aSize );
+
+ Resize(); // damit der Resize-Handler die Controls anordnet
+
+ // make object catalog keyboard accessible
+ pParent->GetSystemWindow()->GetTaskPaneList()->AddWindow( this );
+}
+
+ObjectCatalog::~ObjectCatalog()
+{
+ GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this );
+}
+
+void __EXPORT ObjectCatalog::Move()
+{
+ IDE_DLL()->GetExtraData()->SetObjectCatalogPos( GetPosPixel() );
+}
+
+BOOL __EXPORT ObjectCatalog::Close()
+{
+ aCancelHdl.Call( this );
+ return TRUE;
+}
+
+void __EXPORT ObjectCatalog::Resize()
+{
+ Size aOutSz = GetOutputSizePixel();
+ IDE_DLL()->GetExtraData()->SetObjectCatalogSize( aOutSz );
+
+ Point aTreePos = aMacroTreeList.GetPosPixel();
+ Size aDescrSz = aMacroDescr.GetSizePixel();
+
+ Size aTreeSz;
+ long nCtrlWidth = aOutSz.Width() - 2*aTreePos.X();
+ aTreeSz.Width() = nCtrlWidth;
+ aTreeSz.Height() = aOutSz.Height() - aTreePos.Y() -
+ 2*aTreePos.X() - aDescrSz.Height();
+
+ if ( aTreeSz.Height() > 0 )
+ {
+ aMacroTreeList.SetSizePixel( aTreeSz );
+
+ Point aDescrPos( aTreePos.X(), aTreePos.Y()+aTreeSz.Height()+aTreePos.X() );
+
+ aMacroDescr.SetPosSizePixel( aDescrPos, Size( nCtrlWidth, aDescrSz.Height() ) );
+
+ String aDesc = aMacroDescr.GetText();
+ aMacroDescr.SetText(String());
+ aMacroDescr.SetText(aDesc);
+ }
+
+ // Die Buttons oben bleiben immer unveraendert stehen...
+}
+
+IMPL_LINK( ObjectCatalog, ToolBoxHdl, ToolBox*, pToolBox )
+{
+ USHORT nCurItem = pToolBox->GetCurItemId();
+ switch ( nCurItem )
+ {
+ case TBITEM_SHOW:
+ {
+ SfxAllItemSet aArgs( SFX_APP()->GetPool() );
+ SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs );
+ SFX_APP()->ExecuteSlot( aRequest );
+
+ SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry();
+ DBG_ASSERT( pCurEntry, "Entry?!" );
+ BasicEntryDescriptor aDesc( aMacroTreeList.GetEntryDescriptor( pCurEntry ) );
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+ if ( aDesc.GetType() == OBJ_TYPE_MODULE ||
+ aDesc.GetType() == OBJ_TYPE_DIALOG ||
+ aDesc.GetType() == OBJ_TYPE_METHOD )
+ {
+ if( pDispatcher )
+ {
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), aDesc.GetName(),
+ aDesc.GetMethodName(), aMacroTreeList.ConvertType( aDesc.GetType() ) );
+ pDispatcher->Execute( SID_BASICIDE_SHOWSBX,
+ SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
+ }
+ }
+ else
+ {
+ ErrorBox( this, WB_OK, String( IDEResId( RID_STR_OBJNOTFOUND ) ) ).Execute();
+ aMacroTreeList.GetModel()->Remove( pCurEntry );
+ CheckButtons();
+ }
+ }
+ break;
+ }
+
+ return 0;
+}
+
+
+
+void ObjectCatalog::CheckButtons()
+{
+ SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry();
+ BasicEntryType eType = pCurEntry ? ((BasicEntry*)pCurEntry->GetUserData())->GetType() : OBJ_TYPE_UNKNOWN;
+ if ( eType == OBJ_TYPE_DIALOG || eType == OBJ_TYPE_MODULE || eType == OBJ_TYPE_METHOD )
+ aToolBox.EnableItem( TBITEM_SHOW, TRUE );
+ else
+ aToolBox.EnableItem( TBITEM_SHOW, FALSE );
+}
+
+
+
+IMPL_LINK_INLINE_START( ObjectCatalog, TreeListHighlightHdl, SvTreeListBox *, pBox )
+{
+ if ( pBox->IsSelected( pBox->GetHdlEntry() ) )
+ UpdateFields();
+ return 0;
+}
+IMPL_LINK_INLINE_END( ObjectCatalog, TreeListHighlightHdl, SvTreeListBox *, pBox )
+
+
+void ObjectCatalog::UpdateFields()
+{
+ SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry();
+ if ( pCurEntry )
+ {
+ CheckButtons();
+ aMacroDescr.SetText( String() );
+ SbxVariable* pVar = aMacroTreeList.FindVariable( pCurEntry );
+ if ( pVar )
+ {
+ SbxInfoRef xInfo = pVar->GetInfo();
+ if ( xInfo.Is() )
+ aMacroDescr.SetText( xInfo->GetComment() );
+ }
+ }
+}
+
+
+void ObjectCatalog::UpdateEntries()
+{
+ aMacroTreeList.UpdateEntries();
+}
+
+void ObjectCatalog::SetCurrentEntry( BasicEntryDescriptor& rDesc )
+{
+ aMacroTreeList.SetCurrentEntry( rDesc );
+}
+
+ObjectCatalogToolBox_Impl::ObjectCatalogToolBox_Impl(
+ Window * pParent, ResId const & rResId,
+ ResId const & rImagesHighContrastId):
+ ToolBox(pParent, rResId),
+ m_aImagesNormal(GetImageList()),
+ m_aImagesHighContrast(rImagesHighContrastId),
+ m_bHighContrast(false)
+{
+ setImages();
+}
+
+// virtual
+void ObjectCatalogToolBox_Impl::DataChanged(DataChangedEvent const & rDCEvt)
+{
+ ToolBox::DataChanged(rDCEvt);
+ if ((rDCEvt.GetType() == DATACHANGED_SETTINGS
+ || rDCEvt.GetType() == DATACHANGED_DISPLAY)
+ && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
+ setImages();
+}
+
+void ObjectCatalogToolBox_Impl::setImages()
+{
+ bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
+ if (bHC != m_bHighContrast)
+ {
+ SetImageList(bHC ? m_aImagesHighContrast : m_aImagesNormal);
+ m_bHighContrast = bHC;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/objdlg.hrc b/basctl/source/basicide/objdlg.hrc
new file mode 100644
index 000000000000..930ab31a4ae8
--- /dev/null
+++ b/basctl/source/basicide/objdlg.hrc
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _OBJDLG_HRC
+#define _OBJDLG_HRC
+
+#include <svl/solar.hrc>
+
+#define RID_BASICIDE_OBJCAT ( RID_BASICIDE_START + 70 )
+#define RID_FT_MACRODESCR 8
+#define RID_IMGLST_TB_HC 9
+#define RID_TLB_MACROS 10
+#define RID_TB_TOOLBOX 11
+
+#define TBITEM_SHOW 1
+
+#endif // _OBJDLG_HXX
diff --git a/basctl/source/basicide/objdlg.hxx b/basctl/source/basicide/objdlg.hxx
new file mode 100644
index 000000000000..cd48a135a882
--- /dev/null
+++ b/basctl/source/basicide/objdlg.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OBJDLG_HXX
+#define _OBJDLG_HXX
+
+#include <svheader.hxx>
+#include <vcl/floatwin.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/fixed.hxx>
+#include "vcl/image.hxx"
+
+#include <bastype2.hxx>
+
+class StarBASIC;
+
+class ObjectTreeListBox : public BasicTreeListBox
+{
+private:
+
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+
+public:
+ ObjectTreeListBox( Window* pParent, const ResId& rRes );
+ ~ObjectTreeListBox();
+};
+
+class ObjectCatalogToolBox_Impl: public ToolBox
+{
+public:
+ ObjectCatalogToolBox_Impl(Window * pParent, ResId const & rResId,
+ ResId const & rImagesHighContrastId);
+
+private:
+ virtual void DataChanged(DataChangedEvent const & rDCEvt);
+
+ void setImages();
+
+ ImageList m_aImagesNormal;
+ ImageList m_aImagesHighContrast;
+ bool m_bHighContrast;
+};
+
+class ObjectCatalog : public FloatingWindow
+{
+private:
+ ObjectTreeListBox aMacroTreeList;
+ ObjectCatalogToolBox_Impl aToolBox;
+ FixedText aMacroDescr;
+ Link aCancelHdl;
+
+protected:
+ DECL_LINK( ToolBoxHdl, ToolBox* );
+ void CheckButtons();
+ DECL_LINK( TreeListHighlightHdl, SvTreeListBox * );
+ void UpdateFields();
+ virtual void Move();
+ virtual BOOL Close();
+ virtual void Resize();
+
+public:
+ ObjectCatalog( Window * pParent );
+ virtual ~ObjectCatalog();
+
+ void UpdateEntries();
+ void SetCurrentEntry( BasicEntryDescriptor& rDesc );
+
+ void SetCancelHdl( const Link& rLink ) { aCancelHdl = rLink; }
+};
+
+#endif //_OBJDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/objdlg.src b/basctl/source/basicide/objdlg.src
new file mode 100644
index 000000000000..c8de023dec53
--- /dev/null
+++ b/basctl/source/basicide/objdlg.src
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <objdlg.hrc>
+#include <helpid.hrc>
+
+#define MASKCOLOR MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; };
+
+FloatingWindow RID_BASICIDE_OBJCAT
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 191 , 179 ) ;
+ Text [ en-US ] = "Objects" ;
+ Closeable = TRUE ;
+ Moveable = TRUE ;
+ Sizeable = TRUE ;
+ Zoomable = TRUE ;
+ Hide = TRUE ;
+ ClipChildren = TRUE ;
+ Control RID_TLB_MACROS
+ {
+ HelpId = HID_BASICIDE_OBJECTCAT ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 3 , 24 ) ;
+ Size = MAP_APPFONT ( 185 , 126 ) ;
+ TabStop = TRUE ;
+ };
+ ToolBox RID_TB_TOOLBOX
+ {
+ HelpId = HID_BASICIDE_OBJECTS ;
+ SVLook = TRUE ;
+ Align = BOXALIGN_TOP ;
+ Pos = MAP_APPFONT ( 4 , 6 ) ;
+ ItemImageList = ImageList
+ {
+ Prefix = "im";
+ MASKCOLOR
+ IdList =
+ {
+ TBITEM_SHOW ;
+ };
+ };
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = TBITEM_SHOW ;
+ HelpId = HID_BASICIDE_OBJCAT_SHOW ;
+ Text [ en-US ] = "Show" ;
+ };
+ };
+ };
+ ImageList RID_IMGLST_TB_HC
+ {
+ Prefix = "imh";
+ MASKCOLOR
+ IdList =
+ {
+ TBITEM_SHOW ;
+ };
+ };
+ FixedText RID_FT_MACRODESCR
+ {
+ WordBreak = TRUE ;
+ Pos = MAP_APPFONT ( 3 , 156 ) ;
+ Size = MAP_APPFONT ( 185 , 18 ) ;
+ };
+};
diff --git a/basctl/source/basicide/register.cxx b/basctl/source/basicide/register.cxx
new file mode 100644
index 000000000000..612a3dc1f303
--- /dev/null
+++ b/basctl/source/basicide/register.cxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/uno/Sequence.h>
+#include <rtl/ustring.hxx>
+
+#include <cppuhelper/factory.hxx>
+
+#include "unomodel.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+
+extern "C" {
+
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char** ppEnvironmentTypeName,
+ uno_Environment** ppEnvironment )
+{
+ (void)ppEnvironment;
+ *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
+}
+
+SAL_DLLPUBLIC_EXPORT
+sal_Bool SAL_CALL component_writeInfo( void* pServiceManager ,
+ void* pRegistryKey )
+{
+ (void)pServiceManager;
+
+ Reference< ::registry::XRegistryKey >
+ xKey( reinterpret_cast< ::registry::XRegistryKey* >( pRegistryKey ) ) ;
+
+ OUString aDelimiter( RTL_CONSTASCII_USTRINGPARAM("/") );
+ OUString aUnoServices( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") );
+
+ sal_Int32 i;
+ Reference< ::registry::XRegistryKey > xNewKey;
+ xNewKey = xKey->createKey( aDelimiter + SIDEModel::getImplementationName_Static() + aUnoServices );
+ Sequence< OUString > aServices = SIDEModel::getSupportedServiceNames_Static();
+ for(i = 0; i < aServices.getLength(); i++ )
+ xNewKey->createKey( aServices.getConstArray()[i] );
+
+ return sal_True;
+}
+
+SAL_DLLPUBLIC_EXPORT
+void* SAL_CALL component_getFactory( const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* pRegistryKey )
+{
+ (void)pRegistryKey;
+
+ // Set default return value for this operation - if it failed.
+ void* pReturn = NULL ;
+
+ if (
+ ( pImplementationName != NULL ) &&
+ ( pServiceManager != NULL )
+ )
+ {
+ // Define variables which are used in following macros.
+ Reference< XSingleServiceFactory > xFactory ;
+ Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
+
+ if( SIDEModel::getImplementationName_Static().equalsAscii( pImplementationName ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xServiceManager,
+ SIDEModel::getImplementationName_Static(),
+ SIDEModel_createInstance,
+ SIDEModel::getSupportedServiceNames_Static() );
+ }
+
+ // Factory is valid - service was found.
+ if ( xFactory.is() )
+ {
+ xFactory->acquire();
+ pReturn = xFactory.get();
+ }
+ }
+
+ // Return with result of this operation.
+ return pReturn ;
+}
+} // extern "C"
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx
new file mode 100644
index 000000000000..bc21f4b3f556
--- /dev/null
+++ b/basctl/source/basicide/scriptdocument.cxx
@@ -0,0 +1,1631 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include "scriptdocument.hxx"
+#include "basobj.hxx"
+#include "basidesh.hrc"
+#include "iderid.hxx"
+#include "dlgeddef.hxx"
+#include "localizationmgr.hxx"
+#include "doceventnotifier.hxx"
+#include "documentenumeration.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/script/XLibraryContainer2.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uri/XUriReferenceFactory.hpp>
+#include <com/sun/star/util/XMacroExpander.hpp>
+#include <com/sun/star/document/MacroExecMode.hpp>
+#include <com/sun/star/document/XEventBroadcaster.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
+#include <com/sun/star/awt/XWindow2.hpp>
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/script/vba/XVBACompatibility.hpp>
+#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
+/** === end UNO includes === **/
+
+#include <sfx2/objsh.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/docfile.hxx>
+
+#include <vcl/svapp.hxx>
+
+#include <basic/basicmanagerrepository.hxx>
+
+#include <xmlscript/xmldlg_imexp.hxx>
+
+#include <unotools/syslocale.hxx>
+
+#include <unotools/collatorwrapper.hxx>
+
+#include <tools/diagnose_ex.h>
+#include <tools/urlobj.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/documentinfo.hxx>
+#include <comphelper/componentcontext.hxx>
+
+#include <osl/mutex.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <rtl/uri.hxx>
+#include <rtl/bootstrap.hxx>
+
+#include <osl/process.h>
+#include <osl/file.hxx>
+
+#include <algorithm>
+#include <functional>
+#include <set>
+
+//........................................................................
+namespace basctl
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::script::XLibraryContainer;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::container::XNameContainer;
+ using ::com::sun::star::container::NoSuchElementException;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::task::XStatusIndicator;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::script::XLibraryContainer2;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::uri::XUriReferenceFactory;
+ using ::com::sun::star::uri::XUriReference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::util::XMacroExpander;
+ using ::com::sun::star::io::XInputStreamProvider;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::io::XInputStream;
+ using ::com::sun::star::frame::XStorable;
+ using ::com::sun::star::util::XModifiable;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::util::URL;
+ using ::com::sun::star::frame::XDispatchProvider;
+ using ::com::sun::star::frame::XDispatch;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::frame::XDesktop;
+ using ::com::sun::star::container::XEnumerationAccess;
+ using ::com::sun::star::container::XEnumeration;
+ using ::com::sun::star::frame::XModel2;
+ using ::com::sun::star::awt::XWindow2;
+ using ::com::sun::star::document::XEventListener;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::document::XEventBroadcaster;
+ using ::com::sun::star::document::XEmbeddedScripts;
+ using ::com::sun::star::script::ModuleInfo;
+ using ::com::sun::star::script::vba::XVBACompatibility;
+ using ::com::sun::star::script::vba::XVBAModuleInfo;
+ /** === end UNO using === **/
+ namespace MacroExecMode = ::com::sun::star::document::MacroExecMode;
+ namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag;
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ //................................................................
+ static bool StringCompareLessThan( const String& lhs, const String& rhs )
+ {
+ return ( lhs.CompareIgnoreCaseToAscii( rhs ) == COMPARE_LESS );
+ }
+
+ //................................................................
+ class FilterDocuments : public docs::IDocumentDescriptorFilter
+ {
+ public:
+ FilterDocuments( bool _bFilterInvisible ) : m_bFilterInvisible( _bFilterInvisible ) { }
+
+ virtual bool includeDocument( const docs::DocumentDescriptor& _rDocument ) const;
+
+ private:
+ bool impl_isDocumentVisible_nothrow( const docs::DocumentDescriptor& _rDocument ) const;
+
+ private:
+ bool m_bFilterInvisible;
+ };
+
+ //................................................................
+ bool FilterDocuments::impl_isDocumentVisible_nothrow( const docs::DocumentDescriptor& _rDocument ) const
+ {
+ try
+ {
+ for ( docs::Controllers::const_iterator controller = _rDocument.aControllers.begin();
+ controller != _rDocument.aControllers.end();
+ ++controller
+ )
+ {
+ Reference< XFrame > xFrame( (*controller)->getFrame(), UNO_SET_THROW );
+ Reference< XWindow2 > xContainer( xFrame->getContainerWindow(), UNO_QUERY_THROW );
+ if ( xContainer->isVisible() )
+ return true;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+ //................................................................
+ bool FilterDocuments::includeDocument( const docs::DocumentDescriptor& _rDocument ) const
+ {
+ Reference< XEmbeddedScripts > xScripts( _rDocument.xModel, UNO_QUERY );
+ if ( !xScripts.is() )
+ return false;
+ if ( !m_bFilterInvisible || impl_isDocumentVisible_nothrow( _rDocument ) )
+ return true;
+ return false;
+ }
+
+ //................................................................
+ void lcl_getAllModels_throw( docs::Documents& _out_rModels, bool _bVisibleOnly )
+ {
+ _out_rModels.clear();
+
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ FilterDocuments aFilter( _bVisibleOnly );
+ docs::DocumentEnumeration aEnum( aContext, &aFilter );
+
+ aEnum.getDocuments( _out_rModels );
+ }
+ }
+
+ //====================================================================
+ //= ScriptDocument_Impl - declaration
+ //====================================================================
+ class ScriptDocument_Impl : public DocumentEventListener
+ {
+ private:
+ bool m_bIsApplication;
+ bool m_bValid;
+ bool m_bDocumentClosed;
+ Reference< XModel > m_xDocument;
+ Reference< XModifiable > m_xDocModify;
+ Reference< XEmbeddedScripts > m_xScriptAccess;
+ ::std::auto_ptr< DocumentEventNotifier >
+ m_pDocListener;
+
+ public:
+ ScriptDocument_Impl( );
+ ScriptDocument_Impl( const Reference< XModel >& _rxDocument );
+ ~ScriptDocument_Impl();
+
+ /** determines whether the instance refers to a valid "document" with script and
+ dialog libraries
+ */
+ inline bool isValid() const { return m_bValid; }
+ /** determines whether the instance refers to a non-closed document
+ */
+ inline bool isAlive() const { return m_bValid ? ( m_bIsApplication ? true : !m_bDocumentClosed ) : false; }
+ /// determines whether the "document" refers to the application in real
+ inline bool isApplication() const { return m_bValid && m_bIsApplication; }
+ /// determines whether the document refers to a real document (instead of the application)
+ inline bool isDocument() const { return m_bValid && !m_bIsApplication; }
+
+ /** invalidates the instance
+ */
+ void invalidate();
+
+ const Reference< XModel >&
+ getDocumentRef() const { return m_xDocument; }
+
+ /// returns a library container belonging to the document
+ Reference< XLibraryContainer >
+ getLibraryContainer( LibraryContainerType _eType ) const;
+
+ /// determines whether a given library is part of the shared installation
+ bool isLibraryShared( const ::rtl::OUString& _rLibName, LibraryContainerType _eType );
+
+ /** returns the current frame of the document
+
+ To be called for documents only, not for the application.
+
+ If <FALSE/> is returned, an assertion will be raised in non-product builds.
+ */
+ bool getCurrentFrame( Reference< XFrame >& _out_rxFrame ) const;
+
+ // versions with the same signature/semantics as in ScriptDocument itself
+ bool isReadOnly() const;
+ bool isInVBAMode() const;
+ BasicManager*
+ getBasicManager() const;
+ Reference< XModel >
+ getDocument() const;
+ void setDocumentModified() const;
+ bool isDocumentModified() const;
+ bool saveDocument( const Reference< XStatusIndicator >& _rxStatusIndicator ) const;
+
+ ::rtl::OUString
+ getTitle() const;
+ ::rtl::OUString
+ getURL() const;
+
+ bool allowMacros() const;
+
+ Reference< XNameContainer >
+ getLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, bool _bLoadLibrary ) const
+ SAL_THROW((NoSuchElementException));
+ bool hasLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const;
+ Reference< XNameContainer >
+ getOrCreateLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const;
+
+ void loadLibraryIfExists( LibraryContainerType _eType, const ::rtl::OUString& _rLibrary );
+
+ bool removeModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModuleName );
+ bool hasModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName ) const;
+ bool getModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rObjectName, Any& _out_rModuleOrDialog );
+ bool renameModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rOldName, const ::rtl::OUString& _rNewName, const Reference< XNameContainer >& _rxExistingDialogModel );
+ bool createModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, bool _bCreateMain, ::rtl::OUString& _out_rNewModuleCode ) const;
+ bool insertModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rObjectName, const ::rtl::OUString& _rModName, const Any& _rElement ) const;
+ bool updateModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, const ::rtl::OUString& _rModuleCode ) const;
+ bool createDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName, Reference< XInputStreamProvider >& _out_rDialogProvider ) const;
+
+ protected:
+ // DocumentEventListener
+ virtual void onDocumentCreated( const ScriptDocument& _rDocument );
+ virtual void onDocumentOpened( const ScriptDocument& _rDocument );
+ virtual void onDocumentSave( const ScriptDocument& _rDocument );
+ virtual void onDocumentSaveDone( const ScriptDocument& _rDocument );
+ virtual void onDocumentSaveAs( const ScriptDocument& _rDocument );
+ virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument );
+ virtual void onDocumentClosed( const ScriptDocument& _rDocument );
+ virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument );
+ virtual void onDocumentModeChanged( const ScriptDocument& _rDocument );
+
+ private:
+ bool impl_initDocument_nothrow( const Reference< XModel >& _rxModel );
+ };
+
+ //====================================================================
+ //= ScriptDocument_Impl - implementation
+ //====================================================================
+ //--------------------------------------------------------------------
+ ScriptDocument_Impl::ScriptDocument_Impl()
+ :m_bIsApplication( true )
+ ,m_bValid( true )
+ ,m_bDocumentClosed( false )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ScriptDocument_Impl::ScriptDocument_Impl( const Reference< XModel >& _rxDocument )
+ :m_bIsApplication( false )
+ ,m_bValid( false )
+ ,m_bDocumentClosed( false )
+ {
+ if ( _rxDocument.is() )
+ {
+ if ( impl_initDocument_nothrow( _rxDocument ) )
+ {
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ScriptDocument_Impl::~ScriptDocument_Impl()
+ {
+ invalidate();
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument_Impl::invalidate()
+ {
+ m_bIsApplication = false;
+ m_bValid = false;
+ m_bDocumentClosed = false;
+
+ m_xDocument.clear();
+ m_xDocModify.clear();
+ m_xScriptAccess.clear();
+
+ if ( m_pDocListener.get() )
+ m_pDocListener->dispose();
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::impl_initDocument_nothrow( const Reference< XModel >& _rxModel )
+ {
+ try
+ {
+ m_xDocument.set ( _rxModel, UNO_SET_THROW );
+ m_xDocModify.set ( _rxModel, UNO_QUERY_THROW );
+ m_xScriptAccess.set ( _rxModel, UNO_QUERY );
+
+ m_bValid = m_xScriptAccess.is();
+
+ if ( m_bValid )
+ m_pDocListener.reset( new DocumentEventNotifier( *this, _rxModel ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ m_bValid = false;
+ }
+
+ if ( !m_bValid )
+ {
+ invalidate();
+ }
+
+ return m_bValid;
+ }
+ //--------------------------------------------------------------------
+ Reference< XLibraryContainer > ScriptDocument_Impl::getLibraryContainer( LibraryContainerType _eType ) const
+ {
+ OSL_ENSURE( isValid(), "ScriptDocument_Impl::getLibraryContainer: invalid!" );
+
+ Reference< XLibraryContainer > xContainer;
+ if ( !isValid() )
+ return xContainer;
+
+ try
+ {
+ if ( isApplication() )
+ xContainer.set( _eType == E_SCRIPTS ? SFX_APP()->GetBasicContainer() : SFX_APP()->GetDialogContainer(), UNO_QUERY_THROW );
+ else
+ {
+ xContainer.set(
+ _eType == E_SCRIPTS ? m_xScriptAccess->getBasicLibraries() : m_xScriptAccess->getDialogLibraries(),
+ UNO_QUERY_THROW );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xContainer;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::isReadOnly() const
+ {
+ OSL_ENSURE( isValid(), "ScriptDocument_Impl::isReadOnly: invalid state!" );
+ OSL_ENSURE( !isApplication(), "ScriptDocument_Impl::isReadOnly: not allowed to be called for the application!" );
+
+ bool bIsReadOnly = true;
+ if ( isValid() && !isApplication() )
+ {
+ try
+ {
+ // note that XStorable is required by the OfficeDocument service
+ Reference< XStorable > xDocStorable( m_xDocument, UNO_QUERY_THROW );
+ bIsReadOnly = xDocStorable->isReadonly();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return bIsReadOnly;
+ }
+
+ bool ScriptDocument_Impl::isInVBAMode() const
+ {
+ bool bResult = false;
+ if ( !isApplication() )
+ {
+ Reference< XVBACompatibility > xVBACompat( getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ if ( xVBACompat.is() )
+ bResult = xVBACompat->getVBACompatibilityMode();
+ }
+ return bResult;
+ }
+
+ //--------------------------------------------------------------------
+ BasicManager* ScriptDocument_Impl::getBasicManager() const
+ {
+ OSL_ENSURE( isValid(), "ScriptDocument_Impl::getBasicManager: invalid state!" );
+ if ( !isValid() )
+ return NULL;
+
+ if ( isApplication() )
+ return SFX_APP()->GetBasicManager();
+
+ return ::basic::BasicManagerRepository::getDocumentBasicManager( m_xDocument );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XModel > ScriptDocument_Impl::getDocument() const
+ {
+ OSL_ENSURE( isValid(), "ScriptDocument_Impl::getDocument: invalid state!" );
+ OSL_ENSURE( isDocument(), "ScriptDocument_Impl::getDocument: for documents only!" );
+ if ( !isValid() || !isDocument() )
+ return NULL;
+
+ return m_xDocument;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XNameContainer > ScriptDocument_Impl::getLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, bool _bLoadLibrary ) const
+ SAL_THROW((NoSuchElementException))
+ {
+ OSL_ENSURE( isValid(), "ScriptDocument_Impl::getLibrary: invalid state!" );
+
+ Reference< XNameContainer > xContainer;
+ try
+ {
+ Reference< XLibraryContainer > xLibContainer = getLibraryContainer( _eType );
+ if ( isValid() )
+ {
+ if ( xLibContainer.is() )
+ xContainer.set( xLibContainer->getByName( _rLibName ), UNO_QUERY_THROW );
+ }
+
+ if ( !xContainer.is() )
+ throw NoSuchElementException();
+
+ // load library
+ if ( _bLoadLibrary && !xLibContainer->isLibraryLoaded( _rLibName ) )
+ xLibContainer->loadLibrary( _rLibName );
+ }
+ catch( const NoSuchElementException& )
+ {
+ throw; // allowed to leave
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return xContainer;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::hasLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const
+ {
+ bool bHas = false;
+ try
+ {
+ Reference< XLibraryContainer > xLibContainer = getLibraryContainer( _eType );
+ bHas = xLibContainer.is() && xLibContainer->hasByName( _rLibName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bHas;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XNameContainer > ScriptDocument_Impl::getOrCreateLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const
+ {
+ Reference< XNameContainer > xLibrary;
+ try
+ {
+ Reference< XLibraryContainer > xLibContainer( getLibraryContainer( _eType ), UNO_QUERY_THROW );
+ if ( xLibContainer->hasByName( _rLibName ) )
+ xLibrary.set( xLibContainer->getByName( _rLibName ), UNO_QUERY_THROW );
+ else
+ xLibrary.set( xLibContainer->createLibrary( _rLibName ), UNO_QUERY_THROW );
+
+ if ( !xLibContainer->isLibraryLoaded( _rLibName ) )
+ xLibContainer->loadLibrary( _rLibName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xLibrary;
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument_Impl::loadLibraryIfExists( LibraryContainerType _eType, const ::rtl::OUString& _rLibrary )
+ {
+ try
+ {
+ Reference< XLibraryContainer > xLibContainer( getLibraryContainer( _eType ) );
+ if ( xLibContainer.is() && xLibContainer->hasByName( _rLibrary ) && !xLibContainer->isLibraryLoaded( _rLibrary ) )
+ xLibContainer->loadLibrary( _rLibrary );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::removeModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModuleName )
+ {
+ OSL_ENSURE( isValid(), "ScriptDocument_Impl::removeModuleOrDialog: invalid!" );
+ if ( isValid() )
+ {
+ try
+ {
+ Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, TRUE ) );
+ if ( xLib.is() )
+ {
+ xLib->removeByName( _rModuleName );
+ return true;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::hasModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName ) const
+ {
+ OSL_ENSURE( isValid(), "ScriptDocument_Impl::hasModuleOrDialog: invalid!" );
+ if ( !isValid() )
+ return false;
+
+ try
+ {
+ Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, TRUE ) );
+ if ( xLib.is() )
+ return xLib->hasByName( _rModName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::getModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rObjectName, Any& _out_rModuleOrDialog )
+ {
+ OSL_ENSURE( isValid(), "ScriptDocument_Impl::getModuleOrDialog: invalid!" );
+ if ( !isValid() )
+ return false;
+
+ _out_rModuleOrDialog.clear();
+ try
+ {
+ Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, TRUE ), UNO_QUERY_THROW );
+ if ( xLib->hasByName( _rObjectName ) )
+ {
+ _out_rModuleOrDialog = xLib->getByName( _rObjectName );
+ return true;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::renameModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName,
+ const ::rtl::OUString& _rOldName, const ::rtl::OUString& _rNewName, const Reference< XNameContainer >& _rxExistingDialogModel )
+ {
+ OSL_ENSURE( isValid(), "ScriptDocument_Impl::renameModuleOrDialog: invalid!" );
+ if ( !isValid() )
+ return false;
+
+ try
+ {
+ Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, TRUE ), UNO_QUERY_THROW );
+
+ // get element
+ Any aElement( xLib->getByName( _rOldName ) );
+
+ // remove element from container
+ xLib->removeByName( _rOldName );
+
+ // if it's a dialog, import and export, to reflect the new name
+ if ( _eType == E_DIALOGS )
+ {
+ // create dialog model
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ Reference< XNameContainer > xDialogModel;
+ if ( _rxExistingDialogModel.is() )
+ xDialogModel = _rxExistingDialogModel;
+ else
+ if ( !aContext.createComponent( "com.sun.star.awt.UnoControlDialogModel", xDialogModel ) )
+ return false;
+
+ // import dialog model
+ Reference< XInputStreamProvider > xISP( aElement, UNO_QUERY_THROW );
+ if ( !_rxExistingDialogModel.is() )
+ {
+ Reference< XInputStream > xInput( xISP->createInputStream(), UNO_QUERY_THROW );
+ ::xmlscript::importDialogModel( xInput, xDialogModel, aContext.getUNOContext(), isDocument() ? getDocument() : Reference< XModel >() );
+ }
+
+ // set new name as property
+ Reference< XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY_THROW );
+ xDlgPSet->setPropertyValue( DLGED_PROP_NAME, makeAny( _rNewName ) );
+
+ // export dialog model
+ xISP = ::xmlscript::exportDialogModel( xDialogModel, aContext.getUNOContext(), isDocument() ? getDocument() : Reference< XModel >() );
+ aElement <<= xISP;
+ }
+
+ // insert element by new name in container
+ if ( _eType == E_SCRIPTS )
+ {
+ Reference< XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY );
+ if ( xVBAModuleInfo->hasModuleInfo( _rOldName ) )
+ {
+ ModuleInfo sModuleInfo = xVBAModuleInfo->getModuleInfo( _rOldName );
+ xVBAModuleInfo->removeModuleInfo( _rOldName );
+ xVBAModuleInfo->insertModuleInfo( _rNewName, sModuleInfo );
+ }
+ }
+ xLib->insertByName( _rNewName, aElement );
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::createModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, bool _bCreateMain, ::rtl::OUString& _out_rNewModuleCode ) const
+ {
+ _out_rNewModuleCode = ::rtl::OUString();
+ try
+ {
+ Reference< XNameContainer > xLib( getLibrary( E_SCRIPTS, _rLibName, TRUE ) );
+ if ( !xLib.is() || xLib->hasByName( _rModName ) )
+ return false;
+
+ // create new module
+ _out_rNewModuleCode = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "REM ***** BASIC *****\n\n" ) );
+ if ( _bCreateMain )
+ _out_rNewModuleCode += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Sub Main\n\nEnd Sub\n" ) );
+
+ // insert module into library
+ xLib->insertByName( _rModName, makeAny( _out_rNewModuleCode ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return false;
+ }
+
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::insertModuleOrDialog( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rObjectName, const Any& _rElement ) const
+ {
+ try
+ {
+ Reference< XNameContainer > xLib( getOrCreateLibrary( _eType, _rLibName ), UNO_QUERY_THROW );
+ if ( xLib->hasByName( _rObjectName ) )
+ return false;
+
+ xLib->insertByName( _rObjectName, _rElement );
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::updateModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, const ::rtl::OUString& _rModuleCode ) const
+ {
+ try
+ {
+ Reference< XNameContainer > xLib( getOrCreateLibrary( E_SCRIPTS, _rLibName ), UNO_QUERY_THROW );
+ if ( !xLib->hasByName( _rModName ) )
+ return false;
+ xLib->replaceByName( _rModName, makeAny( _rModuleCode ) );
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::createDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName, Reference< XInputStreamProvider >& _out_rDialogProvider ) const
+ {
+ try
+ {
+ Reference< XNameContainer > xLib( getLibrary( E_DIALOGS, _rLibName, TRUE ), UNO_QUERY_THROW );
+
+ // create dialog
+ _out_rDialogProvider.clear();
+ if ( xLib->hasByName( _rDialogName ) )
+ return false;
+
+ // create new dialog model
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ Reference< XNameContainer > xDialogModel;
+ if ( !aContext.createComponent( "com.sun.star.awt.UnoControlDialogModel", xDialogModel ) )
+ return false;
+
+ // set name property
+ Reference< XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY_THROW );
+ xDlgPSet->setPropertyValue( DLGED_PROP_NAME, makeAny( _rDialogName ) );
+
+ // export dialog model
+ _out_rDialogProvider = ::xmlscript::exportDialogModel( xDialogModel, aContext.getUNOContext(), isDocument() ? getDocument() : Reference< XModel >() );
+
+ // insert dialog into library
+ xLib->insertByName( _rDialogName, makeAny( _out_rDialogProvider ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return _out_rDialogProvider.is();
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument_Impl::setDocumentModified() const
+ {
+ OSL_ENSURE( isValid() && isDocument(), "ScriptDocument_Impl::setDocumentModified: only to be called for real documents!" );
+ if ( isValid() && isDocument() )
+ {
+ try
+ {
+ m_xDocModify->setModified( sal_True );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::isDocumentModified() const
+ {
+ OSL_ENSURE( isValid() && isDocument(), "ScriptDocument_Impl::isDocumentModified: only to be called for real documents!" );
+ bool bIsModified = false;
+ if ( isValid() && isDocument() )
+ {
+ try
+ {
+ bIsModified = m_xDocModify->isModified();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return bIsModified;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::saveDocument( const Reference< XStatusIndicator >& _rxStatusIndicator ) const
+ {
+ Reference< XFrame > xFrame;
+ if ( !getCurrentFrame( xFrame ) )
+ return false;
+
+ Sequence< PropertyValue > aArgs;
+ if ( _rxStatusIndicator.is() )
+ {
+ aArgs.realloc(1);
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusIndicator" ) );
+ aArgs[0].Value <<= _rxStatusIndicator;
+ }
+
+ try
+ {
+ URL aURL;
+ aURL.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Save" ) );
+ aURL.Main = aURL.Complete;
+ aURL.Protocol = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ) );
+ aURL.Path = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Save" ) );
+
+ Reference< XDispatchProvider > xDispProv( xFrame, UNO_QUERY_THROW );
+ Reference< XDispatch > xDispatch(
+ xDispProv->queryDispatch( aURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ), FrameSearchFlag::AUTO ),
+ UNO_SET_THROW );
+
+ xDispatch->dispatch( aURL, aArgs );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return false;
+ }
+
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString ScriptDocument_Impl::getTitle() const
+ {
+ OSL_PRECOND( isValid() && isDocument(), "ScriptDocument_Impl::getTitle: for documents only!" );
+
+ ::rtl::OUString sTitle;
+ if ( isValid() && isDocument() )
+ {
+ sTitle = ::comphelper::DocumentInfo::getDocumentTitle( m_xDocument );
+ }
+ return sTitle;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString ScriptDocument_Impl::getURL() const
+ {
+ OSL_PRECOND( isValid() && isDocument(), "ScriptDocument_Impl::getURL: for documents only!" );
+
+ ::rtl::OUString sURL;
+ if ( isValid() && isDocument() )
+ {
+ try
+ {
+ sURL = m_xDocument->getURL();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return sURL;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::allowMacros() const
+ {
+ OSL_ENSURE( isValid() && isDocument(), "ScriptDocument_Impl::allowMacros: for documents only!" );
+ bool bAllow = false;
+ if ( isValid() && isDocument() )
+ {
+ try
+ {
+ bAllow = m_xScriptAccess->getAllowMacroExecution();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return bAllow;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::getCurrentFrame( Reference< XFrame >& _out_rxFrame ) const
+ {
+ _out_rxFrame.clear();
+ OSL_PRECOND( isValid() && isDocument(), "ScriptDocument_Impl::getCurrentFrame: documents only!" );
+ if ( !isValid() || !isDocument() )
+ return false;
+
+ try
+ {
+ Reference< XModel > xDocument( m_xDocument, UNO_SET_THROW );
+ Reference< XController > xController( xDocument->getCurrentController(), UNO_SET_THROW );
+ _out_rxFrame.set( xController->getFrame(), UNO_SET_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return _out_rxFrame.is();
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument_Impl::isLibraryShared( const ::rtl::OUString& _rLibName, LibraryContainerType _eType )
+ {
+ bool bIsShared = false;
+ try
+ {
+ Reference< XLibraryContainer2 > xLibContainer( getLibraryContainer( _eType ), UNO_QUERY_THROW );
+
+ if ( !xLibContainer->hasByName( _rLibName ) || !xLibContainer->isLibraryLink( _rLibName ) )
+ return false;
+ ::rtl::OUString aFileURL;
+ Reference< XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
+ Reference< XUriReferenceFactory > xUriFac;
+ if ( xMSF.is() )
+ {
+ xUriFac.set(
+ xMSF->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.uri.UriReferenceFactory" ) ) ),
+ UNO_QUERY_THROW );
+ }
+
+ ::rtl::OUString aLinkURL( xLibContainer->getLibraryLinkURL( _rLibName ) );
+ Reference< XUriReference > xUriRef( xUriFac->parse( aLinkURL ), UNO_QUERY_THROW );
+
+ ::rtl::OUString aScheme = xUriRef->getScheme();
+ if ( aScheme.equalsIgnoreAsciiCaseAscii( "file" ) )
+ {
+ aFileURL = aLinkURL;
+ }
+ else if ( aScheme.equalsIgnoreAsciiCaseAscii( "vnd.sun.star.pkg" ) )
+ {
+ ::rtl::OUString aAuthority = xUriRef->getAuthority();
+ if ( aAuthority.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.expand:" ) ) )
+ {
+ ::rtl::OUString aDecodedURL( aAuthority.copy( sizeof ( "vnd.sun.star.expand:" ) - 1 ) );
+ aDecodedURL = ::rtl::Uri::decode( aDecodedURL, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
+ Reference< XComponentContext > xContext;
+ Reference< XPropertySet > xProps( xMSF, UNO_QUERY_THROW );
+ xContext.set( xProps->getPropertyValue( ::rtl::OUString::createFromAscii( "DefaultContext" ) ), UNO_QUERY_THROW );
+ Reference< XMacroExpander > xMacroExpander(
+ xContext->getValueByName(
+ ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ),
+ UNO_QUERY_THROW );
+ aFileURL = xMacroExpander->expandMacros( aDecodedURL );
+ }
+ }
+
+ if ( aFileURL.getLength() )
+ {
+ ::osl::DirectoryItem aFileItem;
+ ::osl::FileStatus aFileStatus( FileStatusMask_FileURL );
+ OSL_VERIFY( ::osl::DirectoryItem::get( aFileURL, aFileItem ) == ::osl::FileBase::E_None );
+ OSL_VERIFY( aFileItem.getFileStatus( aFileStatus ) == ::osl::FileBase::E_None );
+ ::rtl::OUString aCanonicalFileURL( aFileStatus.getFileURL() );
+
+ ::rtl::OUString aSearchURL1( RTL_CONSTASCII_USTRINGPARAM( "share/basic" ) );
+ ::rtl::OUString aSearchURL2( RTL_CONSTASCII_USTRINGPARAM( "share/uno_packages" ) );
+ ::rtl::OUString aSearchURL3( RTL_CONSTASCII_USTRINGPARAM( "share/extensions" ) );
+ if( aCanonicalFileURL.indexOf( aSearchURL1 ) != -1 ||
+ aCanonicalFileURL.indexOf( aSearchURL2 ) != -1 ||
+ aCanonicalFileURL.indexOf( aSearchURL3 ) != -1 )
+ bIsShared = true;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return bIsShared;
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument_Impl::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument_Impl::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument_Impl::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument_Impl::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument_Impl::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument_Impl::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ )
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument_Impl::onDocumentClosed( const ScriptDocument& _rDocument )
+ {
+ DBG_TESTSOLARMUTEX();
+ OSL_PRECOND( isValid(), "ScriptDocument_Impl::onDocumentClosed: should not be listening if I'm not valid!" );
+
+ bool bMyDocument = m_xDocument == _rDocument.getDocument();
+ OSL_PRECOND( bMyDocument, "ScriptDocument_Impl::onDocumentClosed: didn't want to know *this*!" );
+ if ( bMyDocument )
+ {
+ m_bDocumentClosed = true;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument_Impl::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument_Impl::onDocumentModeChanged( const ScriptDocument& /*_rDocument*/ )
+ {
+ // not interested in
+ }
+
+ //====================================================================
+ //= ScriptDocument
+ //====================================================================
+ //--------------------------------------------------------------------
+ ScriptDocument::ScriptDocument()
+ :m_pImpl( new ScriptDocument_Impl() )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ScriptDocument::ScriptDocument( ScriptDocument::SpecialDocument _eType )
+ :m_pImpl( new ScriptDocument_Impl( Reference< XModel >() ) )
+ {
+ OSL_ENSURE( _eType == NoDocument, "ScriptDocument::ScriptDocument: unknown SpecialDocument type!" );
+ (void)_eType;
+ }
+
+ //--------------------------------------------------------------------
+ ScriptDocument::ScriptDocument( const Reference< XModel >& _rxDocument )
+ :m_pImpl( new ScriptDocument_Impl( _rxDocument ) )
+ {
+ OSL_ENSURE( _rxDocument.is(), "ScriptDocument::ScriptDocument: document must not be NULL!" );
+ // a NULL document results in an uninitialized instance, and for this
+ // purpose, there is a dedicated constructor
+ }
+
+ //--------------------------------------------------------------------
+ ScriptDocument::ScriptDocument( const ScriptDocument& _rSource )
+ :m_pImpl( _rSource.m_pImpl )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ScriptDocument::~ScriptDocument()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ const ScriptDocument& ScriptDocument::getApplicationScriptDocument()
+ {
+ static ScriptDocument s_aApplicationScripts;
+ return s_aApplicationScripts;
+ }
+
+ //--------------------------------------------------------------------
+ ScriptDocument ScriptDocument::getDocumentForBasicManager( const BasicManager* _pManager )
+ {
+ if ( _pManager == SFX_APP()->GetBasicManager() )
+ return getApplicationScriptDocument();
+
+ docs::Documents aDocuments;
+ lcl_getAllModels_throw( aDocuments, false );
+
+ for ( docs::Documents::const_iterator doc = aDocuments.begin();
+ doc != aDocuments.end();
+ ++doc
+ )
+ {
+ const BasicManager* pDocBasicManager = ::basic::BasicManagerRepository::getDocumentBasicManager( doc->xModel );
+ if ( ( pDocBasicManager != SFX_APP()->GetBasicManager() )
+ && ( pDocBasicManager == _pManager )
+ )
+ {
+ return ScriptDocument( doc->xModel );
+ }
+ }
+
+ OSL_ENSURE( false, "ScriptDocument::getDocumentForBasicManager: did not find a document for this manager!" );
+ return ScriptDocument( NoDocument );
+ }
+
+ //--------------------------------------------------------------------
+ ScriptDocument ScriptDocument::getDocumentWithURLOrCaption( const ::rtl::OUString& _rUrlOrCaption )
+ {
+ ScriptDocument aDocument( getApplicationScriptDocument() );
+ if ( _rUrlOrCaption.getLength() == 0 )
+ return aDocument;
+
+ docs::Documents aDocuments;
+ lcl_getAllModels_throw( aDocuments, false );
+
+ for ( docs::Documents::const_iterator doc = aDocuments.begin();
+ doc != aDocuments.end();
+ ++doc
+ )
+ {
+ const ScriptDocument aCheck = ScriptDocument( doc->xModel );
+ if ( _rUrlOrCaption == aCheck.getTitle()
+ || _rUrlOrCaption == aCheck.getURL()
+ )
+ {
+ aDocument = aCheck;
+ break;
+ }
+ }
+
+ return aDocument;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ struct DocumentTitleLess : public ::std::binary_function< ScriptDocument, ScriptDocument, bool >
+ {
+ DocumentTitleLess( const CollatorWrapper& _rCollator )
+ :m_aCollator( _rCollator )
+ {
+ }
+
+ bool operator()( const ScriptDocument& _lhs, const ScriptDocument& _rhs ) const
+ {
+ return m_aCollator.compareString( _lhs.getTitle(), _rhs.getTitle() ) < 0;
+ }
+ private:
+ const CollatorWrapper m_aCollator;
+ };
+ }
+
+ //--------------------------------------------------------------------
+ ScriptDocuments ScriptDocument::getAllScriptDocuments( ScriptDocument::ScriptDocumentList _eListType )
+ {
+ ScriptDocuments aScriptDocs;
+
+ // include application?
+ if ( _eListType == AllWithApplication )
+ aScriptDocs.push_back( getApplicationScriptDocument() );
+
+ // obtain documents
+ try
+ {
+ docs::Documents aDocuments;
+ lcl_getAllModels_throw( aDocuments, true /* exclude invisible */ );
+
+ for ( docs::Documents::const_iterator doc = aDocuments.begin();
+ doc != aDocuments.end();
+ ++doc
+ )
+ {
+ // exclude documents without script/library containers
+ ScriptDocument aDoc( doc->xModel );
+ if ( !aDoc.isValid() )
+ continue;
+
+ aScriptDocs.push_back( aDoc );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // sort document list by doc title?
+ if ( _eListType == DocumentsSorted )
+ {
+ CollatorWrapper aCollator( ::comphelper::getProcessServiceFactory() );
+ aCollator.loadDefaultCollator( SvtSysLocale().GetLocaleData().getLocale(), 0 );
+ ::std::sort( aScriptDocs.begin(), aScriptDocs.end(), DocumentTitleLess( aCollator ) );
+ }
+
+ return aScriptDocs;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::operator==( const ScriptDocument& _rhs ) const
+ {
+ return m_pImpl->getDocumentRef() == _rhs.m_pImpl->getDocumentRef();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 ScriptDocument::hashCode() const
+ {
+ return sal::static_int_cast<sal_Int32>(reinterpret_cast< sal_IntPtr >( m_pImpl->getDocumentRef().get() ));
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::isValid() const
+ {
+ return m_pImpl->isValid();
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::isAlive() const
+ {
+ return m_pImpl->isAlive();
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XLibraryContainer > ScriptDocument::getLibraryContainer( LibraryContainerType _eType ) const
+ {
+ return m_pImpl->getLibraryContainer( _eType );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XNameContainer > ScriptDocument::getLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, bool _bLoadLibrary ) const
+ SAL_THROW((NoSuchElementException))
+ {
+ return m_pImpl->getLibrary( _eType, _rLibName, _bLoadLibrary );
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::hasLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const
+ {
+ return m_pImpl->hasLibrary( _eType, _rLibName );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XNameContainer > ScriptDocument::getOrCreateLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const
+ {
+ return m_pImpl->getOrCreateLibrary( _eType, _rLibName );
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument::loadLibraryIfExists( LibraryContainerType _eType, const ::rtl::OUString& _rLibrary )
+ {
+ m_pImpl->loadLibraryIfExists( _eType, _rLibrary );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > ScriptDocument::getObjectNames( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const
+ {
+ Sequence< ::rtl::OUString > aModuleNames;
+
+ try
+ {
+ if ( hasLibrary( _eType, _rLibName ) )
+ {
+ Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, false ) );
+ if ( xLib.is() )
+ aModuleNames = xLib->getElementNames();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // sort
+ ::std::sort( aModuleNames.getArray() , aModuleNames.getArray() + aModuleNames.getLength() , StringCompareLessThan );
+
+ return aModuleNames;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString ScriptDocument::createObjectName( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const
+ {
+ ::rtl::OUString aObjectName;
+
+ ::rtl::OUString aBaseName = _eType == E_SCRIPTS
+ ? ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Module" ) )
+ : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dialog" ) );
+
+ Sequence< ::rtl::OUString > aUsedNames( getObjectNames( _eType, _rLibName ) );
+ ::std::set< ::rtl::OUString > aUsedNamesCheck;
+ ::std::copy( aUsedNames.getConstArray(), aUsedNames.getConstArray() + aUsedNames.getLength(),
+ ::std::insert_iterator< ::std::set< ::rtl::OUString > >( aUsedNamesCheck, aUsedNamesCheck.begin() ) );
+
+ bool bValid = false;
+ USHORT i = 1;
+ while ( !bValid )
+ {
+ aObjectName = aBaseName;
+ aObjectName += String::CreateFromInt32( i );
+
+ if ( aUsedNamesCheck.find( aObjectName ) == aUsedNamesCheck.end() )
+ bValid = TRUE;
+
+ ++i;
+ }
+
+ return aObjectName;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > ScriptDocument::getLibraryNames() const
+ {
+ return BasicIDE::GetMergedLibraryNames( getLibraryContainer( E_SCRIPTS ), getLibraryContainer( E_DIALOGS ) );
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::isReadOnly() const
+ {
+ return m_pImpl->isReadOnly();
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::isApplication() const
+ {
+ return m_pImpl->isApplication();
+ }
+
+ bool ScriptDocument::isInVBAMode() const
+ {
+ return m_pImpl->isInVBAMode();
+ }
+
+ //--------------------------------------------------------------------
+ BasicManager* ScriptDocument::getBasicManager() const
+ {
+ return m_pImpl->getBasicManager();
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XModel > ScriptDocument::getDocument() const
+ {
+ return m_pImpl->getDocument();
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XModel > ScriptDocument::getDocumentOrNull() const
+ {
+ if ( isDocument() )
+ return m_pImpl->getDocument();
+ return NULL;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::removeModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModuleName ) const
+ {
+ return m_pImpl->removeModuleOrDialog( E_SCRIPTS, _rLibName, _rModuleName );
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::hasModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModuleName ) const
+ {
+ return m_pImpl->hasModuleOrDialog( E_SCRIPTS, _rLibName, _rModuleName );
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::getModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, ::rtl::OUString& _out_rModuleSource ) const
+ {
+ Any aCode;
+ if ( !m_pImpl->getModuleOrDialog( E_SCRIPTS, _rLibName, _rModName, aCode ) )
+ return false;
+ OSL_VERIFY( aCode >>= _out_rModuleSource );
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::renameModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rOldName, const ::rtl::OUString& _rNewName ) const
+ {
+ return m_pImpl->renameModuleOrDialog( E_SCRIPTS, _rLibName, _rOldName, _rNewName, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::createModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, bool _bCreateMain, ::rtl::OUString& _out_rNewModuleCode ) const
+ {
+ if ( !m_pImpl->createModule( _rLibName, _rModName, _bCreateMain, _out_rNewModuleCode ) )
+ return false;
+
+ // doc shell modified
+ BasicIDE::MarkDocumentModified( *const_cast< ScriptDocument* >( this ) ); // here?
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::insertModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, const ::rtl::OUString& _rModuleCode ) const
+ {
+ return m_pImpl->insertModuleOrDialog( E_SCRIPTS, _rLibName, _rModName, makeAny( _rModuleCode ) );
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::updateModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, const ::rtl::OUString& _rModuleCode ) const
+ {
+ return m_pImpl->updateModule( _rLibName, _rModName, _rModuleCode );
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::removeDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName ) const
+ {
+ return m_pImpl->removeModuleOrDialog( E_DIALOGS, _rLibName, _rDialogName );
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::hasDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName ) const
+ {
+ return m_pImpl->hasModuleOrDialog( E_DIALOGS, _rLibName, _rDialogName );
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::getDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName, Reference< XInputStreamProvider >& _out_rDialogProvider ) const
+ {
+ Any aCode;
+ if ( !m_pImpl->getModuleOrDialog( E_DIALOGS, _rLibName, _rDialogName, aCode ) )
+ return false;
+ OSL_VERIFY( aCode >>= _out_rDialogProvider );
+ return _out_rDialogProvider.is();
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::renameDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rOldName, const ::rtl::OUString& _rNewName, const Reference< XNameContainer >& _rxExistingDialogModel ) const
+ {
+ return m_pImpl->renameModuleOrDialog( E_DIALOGS, _rLibName, _rOldName, _rNewName, _rxExistingDialogModel );
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::createDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName, Reference< XInputStreamProvider >& _out_rDialogProvider ) const
+ {
+ if ( !m_pImpl->createDialog( _rLibName, _rDialogName, _out_rDialogProvider ) )
+ return false;
+
+ BasicIDE::MarkDocumentModified( *const_cast< ScriptDocument* >( this ) ); // here?
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::insertDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName, const Reference< XInputStreamProvider >& _rxDialogProvider ) const
+ {
+ return m_pImpl->insertModuleOrDialog( E_DIALOGS, _rLibName, _rDialogName, makeAny( _rxDialogProvider ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ScriptDocument::setDocumentModified() const
+ {
+ m_pImpl->setDocumentModified();
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::isDocumentModified() const
+ {
+ return m_pImpl->isDocumentModified();
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::saveDocument( const Reference< XStatusIndicator >& _rxStatusIndicator ) const
+ {
+ return m_pImpl->saveDocument( _rxStatusIndicator );
+ }
+
+ //--------------------------------------------------------------------
+ LibraryLocation ScriptDocument::getLibraryLocation( const ::rtl::OUString& _rLibName ) const
+ {
+ LibraryLocation eLocation = LIBRARY_LOCATION_UNKNOWN;
+ if ( _rLibName.getLength() )
+ {
+ if ( isDocument() )
+ {
+ eLocation = LIBRARY_LOCATION_DOCUMENT;
+ }
+ else
+ {
+ if ( ( hasLibrary( E_SCRIPTS, _rLibName ) && !m_pImpl->isLibraryShared( _rLibName, E_SCRIPTS ) )
+ || ( hasLibrary( E_DIALOGS, _rLibName ) && !m_pImpl->isLibraryShared( _rLibName, E_DIALOGS ) )
+ )
+ {
+ eLocation = LIBRARY_LOCATION_USER;
+ }
+ else
+ {
+ eLocation = LIBRARY_LOCATION_SHARE;
+ }
+ }
+ }
+
+ return eLocation;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString ScriptDocument::getTitle( LibraryLocation _eLocation, LibraryType _eType ) const
+ {
+ ::rtl::OUString aTitle;
+
+ switch ( _eLocation )
+ {
+ case LIBRARY_LOCATION_USER:
+ {
+ switch ( _eType )
+ {
+ case LIBRARY_TYPE_MODULE: aTitle = String( IDEResId( RID_STR_USERMACROS ) ); break;
+ case LIBRARY_TYPE_DIALOG: aTitle = String( IDEResId( RID_STR_USERDIALOGS ) ); break;
+ case LIBRARY_TYPE_ALL: aTitle = String( IDEResId( RID_STR_USERMACROSDIALOGS ) ); break;
+ default:
+ break;
+ }
+ break;
+ case LIBRARY_LOCATION_SHARE:
+ {
+ switch ( _eType )
+ {
+ case LIBRARY_TYPE_MODULE: aTitle = String( IDEResId( RID_STR_SHAREMACROS ) ); break;
+ case LIBRARY_TYPE_DIALOG: aTitle = String( IDEResId( RID_STR_SHAREDIALOGS ) ); break;
+ case LIBRARY_TYPE_ALL: aTitle = String( IDEResId( RID_STR_SHAREMACROSDIALOGS ) ); break;
+ default:
+ break;
+ }
+ }
+ break;
+ case LIBRARY_LOCATION_DOCUMENT:
+ aTitle = getTitle();
+ break;
+ default:
+ break;
+ }
+ }
+
+ return aTitle;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString ScriptDocument::getTitle() const
+ {
+ return m_pImpl->getTitle();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString ScriptDocument::getURL() const
+ {
+ return m_pImpl->getURL();
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::isActive() const
+ {
+ bool bIsActive( false );
+ try
+ {
+ Reference< XFrame > xFrame;
+ if ( m_pImpl->getCurrentFrame( xFrame ) )
+ bIsActive = xFrame->isActive();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bIsActive;
+ }
+
+ //--------------------------------------------------------------------
+ bool ScriptDocument::allowMacros() const
+ {
+ return m_pImpl->allowMacros();
+ }
+
+//........................................................................
+} // namespace basctl
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/tbxctl.cxx b/basctl/source/basicide/tbxctl.cxx
new file mode 100644
index 000000000000..3f3968524245
--- /dev/null
+++ b/basctl/source/basicide/tbxctl.cxx
@@ -0,0 +1,243 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include <ide_pch.hxx>
+
+
+#define _BASIDE_POPUPWINDOWTBX
+#include <tbxctl.hxx>
+#include <svx/svxids.hrc>
+#include <iderid.hxx>
+#include <tbxctl.hrc>
+#include <idetemp.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <svl/aeitem.hxx>
+#include <vcl/toolbox.hxx>
+
+using namespace ::com::sun::star::uno;
+
+
+static ::rtl::OUString aSubToolBarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertcontrolsbar" ) );
+
+SFX_IMPL_TOOLBOX_CONTROL( TbxControls, SfxAllEnumItem )
+
+/*************************************************************************
+|*
+|* WorkWindow Alignment
+|*
+\************************************************************************/
+/*
+IMPL_LINK( PopupWindowTbx, SelectHdl, void*, EMPTYARG )
+{
+ if ( IsInPopupMode() )
+ EndPopupMode();
+
+ aSelectLink.Call( &aTbx.GetToolBox() );
+
+ return 0;
+}
+
+PopupWindowTbx::PopupWindowTbx( USHORT nId, WindowAlign eAlign,
+ ResId aRIdWin, ResId aRIdTbx,
+ SfxBindings& rBind ) :
+ SfxPopupWindow ( nId, aRIdWin, rBind ),
+ aTbx ( this, GetBindings(), aRIdTbx )
+{
+ FreeResource();
+ aTbx.Initialize();
+
+ ToolBox& rBox = aTbx.GetToolBox();
+ rBox.SetAlign( eAlign );
+ if( eAlign == WINDOWALIGN_LEFT )
+ SetText( String() );
+
+ Size aSize = aTbx.CalcWindowSizePixel();
+ rBox.SetSizePixel( aSize );
+ SetOutputSizePixel( aSize );
+ aSelectLink = rBox.GetSelectHdl();
+ rBox.SetSelectHdl( LINK( this, PopupWindowTbx, SelectHdl ) );
+}
+
+SfxPopupWindow* PopupWindowTbx::Clone() const
+{
+ return new PopupWindowTbx( GetId(), aTbx.GetAlign(),
+ IDEResId( RID_TBXCONTROLS ),
+ IDEResId( RID_TOOLBOX ),
+ (SfxBindings&) GetBindings() );
+}
+
+void PopupWindowTbx::PopupModeEnd()
+{
+ aTbx.GetToolBox().EndSelection();
+ SfxPopupWindow::PopupModeEnd();
+}
+
+void PopupWindowTbx::Update()
+{
+ ToolBox *pBox = &aTbx.GetToolBox();
+ aTbx.Activate( pBox );
+ aTbx.Deactivate( pBox );
+}
+
+PopupWindowTbx::~PopupWindowTbx()
+{
+}
+*/
+/*************************************************************************
+|*
+|* Klasse fuer Toolbox
+|*
+\************************************************************************/
+
+TbxControls::TbxControls( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ nLastSlot = USHRT_MAX;
+
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+ rTbx.Invalidate();
+}
+
+/*************************************************************************
+|*
+|* Wenn man ein PopupWindow erzeugen will
+|*
+\************************************************************************/
+SfxPopupWindowType TbxControls::GetPopupWindowType() const
+{
+ if( nLastSlot == USHRT_MAX )
+ return(SFX_POPUPWINDOW_ONCLICK);
+ return(SFX_POPUPWINDOW_ONTIMEOUT);
+}
+
+void TbxControls::StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ if( pState )
+ {
+ SfxAllEnumItem* pItem = PTR_CAST(SfxAllEnumItem, pState);
+ if( pItem )
+ {
+ USHORT nLastEnum = pItem->GetValue();
+ USHORT nTemp = 0;
+ switch( nLastEnum )
+ {
+ case SVX_SNAP_PUSHBUTTON: nTemp = SID_INSERT_PUSHBUTTON; break;
+ case SVX_SNAP_CHECKBOX: nTemp = SID_INSERT_CHECKBOX; break;
+ case SVX_SNAP_RADIOBUTTON: nTemp = SID_INSERT_RADIOBUTTON; break;
+ case SVX_SNAP_SPINBUTTON: nTemp = SID_INSERT_SPINBUTTON; break;
+ case SVX_SNAP_FIXEDTEXT: nTemp = SID_INSERT_FIXEDTEXT; break;
+ case SVX_SNAP_GROUPBOX: nTemp = SID_INSERT_GROUPBOX; break;
+ case SVX_SNAP_LISTBOX: nTemp = SID_INSERT_LISTBOX; break;
+ case SVX_SNAP_COMBOBOX: nTemp = SID_INSERT_COMBOBOX; break;
+ case SVX_SNAP_EDIT: nTemp = SID_INSERT_EDIT; break;
+ case SVX_SNAP_HSCROLLBAR: nTemp = SID_INSERT_HSCROLLBAR; break;
+ case SVX_SNAP_VSCROLLBAR: nTemp = SID_INSERT_VSCROLLBAR; break;
+ case SVX_SNAP_PREVIEW: nTemp = SID_INSERT_PREVIEW; break;
+ case SVX_SNAP_URLBUTTON: nTemp = SID_INSERT_URLBUTTON; break;
+ case SVX_SNAP_IMAGECONTROL: nTemp = SID_INSERT_IMAGECONTROL; break;
+ case SVX_SNAP_PROGRESSBAR: nTemp = SID_INSERT_PROGRESSBAR; break;
+ case SVX_SNAP_HFIXEDLINE: nTemp = SID_INSERT_HFIXEDLINE; break;
+ case SVX_SNAP_VFIXEDLINE: nTemp = SID_INSERT_VFIXEDLINE; break;
+ case SVX_SNAP_DATEFIELD: nTemp = SID_INSERT_DATEFIELD; break;
+ case SVX_SNAP_TIMEFIELD: nTemp = SID_INSERT_TIMEFIELD; break;
+ case SVX_SNAP_NUMERICFIELD: nTemp = SID_INSERT_NUMERICFIELD; break;
+ case SVX_SNAP_CURRENCYFIELD: nTemp = SID_INSERT_CURRENCYFIELD; break;
+ case SVX_SNAP_FORMATTEDFIELD: nTemp = SID_INSERT_FORMATTEDFIELD; break;
+ case SVX_SNAP_PATTERNFIELD: nTemp = SID_INSERT_PATTERNFIELD; break;
+ case SVX_SNAP_FILECONTROL: nTemp = SID_INSERT_FILECONTROL; break;
+ case SVX_SNAP_TREECONTROL: nTemp = SID_INSERT_TREECONTROL; break;
+ }
+ if( nTemp )
+ {
+ rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
+ aSlotURL += rtl::OUString::valueOf( sal_Int32( nTemp ));
+ Image aImage = GetImage( m_xFrame,
+ aSlotURL,
+ hasBigImages(),
+ GetToolBox().GetSettings().GetStyleSettings().GetHighContrastMode() );
+ ToolBox& rBox = GetToolBox();
+ rBox.SetItemImage(GetId(), aImage);
+ nLastSlot = nLastEnum;
+ }
+ }
+ }
+ SfxToolBoxControl::StateChanged( nSID, eState,pState );
+}
+
+void TbxControls::Select( USHORT nModifier )
+{
+ (void)nModifier;
+ SfxAllEnumItem aItem( SID_CHOOSE_CONTROLS, nLastSlot );
+ SfxViewFrame* pCurFrame = SfxViewFrame::Current();
+ DBG_ASSERT( pCurFrame != NULL, "No current view frame!" );
+ SfxDispatcher* pDispatcher = pCurFrame ? pCurFrame->GetDispatcher() : NULL;
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( SID_CHOOSE_CONTROLS, SFX_CALLMODE_SYNCHRON, &aItem, 0L );
+ }
+}
+
+/*************************************************************************
+|*
+|* Hier wird das Fenster erzeugt
+|* Lage der Toolbox mit GetToolBox() abfragbar
+|* rItemRect sind die Screen-Koordinaten
+|*
+\************************************************************************/
+SfxPopupWindow* TbxControls::CreatePopupWindow()
+{
+ if ( GetSlotId() == SID_CHOOSE_CONTROLS )
+ createAndPositionSubToolBar( aSubToolBarResName );
+
+/*
+ if (GetId() == SID_CHOOSE_CONTROLS)
+ {
+ PopupWindowTbx *pWin =
+ new PopupWindowTbx( GetId(),
+ GetToolBox().IsHorizontal() ?
+ WINDOWALIGN_LEFT : WINDOWALIGN_TOP,
+ IDEResId( RID_TBXCONTROLS ),
+ IDEResId( RID_TOOLBOX ),
+ GetBindings() );
+ pWin->StartPopupMode(&GetToolBox(), TRUE);
+ pWin->Update();
+ pWin->StartSelection();
+ pWin->Show();
+ return(pWin);
+ }
+*/
+ return(0);
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/tbxctl.hrc b/basctl/source/basicide/tbxctl.hrc
new file mode 100644
index 000000000000..2765b5ba8c80
--- /dev/null
+++ b/basctl/source/basicide/tbxctl.hrc
@@ -0,0 +1,30 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <svl/solar.hrc>
+
+#define RID_TBXCONTROLS ( RID_BASICIDE_START + 65 )
+#define RID_TOOLBOX ( RID_BASICIDE_START + 66 )
diff --git a/basctl/source/basicide/tbxctl.hxx b/basctl/source/basicide/tbxctl.hxx
new file mode 100644
index 000000000000..6a1461c78640
--- /dev/null
+++ b/basctl/source/basicide/tbxctl.hxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BASIDE_TBXCTL_HXX
+#define _BASIDE_TBXCTL_HXX
+
+#include <sfx2/tbxctrl.hxx>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+
+/*
+#ifdef _BASIDE_POPUPWINDOWTBX
+
+// class PopupWindowTbx --------------------------------------------------
+
+class PopupWindowTbx : public SfxPopupWindow
+{
+private:
+ SfxToolBoxManager aTbx;
+ Link aSelectLink;
+
+ DECL_LINK( SelectHdl, void* );
+
+public:
+ PopupWindowTbx( USHORT nId, WindowAlign eAlign,
+ ResId aRIdWin, ResId aRIdTbx, SfxBindings& rBind );
+ ~PopupWindowTbx();
+
+ void StartSelection()
+ { aTbx.GetToolBox().StartSelection(); }
+ void Update();
+
+ virtual SfxPopupWindow* Clone() const;
+ virtual void PopupModeEnd();
+};
+#endif
+*/
+//-------------------
+// class TbxControls
+//-------------------
+class TbxControls : public SfxToolBoxControl
+{
+private:
+
+ struct StateChangedInfo
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
+ bool bDisabled;
+ };
+
+ USHORT nLastSlot;
+
+protected:
+ virtual void StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState );
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ TbxControls(USHORT nSlotId, USHORT nId, ToolBox& rTbx );
+ ~TbxControls() {}
+
+ virtual SfxPopupWindowType GetPopupWindowType() const;
+ virtual SfxPopupWindow* CreatePopupWindow();
+
+ using SfxToolBoxControl::Select;
+ void Select( USHORT nModifier );
+};
+
+
+#endif // _BASIDE_TBXCTL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/tbxctl.src b/basctl/source/basicide/tbxctl.src
new file mode 100644
index 000000000000..89d839619238
--- /dev/null
+++ b/basctl/source/basicide/tbxctl.src
@@ -0,0 +1,273 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "svx/svxids.hrc"
+#include "tbxctl.hrc"
+#include "helpid.hrc"
+FloatingWindow RID_TBXCONTROLS
+{
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ HelpId = HID_BASICIDE_CONTROLS ;
+ Text [ en-US ] = "Controls" ;
+ String RID_TOOLBOX
+ {
+ Text [ en-US ] = "Controls" ;
+ };
+};
+ToolBox RID_TOOLBOX
+{
+ SVLook = TRUE ;
+ // HelpId = HID_BASICIDE_CONTROLS ;
+ LineCount = 2 ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_PUSHBUTTON ;
+ Identifier = SID_INSERT_PUSHBUTTON ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Button" ;
+ /* ### ACHTUNG: Neuer Text in Resource? CommandButton einfügen : CommandButton einf³gen */
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_CHECKBOX ;
+ Identifier = SID_INSERT_CHECKBOX ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Check Box" ;
+ /* ### ACHTUNG: Neuer Text in Resource? CheckBox einfügen : CheckBox einf³gen */
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_FIXEDTEXT ;
+ Identifier = SID_INSERT_FIXEDTEXT ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Label field" ;
+ /* ### ACHTUNG: Neuer Text in Resource? Label einfügen : Label einf³gen */
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_LISTBOX ;
+ Identifier = SID_INSERT_LISTBOX ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "List Box" ;
+ /* ### ACHTUNG: Neuer Text in Resource? ListBox einfügen : ListBox einf³gen */
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_HSCROLLBAR ;
+ Identifier = SID_INSERT_HSCROLLBAR ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Horizontal Scroll Bar" ;
+ /* ### ACHTUNG: Neuer Text in Resource? Horizontale ScrollBar einfügen : Horizontale ScrollBar einf³gen */
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_GROUPBOX ;
+ Identifier = SID_INSERT_GROUPBOX ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Group Box" ;
+ /* ### ACHTUNG: Neuer Text in Resource? GroupBox einfügen : GroupBox einf³gen */
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_HFIXEDLINE ;
+ Identifier = SID_INSERT_HFIXEDLINE ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Horizontal Line" ;
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_DATEFIELD ;
+ Identifier = SID_INSERT_DATEFIELD ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Date Field";
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_NUMERICFIELD ;
+ Identifier = SID_INSERT_NUMERICFIELD ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Numeric Field";
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_FORMATTEDFIELD ;
+ Identifier = SID_INSERT_FORMATTEDFIELD ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Formatted Field";
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_FILECONTROL ;
+ Identifier = SID_INSERT_FILECONTROL ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "File Selection";
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_TREECONTROL ;
+ Identifier = SID_INSERT_TREECONTROL ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Tree Control";
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ ToolBoxItem
+ {
+ HelpId = SID_SHOW_PROPERTYBROWSER ;
+ Identifier = SID_SHOW_PROPERTYBROWSER ;
+ Text [ en-US ] = "Properties" ;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_BREAK ; };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_IMAGECONTROL ;
+ Identifier = SID_INSERT_IMAGECONTROL ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Image Control" ;
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_RADIOBUTTON ;
+ Identifier = SID_INSERT_RADIOBUTTON ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Option Button" ;
+ /* ### ACHTUNG: Neuer Text in Resource? RadioButton einfügen : RadioButton einf³gen */
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_EDIT ;
+ Identifier = SID_INSERT_EDIT ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Text Box" ;
+ /* ### ACHTUNG: Neuer Text in Resource? Edit einfügen : Edit einf³gen */
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_COMBOBOX ;
+ Identifier = SID_INSERT_COMBOBOX ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Combo Box" ;
+ /* ### ACHTUNG: Neuer Text in Resource? ComboBox einfügen : ComboBox einf³gen */
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_VSCROLLBAR ;
+ Identifier = SID_INSERT_VSCROLLBAR ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Vertical Scroll Bar" ;
+ /* ### ACHTUNG: Neuer Text in Resource? Vertikale ScrollBar einfügen : Vertikale ScrollBar einf³gen */
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_PROGRESSBAR ;
+ Identifier = SID_INSERT_PROGRESSBAR ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Progress Bar" ;
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_VFIXEDLINE ;
+ Identifier = SID_INSERT_VFIXEDLINE ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Vertical Line" ;
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_TIMEFIELD ;
+ Identifier = SID_INSERT_TIMEFIELD ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Time Field";
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_CURRENCYFIELD ;
+ Identifier = SID_INSERT_CURRENCYFIELD ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Currency Field";
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_PATTERNFIELD ;
+ Identifier = SID_INSERT_PATTERNFIELD ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Pattern Field";
+ };
+ ToolBoxItem
+ {
+ HelpId = SID_INSERT_SELECT ;
+ Identifier = SID_INSERT_SELECT ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Select" ;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ ToolBoxItem
+ {
+ HelpId = SID_DIALOG_TESTMODE ;
+ Identifier = SID_DIALOG_TESTMODE ;
+ Text [ en-US ] = "Activate Test Mode" ;
+ };
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/basctl/source/basicide/unomodel.cxx b/basctl/source/basicide/unomodel.cxx
new file mode 100644
index 000000000000..ab61423b9314
--- /dev/null
+++ b/basctl/source/basicide/unomodel.cxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include "unomodel.hxx"
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+#include <sfx2/docfac.hxx>
+#include <sfx2/objsh.hxx>
+
+#include <iderdll.hxx>
+#include <basdoc.hxx>
+
+using ::rtl::OUString;
+using namespace ::cppu;
+using namespace ::std;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+SIDEModel::SIDEModel( SfxObjectShell *pObjSh )
+: SfxBaseModel(pObjSh)
+{
+}
+
+SIDEModel::~SIDEModel()
+{
+}
+
+uno::Any SAL_CALL SIDEModel::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
+{
+ uno::Any aRet = ::cppu::queryInterface ( rType,
+ // OWeakObject interfaces
+ static_cast< XInterface* >( static_cast< OWeakObject* >( this ) ),
+ static_cast< XWeak* > ( this ),
+ static_cast< XServiceInfo* > ( this ) );
+ if (!aRet.hasValue())
+ aRet = SfxBaseModel::queryInterface ( rType );
+ return aRet;
+}
+
+void SAL_CALL SIDEModel::acquire() throw()
+{
+ SolarMutexGuard aGuard;
+ OWeakObject::acquire();
+}
+
+void SAL_CALL SIDEModel::release() throw()
+{
+ SolarMutexGuard aGuard;
+ OWeakObject::release();
+}
+
+uno::Sequence< uno::Type > SAL_CALL SIDEModel::getTypes( ) throw(uno::RuntimeException)
+{
+ uno::Sequence< uno::Type > aTypes = SfxBaseModel::getTypes();
+ sal_Int32 nLen = aTypes.getLength();
+ aTypes.realloc(nLen + 1);
+ uno::Type* pTypes = aTypes.getArray();
+ pTypes[nLen++] = ::getCppuType((Reference<XServiceInfo>*)0);
+
+ return aTypes;
+}
+
+OUString SIDEModel::getImplementationName(void) throw( uno::RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+::rtl::OUString SIDEModel::getImplementationName_Static()
+{
+ return rtl::OUString::createFromAscii("com.sun.star.comp.basic.BasicIDE");
+}
+
+sal_Bool SIDEModel::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
+{
+ return rServiceName == ::rtl::OUString::createFromAscii("com.sun.star.script.BasicIDE");
+}
+uno::Sequence< OUString > SIDEModel::getSupportedServiceNames(void) throw( uno::RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+uno::Sequence< OUString > SIDEModel::getSupportedServiceNames_Static(void)
+{
+ uno::Sequence< OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = ::rtl::OUString::createFromAscii("com.sun.star.script.BasicIDE");
+ return aRet;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SIDEModel_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & ) throw( uno::Exception )
+{
+ SolarMutexGuard aGuard;
+ BasicIDEDLL::Init();
+ SfxObjectShell* pShell = new BasicDocShell();
+ return uno::Reference< uno::XInterface >( pShell->GetModel() );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/unomodel.hxx b/basctl/source/basicide/unomodel.hxx
new file mode 100644
index 000000000000..bb2b55889f0e
--- /dev/null
+++ b/basctl/source/basicide/unomodel.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef UNOMODEL_HXX
+#define UNOMODEL_HXX
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <sfx2/sfxbasemodel.hxx>
+
+//-----------------------------------------------------------------------------
+class SIDEModel : public SfxBaseModel,
+ public com::sun::star::lang::XServiceInfo
+{
+public:
+ SIDEModel( SfxObjectShell *pObjSh = 0 );
+ virtual ~SIDEModel();
+
+ //XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire( ) throw();
+ virtual void SAL_CALL release( ) throw();
+
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ //XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName(void)
+ throw( ::com::sun::star::uno::RuntimeException );
+ virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName)
+ throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void)
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ static ::com::sun::star::uno::Sequence< rtl::OUString > getSupportedServiceNames_Static();
+ static ::rtl::OUString getImplementationName_Static();
+};
+
+com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL SIDEModel_createInstance(
+ const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr )
+ throw( com::sun::star::uno::Exception );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
new file mode 100644
index 000000000000..324d7d829153
--- /dev/null
+++ b/basctl/source/dlged/dlged.cxx
@@ -0,0 +1,1425 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+#include "dlged.hxx"
+#include "dlgedfunc.hxx"
+#include "dlgedfac.hxx"
+#include <dlgedmod.hxx>
+#include "dlgedpage.hxx"
+#include "dlgedview.hxx"
+#include "dlgedobj.hxx"
+#include "dlgedclip.hxx"
+#include <dlgeddef.hxx>
+#include "propbrw.hxx"
+#include <localizationmgr.hxx>
+
+#include <basidesh.hxx>
+#include <iderdll.hxx>
+#include <vcl/scrbar.hxx>
+#include <tools/shl.hxx>
+#include <svl/itempool.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include <svx/svxids.hrc>
+#include <svx/svdpagv.hxx>
+#include <xmlscript/xml_helper.hxx>
+#include <xmlscript/xmldlg_imexp.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/awt/XDialog.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+#include <com/sun/star/resource/XStringResourcePersistence.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/types.hxx>
+#include <vcl/svapp.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+// #i74769#
+#include <svx/sdrpaintwindow.hxx>
+
+using namespace comphelper;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::io;
+using ::rtl::OUString;
+
+static ::rtl::OUString aResourceResolverPropName =
+ ::rtl::OUString::createFromAscii( "ResourceResolver" );
+static ::rtl::OUString aDecorationPropName =
+ ::rtl::OUString::createFromAscii( "Decoration" );
+static ::rtl::OUString aTitlePropName =
+ ::rtl::OUString::createFromAscii( "Title" );
+
+
+//============================================================================
+// DlgEdHint
+//============================================================================
+
+TYPEINIT1( DlgEdHint, SfxHint );
+
+//----------------------------------------------------------------------------
+
+DlgEdHint::DlgEdHint( DlgEdHintKind eHint )
+ :eHintKind( eHint )
+{
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdHint::DlgEdHint( DlgEdHintKind eHint, DlgEdObj* pObj )
+ :eHintKind( eHint )
+ ,pDlgEdObj( pObj )
+{
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdHint::~DlgEdHint()
+{
+}
+
+
+//============================================================================
+// DlgEditor
+//============================================================================
+
+void DlgEditor::ShowDialog()
+{
+ uno::Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
+
+ // create a dialog
+ uno::Reference< awt::XControl > xDlg( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialog" ) ) ), uno::UNO_QUERY );
+
+ // clone the dialog model
+ uno::Reference< util::XCloneable > xC( m_xUnoControlDialogModel, uno::UNO_QUERY );
+ uno::Reference< util::XCloneable > xNew = xC->createClone();
+ uno::Reference< awt::XControlModel > xDlgMod( xNew, uno::UNO_QUERY );
+
+ uno::Reference< beans::XPropertySet > xSrcDlgModPropSet( m_xUnoControlDialogModel, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xNewDlgModPropSet( xDlgMod, uno::UNO_QUERY );
+ if( xNewDlgModPropSet.is() )
+ {
+ if( xSrcDlgModPropSet.is() )
+ {
+ try
+ {
+ Any aResourceResolver = xSrcDlgModPropSet->getPropertyValue( aResourceResolverPropName );
+ xNewDlgModPropSet->setPropertyValue( aResourceResolverPropName, aResourceResolver );
+ }
+ catch( UnknownPropertyException& )
+ {
+ DBG_ERROR( "DlgEditor::ShowDialog(): No ResourceResolver property" );
+ }
+ }
+
+ // Disable decoration
+ bool bDecoration = true;
+ try
+ {
+ Any aDecorationAny = xSrcDlgModPropSet->getPropertyValue( aDecorationPropName );
+ aDecorationAny >>= bDecoration;
+ if( !bDecoration )
+ {
+ xNewDlgModPropSet->setPropertyValue( aDecorationPropName, makeAny( true ) );
+ xNewDlgModPropSet->setPropertyValue( aTitlePropName, makeAny( ::rtl::OUString() ) );
+ }
+ }
+ catch( UnknownPropertyException& )
+ {}
+ }
+
+ // set the model
+ xDlg->setModel( xDlgMod );
+
+ // create a peer
+ uno::Reference< awt::XToolkit> xToolkit( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.ExtToolkit" ) ) ), uno::UNO_QUERY );
+ xDlg->createPeer( xToolkit, pWindow->GetComponentInterface() );
+
+ uno::Reference< awt::XDialog > xD( xDlg, uno::UNO_QUERY );
+ xD->execute();
+
+ uno::Reference< lang::XComponent > xComponent(xDlg, uno::UNO_QUERY);
+ if (xComponent.is())
+ xComponent->dispose();
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEditor::UnmarkDialog()
+{
+ SdrObject* pDlgObj = pDlgEdModel->GetPage(0)->GetObj(0);
+ SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
+
+ BOOL bWasMarked = pDlgEdView->IsObjMarked( pDlgObj );
+
+ if( bWasMarked )
+ pDlgEdView->MarkObj( pDlgObj, pPgView, TRUE );
+
+ return bWasMarked;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEditor::RemarkDialog()
+{
+ SdrObject* pDlgObj = pDlgEdModel->GetPage(0)->GetObj(0);
+ SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
+
+ BOOL bWasMarked = pDlgEdView->IsObjMarked( pDlgObj );
+
+ if( !bWasMarked )
+ pDlgEdView->MarkObj( pDlgObj, pPgView, FALSE );
+
+ return bWasMarked;
+}
+
+//----------------------------------------------------------------------------
+
+DlgEditor::DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel )
+ :pHScroll(NULL)
+ ,pVScroll(NULL)
+ ,pDlgEdModel(NULL)
+ ,pDlgEdPage(NULL)
+ ,pDlgEdView(NULL)
+ ,pDlgEdForm(NULL)
+ ,m_xUnoControlDialogModel(NULL)
+ ,m_ClipboardDataFlavors(1)
+ ,m_ClipboardDataFlavorsResource(2)
+ ,pObjFac(NULL)
+ ,pWindow(NULL)
+ ,pFunc(NULL)
+ ,eMode( DLGED_SELECT )
+ ,eActObj( OBJ_DLG_PUSHBUTTON )
+ ,bFirstDraw(FALSE)
+ ,aGridSize( 100, 100 ) // 100TH_MM
+ ,bGridVisible(FALSE)
+ ,bGridSnap(TRUE)
+ ,bCreateOK(TRUE)
+ ,bDialogModelChanged(FALSE)
+ ,mnPaintGuard(0)
+ ,m_xDocument( xModel )
+{
+ pDlgEdModel = new DlgEdModel();
+ pDlgEdModel->GetItemPool().FreezeIdRanges();
+ pDlgEdModel->SetScaleUnit( MAP_100TH_MM );
+
+ SdrLayerAdmin& rAdmin = pDlgEdModel->GetLayerAdmin();
+ rAdmin.NewLayer( rAdmin.GetControlLayerName() );
+ rAdmin.NewLayer( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "HiddenLayer" ) ) );
+
+ pDlgEdPage = new DlgEdPage( *pDlgEdModel );
+ pDlgEdModel->InsertPage( pDlgEdPage );
+
+ pObjFac = new DlgEdFactory();
+
+ pFunc = new DlgEdFuncSelect( this );
+
+ // set clipboard data flavors
+ m_ClipboardDataFlavors[0].MimeType = ::rtl::OUString::createFromAscii("application/vnd.sun.xml.dialog");
+ m_ClipboardDataFlavors[0].HumanPresentableName = ::rtl::OUString::createFromAscii("Dialog 6.0");
+ m_ClipboardDataFlavors[0].DataType = ::getCppuType( (const Sequence< sal_Int8 >*) 0 );
+
+ m_ClipboardDataFlavorsResource[0] = m_ClipboardDataFlavors[0];
+ m_ClipboardDataFlavorsResource[1].MimeType = ::rtl::OUString::createFromAscii("application/vnd.sun.xml.dialogwithresource");
+ m_ClipboardDataFlavorsResource[1].HumanPresentableName = ::rtl::OUString::createFromAscii("Dialog 8.0");
+ m_ClipboardDataFlavorsResource[1].DataType = ::getCppuType( (const Sequence< sal_Int8 >*) 0 );
+
+ aPaintTimer.SetTimeout( 1 );
+ aPaintTimer.SetTimeoutHdl( LINK( this, DlgEditor, PaintTimeout ) );
+
+ aMarkTimer.SetTimeout( 100 );
+ aMarkTimer.SetTimeoutHdl( LINK( this, DlgEditor, MarkTimeout ) );
+}
+
+//----------------------------------------------------------------------------
+
+DlgEditor::~DlgEditor()
+{
+ aPaintTimer.Stop();
+ aMarkTimer.Stop();
+
+ ::comphelper::disposeComponent( m_xControlContainer );
+
+ delete pObjFac;
+ delete pFunc;
+ delete pDlgEdView;
+ delete pDlgEdModel;
+}
+
+//----------------------------------------------------------------------------
+
+Reference< awt::XControlContainer > DlgEditor::GetWindowControlContainer()
+{
+ if ( !m_xControlContainer.is() && pWindow )
+ m_xControlContainer = VCLUnoHelper::CreateControlContainer( pWindow );
+ return m_xControlContainer;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::SetWindow( Window* pWindow_ )
+{
+ DlgEditor::pWindow = pWindow_;
+ pWindow_->SetMapMode( MapMode( MAP_100TH_MM ) );
+ pDlgEdPage->SetSize( pWindow_->PixelToLogic( Size( DLGED_PAGE_WIDTH_MIN, DLGED_PAGE_HEIGHT_MIN ) ) );
+
+ pDlgEdView = new DlgEdView( pDlgEdModel, pWindow_, this );
+ pDlgEdView->ShowSdrPage(pDlgEdView->GetModel()->GetPage(0));
+ pDlgEdView->SetLayerVisible( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "HiddenLayer" ) ), FALSE );
+ pDlgEdView->SetMoveSnapOnlyTopLeft( TRUE );
+ pDlgEdView->SetWorkArea( Rectangle( Point( 0, 0 ), pDlgEdPage->GetSize() ) );
+
+ pDlgEdView->SetGridCoarse( aGridSize );
+ pDlgEdView->SetSnapGridWidth(Fraction(aGridSize.Width(), 1), Fraction(aGridSize.Height(), 1));
+ pDlgEdView->SetGridSnap( bGridSnap );
+ pDlgEdView->SetGridVisible( bGridVisible );
+ pDlgEdView->SetDragStripes( FALSE );
+
+ pDlgEdView->SetDesignMode( TRUE );
+
+ ::comphelper::disposeComponent( m_xControlContainer );
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::SetScrollBars( ScrollBar* pHS, ScrollBar* pVS )
+{
+ pHScroll = pHS;
+ pVScroll = pVS;
+
+ InitScrollBars();
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::InitScrollBars()
+{
+ DBG_ASSERT( pHScroll, "DlgEditor::InitScrollBars: no horizontal scroll bar!" );
+ DBG_ASSERT( pVScroll, "DlgEditor::InitScrollBars: no vertical scroll bar!" );
+ if ( !pHScroll || !pVScroll )
+ return;
+
+ Size aOutSize = pWindow->GetOutputSize();
+ Size aPgSize = pDlgEdPage->GetSize();
+
+ pHScroll->SetRange( Range( 0, aPgSize.Width() ));
+ pVScroll->SetRange( Range( 0, aPgSize.Height() ));
+ pHScroll->SetVisibleSize( (ULONG)aOutSize.Width() );
+ pVScroll->SetVisibleSize( (ULONG)aOutSize.Height() );
+
+ pHScroll->SetLineSize( aOutSize.Width() / 10 );
+ pVScroll->SetLineSize( aOutSize.Height() / 10 );
+ pHScroll->SetPageSize( aOutSize.Width() / 2 );
+ pVScroll->SetPageSize( aOutSize.Height() / 2 );
+
+ DoScroll( pHScroll );
+ DoScroll( pVScroll );
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::DoScroll( ScrollBar* )
+{
+ if( !pHScroll || !pVScroll )
+ return;
+
+ MapMode aMap = pWindow->GetMapMode();
+ Point aOrg = aMap.GetOrigin();
+
+ Size aScrollPos( pHScroll->GetThumbPos(), pVScroll->GetThumbPos() );
+ aScrollPos = pWindow->LogicToPixel( aScrollPos );
+ aScrollPos = pWindow->PixelToLogic( aScrollPos );
+
+ long nX = aScrollPos.Width() + aOrg.X();
+ long nY = aScrollPos.Height() + aOrg.Y();
+
+ if( !nX && !nY )
+ return;
+
+ pWindow->Update();
+
+ // #i31562#
+ // When scrolling, someone was rescuing the Wallpaper and forced the window scroll to
+ // be done without background refresh. I do not know why, but that causes the repaint
+ // problems. Taking that out.
+ // Wallpaper aOldBackground = pWindow->GetBackground();
+ // pWindow->SetBackground();
+
+ // #i74769# children should be scrolled
+ pWindow->Scroll( -nX, -nY, SCROLL_CHILDREN); // SCROLL_NOCHILDREN );
+ aMap.SetOrigin( Point( -aScrollPos.Width(), -aScrollPos.Height() ) );
+ pWindow->SetMapMode( aMap );
+ pWindow->Update();
+
+ // pWindow->SetBackground( aOldBackground );
+
+ DlgEdHint aHint( DLGED_HINT_WINDOWSCROLLED );
+ Broadcast( aHint );
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::UpdateScrollBars()
+{
+ MapMode aMap = pWindow->GetMapMode();
+ Point aOrg = aMap.GetOrigin();
+
+ if ( pHScroll )
+ pHScroll->SetThumbPos( -aOrg.X() );
+
+ if ( pVScroll )
+ pVScroll->SetThumbPos( -aOrg.Y() );
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::SetDialog( uno::Reference< container::XNameContainer > xUnoControlDialogModel )
+{
+ // set dialog model
+ m_xUnoControlDialogModel = xUnoControlDialogModel;
+
+ // create dialog form
+ pDlgEdForm = new DlgEdForm();
+ uno::Reference< awt::XControlModel > xDlgMod( m_xUnoControlDialogModel , uno::UNO_QUERY );
+ pDlgEdForm->SetUnoControlModel(xDlgMod);
+ pDlgEdForm->SetDlgEditor( this );
+ ((DlgEdPage*)pDlgEdModel->GetPage(0))->SetDlgEdForm( pDlgEdForm );
+ pDlgEdModel->GetPage(0)->InsertObject( pDlgEdForm );
+ AdjustPageSize();
+ pDlgEdForm->SetRectFromProps();
+ pDlgEdForm->UpdateTabIndices(); // for backward compatibility
+ pDlgEdForm->StartListening();
+
+ // create controls
+ Reference< ::com::sun::star::container::XNameAccess > xNameAcc( m_xUnoControlDialogModel, UNO_QUERY );
+ if ( xNameAcc.is() )
+ {
+ // get sequence of control names
+ Sequence< ::rtl::OUString > aNames = xNameAcc->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+
+ // create a map of tab indices and control names, sorted by tab index
+ IndexToNameMap aIndexToNameMap;
+ for ( sal_Int32 i = 0; i < nCtrls; ++i )
+ {
+ // get name
+ ::rtl::OUString aName( pNames[i] );
+
+ // get tab index
+ sal_Int16 nTabIndex = -1;
+ Any aCtrl = xNameAcc->getByName( aName );
+ Reference< ::com::sun::star::beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if ( xPSet.is() )
+ xPSet->getPropertyValue( DLGED_PROP_TABINDEX ) >>= nTabIndex;
+
+ // insert into map
+ aIndexToNameMap.insert( IndexToNameMap::value_type( nTabIndex, aName ) );
+ }
+
+ // create controls and insert them into drawing page
+ for ( IndexToNameMap::iterator aIt = aIndexToNameMap.begin(); aIt != aIndexToNameMap.end(); ++aIt )
+ {
+ Any aCtrl = xNameAcc->getByName( aIt->second );
+ Reference< ::com::sun::star::awt::XControlModel > xCtrlModel;
+ aCtrl >>= xCtrlModel;
+ DlgEdObj* pCtrlObj = new DlgEdObj();
+ pCtrlObj->SetUnoControlModel( xCtrlModel );
+ pCtrlObj->SetDlgEdForm( pDlgEdForm );
+ pDlgEdForm->AddChild( pCtrlObj );
+ pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj );
+ pCtrlObj->SetRectFromProps();
+ pCtrlObj->UpdateStep();
+ pCtrlObj->StartListening();
+ }
+ }
+
+ bFirstDraw = TRUE;
+
+ pDlgEdModel->SetChanged( FALSE );
+}
+
+void DlgEditor::ResetDialog( void )
+{
+ DlgEdForm* pOldDlgEdForm = pDlgEdForm;
+ DlgEdPage* pPage = (DlgEdPage*)pDlgEdModel->GetPage(0);
+ SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
+ BOOL bWasMarked = pDlgEdView->IsObjMarked( pOldDlgEdForm );
+ pDlgEdView->UnmarkAll();
+ pPage->Clear();
+ pPage->SetDlgEdForm( NULL );
+ SetDialog( m_xUnoControlDialogModel );
+ if( bWasMarked )
+ pDlgEdView->MarkObj( pDlgEdForm, pPgView, FALSE );
+}
+
+
+//----------------------------------------------------------------------------
+
+Reference< util::XNumberFormatsSupplier > const & DlgEditor::GetNumberFormatsSupplier()
+{
+ if ( !m_xSupplier.is() )
+ {
+ Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
+ Reference< util::XNumberFormatsSupplier > xSupplier( xMSF->createInstance(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatsSupplier") ) ), UNO_QUERY );
+
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !m_xSupplier.is() )
+ {
+ m_xSupplier = xSupplier;
+ }
+ }
+ return m_xSupplier;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if( pWindow )
+ pWindow->GrabFocus();
+ pFunc->MouseButtonDown( rMEvt );
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ BOOL bRet = pFunc->MouseButtonUp( rMEvt );
+
+ if( (eMode == DLGED_INSERT) )
+ bCreateOK = bRet;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::MouseMove( const MouseEvent& rMEvt )
+{
+ pFunc->MouseMove( rMEvt );
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEditor::KeyInput( const KeyEvent& rKEvt )
+{
+ return pFunc->KeyInput( rKEvt );
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::Paint( const Rectangle& rRect )
+{
+ aPaintRect = rRect;
+ PaintTimeout( &aPaintTimer );
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( DlgEditor, PaintTimeout, Timer *, EMPTYARG )
+{
+ if( !pDlgEdView )
+ return 0;
+
+ mnPaintGuard++;
+
+ Size aMacSize;
+ if( bFirstDraw &&
+ pWindow->IsVisible() &&
+ (pWindow->GetOutputSize() != aMacSize) )
+ {
+ bFirstDraw = FALSE;
+
+ // get property set
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPSet(pDlgEdForm->GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY);
+
+ if ( xPSet.is() )
+ {
+ // get dialog size from properties
+ sal_Int32 nWidth = 0, nHeight = 0;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidth;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeight;
+
+ if ( nWidth == 0 && nHeight == 0 )
+ {
+ Size aSize = pWindow->PixelToLogic( Size( 400, 300 ) );
+
+ // align with grid
+ Size aGridSize_(long(pDlgEdView->GetSnapGridWidthX()), long(pDlgEdView->GetSnapGridWidthY()));
+ aSize.Width() -= aSize.Width() % aGridSize_.Width();
+ aSize.Height() -= aSize.Height() % aGridSize_.Height();
+
+ Point aPos;
+ Size aOutSize = pWindow->GetOutputSize();
+ aPos.X() = (aOutSize.Width()>>1) - (aSize.Width()>>1);
+ aPos.Y() = (aOutSize.Height()>>1) - (aSize.Height()>>1);
+
+ // align with grid
+ aPos.X() -= aPos.X() % aGridSize_.Width();
+ aPos.Y() -= aPos.Y() % aGridSize_.Height();
+
+ // don't put in the corner
+ Point aMinPos = pWindow->PixelToLogic( Point( 30, 20 ) );
+ if( (aPos.X() < aMinPos.X()) || (aPos.Y() < aMinPos.Y()) )
+ {
+ aPos = aMinPos;
+ aPos.X() -= aPos.X() % aGridSize_.Width();
+ aPos.Y() -= aPos.Y() % aGridSize_.Height();
+ }
+
+ // set dialog position and size
+ pDlgEdForm->SetSnapRect( Rectangle( aPos, aSize ) );
+ pDlgEdForm->EndListening(sal_False);
+ pDlgEdForm->SetPropsFromRect();
+ pDlgEdForm->GetDlgEditor()->SetDialogModelChanged(TRUE);
+ pDlgEdForm->StartListening();
+
+ // set position and size of controls
+ ULONG nObjCount;
+ if ( pDlgEdPage && ( ( nObjCount = pDlgEdPage->GetObjCount() ) > 0 ) )
+ {
+ for ( ULONG i = 0 ; i < nObjCount ; i++ )
+ {
+ SdrObject* pObj = pDlgEdPage->GetObj(i);
+ DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj);
+ if ( pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) )
+ pDlgEdObj->SetRectFromProps();
+ }
+ }
+ }
+ }
+ }
+
+ // repaint, get PageView and prepare Region
+ SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
+ const Region aPaintRectRegion(aPaintRect);
+
+
+ // #i74769#
+ SdrPaintWindow* pTargetPaintWindow = 0;
+
+ // mark repaint start
+ if(pPgView)
+ {
+ pTargetPaintWindow = pPgView->GetView().BeginDrawLayers(pWindow, aPaintRectRegion);
+ OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
+ }
+
+ // draw background self using wallpaper
+ // #i79128# ...and use correct OutDev for that
+ if(pTargetPaintWindow)
+ {
+ OutputDevice& rTargetOutDev = pTargetPaintWindow->GetTargetOutputDevice();
+ rTargetOutDev.DrawWallpaper(aPaintRect, Wallpaper(Color(COL_WHITE)));
+ }
+
+ // do paint (unbuffered) and mark repaint end
+ if(pPgView)
+ {
+ // paint of control layer is done in EndDrawLayers anyway...
+ pPgView->GetView().EndDrawLayers(*pTargetPaintWindow, true);
+ }
+
+ mnPaintGuard--;
+
+ DBG_ASSERT(pWindow,"Window not set");
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( DlgEditor, MarkTimeout, Timer *, EMPTYARG )
+{
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow( SID_SHOW_PROPERTYBROWSER ) : NULL;
+ if ( !pChildWin )
+ return 0L;
+
+ ((PropBrw*)(pChildWin->GetWindow()))->Update( pIDEShell );
+
+ return 1;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::SetMode( DlgEdMode eNewMode )
+{
+ if ( eNewMode != eMode )
+ {
+ delete pFunc;
+
+ if ( eNewMode == DLGED_INSERT )
+ pFunc = new DlgEdFuncInsert( this );
+ else
+ pFunc = new DlgEdFuncSelect( this );
+
+ if ( eNewMode == DLGED_READONLY )
+ pDlgEdModel->SetReadOnly( TRUE );
+ else
+ pDlgEdModel->SetReadOnly( FALSE );
+ }
+
+ if ( eNewMode == DLGED_TEST )
+ ShowDialog();
+
+ eMode = eNewMode;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::SetInsertObj( USHORT eObj )
+{
+ eActObj = eObj;
+
+ if( pDlgEdView )
+ pDlgEdView->SetCurrentObj( eActObj, DlgInventor );
+}
+
+//----------------------------------------------------------------------------
+
+USHORT DlgEditor::GetInsertObj() const
+{
+ return eActObj;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::CreateDefaultObject()
+{
+ // create object by factory
+ SdrObject* pObj = SdrObjFactory::MakeNewObject( pDlgEdView->GetCurrentObjInventor(), pDlgEdView->GetCurrentObjIdentifier(), pDlgEdPage );
+
+ DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
+ if ( pDlgEdObj )
+ {
+ // set position and size
+ Size aSize = pWindow->PixelToLogic( Size( 96, 24 ) );
+ Point aPoint = (pDlgEdForm->GetSnapRect()).Center();
+ aPoint.X() -= aSize.Width() / 2;
+ aPoint.Y() -= aSize.Height() / 2;
+ pDlgEdObj->SetSnapRect( Rectangle( aPoint, aSize ) );
+
+ // set default property values
+ pDlgEdObj->SetDefaults();
+
+ // insert object into drawing page
+ SdrPageView* pPageView = pDlgEdView->GetSdrPageView();
+ pDlgEdView->InsertObjectAtView( pDlgEdObj, *pPageView);
+
+ // start listening
+ pDlgEdObj->StartListening();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::Cut()
+{
+ Copy();
+ Delete();
+}
+
+//----------------------------------------------------------------------------
+
+void implCopyStreamToByteSequence( Reference< XInputStream > xStream,
+ Sequence< sal_Int8 >& bytes )
+{
+ sal_Int32 nRead = xStream->readBytes( bytes, xStream->available() );
+ for (;;)
+ {
+ Sequence< sal_Int8 > readBytes;
+ nRead = xStream->readBytes( readBytes, 1024 );
+ if (! nRead)
+ break;
+
+ sal_Int32 nPos = bytes.getLength();
+ bytes.realloc( nPos + nRead );
+ ::rtl_copyMemory( bytes.getArray() + nPos, readBytes.getConstArray(), (sal_uInt32)nRead );
+ }
+}
+
+void DlgEditor::Copy()
+{
+ if( !pDlgEdView->AreObjectsMarked() )
+ return;
+
+ // stop all drawing actions
+ pDlgEdView->BrkAction();
+
+ // create an empty clipboard dialog model
+ Reference< util::XCloneable > xClone( m_xUnoControlDialogModel, UNO_QUERY );
+ Reference< util::XCloneable > xNewClone = xClone->createClone();
+ Reference< container::XNameContainer > xClipDialogModel( xNewClone, UNO_QUERY );
+
+ Reference< container::XNameAccess > xNAcc( xClipDialogModel, UNO_QUERY );
+ if ( xNAcc.is() )
+ {
+ Sequence< OUString > aNames = xNAcc->getElementNames();
+ const OUString* pNames = aNames.getConstArray();
+ sal_uInt32 nCtrls = aNames.getLength();
+
+ for ( sal_uInt32 n = 0; n < nCtrls; n++ )
+ {
+ xClipDialogModel->removeByName( pNames[n] );
+ }
+ }
+
+ // insert control models of marked objects into clipboard dialog model
+ ULONG nMark = pDlgEdView->GetMarkedObjectList().GetMarkCount();
+ for( ULONG i = 0; i < nMark; i++ )
+ {
+ SdrObject* pObj = pDlgEdView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj();
+ DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj);
+
+ if (pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) )
+ {
+ ::rtl::OUString aName;
+ Reference< beans::XPropertySet > xMarkPSet(pDlgEdObj->GetUnoControlModel(), uno::UNO_QUERY);
+ if (xMarkPSet.is())
+ {
+ xMarkPSet->getPropertyValue( DLGED_PROP_NAME ) >>= aName;
+ }
+
+ Reference< container::XNameAccess > xNameAcc(m_xUnoControlDialogModel, UNO_QUERY );
+ if ( xNameAcc.is() && xNameAcc->hasByName(aName) )
+ {
+ Any aCtrl = xNameAcc->getByName( aName );
+
+ // clone control model
+ Reference< util::XCloneable > xCtrl;
+ aCtrl >>= xCtrl;
+ Reference< util::XCloneable > xNewCtrl = xCtrl->createClone();
+ Any aNewCtrl;
+ aNewCtrl <<= xNewCtrl;
+
+ if (xClipDialogModel.is())
+ xClipDialogModel->insertByName( aName , aNewCtrl );
+ }
+ }
+ }
+
+ // export clipboard dialog model to xml
+ Reference< XComponentContext > xContext;
+ Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
+ OSL_ASSERT( xProps.is() );
+ OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument );
+ Reference< XInputStream > xStream( xISP->createInputStream() );
+ Sequence< sal_Int8 > DialogModelBytes;
+ implCopyStreamToByteSequence( xStream, DialogModelBytes );
+ xStream->closeInput();
+
+ // set clipboard content
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow()->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ // With resource?
+ uno::Reference< beans::XPropertySet > xDialogModelPropSet( m_xUnoControlDialogModel, uno::UNO_QUERY );
+ uno::Reference< resource::XStringResourcePersistence > xStringResourcePersistence;
+ if( xDialogModelPropSet.is() )
+ {
+ try
+ {
+ Any aResourceResolver = xDialogModelPropSet->getPropertyValue( aResourceResolverPropName );
+ aResourceResolver >>= xStringResourcePersistence;
+ }
+ catch( UnknownPropertyException& )
+ {}
+ }
+
+ DlgEdTransferableImpl* pTrans = NULL;
+ if( xStringResourcePersistence.is() )
+ {
+ // With resource, support old and new format
+
+ // Export xClipDialogModel another time with ids replaced by current language string
+ uno::Reference< resource::XStringResourceManager >
+ xStringResourceManager( xStringResourcePersistence, uno::UNO_QUERY );
+ LocalizationMgr::resetResourceForDialog( xClipDialogModel, xStringResourceManager );
+ Reference< XInputStreamProvider > xISP2 = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument );
+ Reference< XInputStream > xStream2( xISP2->createInputStream() );
+ Sequence< sal_Int8 > NoResourceDialogModelBytes;
+ implCopyStreamToByteSequence( xStream2, NoResourceDialogModelBytes );
+ xStream2->closeInput();
+
+ // Old format contains dialog with replaced ids
+ Sequence< Any > aSeqData(2);
+ Any aNoResourceDialogModelBytesAny;
+ aNoResourceDialogModelBytesAny <<= NoResourceDialogModelBytes;
+ aSeqData[0] = aNoResourceDialogModelBytesAny;
+
+ // New format contains dialog and resource
+ Sequence< sal_Int8 > aResData = xStringResourcePersistence->exportBinary();
+
+ // Create sequence for combined dialog and resource
+ sal_Int32 nDialogDataLen = DialogModelBytes.getLength();
+ sal_Int32 nResDataLen = aResData.getLength();
+
+ // Combined data = 4 Bytes 32Bit Offset to begin of resource data, lowest byte first
+ // + nDialogDataLen bytes dialog data + nResDataLen resource data
+ sal_Int32 nTotalLen = 4 + nDialogDataLen + nResDataLen;
+ sal_Int32 nResOffset = 4 + nDialogDataLen;
+ Sequence< sal_Int8 > aCombinedData( nTotalLen );
+ sal_Int8* pCombinedData = aCombinedData.getArray();
+
+ // Write offset
+ sal_Int32 n = nResOffset;
+ for( sal_Int16 i = 0 ; i < 4 ; i++ )
+ {
+ pCombinedData[i] = sal_Int8( n & 0xff );
+ n >>= 8;
+ }
+ ::rtl_copyMemory( pCombinedData + 4, DialogModelBytes.getConstArray(), nDialogDataLen );
+ ::rtl_copyMemory( pCombinedData + nResOffset, aResData.getConstArray(), nResDataLen );
+
+ Any aCombinedDataAny;
+ aCombinedDataAny <<= aCombinedData;
+ aSeqData[1] = aCombinedDataAny;
+
+ pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavorsResource, aSeqData );
+ }
+ else
+ {
+ // No resource, support only old format
+ Sequence< Any > aSeqData(1);
+ Any aDialogModelBytesAny;
+ aDialogModelBytesAny <<= DialogModelBytes;
+ aSeqData[0] = aDialogModelBytesAny;
+ pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavors , aSeqData );
+ }
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ xClipboard->setContents( pTrans , pTrans );
+ Application::AcquireSolarMutex( nRef );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::Paste()
+{
+ // stop all drawing actions
+ pDlgEdView->BrkAction();
+
+ // unmark all objects
+ pDlgEdView->UnmarkAll();
+
+ // get clipboard
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow()->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ // get clipboard content
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
+ Application::AcquireSolarMutex( nRef );
+ if ( xTransf.is() )
+ {
+ // Is target dialog (library) localized?
+ uno::Reference< beans::XPropertySet > xDialogModelPropSet( m_xUnoControlDialogModel, uno::UNO_QUERY );
+ uno::Reference< resource::XStringResourceManager > xStringResourceManager;
+ if( xDialogModelPropSet.is() )
+ {
+ try
+ {
+ Any aResourceResolver = xDialogModelPropSet->getPropertyValue( aResourceResolverPropName );
+ aResourceResolver >>= xStringResourceManager;
+ }
+ catch( UnknownPropertyException& )
+ {}
+ }
+ bool bLocalized = false;
+ if( xStringResourceManager.is() )
+ bLocalized = ( xStringResourceManager->getLocales().getLength() > 0 );
+
+ if ( xTransf->isDataFlavorSupported( m_ClipboardDataFlavors[0] ) )
+ {
+ // create clipboard dialog model from xml
+ Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
+ Reference< container::XNameContainer > xClipDialogModel( xMSF->createInstance
+ ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ),
+ uno::UNO_QUERY );
+
+ bool bSourceIsLocalized = false;
+ Sequence< sal_Int8 > DialogModelBytes;
+ Sequence< sal_Int8 > aResData;
+ if( bLocalized && xTransf->isDataFlavorSupported( m_ClipboardDataFlavorsResource[1] ) )
+ {
+ bSourceIsLocalized = true;
+
+ Any aCombinedDataAny = xTransf->getTransferData( m_ClipboardDataFlavorsResource[1] );
+ Sequence< sal_Int8 > aCombinedData;
+ aCombinedDataAny >>= aCombinedData;
+ const sal_Int8* pCombinedData = aCombinedData.getConstArray();
+
+ sal_Int32 nTotalLen = aCombinedData.getLength();
+
+ // Reading offset
+ sal_Int32 nResOffset = 0;
+ sal_Int32 nFactor = 1;
+ for( sal_Int16 i = 0; i < 4; i++ )
+ {
+ nResOffset += nFactor * sal_uInt8( pCombinedData[i] );
+ nFactor *= 256;
+ }
+
+ sal_Int32 nResDataLen = nTotalLen - nResOffset;
+ sal_Int32 nDialogDataLen = nTotalLen - nResDataLen - 4;
+
+ DialogModelBytes.realloc( nDialogDataLen );
+ ::rtl_copyMemory( DialogModelBytes.getArray(), pCombinedData + 4, nDialogDataLen );
+
+ aResData.realloc( nResDataLen );
+ ::rtl_copyMemory( aResData.getArray(), pCombinedData + nResOffset, nResDataLen );
+ }
+ else
+ {
+ Any aAny = xTransf->getTransferData( m_ClipboardDataFlavors[0] );
+ aAny >>= DialogModelBytes;
+ }
+
+ if ( xClipDialogModel.is() )
+ {
+ Reference< XComponentContext > xContext;
+ Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
+ OSL_ASSERT( xProps.is() );
+ OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ ::xmlscript::importDialogModel( ::xmlscript::createInputStream( rtl::ByteSequence(DialogModelBytes.getArray(), DialogModelBytes.getLength()) ) , xClipDialogModel, xContext, m_xDocument );
+ }
+
+ // get control models from clipboard dialog model
+ Reference< ::com::sun::star::container::XNameAccess > xNameAcc( xClipDialogModel, UNO_QUERY );
+ if ( xNameAcc.is() )
+ {
+ Sequence< OUString > aNames = xNameAcc->getElementNames();
+ const OUString* pNames = aNames.getConstArray();
+ sal_uInt32 nCtrls = aNames.getLength();
+
+ Reference< resource::XStringResourcePersistence > xStringResourcePersistence;
+ if( nCtrls > 0 && bSourceIsLocalized )
+ {
+ Reference< lang::XMultiServiceFactory > xSMgr = getProcessServiceFactory();
+ xStringResourcePersistence = Reference< resource::XStringResourcePersistence >( xSMgr->createInstance
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.resource.StringResource" ) ), UNO_QUERY );
+ if( xStringResourcePersistence.is() )
+ xStringResourcePersistence->importBinary( aResData );
+ }
+ for( sal_uInt32 n = 0; n < nCtrls; n++ )
+ {
+ Any aA = xNameAcc->getByName( pNames[n] );
+ Reference< ::com::sun::star::awt::XControlModel > xCM;
+ aA >>= xCM;
+
+ // clone the control model
+ Reference< util::XCloneable > xClone( xCM, uno::UNO_QUERY );
+ Reference< awt::XControlModel > xCtrlModel( xClone->createClone(), uno::UNO_QUERY );
+
+ DlgEdObj* pCtrlObj = new DlgEdObj();
+ pCtrlObj->SetDlgEdForm(pDlgEdForm); // set parent form
+ pDlgEdForm->AddChild(pCtrlObj); // add child to parent form
+ pCtrlObj->SetUnoControlModel( xCtrlModel ); // set control model
+
+ // set new name
+ ::rtl::OUString aOUniqueName( pCtrlObj->GetUniqueName() );
+ Reference< beans::XPropertySet > xPSet( xCtrlModel , UNO_QUERY );
+ Any aUniqueName;
+ aUniqueName <<= aOUniqueName;
+ xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName );
+
+ // set tabindex
+ Reference< container::XNameAccess > xNA( m_xUnoControlDialogModel , UNO_QUERY );
+ Sequence< OUString > aNames_ = xNA->getElementNames();
+ Any aTabIndex;
+ aTabIndex <<= (sal_Int16) aNames_.getLength();
+ xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
+
+ if( bLocalized )
+ {
+ Any aControlAny;
+ aControlAny <<= xCtrlModel;
+ if( bSourceIsLocalized && xStringResourcePersistence.is() )
+ {
+ Reference< resource::XStringResourceResolver >
+ xSourceStringResolver( xStringResourcePersistence, UNO_QUERY );
+ LocalizationMgr::copyResourcesForPastedEditorObject( this,
+ aControlAny, aOUniqueName, xSourceStringResolver );
+ }
+ else
+ {
+ LocalizationMgr::setControlResourceIDsForNewEditorObject
+ ( this, aControlAny, aOUniqueName );
+ }
+ }
+
+ // insert control model in editor dialog model
+ Any aCtrlModel;
+ aCtrlModel <<= xCtrlModel;
+ m_xUnoControlDialogModel->insertByName( aOUniqueName , aCtrlModel );
+
+ // insert object into drawing page
+ pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj );
+ pCtrlObj->SetRectFromProps();
+ pCtrlObj->UpdateStep();
+ pDlgEdForm->UpdateTabOrderAndGroups(); // #110559#
+ pCtrlObj->StartListening(); // start listening
+
+ // mark object
+ SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
+ pDlgEdView->MarkObj( pCtrlObj, pPgView, FALSE, TRUE);
+ }
+
+ // center marked objects in dialog editor form
+ Point aMarkCenter = (pDlgEdView->GetMarkedObjRect()).Center();
+ Point aFormCenter = (pDlgEdForm->GetSnapRect()).Center();
+ Point aPoint = aFormCenter - aMarkCenter;
+ Size aSize( aPoint.X() , aPoint.Y() );
+ pDlgEdView->MoveMarkedObj( aSize ); // update of control model properties (position + size) in NbcMove
+ pDlgEdView->MarkListHasChanged();
+
+ // dialog model changed
+ SetDialogModelChanged(TRUE);
+ }
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::Delete()
+{
+ if( !pDlgEdView->AreObjectsMarked() )
+ return;
+
+ // remove control models of marked objects from dialog model
+ ULONG nMark = pDlgEdView->GetMarkedObjectList().GetMarkCount();
+
+ for( ULONG i = 0; i < nMark; i++ )
+ {
+ SdrObject* pObj = pDlgEdView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj();
+ DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj);
+
+ if ( pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) )
+ {
+ // get name from property
+ ::rtl::OUString aName;
+ uno::Reference< beans::XPropertySet > xPSet(pDlgEdObj->GetUnoControlModel(), uno::UNO_QUERY);
+ if (xPSet.is())
+ {
+ xPSet->getPropertyValue( DLGED_PROP_NAME ) >>= aName;
+ }
+
+ // remove control from dialog model
+ Reference< ::com::sun::star::container::XNameAccess > xNameAcc(pDlgEdObj->GetDlgEdForm()->GetUnoControlModel(), UNO_QUERY );
+ if ( xNameAcc.is() && xNameAcc->hasByName(aName) )
+ {
+ Reference< ::com::sun::star::container::XNameContainer > xCont(xNameAcc, UNO_QUERY );
+ if ( xCont.is() )
+ {
+ if( xCont->hasByName( aName ) )
+ {
+ Any aAny = xCont->getByName( aName );
+ LocalizationMgr::deleteControlResourceIDsForDeletedEditorObject( this, aAny, aName );
+ }
+ xCont->removeByName( aName );
+ }
+ }
+
+ // remove child from parent form
+ pDlgEdForm->RemoveChild( pDlgEdObj );
+ }
+ }
+
+ // update tab indices
+ pDlgEdForm->UpdateTabIndices();
+
+ pDlgEdView->BrkAction();
+
+ BOOL bDlgMarked = UnmarkDialog();
+ pDlgEdView->DeleteMarked();
+ if( bDlgMarked )
+ RemarkDialog();
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEditor::IsPasteAllowed()
+{
+ BOOL bPaste = FALSE;
+
+ // get clipboard
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow()->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ // get clipboard content
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
+ Application::AcquireSolarMutex( nRef );
+ if ( xTransf.is() )
+ {
+ if ( xTransf->isDataFlavorSupported( m_ClipboardDataFlavors[0] ) )
+ {
+ bPaste = TRUE;
+ }
+ }
+ }
+
+ return bPaste;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::ShowProperties()
+{
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ if ( pViewFrame && !pViewFrame->HasChildWindow( SID_SHOW_PROPERTYBROWSER ) )
+ pViewFrame->ToggleChildWindow( SID_SHOW_PROPERTYBROWSER );
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::UpdatePropertyBrowserDelayed()
+{
+ aMarkTimer.Start();
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEditor::IsModified() const
+{
+ return pDlgEdModel->IsChanged() || bDialogModelChanged;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::ClearModifyFlag()
+{
+ pDlgEdModel->SetChanged( FALSE );
+ bDialogModelChanged = FALSE;
+}
+
+//----------------------------------------------------------------------------
+
+#define LMARGPRN 1700
+#define RMARGPRN 900
+#define TMARGPRN 2000
+#define BMARGPRN 1000
+#define BORDERPRN 300
+
+//----------------------------------------------------------------------------
+
+void lcl_PrintHeader( Printer* pPrinter, const String& rTitle ) // not working yet
+{
+ pPrinter->Push();
+
+ short nLeftMargin = LMARGPRN;
+ Size aSz = pPrinter->GetOutputSize();
+ short nBorder = BORDERPRN;
+
+ pPrinter->SetLineColor( COL_BLACK );
+ pPrinter->SetFillColor();
+
+ Font aFont( pPrinter->GetFont() );
+ aFont.SetWeight( WEIGHT_BOLD );
+ aFont.SetAlign( ALIGN_BOTTOM );
+ pPrinter->SetFont( aFont );
+
+ long nFontHeight = pPrinter->GetTextHeight();
+
+ // 1.Border => Strich, 2+3 Border = Freiraum.
+ long nYTop = TMARGPRN-3*nBorder-nFontHeight;
+
+ long nXLeft = nLeftMargin-nBorder;
+ long nXRight = aSz.Width()-RMARGPRN+nBorder;
+
+ pPrinter->DrawRect( Rectangle(
+ Point( nXLeft, nYTop ),
+ Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) );
+
+ long nY = TMARGPRN-2*nBorder;
+ Point aPos( nLeftMargin, nY );
+ pPrinter->DrawText( aPos, rTitle );
+
+ nY = TMARGPRN-nBorder;
+
+ pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) );
+
+ pPrinter->Pop();
+}
+
+//----------------------------------------------------------------------------
+
+sal_Int32 DlgEditor::countPages( Printer* )
+{
+ return 1;
+}
+
+void DlgEditor::printPage( sal_Int32 nPage, Printer* pPrinter, const String& rTitle )
+{
+ if( nPage == 0 )
+ Print( pPrinter, rTitle );
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEditor::Print( Printer* pPrinter, const String& rTitle ) // not working yet
+{
+ if( pDlgEdView )
+ {
+ MapMode aOldMap( pPrinter->GetMapMode());
+ Font aOldFont( pPrinter->GetFont() );
+
+ MapMode aMap( MAP_100TH_MM );
+ pPrinter->SetMapMode( aMap );
+ Font aFont;
+#ifdef OS2
+ //aFont.SetName( System::GetStandardFont( STDFONT_SWISS ).GetName() );
+#endif
+ aFont.SetAlign( ALIGN_BOTTOM );
+ aFont.SetSize( Size( 0, 360 ));
+ pPrinter->SetFont( aFont );
+
+ Size aPaperSz = pPrinter->GetOutputSize();
+ aPaperSz.Width() -= (LMARGPRN+RMARGPRN);
+ aPaperSz.Height() -= (TMARGPRN+BMARGPRN);
+
+ lcl_PrintHeader( pPrinter, rTitle );
+
+ Bitmap aDlg;
+#ifdef OS2
+ Bitmap* pDlg = new Bitmap;
+ //pSbxForm->SnapShot( *pDlg );
+ SvMemoryStream* pStrm = new SvMemoryStream;
+ *pStrm << *pDlg;
+ delete pDlg;
+ pStrm->Seek(0);
+ *pStrm >> aDlg;
+ delete pStrm;
+#else
+ //pSbxForm->SnapShot( aDlg );
+#endif
+ Size aBmpSz( pPrinter->PixelToLogic( aDlg.GetSizePixel() ) );
+ double nPaperSzWidth = aPaperSz.Width();
+ double nPaperSzHeight = aPaperSz.Height();
+ double nBmpSzWidth = aBmpSz.Width();
+ double nBmpSzHeight = aBmpSz.Height();
+ double nScaleX = (nPaperSzWidth / nBmpSzWidth );
+ double nScaleY = (nPaperSzHeight / nBmpSzHeight );
+
+ Size aOutputSz;
+ if( nBmpSzHeight * nScaleX <= nPaperSzHeight )
+ {
+ aOutputSz.Width() = (long)(((double)nBmpSzWidth) * nScaleX);
+ aOutputSz.Height() = (long)(((double)nBmpSzHeight) * nScaleX);
+ }
+ else
+ {
+ aOutputSz.Width() = (long)(((double)nBmpSzWidth) * nScaleY);
+ aOutputSz.Height() = (long)(((double)nBmpSzHeight) * nScaleY);
+ }
+
+ Point aPosOffs(
+ (aPaperSz.Width() / 2) - (aOutputSz.Width() / 2),
+ (aPaperSz.Height()/ 2) - (aOutputSz.Height() / 2));
+
+ aPosOffs.X() += LMARGPRN;
+ aPosOffs.Y() += TMARGPRN;
+
+ pPrinter->DrawBitmap( aPosOffs, aOutputSz, aDlg );
+
+ pPrinter->SetMapMode( aOldMap );
+ pPrinter->SetFont( aOldFont );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+bool DlgEditor::AdjustPageSize()
+{
+ bool bAdjustedPageSize = false;
+ Reference< beans::XPropertySet > xPSet( m_xUnoControlDialogModel, UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ sal_Int32 nFormXIn = 0, nFormYIn = 0, nFormWidthIn = 0, nFormHeightIn = 0;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nFormXIn;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nFormYIn;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nFormWidthIn;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nFormHeightIn;
+
+ sal_Int32 nFormX, nFormY, nFormWidth, nFormHeight;
+ if ( pDlgEdForm && pDlgEdForm->TransformFormToSdrCoordinates( nFormXIn, nFormYIn, nFormWidthIn, nFormHeightIn, nFormX, nFormY, nFormWidth, nFormHeight ) )
+ {
+ Size aPageSizeDelta( 400, 300 );
+ DBG_ASSERT( pWindow, "DlgEditor::AdjustPageSize: no window!" );
+ if ( pWindow )
+ aPageSizeDelta = pWindow->PixelToLogic( aPageSizeDelta, MapMode( MAP_100TH_MM ) );
+
+ sal_Int32 nNewPageWidth = nFormX + nFormWidth + aPageSizeDelta.Width();
+ sal_Int32 nNewPageHeight = nFormY + nFormHeight + aPageSizeDelta.Height();
+
+ Size aPageSizeMin( DLGED_PAGE_WIDTH_MIN, DLGED_PAGE_HEIGHT_MIN );
+ DBG_ASSERT( pWindow, "DlgEditor::AdjustPageSize: no window!" );
+ if ( pWindow )
+ aPageSizeMin = pWindow->PixelToLogic( aPageSizeMin, MapMode( MAP_100TH_MM ) );
+ sal_Int32 nPageWidthMin = aPageSizeMin.Width();
+ sal_Int32 nPageHeightMin = aPageSizeMin.Height();
+
+ if ( nNewPageWidth < nPageWidthMin )
+ nNewPageWidth = nPageWidthMin;
+
+ if ( nNewPageHeight < nPageHeightMin )
+ nNewPageHeight = nPageHeightMin;
+
+ if ( pDlgEdPage )
+ {
+ Size aPageSize = pDlgEdPage->GetSize();
+ if ( nNewPageWidth != aPageSize.Width() || nNewPageHeight != aPageSize.Height() )
+ {
+ Size aNewPageSize( nNewPageWidth, nNewPageHeight );
+ pDlgEdPage->SetSize( aNewPageSize );
+ DBG_ASSERT( pDlgEdView, "DlgEditor::AdjustPageSize: no view!" );
+ if ( pDlgEdView )
+ pDlgEdView->SetWorkArea( Rectangle( Point( 0, 0 ), aNewPageSize ) );
+ bAdjustedPageSize = true;
+ }
+ }
+ }
+ }
+
+ return bAdjustedPageSize;
+}
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedclip.cxx b/basctl/source/dlged/dlgedclip.cxx
new file mode 100644
index 000000000000..17392b2510ac
--- /dev/null
+++ b/basctl/source/dlged/dlgedclip.cxx
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+#include "dlgedclip.hxx"
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/datatransfer/XMimeContentType.hpp>
+#include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
+
+
+using namespace comphelper;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::clipboard;
+
+
+//----------------------------------------------------------------------------
+
+DlgEdTransferableImpl::DlgEdTransferableImpl( const Sequence< DataFlavor >& aSeqFlavors, const Sequence< Any >& aSeqData )
+{
+ m_SeqFlavors = aSeqFlavors;
+ m_SeqData = aSeqData;
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdTransferableImpl::~DlgEdTransferableImpl()
+{
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdTransferableImpl::compareDataFlavors( const DataFlavor& lFlavor, const DataFlavor& rFlavor )
+{
+ sal_Bool bRet = sal_False;
+
+ // compare mime content types
+ Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
+ Reference< datatransfer::XMimeContentTypeFactory >
+ xMCntTypeFactory( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.datatransfer.MimeContentTypeFactory" ) ) ), UNO_QUERY );
+
+ if ( xMCntTypeFactory.is( ) )
+ {
+ // compare full media types
+ Reference< datatransfer::XMimeContentType > xLType = xMCntTypeFactory->createMimeContentType( lFlavor.MimeType );
+ Reference< datatransfer::XMimeContentType > xRType = xMCntTypeFactory->createMimeContentType( rFlavor.MimeType );
+
+ ::rtl::OUString aLFullMediaType = xLType->getFullMediaType();
+ ::rtl::OUString aRFullMediaType = xRType->getFullMediaType();
+
+ bRet = aLFullMediaType.equalsIgnoreAsciiCase( aRFullMediaType );
+ }
+
+ return bRet;
+}
+
+// XTransferable
+//----------------------------------------------------------------------------
+
+Any SAL_CALL DlgEdTransferableImpl::getTransferData( const DataFlavor& rFlavor ) throw(UnsupportedFlavorException, IOException, RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ if ( !isDataFlavorSupported( rFlavor ) )
+ throw UnsupportedFlavorException();
+
+ Any aData;
+
+ for ( sal_Int32 i = 0; i < m_SeqFlavors.getLength(); i++ )
+ {
+ if ( compareDataFlavors( m_SeqFlavors[i] , rFlavor ) )
+ {
+ aData = m_SeqData[i];
+ break;
+ }
+ }
+
+ return aData;
+}
+
+//----------------------------------------------------------------------------
+
+Sequence< DataFlavor > SAL_CALL DlgEdTransferableImpl::getTransferDataFlavors( ) throw(RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ return m_SeqFlavors;
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL DlgEdTransferableImpl::isDataFlavorSupported( const DataFlavor& rFlavor ) throw(RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ sal_Bool bRet = sal_False;
+
+ for ( sal_Int32 i = 0; i < m_SeqFlavors.getLength(); i++ )
+ {
+ if ( compareDataFlavors( m_SeqFlavors[i] , rFlavor ) )
+ {
+ bRet = sal_True;
+ break;
+ }
+ }
+
+ return bRet;
+}
+
+// XClipboardOwner
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdTransferableImpl::lostOwnership( const Reference< XClipboard >&, const Reference< XTransferable >& ) throw(RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ m_SeqFlavors = Sequence< DataFlavor >();
+ m_SeqData = Sequence< Any >();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedfac.cxx b/basctl/source/dlged/dlgedfac.cxx
new file mode 100644
index 000000000000..27bae6fbb8c7
--- /dev/null
+++ b/basctl/source/dlged/dlgedfac.cxx
@@ -0,0 +1,270 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include "dlgedfac.hxx"
+#include "dlgedobj.hxx"
+#include <dlgeddef.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/awt/ScrollBarOrientation.hpp>
+
+using namespace ::com::sun::star;
+
+//----------------------------------------------------------------------------
+
+DlgEdFactory::DlgEdFactory()
+{
+ SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdFactory::~DlgEdFactory()
+{
+ SdrObjFactory::RemoveMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory )
+{
+ static sal_Bool bNeedsInit = sal_True;
+ static uno::Reference< lang::XMultiServiceFactory > xDialogSFact;
+
+ if( bNeedsInit )
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
+ uno::Reference< container::XNameContainer > xC( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), uno::UNO_QUERY );
+ if( xC.is() )
+ {
+ uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY );
+ xDialogSFact = xModFact;
+ }
+ bNeedsInit = sal_False;
+ }
+
+ if( (pObjFactory->nInventor == DlgInventor) &&
+ (pObjFactory->nIdentifier >= OBJ_DLG_PUSHBUTTON) &&
+ (pObjFactory->nIdentifier <= OBJ_DLG_TREECONTROL) )
+ {
+ switch( pObjFactory->nIdentifier )
+ {
+ case OBJ_DLG_PUSHBUTTON:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlButtonModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_RADIOBUTTON:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlRadioButtonModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_CHECKBOX:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlCheckBoxModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_LISTBOX:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlListBoxModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_COMBOBOX:
+ {
+ DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlComboBoxModel") , xDialogSFact );
+ pObjFactory->pNewObj = pNew;
+ try
+ {
+ uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
+ if (xPSet.is())
+ {
+ sal_Bool bB = sal_True;
+ xPSet->setPropertyValue( DLGED_PROP_DROPDOWN, uno::Any(&bB,::getBooleanCppuType()));
+ }
+ }
+ catch(...)
+ {
+ }
+ } break;
+ case OBJ_DLG_GROUPBOX:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlGroupBoxModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_EDIT:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlEditModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_FIXEDTEXT:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFixedTextModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_IMAGECONTROL:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlImageControlModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_PROGRESSBAR:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlProgressBarModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_HSCROLLBAR:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlScrollBarModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_VSCROLLBAR:
+ {
+ DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlScrollBarModel") , xDialogSFact );
+ pObjFactory->pNewObj = pNew;
+ // set vertical orientation
+ try
+ {
+ uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
+ if (xPSet.is())
+ {
+ uno::Any aValue;
+ aValue <<= (sal_Int32) ::com::sun::star::awt::ScrollBarOrientation::VERTICAL;
+ xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue );
+ }
+ }
+ catch(...)
+ {
+ }
+ } break;
+ case OBJ_DLG_HFIXEDLINE:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFixedLineModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_VFIXEDLINE:
+ {
+ DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFixedLineModel") , xDialogSFact );
+ pObjFactory->pNewObj = pNew;
+ // set vertical orientation
+ try
+ {
+ uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
+ if (xPSet.is())
+ {
+ uno::Any aValue;
+ aValue <<= (sal_Int32) 1;
+ xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue );
+ }
+ }
+ catch(...)
+ {
+ }
+ } break;
+ case OBJ_DLG_DATEFIELD:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlDateFieldModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_TIMEFIELD:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlTimeFieldModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_NUMERICFIELD:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlNumericFieldModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_CURRENCYFIELD:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlCurrencyFieldModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_FORMATTEDFIELD:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFormattedFieldModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_PATTERNFIELD:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlPatternFieldModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_FILECONTROL:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFileControlModel") , xDialogSFact );
+ break;
+ case OBJ_DLG_TREECONTROL:
+ DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.tree.TreeControlModel") , xDialogSFact );
+ pObjFactory->pNewObj = pNew;
+ /*
+ try
+ {
+ uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
+ if (xPSet.is())
+ {
+ // first create a data model for our tree control
+ Reference< XComponentContext > xComponentContext;
+
+ Reference< XPropertySet > xPropSet( xInterface, UNO_QUERY );
+ xPropSet->getPropertyValue( OUString::createFromAscii("DefaultContext") ) >>= xComponentContext;
+
+ // gets the service manager from the office
+ Reference< XMultiComponentFactory > xMultiComponentFactoryServer( xComponentContext->getServiceManager() );
+
+
+ // gets the TreeDataModel
+ Reference< XMutableTreeDataModel > xTreeDataModel;
+
+ xTreeDataModel = Reference< XMutableTreeDataModel >(
+ xMultiComponentFactoryServer->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.tree.MutableTreeDataModel" ) ), xComponentContext ), UNO_QUERY_THROW );
+
+ // now fill it with some sample data
+ const OUString sRoot( RTL_CONSTASCII_USTRINGPARAM( "Root" ) );
+
+ Reference< XMutableTreeNode > xNode( mxTreeDataModel->createNode( sRoot, false ), UNO_QUERY_THROW );
+ xNode->setDataValue( sRoot );
+ xNode->setExpandedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_down.png" ) ) );
+ xNode->setCollapsedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_right.png" ) ) );
+
+ const OUString sNode_1( RTL_CONSTASCII_USTRINGPARAM( "Node_1" ) );
+
+ Reference< XMutableTreeNode > xChildNode_1( mxTreeDataModel->createNode( sNode_1, true ), UNO_QUERY_THROW );
+ xChildNode_1->setDataValue( sNode_1 );
+ xChildNode_1->setExpandedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_down.png" ) ) );
+ xChildNode_1->setCollapsedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_right.png" ) ) );
+
+ xNode->appendChild( xChildNode_1 );
+
+ const OUString sNode_1_1( RTL_CONSTASCII_USTRINGPARAM( "Node_1_1" ) );
+
+ Reference< XMutableTreeNode > xChildNode_1_1( mxTreeDataModel->createNode( sNode_1_1, false ), UNO_QUERY_THROW );
+ xChildNode_1_1->setDataValue( sNode_1_1 );
+ xChildNode_1_1->setExpandedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_down.png" ) ) );
+ xChildNode_1_1->setCollapsedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_right.png" ) ) );
+
+ xChildNode_1->appendChild( xChildNode_1_1 );
+
+ const OUString sNode_1_1( RTL_CONSTASCII_USTRINGPARAM( "Node_2" ) );
+
+ Reference< XMutableTreeNode > xChildNode_2( mxTreeDataModel->createNode( sNode_2, false ), UNO_QUERY_THROW );
+ xChildNode_2->setDataValue( sNode_2 );
+ xChildNode_2->setNodeGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM("private:graphicrepository/sw/imglst/nc20010.png") ) );
+ xNode->appendChild( xChildNode_2 );
+
+ xTreeDataModel->setRoot( xNode );
+
+
+ const OUString sDataModel( RTL_CONSTASCII_USTRINGPARAM( "DataModel" ) );
+
+ xPSet->setPropertyValue( sDataModel, xTreeDataModel );
+ }
+ }
+ catch(...)
+ {
+ }*/
+ break;
+ }
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedfunc.cxx b/basctl/source/dlged/dlgedfunc.cxx
new file mode 100644
index 000000000000..9ef46deb69c0
--- /dev/null
+++ b/basctl/source/dlged/dlgedfunc.cxx
@@ -0,0 +1,640 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+#include <vcl/scrbar.hxx>
+#include <svx/svdview.hxx>
+#include "dlgedfunc.hxx"
+#include "dlged.hxx"
+#include "dlgedview.hxx"
+#include <vcl/seleng.hxx>
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( DlgEdFunc, ScrollTimeout, Timer *, pTimer )
+{
+ (void)pTimer;
+ Window* pWindow = pParent->GetWindow();
+ Point aPos = pWindow->ScreenToOutputPixel( pWindow->GetPointerPosPixel() );
+ aPos = pWindow->PixelToLogic( aPos );
+ ForceScroll( aPos );
+ return 0;
+}
+IMPL_LINK_INLINE_END( DlgEdFunc, ScrollTimeout, Timer *, pTimer )
+
+//----------------------------------------------------------------------------
+
+void DlgEdFunc::ForceScroll( const Point& rPos )
+{
+ aScrollTimer.Stop();
+
+ Window* pWindow = pParent->GetWindow();
+
+ static Point aDefPoint;
+ Rectangle aOutRect( aDefPoint, pWindow->GetOutputSizePixel() );
+ aOutRect = pWindow->PixelToLogic( aOutRect );
+
+ ScrollBar* pHScroll = pParent->GetHScroll();
+ ScrollBar* pVScroll = pParent->GetVScroll();
+ long nDeltaX = pHScroll->GetLineSize();
+ long nDeltaY = pVScroll->GetLineSize();
+
+ if( !aOutRect.IsInside( rPos ) )
+ {
+ if( rPos.X() < aOutRect.Left() )
+ nDeltaX = -nDeltaX;
+ else
+ if( rPos.X() <= aOutRect.Right() )
+ nDeltaX = 0;
+
+ if( rPos.Y() < aOutRect.Top() )
+ nDeltaY = -nDeltaY;
+ else
+ if( rPos.Y() <= aOutRect.Bottom() )
+ nDeltaY = 0;
+
+ if( nDeltaX )
+ pHScroll->SetThumbPos( pHScroll->GetThumbPos() + nDeltaX );
+ if( nDeltaY )
+ pVScroll->SetThumbPos( pVScroll->GetThumbPos() + nDeltaY );
+
+ if( nDeltaX )
+ pParent->DoScroll( pHScroll );
+ if( nDeltaY )
+ pParent->DoScroll( pVScroll );
+ }
+
+ aScrollTimer.Start();
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdFunc::DlgEdFunc( DlgEditor* pParent_ )
+{
+ DlgEdFunc::pParent = pParent_;
+ aScrollTimer.SetTimeoutHdl( LINK( this, DlgEdFunc, ScrollTimeout ) );
+ aScrollTimer.SetTimeout( SELENG_AUTOREPEAT_INTERVAL );
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdFunc::~DlgEdFunc()
+{
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEdFunc::MouseButtonDown( const MouseEvent& )
+{
+ return TRUE;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEdFunc::MouseButtonUp( const MouseEvent& )
+{
+ aScrollTimer.Stop();
+ return TRUE;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEdFunc::MouseMove( const MouseEvent& )
+{
+ return TRUE;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEdFunc::KeyInput( const KeyEvent& rKEvt )
+{
+ BOOL bReturn = FALSE;
+
+ SdrView* pView = pParent->GetView();
+ Window* pWindow = pParent->GetWindow();
+
+ KeyCode aCode = rKEvt.GetKeyCode();
+ USHORT nCode = aCode.GetCode();
+
+ switch ( nCode )
+ {
+ case KEY_ESCAPE:
+ {
+ if ( pView->IsAction() )
+ {
+ pView->BrkAction();
+ bReturn = TRUE;
+ }
+ else if ( pView->AreObjectsMarked() )
+ {
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+ if ( pHdl )
+ ((SdrHdlList&)rHdlList).ResetFocusHdl();
+ else
+ pView->UnmarkAll();
+
+ bReturn = TRUE;
+ }
+ }
+ break;
+ case KEY_TAB:
+ {
+ if ( !aCode.IsMod1() && !aCode.IsMod2() )
+ {
+ // mark next object
+ if ( !pView->MarkNextObj( !aCode.IsShift() ) )
+ {
+ // if no next object, mark first/last
+ pView->UnmarkAllObj();
+ pView->MarkNextObj( !aCode.IsShift() );
+ }
+
+ if ( pView->AreObjectsMarked() )
+ pView->MakeVisible( pView->GetAllMarkedRect(), *pWindow );
+
+ bReturn = TRUE;
+ }
+ else if ( aCode.IsMod1() )
+ {
+ // selected handle
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ ((SdrHdlList&)rHdlList).TravelFocusHdl( !aCode.IsShift() );
+
+ // guarantee visibility of focused handle
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+ if ( pHdl )
+ {
+ Point aHdlPosition( pHdl->GetPos() );
+ Rectangle aVisRect( aHdlPosition - Point( 100, 100 ), Size( 200, 200 ) );
+ pView->MakeVisible( aVisRect, *pWindow );
+ }
+
+ bReturn = TRUE;
+ }
+ }
+ break;
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_LEFT:
+ case KEY_RIGHT:
+ {
+ long nX = 0;
+ long nY = 0;
+
+ if ( nCode == KEY_UP )
+ {
+ // scroll up
+ nX = 0;
+ nY = -1;
+ }
+ else if ( nCode == KEY_DOWN )
+ {
+ // scroll down
+ nX = 0;
+ nY = 1;
+ }
+ else if ( nCode == KEY_LEFT )
+ {
+ // scroll left
+ nX = -1;
+ nY = 0;
+ }
+ else if ( nCode == KEY_RIGHT )
+ {
+ // scroll right
+ nX = 1;
+ nY = 0;
+ }
+
+ if ( pView->AreObjectsMarked() && !aCode.IsMod1() )
+ {
+ if ( aCode.IsMod2() )
+ {
+ // move in 1 pixel distance
+ Size aPixelSize = pWindow ? pWindow->PixelToLogic( Size( 1, 1 ) ) : Size( 100, 100 );
+ nX *= aPixelSize.Width();
+ nY *= aPixelSize.Height();
+ }
+ else
+ {
+ // move in 1 mm distance
+ nX *= 100;
+ nY *= 100;
+ }
+
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+
+ if ( pHdl == 0 )
+ {
+ // no handle selected
+ if ( pView->IsMoveAllowed() )
+ {
+ // restrict movement to work area
+ const Rectangle& rWorkArea = pView->GetWorkArea();
+
+ if ( !rWorkArea.IsEmpty() )
+ {
+ Rectangle aMarkRect( pView->GetMarkedObjRect() );
+ aMarkRect.Move( nX, nY );
+
+ if ( !rWorkArea.IsInside( aMarkRect ) )
+ {
+ if ( aMarkRect.Left() < rWorkArea.Left() )
+ nX += rWorkArea.Left() - aMarkRect.Left();
+
+ if ( aMarkRect.Right() > rWorkArea.Right() )
+ nX -= aMarkRect.Right() - rWorkArea.Right();
+
+ if ( aMarkRect.Top() < rWorkArea.Top() )
+ nY += rWorkArea.Top() - aMarkRect.Top();
+
+ if ( aMarkRect.Bottom() > rWorkArea.Bottom() )
+ nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
+ }
+ }
+
+ if ( nX != 0 || nY != 0 )
+ {
+ pView->MoveAllMarked( Size( nX, nY ) );
+ pView->MakeVisible( pView->GetAllMarkedRect(), *pWindow );
+ }
+ }
+ }
+ else
+ {
+ // move the handle
+ if ( pHdl && ( nX || nY ) )
+ {
+ Point aStartPoint( pHdl->GetPos() );
+ Point aEndPoint( pHdl->GetPos() + Point( nX, nY ) );
+ const SdrDragStat& rDragStat = pView->GetDragStat();
+
+ // start dragging
+ pView->BegDragObj( aStartPoint, 0, pHdl, 0 );
+
+ if ( pView->IsDragObj() )
+ {
+ bool bWasNoSnap = rDragStat.IsNoSnap();
+ BOOL bWasSnapEnabled = pView->IsSnapEnabled();
+
+ // switch snapping off
+ if ( !bWasNoSnap )
+ ((SdrDragStat&)rDragStat).SetNoSnap( TRUE );
+ if ( bWasSnapEnabled )
+ pView->SetSnapEnabled( FALSE );
+
+ pView->MovAction( aEndPoint );
+ pView->EndDragObj();
+
+ // restore snap
+ if ( !bWasNoSnap )
+ ((SdrDragStat&)rDragStat).SetNoSnap( bWasNoSnap );
+ if ( bWasSnapEnabled )
+ pView->SetSnapEnabled( bWasSnapEnabled );
+ }
+
+ // make moved handle visible
+ Rectangle aVisRect( aEndPoint - Point( 100, 100 ), Size( 200, 200 ) );
+ pView->MakeVisible( aVisRect, *pWindow );
+ }
+ }
+ }
+ else
+ {
+ // scroll page
+ ScrollBar* pScrollBar = ( nX != 0 ) ? pParent->GetHScroll() : pParent->GetVScroll();
+ if ( pScrollBar )
+ {
+ long nRangeMin = pScrollBar->GetRangeMin();
+ long nRangeMax = pScrollBar->GetRangeMax();
+ long nThumbPos = pScrollBar->GetThumbPos() + ( ( nX != 0 ) ? nX : nY ) * pScrollBar->GetLineSize();
+ if ( nThumbPos < nRangeMin )
+ nThumbPos = nRangeMin;
+ if ( nThumbPos > nRangeMax )
+ nThumbPos = nRangeMax;
+ pScrollBar->SetThumbPos( nThumbPos );
+ pParent->DoScroll( pScrollBar );
+ }
+ }
+
+ bReturn = TRUE;
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+
+ if ( bReturn )
+ pWindow->ReleaseMouse();
+
+ return bReturn;
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdFuncInsert::DlgEdFuncInsert( DlgEditor* pParent_ ) :
+ DlgEdFunc( pParent_ )
+{
+ pParent_->GetView()->SetCreateMode( TRUE );
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdFuncInsert::~DlgEdFuncInsert()
+{
+ pParent->GetView()->SetEditMode( TRUE );
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEdFuncInsert::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if( !rMEvt.IsLeft() )
+ return TRUE;
+
+ SdrView* pView = pParent->GetView();
+ Window* pWindow= pParent->GetWindow();
+ pView->SetActualWin( pWindow );
+
+ Point aPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
+ USHORT nHitLog = USHORT ( pWindow->PixelToLogic(Size(3,0)).Width() );
+ USHORT nDrgLog = USHORT ( pWindow->PixelToLogic(Size(3,0)).Width() );
+
+ pWindow->CaptureMouse();
+
+ if ( rMEvt.IsLeft() && rMEvt.GetClicks() == 1 )
+ {
+ SdrHdl* pHdl = pView->PickHandle(aPos);
+
+ // if selected object was hit, drag object
+ if ( pHdl!=NULL || pView->IsMarkedHit(aPos, nHitLog) )
+ pView->BegDragObj(aPos, (OutputDevice*) NULL, pHdl, nDrgLog);
+ else if ( pView->AreObjectsMarked() )
+ pView->UnmarkAll();
+
+ // if no action, create object
+ if ( !pView->IsAction() )
+ pView->BegCreateObj(aPos);
+ }
+ else if ( rMEvt.IsLeft() && rMEvt.GetClicks() == 2 )
+ {
+ // if object was hit, show property browser
+ if ( pView->IsMarkedHit(aPos, nHitLog) && pParent->GetMode() != DLGED_READONLY )
+ pParent->ShowProperties();
+ }
+
+ return TRUE;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEdFuncInsert::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ DlgEdFunc::MouseButtonUp( rMEvt );
+
+ SdrView* pView = pParent->GetView();
+ Window* pWindow= pParent->GetWindow();
+ pView->SetActualWin( pWindow );
+
+ pWindow->ReleaseMouse();
+
+ // object creation active?
+ if ( pView->IsCreateObj() )
+ {
+ pView->EndCreateObj(SDRCREATE_FORCEEND);
+
+ if ( !pView->AreObjectsMarked() )
+ {
+ USHORT nHitLog = USHORT ( pWindow->PixelToLogic(Size(3,0)).Width() );
+ Point aPos( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ pView->MarkObj(aPos, nHitLog);
+ }
+
+ if( pView->AreObjectsMarked() )
+ return TRUE;
+ else
+ return FALSE;
+ }
+ else
+ {
+ if ( pView->IsDragObj() )
+ pView->EndDragObj( rMEvt.IsMod1() );
+ return TRUE;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEdFuncInsert::MouseMove( const MouseEvent& rMEvt )
+{
+ SdrView* pView = pParent->GetView();
+ Window* pWindow= pParent->GetWindow();
+ pView->SetActualWin( pWindow );
+
+ Point aPos( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ USHORT nHitLog = USHORT ( pWindow->PixelToLogic(Size(3,0)).Width() );
+
+ if ( pView->IsAction() )
+ {
+ ForceScroll(aPos);
+ pView->MovAction(aPos);
+ }
+
+ pWindow->SetPointer( pView->GetPreferedPointer( aPos, pWindow, nHitLog ) );
+
+ return TRUE;
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdFuncSelect::DlgEdFuncSelect( DlgEditor* pParent_ ) :
+ DlgEdFunc( pParent_ ),
+ bMarkAction(FALSE)
+{
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdFuncSelect::~DlgEdFuncSelect()
+{
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEdFuncSelect::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ // get view from parent
+ SdrView* pView = pParent->GetView();
+ Window* pWindow = pParent->GetWindow();
+ pView->SetActualWin( pWindow );
+
+ USHORT nDrgLog = USHORT ( pWindow->PixelToLogic(Size(3,0)).Width() );
+ USHORT nHitLog = USHORT ( pWindow->PixelToLogic(Size(3,0)).Width() );
+ Point aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
+
+ if ( rMEvt.IsLeft() && rMEvt.GetClicks() == 1 )
+ {
+ SdrHdl* pHdl = pView->PickHandle(aMDPos);
+ SdrObject* pObj;
+ SdrPageView* pPV;
+
+ // hit selected object?
+ if ( pHdl!=NULL || pView->IsMarkedHit(aMDPos, nHitLog) )
+ {
+ pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
+ }
+ else
+ {
+ // if not multi selection, unmark all
+ if ( !rMEvt.IsShift() )
+ pView->UnmarkAll();
+ else
+ {
+ if( pView->PickObj( aMDPos, nHitLog, pObj, pPV ) )
+ {
+ //if( pObj->ISA( DlgEdForm ) )
+ // pView->UnmarkAll();
+ //else
+ // pParent->UnmarkDialog();
+ }
+ }
+
+ if ( pView->MarkObj(aMDPos, nHitLog) )
+ {
+ // drag object
+ pHdl=pView->PickHandle(aMDPos);
+ pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
+ }
+ else
+ {
+ // select object
+ pView->BegMarkObj(aMDPos);
+ bMarkAction = TRUE;
+ }
+ }
+ }
+ else if ( rMEvt.IsLeft() && rMEvt.GetClicks() == 2 )
+ {
+ // if object was hit, show property browser
+ if ( pView->IsMarkedHit(aMDPos, nHitLog) && pParent->GetMode() != DLGED_READONLY )
+ pParent->ShowProperties();
+ }
+
+ return TRUE;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEdFuncSelect::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ DlgEdFunc::MouseButtonUp( rMEvt );
+
+ // get view from parent
+ SdrView* pView = pParent->GetView();
+ Window* pWindow= pParent->GetWindow();
+ pView->SetActualWin( pWindow );
+
+ Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ USHORT nHitLog = USHORT ( pWindow->PixelToLogic(Size(3,0)).Width() );
+
+ if ( rMEvt.IsLeft() )
+ {
+ if ( pView->IsDragObj() )
+ {
+ // object was dragged
+ pView->EndDragObj( rMEvt.IsMod1() );
+ pView->ForceMarkedToAnotherPage();
+ }
+ else
+ if (pView->IsAction() )
+ {
+ pView->EndAction();
+ //if( bMarkAction )
+ //pParent->UnmarkDialog();
+ }
+ }
+
+// USHORT nClicks = rMEvt.GetClicks();
+// if (nClicks == 2)
+// {
+// if ( pView->AreObjectsMarked() )
+// {
+// const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+//
+// if (rMarkList.GetMarkCount() == 1)
+// {
+// SdrMark* pMark = rMarkList.GetMark(0);
+// SdrObject* pObj = pMark->GetMarkedSdrObj();
+//
+// // edit objects here
+// }
+// }
+// }
+
+ bMarkAction = FALSE;
+
+ pWindow->SetPointer( pView->GetPreferedPointer( aPnt, pWindow, nHitLog ) );
+ pWindow->ReleaseMouse();
+
+ return TRUE;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL DlgEdFuncSelect::MouseMove( const MouseEvent& rMEvt )
+{
+ SdrView* pView = pParent->GetView();
+ Window* pWindow= pParent->GetWindow();
+ pView->SetActualWin( pWindow );
+
+ Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ USHORT nHitLog = USHORT ( pWindow->PixelToLogic(Size(3,0)).Width() );
+
+ if ( pView->IsAction() )
+ {
+ Point aPix(rMEvt.GetPosPixel());
+ Point aPnt_(pWindow->PixelToLogic(aPix));
+
+ ForceScroll(aPnt_);
+ pView->MovAction(aPnt_);
+ }
+
+ pWindow->SetPointer( pView->GetPreferedPointer( aPnt, pWindow, nHitLog ) );
+
+ return TRUE;
+}
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedlist.cxx b/basctl/source/dlged/dlgedlist.cxx
new file mode 100644
index 000000000000..41fa01b262c8
--- /dev/null
+++ b/basctl/source/dlged/dlgedlist.cxx
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+#include "dlgedlist.hxx"
+#include "dlgedobj.hxx"
+
+//============================================================================
+// DlgEdPropListenerImpl
+//============================================================================
+
+//----------------------------------------------------------------------------
+
+DlgEdPropListenerImpl::DlgEdPropListenerImpl(DlgEdObj* pObj)
+ :pDlgEdObj(pObj)
+{
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdPropListenerImpl::~DlgEdPropListenerImpl()
+{
+}
+
+// XEventListener
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdPropListenerImpl::disposing( const ::com::sun::star::lang::EventObject& ) throw( ::com::sun::star::uno::RuntimeException)
+{
+ /*
+ // disconnect the listener
+ if (pDlgEdObj)
+ {
+ (pDlgEdObj->m_xPropertyChangeListener).clear();
+ }
+ */
+}
+
+// XPropertyChangeListener
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdPropListenerImpl::propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException)
+{
+ pDlgEdObj->_propertyChange( evt );
+}
+
+//----------------------------------------------------------------------------
+
+//============================================================================
+// DlgEdEvtContListenerImpl
+//============================================================================
+
+//----------------------------------------------------------------------------
+
+DlgEdEvtContListenerImpl::DlgEdEvtContListenerImpl(DlgEdObj* pObj)
+ :pDlgEdObj(pObj)
+{
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdEvtContListenerImpl::~DlgEdEvtContListenerImpl()
+{
+}
+
+// XEventListener
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdEvtContListenerImpl::disposing( const ::com::sun::star::lang::EventObject& ) throw( ::com::sun::star::uno::RuntimeException)
+{
+ /*
+ // disconnect the listener
+ if (pDlgEdObj)
+ {
+ (pDlgEdObj->m_xContainerListener).clear();
+ }
+ */
+}
+
+// XContainerListener
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdEvtContListenerImpl::elementInserted(const ::com::sun::star::container::ContainerEvent& Event) throw(::com::sun::star::uno::RuntimeException)
+{
+ pDlgEdObj->_elementInserted( Event );
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdEvtContListenerImpl::elementReplaced(const ::com::sun::star::container::ContainerEvent& Event) throw(::com::sun::star::uno::RuntimeException)
+{
+ pDlgEdObj->_elementReplaced( Event );
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdEvtContListenerImpl::elementRemoved(const ::com::sun::star::container::ContainerEvent& Event) throw(::com::sun::star::uno::RuntimeException)
+{
+ pDlgEdObj->_elementRemoved( Event );
+}
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedmod.cxx b/basctl/source/dlged/dlgedmod.cxx
new file mode 100644
index 000000000000..ceb5555a1bc2
--- /dev/null
+++ b/basctl/source/dlged/dlgedmod.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include "dlgedmod.hxx"
+#include "dlgedpage.hxx"
+#include <tools/debug.hxx>
+
+
+DBG_NAME(DlgEdModel)
+
+TYPEINIT1(DlgEdModel,SdrModel);
+
+//----------------------------------------------------------------------------
+
+DlgEdModel::DlgEdModel()
+ :SdrModel(NULL, NULL)
+{
+ DBG_CTOR(DlgEdModel,0);
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdModel::~DlgEdModel()
+{
+ DBG_DTOR(DlgEdModel,0);
+}
+
+//----------------------------------------------------------------------------
+
+SdrPage* DlgEdModel::AllocPage(bool bMasterPage)
+{
+ DBG_CHKTHIS(DlgEdModel, 0);
+ return new DlgEdPage(*this, bMasterPage);
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdModel::DlgEdModelChanged(bool bChanged )
+{
+ SetChanged( bChanged );
+}
+
+//----------------------------------------------------------------------------
+
+Window* DlgEdModel::GetCurDocViewWin()
+{
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
new file mode 100644
index 000000000000..769290fe0690
--- /dev/null
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -0,0 +1,1896 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include <vector>
+#include <algorithm>
+#include <dlgeddef.hxx>
+#include "dlgedobj.hxx"
+#include "dlged.hxx"
+#include "dlgedmod.hxx"
+#include "dlgedpage.hxx"
+#include "dlgedview.hxx"
+#include "dlgedlist.hxx"
+#include <iderid.hxx>
+#include <localizationmgr.hxx>
+
+#include <dlgresid.hrc>
+#include <tools/resmgr.hxx>
+#include <tools/shl.hxx>
+#include <unotools/sharedunocomponent.hxx>
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <com/sun/star/awt/XUnoControlContainer.hpp>
+#include <com/sun/star/awt/XVclContainerPeer.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/script/XScriptEventsSupplier.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/types.hxx>
+#include <vcl/svapp.hxx>
+
+#include <algorithm>
+#include <functional>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::script;
+using ::rtl::OUString;
+
+
+TYPEINIT1(DlgEdObj, SdrUnoObj);
+DBG_NAME(DlgEdObj);
+
+//----------------------------------------------------------------------------
+
+DlgEdObj::DlgEdObj()
+ :SdrUnoObj(String(), sal_False)
+ ,bIsListening(sal_False)
+ ,pDlgEdForm( NULL )
+{
+ DBG_CTOR(DlgEdObj, NULL);
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdObj::DlgEdObj(const ::rtl::OUString& rModelName,
+ const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSFac)
+ :SdrUnoObj(rModelName, rxSFac, sal_False)
+ ,bIsListening(sal_False)
+ ,pDlgEdForm( NULL )
+{
+ DBG_CTOR(DlgEdObj, NULL);
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdObj::~DlgEdObj()
+{
+ DBG_DTOR(DlgEdObj, NULL);
+
+ if ( isListening() )
+ EndListening();
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::SetPage(SdrPage* _pNewPage)
+{
+ // now set the page
+ SdrUnoObj::SetPage(_pNewPage);
+}
+
+//----------------------------------------------------------------------------
+
+namespace
+{
+ /** returns the DlgEdForm which the given DlgEdObj belongs to
+ (which might in fact be the object itself)
+
+ Failure to obtain the form will be reported with an assertion in the non-product
+ version.
+ */
+ bool lcl_getDlgEdForm( DlgEdObj* _pObject, DlgEdForm*& _out_pDlgEdForm )
+ {
+ _out_pDlgEdForm = dynamic_cast< DlgEdForm* >( _pObject );
+ if ( !_out_pDlgEdForm )
+ _out_pDlgEdForm = _pObject->GetDlgEdForm();
+ DBG_ASSERT( _out_pDlgEdForm, "lcl_getDlgEdForm: no form!" );
+ return ( _out_pDlgEdForm != NULL );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+uno::Reference< awt::XControl > DlgEdObj::GetControl() const
+{
+ const DlgEdForm* pForm = GetDlgEdForm();
+ const DlgEditor* pEditor = pForm ? pForm->GetDlgEditor() : NULL;
+ SdrView* pView = pEditor ? pEditor->GetView() : NULL;
+ Window* pWindow = pEditor ? pEditor->GetWindow() : NULL;
+ OSL_ENSURE( ( pView && pWindow ) || !pForm, "DlgEdObj::GetControl: no view or no window!" );
+
+ uno::Reference< awt::XControl > xControl;
+ if ( pView && pWindow )
+ xControl = GetUnoControl( *pView, *pWindow );
+
+ return xControl;
+}
+
+//----------------------------------------------------------------------------
+
+bool DlgEdObj::TransformSdrToControlCoordinates(
+ sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
+ sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut )
+{
+ // input position and size
+ Size aPos( nXIn, nYIn );
+ Size aSize( nWidthIn, nHeightIn );
+
+ // form position
+ DlgEdForm* pForm = NULL;
+ if ( !lcl_getDlgEdForm( this, pForm ) )
+ return false;
+ Rectangle aFormRect = pForm->GetSnapRect();
+ Size aFormPos( aFormRect.Left(), aFormRect.Top() );
+
+ // convert 100th_mm to pixel
+ OutputDevice* pDevice = Application::GetDefaultDevice();
+ DBG_ASSERT( pDevice, "DlgEdObj::TransformSdrToControlCoordinates: missing default device!" );
+ if ( !pDevice )
+ return false;
+ aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_100TH_MM ) );
+ aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) );
+ aFormPos = pDevice->LogicToPixel( aFormPos, MapMode( MAP_100TH_MM ) );
+
+ // subtract form position
+ aPos.Width() -= aFormPos.Width();
+ aPos.Height() -= aFormPos.Height();
+
+ // take window borders into account
+ Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY );
+ DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformFormToSdrCoordinates: no form property set!" );
+ if ( !xPSetForm.is() )
+ return false;
+ bool bDecoration = true;
+ xPSetForm->getPropertyValue( DLGED_PROP_DECORATION ) >>= bDecoration;
+ if( bDecoration )
+ {
+ awt::DeviceInfo aDeviceInfo = pForm->getDeviceInfo();
+ aPos.Width() -= aDeviceInfo.LeftInset;
+ aPos.Height() -= aDeviceInfo.TopInset;
+ }
+
+ // convert pixel to logic units
+ aPos = pDevice->PixelToLogic( aPos, MAP_APPFONT );
+ aSize = pDevice->PixelToLogic( aSize, MAP_APPFONT );
+
+ // set out parameters
+ nXOut = aPos.Width();
+ nYOut = aPos.Height();
+ nWidthOut = aSize.Width();
+ nHeightOut = aSize.Height();
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+bool DlgEdObj::TransformSdrToFormCoordinates(
+ sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
+ sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut )
+{
+ // input position and size
+ Size aPos( nXIn, nYIn );
+ Size aSize( nWidthIn, nHeightIn );
+
+ // convert 100th_mm to pixel
+ OutputDevice* pDevice = Application::GetDefaultDevice();
+ DBG_ASSERT( pDevice, "DlgEdObj::TransformSdrToFormCoordinates: missing default device!" );
+ if ( !pDevice )
+ return false;
+ aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_100TH_MM ) );
+ aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) );
+
+ // take window borders into account
+ DlgEdForm* pForm = NULL;
+ if ( !lcl_getDlgEdForm( this, pForm ) )
+ return false;
+
+ // take window borders into account
+ Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY );
+ DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformFormToSdrCoordinates: no form property set!" );
+ if ( !xPSetForm.is() )
+ return false;
+ bool bDecoration = true;
+ xPSetForm->getPropertyValue( DLGED_PROP_DECORATION ) >>= bDecoration;
+ if( bDecoration )
+ {
+ awt::DeviceInfo aDeviceInfo = pForm->getDeviceInfo();
+ aSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
+ aSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
+ }
+ // convert pixel to logic units
+ aPos = pDevice->PixelToLogic( aPos, MAP_APPFONT );
+ aSize = pDevice->PixelToLogic( aSize, MAP_APPFONT );
+
+ // set out parameters
+ nXOut = aPos.Width();
+ nYOut = aPos.Height();
+ nWidthOut = aSize.Width();
+ nHeightOut = aSize.Height();
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+bool DlgEdObj::TransformControlToSdrCoordinates(
+ sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
+ sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut )
+{
+ // input position and size
+ Size aPos( nXIn, nYIn );
+ Size aSize( nWidthIn, nHeightIn );
+
+ // form position
+ DlgEdForm* pForm = NULL;
+ if ( !lcl_getDlgEdForm( this, pForm ) )
+ return false;
+
+ Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY );
+ DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformControlToSdrCoordinates: no form property set!" );
+ if ( !xPSetForm.is() )
+ return false;
+ sal_Int32 nFormX = 0, nFormY = 0, nFormWidth, nFormHeight;
+ xPSetForm->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nFormX;
+ xPSetForm->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nFormY;
+ xPSetForm->getPropertyValue( DLGED_PROP_WIDTH ) >>= nFormWidth;
+ xPSetForm->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nFormHeight;
+ Size aFormPos( nFormX, nFormY );
+
+ // convert logic units to pixel
+ OutputDevice* pDevice = Application::GetDefaultDevice();
+ DBG_ASSERT( pDevice, "DlgEdObj::TransformControlToSdrCoordinates: missing default device!" );
+ if ( !pDevice )
+ return false;
+ aPos = pDevice->LogicToPixel( aPos, MAP_APPFONT );
+ aSize = pDevice->LogicToPixel( aSize, MAP_APPFONT );
+ aFormPos = pDevice->LogicToPixel( aFormPos, MAP_APPFONT );
+
+ // add form position
+ aPos.Width() += aFormPos.Width();
+ aPos.Height() += aFormPos.Height();
+
+ // take window borders into account
+ bool bDecoration = true;
+ xPSetForm->getPropertyValue( DLGED_PROP_DECORATION ) >>= bDecoration;
+ if( bDecoration )
+ {
+ awt::DeviceInfo aDeviceInfo = pForm->getDeviceInfo();
+ aPos.Width() += aDeviceInfo.LeftInset;
+ aPos.Height() += aDeviceInfo.TopInset;
+ }
+
+ // convert pixel to 100th_mm
+ aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_100TH_MM ) );
+ aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_100TH_MM ) );
+
+ // set out parameters
+ nXOut = aPos.Width();
+ nYOut = aPos.Height();
+ nWidthOut = aSize.Width();
+ nHeightOut = aSize.Height();
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+bool DlgEdObj::TransformFormToSdrCoordinates(
+ sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
+ sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut )
+{
+ // input position and size
+ Size aPos( nXIn, nYIn );
+ Size aSize( nWidthIn, nHeightIn );
+
+ // convert logic units to pixel
+ OutputDevice* pDevice = Application::GetDefaultDevice();
+ DBG_ASSERT( pDevice, "DlgEdObj::TransformFormToSdrCoordinates: missing default device!" );
+ if ( !pDevice )
+ return false;
+
+ // take window borders into account
+ DlgEdForm* pForm = NULL;
+ if ( !lcl_getDlgEdForm( this, pForm ) )
+ return false;
+
+ aPos = pDevice->LogicToPixel( aPos, MAP_APPFONT );
+ aSize = pDevice->LogicToPixel( aSize, MAP_APPFONT );
+
+ // take window borders into account
+ Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY );
+ DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformFormToSdrCoordinates: no form property set!" );
+ if ( !xPSetForm.is() )
+ return false;
+ bool bDecoration = true;
+ xPSetForm->getPropertyValue( DLGED_PROP_DECORATION ) >>= bDecoration;
+ if( bDecoration )
+ {
+ awt::DeviceInfo aDeviceInfo = pForm->getDeviceInfo();
+ aSize.Width() += aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
+ aSize.Height() += aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
+ }
+
+ // convert pixel to 100th_mm
+ aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_100TH_MM ) );
+ aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_100TH_MM ) );
+
+ // set out parameters
+ nXOut = aPos.Width();
+ nYOut = aPos.Height();
+ nWidthOut = aSize.Width();
+ nHeightOut = aSize.Height();
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::SetRectFromProps()
+{
+ // get control position and size from properties
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ sal_Int32 nXIn = 0, nYIn = 0, nWidthIn = 0, nHeightIn = 0;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nXIn;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nYIn;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidthIn;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeightIn;
+
+ // transform coordinates
+ sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
+ if ( TransformControlToSdrCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
+ {
+ // set rectangle position and size
+ Point aPoint( nXOut, nYOut );
+ Size aSize( nWidthOut, nHeightOut );
+ SetSnapRect( Rectangle( aPoint, aSize ) );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::SetPropsFromRect()
+{
+ // get control position and size from rectangle
+ Rectangle aRect_ = GetSnapRect();
+ sal_Int32 nXIn = aRect_.Left();
+ sal_Int32 nYIn = aRect_.Top();
+ sal_Int32 nWidthIn = aRect_.GetWidth();
+ sal_Int32 nHeightIn = aRect_.GetHeight();
+
+ // transform coordinates
+ sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
+ if ( TransformSdrToControlCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
+ {
+ // set properties
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ Any aValue;
+ aValue <<= nXOut;
+ xPSet->setPropertyValue( DLGED_PROP_POSITIONX, aValue );
+ aValue <<= nYOut;
+ xPSet->setPropertyValue( DLGED_PROP_POSITIONY, aValue );
+ aValue <<= nWidthOut;
+ xPSet->setPropertyValue( DLGED_PROP_WIDTH, aValue );
+ aValue <<= nHeightOut;
+ xPSet->setPropertyValue( DLGED_PROP_HEIGHT, aValue );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::PositionAndSizeChange( const beans::PropertyChangeEvent& evt )
+{
+ DlgEdPage* pPage_ = 0;
+ if ( pDlgEdForm )
+ {
+ DlgEditor* pEditor = pDlgEdForm->GetDlgEditor();
+ if ( pEditor )
+ pPage_ = pEditor->GetPage();
+ }
+ DBG_ASSERT( pPage_, "DlgEdObj::PositionAndSizeChange: no page!" );
+ if ( pPage_ )
+ {
+ sal_Int32 nPageXIn = 0;
+ sal_Int32 nPageYIn = 0;
+ Size aPageSize = pPage_->GetSize();
+ sal_Int32 nPageWidthIn = aPageSize.Width();
+ sal_Int32 nPageHeightIn = aPageSize.Height();
+ sal_Int32 nPageX, nPageY, nPageWidth, nPageHeight;
+ if ( TransformSdrToControlCoordinates( nPageXIn, nPageYIn, nPageWidthIn, nPageHeightIn, nPageX, nPageY, nPageWidth, nPageHeight ) )
+ {
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ sal_Int32 nX = 0, nY = 0, nWidth = 0, nHeight = 0;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nX;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nY;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidth;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeight;
+
+ sal_Int32 nValue = 0;
+ evt.NewValue >>= nValue;
+ sal_Int32 nNewValue = nValue;
+
+ if ( evt.PropertyName == DLGED_PROP_POSITIONX )
+ {
+ if ( nNewValue + nWidth > nPageX + nPageWidth )
+ nNewValue = nPageX + nPageWidth - nWidth;
+ if ( nNewValue < nPageX )
+ nNewValue = nPageX;
+ }
+ else if ( evt.PropertyName == DLGED_PROP_POSITIONY )
+ {
+ if ( nNewValue + nHeight > nPageY + nPageHeight )
+ nNewValue = nPageY + nPageHeight - nHeight;
+ if ( nNewValue < nPageY )
+ nNewValue = nPageY;
+ }
+ else if ( evt.PropertyName == DLGED_PROP_WIDTH )
+ {
+ if ( nX + nNewValue > nPageX + nPageWidth )
+ nNewValue = nPageX + nPageWidth - nX;
+ if ( nNewValue < 1 )
+ nNewValue = 1;
+ }
+ else if ( evt.PropertyName == DLGED_PROP_HEIGHT )
+ {
+ if ( nY + nNewValue > nPageY + nPageHeight )
+ nNewValue = nPageY + nPageHeight - nY;
+ if ( nNewValue < 1 )
+ nNewValue = 1;
+ }
+
+ if ( nNewValue != nValue )
+ {
+ Any aNewValue;
+ aNewValue <<= nNewValue;
+ EndListening( sal_False );
+ xPSet->setPropertyValue( evt.PropertyName, aNewValue );
+ StartListening();
+ }
+ }
+ }
+ }
+
+ SetRectFromProps();
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdObj::NameChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException)
+{
+ // get old name
+ ::rtl::OUString aOldName;
+ evt.OldValue >>= aOldName;
+
+ // get new name
+ ::rtl::OUString aNewName;
+ evt.NewValue >>= aNewName;
+
+ if ( !aNewName.equals(aOldName) )
+ {
+ Reference< container::XNameAccess > xNameAcc((GetDlgEdForm()->GetUnoControlModel()), UNO_QUERY);
+ if ( xNameAcc.is() && xNameAcc->hasByName(aOldName) )
+ {
+ if ( !xNameAcc->hasByName(aNewName) && aNewName.getLength() != 0 )
+ {
+ // remove the control by the old name and insert the control by the new name in the container
+ Reference< container::XNameContainer > xCont(xNameAcc, UNO_QUERY );
+ if ( xCont.is() )
+ {
+ Reference< awt::XControlModel > xCtrl(GetUnoControlModel(), UNO_QUERY);
+ Any aAny;
+ aAny <<= xCtrl;
+ xCont->removeByName( aOldName );
+ xCont->insertByName( aNewName , aAny );
+
+ DlgEditor* pEditor;
+ if ( ISA(DlgEdForm) )
+ pEditor = ((DlgEdForm*)this)->GetDlgEditor();
+ else
+ pEditor = GetDlgEdForm()->GetDlgEditor();
+ LocalizationMgr::renameControlResourceIDsForEditorObject( pEditor, aAny, aNewName );
+ }
+ }
+ else
+ {
+ // set old name property
+ EndListening(sal_False);
+ Reference< beans::XPropertySet > xPSet(GetUnoControlModel(), UNO_QUERY);
+ Any aName;
+ aName <<= aOldName;
+ xPSet->setPropertyValue( DLGED_PROP_NAME, aName );
+ StartListening();
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+sal_Int32 DlgEdObj::GetStep() const
+{
+ // get step property
+ sal_Int32 nStep = 0;
+ uno::Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), uno::UNO_QUERY );
+ if (xPSet.is())
+ {
+ xPSet->getPropertyValue( DLGED_PROP_STEP ) >>= nStep;
+ }
+ return nStep;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::UpdateStep()
+{
+ sal_Int32 nCurStep = GetDlgEdForm()->GetStep();
+ sal_Int32 nStep = GetStep();
+
+ SdrLayerAdmin& rLayerAdmin = GetModel()->GetLayerAdmin();
+ SdrLayerID nHiddenLayerId = rLayerAdmin.GetLayerID( String( RTL_CONSTASCII_USTRINGPARAM( "HiddenLayer" ) ), FALSE );
+ SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID( rLayerAdmin.GetControlLayerName(), sal_False );
+
+ if( nCurStep )
+ {
+ if ( nStep && (nStep != nCurStep) )
+ {
+ SetLayer( nHiddenLayerId );
+ }
+ else
+ {
+ SetLayer( nControlLayerId );
+ }
+ }
+ else
+ {
+ SetLayer( nControlLayerId );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::TabIndexChange( const beans::PropertyChangeEvent& evt ) throw (RuntimeException)
+{
+ DlgEdForm* pForm = GetDlgEdForm();
+ if ( pForm )
+ {
+ // stop listening with all children
+ ::std::vector<DlgEdObj*> aChildList = pForm->GetChilds();
+ ::std::vector<DlgEdObj*>::iterator aIter;
+ for ( aIter = aChildList.begin() ; aIter != aChildList.end() ; ++aIter )
+ {
+ (*aIter)->EndListening( sal_False );
+ }
+
+ Reference< container::XNameAccess > xNameAcc( pForm->GetUnoControlModel() , UNO_QUERY );
+ if ( xNameAcc.is() )
+ {
+ // get sequence of control names
+ Sequence< ::rtl::OUString > aNames = xNameAcc->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+ sal_Int16 i;
+
+ // create a map of tab indices and control names, sorted by tab index
+ IndexToNameMap aIndexToNameMap;
+ for ( i = 0; i < nCtrls; ++i )
+ {
+ // get control name
+ ::rtl::OUString aName( pNames[i] );
+
+ // get tab index
+ sal_Int16 nTabIndex = -1;
+ Any aCtrl = xNameAcc->getByName( aName );
+ Reference< beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if ( xPSet.is() && xPSet == Reference< beans::XPropertySet >( evt.Source, UNO_QUERY ) )
+ evt.OldValue >>= nTabIndex;
+ else if ( xPSet.is() )
+ xPSet->getPropertyValue( DLGED_PROP_TABINDEX ) >>= nTabIndex;
+
+ // insert into map
+ aIndexToNameMap.insert( IndexToNameMap::value_type( nTabIndex, aName ) );
+ }
+
+ // create a helper list of control names, sorted by tab index
+ ::std::vector< ::rtl::OUString > aNameList( aIndexToNameMap.size() );
+ ::std::transform(
+ aIndexToNameMap.begin(), aIndexToNameMap.end(),
+ aNameList.begin(),
+ ::std::select2nd< IndexToNameMap::value_type >( )
+ );
+
+ // check tab index
+ sal_Int16 nOldTabIndex = 0;
+ evt.OldValue >>= nOldTabIndex;
+ sal_Int16 nNewTabIndex = 0;
+ evt.NewValue >>= nNewTabIndex;
+ if ( nNewTabIndex < 0 )
+ nNewTabIndex = 0;
+ else if ( nNewTabIndex > nCtrls - 1 )
+ nNewTabIndex = sal::static_int_cast<sal_Int16>( nCtrls - 1 );
+
+ // reorder helper list
+ ::rtl::OUString aCtrlName = aNameList[nOldTabIndex];
+ aNameList.erase( aNameList.begin() + nOldTabIndex );
+ aNameList.insert( aNameList.begin() + nNewTabIndex , aCtrlName );
+
+ // set new tab indices
+ for ( i = 0; i < nCtrls; ++i )
+ {
+ Any aCtrl = xNameAcc->getByName( aNameList[i] );
+ Reference< beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if ( xPSet.is() )
+ {
+ Any aTabIndex;
+ aTabIndex <<= (sal_Int16) i;
+ xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
+ }
+ }
+
+ // reorder objects in drawing page
+ GetModel()->GetPage(0)->SetObjectOrdNum( nOldTabIndex + 1, nNewTabIndex + 1 );
+
+ // #110559#
+ pForm->UpdateTabOrderAndGroups();
+ }
+
+ // start listening with all children
+ for ( aIter = aChildList.begin() ; aIter != aChildList.end() ; ++aIter )
+ {
+ (*aIter)->StartListening();
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdObj::supportsService( const sal_Char* _pServiceName ) const
+{
+ sal_Bool bSupports = sal_False;
+
+ Reference< lang::XServiceInfo > xServiceInfo( GetUnoControlModel() , UNO_QUERY );
+ // TODO: cache xServiceInfo as member?
+ if ( xServiceInfo.is() )
+ bSupports = xServiceInfo->supportsService( ::rtl::OUString::createFromAscii( _pServiceName ) );
+
+ return bSupports;
+}
+
+//----------------------------------------------------------------------------
+
+::rtl::OUString DlgEdObj::GetDefaultName() const
+{
+ sal_uInt16 nResId = 0;
+ ::rtl::OUString aDefaultName;
+ if ( supportsService( "com.sun.star.awt.UnoControlDialogModel" ) )
+ {
+ nResId = RID_STR_CLASS_DIALOG;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlButtonModel" ) )
+ {
+ nResId = RID_STR_CLASS_BUTTON;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ) )
+ {
+ nResId = RID_STR_CLASS_RADIOBUTTON;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" ) )
+ {
+ nResId = RID_STR_CLASS_CHECKBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlListBoxModel" ) )
+ {
+ nResId = RID_STR_CLASS_LISTBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlComboBoxModel" ) )
+ {
+ nResId = RID_STR_CLASS_COMBOBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" ) )
+ {
+ nResId = RID_STR_CLASS_GROUPBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlEditModel" ) )
+ {
+ nResId = RID_STR_CLASS_EDIT;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ) )
+ {
+ nResId = RID_STR_CLASS_FIXEDTEXT;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlImageControlModel" ) )
+ {
+ nResId = RID_STR_CLASS_IMAGECONTROL;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlProgressBarModel" ) )
+ {
+ nResId = RID_STR_CLASS_PROGRESSBAR;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlScrollBarModel" ) )
+ {
+ nResId = RID_STR_CLASS_SCROLLBAR;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFixedLineModel" ) )
+ {
+ nResId = RID_STR_CLASS_FIXEDLINE;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlDateFieldModel" ) )
+ {
+ nResId = RID_STR_CLASS_DATEFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlTimeFieldModel" ) )
+ {
+ nResId = RID_STR_CLASS_TIMEFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlNumericFieldModel" ) )
+ {
+ nResId = RID_STR_CLASS_NUMERICFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlCurrencyFieldModel" ) )
+ {
+ nResId = RID_STR_CLASS_CURRENCYFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFormattedFieldModel" ) )
+ {
+ nResId = RID_STR_CLASS_FORMATTEDFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlPatternFieldModel" ) )
+ {
+ nResId = RID_STR_CLASS_PATTERNFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFileControlModel" ) )
+ {
+ nResId = RID_STR_CLASS_FILECONTROL;
+ }
+ else if ( supportsService( "com.sun.star.awt.tree.TreeControlModel" ) )
+ {
+ nResId = RID_STR_CLASS_TREECONTROL;
+ }
+
+ else
+ {
+ nResId = RID_STR_CLASS_CONTROL;
+ }
+
+ if (nResId)
+ {
+ aDefaultName = ::rtl::OUString( String(IDEResId(nResId)) );
+ }
+
+ return aDefaultName;
+}
+
+//----------------------------------------------------------------------------
+
+::rtl::OUString DlgEdObj::GetUniqueName() const
+{
+ ::rtl::OUString aUniqueName;
+ uno::Reference< container::XNameAccess > xNameAcc((GetDlgEdForm()->GetUnoControlModel()), uno::UNO_QUERY);
+
+ if ( xNameAcc.is() )
+ {
+ sal_Int32 n = 0;
+ ::rtl::OUString aDefaultName = GetDefaultName();
+
+ do
+ {
+ aUniqueName = aDefaultName + ::rtl::OUString::valueOf(++n);
+ } while (xNameAcc->hasByName(aUniqueName));
+ }
+
+ return aUniqueName;
+}
+
+//----------------------------------------------------------------------------
+
+sal_uInt32 DlgEdObj::GetObjInventor() const
+{
+ return DlgInventor;
+}
+
+//----------------------------------------------------------------------------
+
+sal_uInt16 DlgEdObj::GetObjIdentifier() const
+{
+ if ( supportsService( "com.sun.star.awt.UnoControlDialogModel" ))
+ {
+ return OBJ_DLG_DIALOG;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlButtonModel" ))
+ {
+ return OBJ_DLG_PUSHBUTTON;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ))
+ {
+ return OBJ_DLG_RADIOBUTTON;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" ))
+ {
+ return OBJ_DLG_CHECKBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlListBoxModel" ))
+ {
+ return OBJ_DLG_LISTBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlComboBoxModel" ))
+ {
+ return OBJ_DLG_COMBOBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" ))
+ {
+ return OBJ_DLG_GROUPBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlEditModel" ))
+ {
+ return OBJ_DLG_EDIT;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ))
+ {
+ return OBJ_DLG_FIXEDTEXT;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlImageControlModel" ))
+ {
+ return OBJ_DLG_IMAGECONTROL;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlProgressBarModel" ))
+ {
+ return OBJ_DLG_PROGRESSBAR;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlScrollBarModel" ))
+ {
+ return OBJ_DLG_HSCROLLBAR;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFixedLineModel" ))
+ {
+ return OBJ_DLG_HFIXEDLINE;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlDateFieldModel" ))
+ {
+ return OBJ_DLG_DATEFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlTimeFieldModel" ))
+ {
+ return OBJ_DLG_TIMEFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlNumericFieldModel" ))
+ {
+ return OBJ_DLG_NUMERICFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlCurrencyFieldModel" ))
+ {
+ return OBJ_DLG_CURRENCYFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFormattedFieldModel" ))
+ {
+ return OBJ_DLG_FORMATTEDFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlPatternFieldModel" ))
+ {
+ return OBJ_DLG_PATTERNFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFileControlModel" ))
+ {
+ return OBJ_DLG_FILECONTROL;
+ }
+ else if ( supportsService( "com.sun.star.awt.tree.TreeControlModel" ))
+ {
+ return OBJ_DLG_TREECONTROL;
+ }
+ else
+ {
+ return OBJ_DLG_CONTROL;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::clonedFrom(const DlgEdObj* _pSource)
+{
+ // set parent form
+ pDlgEdForm = _pSource->pDlgEdForm;
+
+ // add child to parent form
+ pDlgEdForm->AddChild( this );
+
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ // set new name
+ ::rtl::OUString aOUniqueName( GetUniqueName() );
+ Any aUniqueName;
+ aUniqueName <<= aOUniqueName;
+ xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName );
+
+ Reference< container::XNameContainer > xCont( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY );
+ if ( xCont.is() )
+ {
+ // set tabindex
+ Sequence< OUString > aNames = xCont->getElementNames();
+ Any aTabIndex;
+ aTabIndex <<= (sal_Int16) aNames.getLength();
+ xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
+
+ // insert control model in dialog model
+ Reference< awt::XControlModel > xCtrl( xPSet , UNO_QUERY );
+ Any aCtrl;
+ aCtrl <<= xCtrl;
+ xCont->insertByName( aOUniqueName , aCtrl );
+
+ // #110559#
+ pDlgEdForm->UpdateTabOrderAndGroups();
+ }
+ }
+
+ // start listening
+ StartListening();
+}
+
+//----------------------------------------------------------------------------
+
+SdrObject* DlgEdObj::Clone() const
+{
+ SdrObject* pReturn = SdrUnoObj::Clone();
+
+ DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pReturn);
+ DBG_ASSERT( pDlgEdObj != NULL, "DlgEdObj::Clone: invalid clone!" );
+ if ( pDlgEdObj )
+ pDlgEdObj->clonedFrom( this );
+
+ return pReturn;
+}
+
+//----------------------------------------------------------------------------
+
+SdrObject* DlgEdObj::getFullDragClone() const
+{
+ // no need to really add the clone for dragging, it's a temporary
+ // object
+ SdrObject* pObj = new SdrUnoObj(String());
+ *pObj = *((const SdrUnoObj*)this);
+
+ return pObj;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::operator= (const SdrObject& rObj)
+{
+ SdrUnoObj::operator= (rObj);
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::NbcMove( const Size& rSize )
+{
+ SdrUnoObj::NbcMove( rSize );
+
+ // stop listening
+ EndListening(sal_False);
+
+ // set geometry properties
+ SetPropsFromRect();
+
+ // start listening
+ StartListening();
+
+ // dialog model changed
+ GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(TRUE);
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
+{
+ SdrUnoObj::NbcResize( rRef, xFract, yFract );
+
+ // stop listening
+ EndListening(sal_False);
+
+ // set geometry properties
+ SetPropsFromRect();
+
+ // start listening
+ StartListening();
+
+ // dialog model changed
+ GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(TRUE);
+}
+
+//----------------------------------------------------------------------------
+
+bool DlgEdObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
+
+ SetDefaults();
+ StartListening();
+
+ return bResult;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::SetDefaults()
+{
+ // set parent form
+ pDlgEdForm = ((DlgEdPage*)GetPage())->GetDlgEdForm();
+
+ if ( pDlgEdForm )
+ {
+ // add child to parent form
+ pDlgEdForm->AddChild( this );
+
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ // get unique name
+ ::rtl::OUString aOUniqueName( GetUniqueName() );
+
+ // set name property
+ Any aUniqueName;
+ aUniqueName <<= aOUniqueName;
+ xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName );
+
+ // set labels
+ if ( supportsService( "com.sun.star.awt.UnoControlButtonModel" ) ||
+ supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ) ||
+ supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" ) ||
+ supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" ) ||
+ supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ) )
+ {
+ xPSet->setPropertyValue( DLGED_PROP_LABEL, aUniqueName );
+ }
+
+ // set number formats supplier for formatted field
+ if ( supportsService( "com.sun.star.awt.UnoControlFormattedFieldModel" ) )
+ {
+ Reference< util::XNumberFormatsSupplier > xSupplier = GetDlgEdForm()->GetDlgEditor()->GetNumberFormatsSupplier();
+ if ( xSupplier.is() )
+ {
+ Any aSupplier;
+ aSupplier <<= xSupplier;
+ xPSet->setPropertyValue( DLGED_PROP_FORMATSSUPPLIER, aSupplier );
+ }
+ }
+
+ // set geometry properties
+ SetPropsFromRect();
+
+ Reference< container::XNameContainer > xCont( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY );
+ if ( xCont.is() )
+ {
+ // set tabindex
+ Sequence< OUString > aNames = xCont->getElementNames();
+ uno::Any aTabIndex;
+ aTabIndex <<= (sal_Int16) aNames.getLength();
+ xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
+
+ // set step
+ Reference< beans::XPropertySet > xPSetForm( xCont, UNO_QUERY );
+ if ( xPSetForm.is() )
+ {
+ Any aStep = xPSetForm->getPropertyValue( DLGED_PROP_STEP );
+ xPSet->setPropertyValue( DLGED_PROP_STEP, aStep );
+ }
+
+ // insert control model in dialog model
+ Reference< awt::XControlModel > xCtrl( xPSet , UNO_QUERY );
+ Any aAny;
+ aAny <<= xCtrl;
+ xCont->insertByName( aOUniqueName , aAny );
+
+ DlgEditor* pEditor;
+ if ( ISA(DlgEdForm) )
+ pEditor = ((DlgEdForm*)this)->GetDlgEditor();
+ else
+ pEditor = GetDlgEdForm()->GetDlgEditor();
+ LocalizationMgr::setControlResourceIDsForNewEditorObject( pEditor, aAny, aOUniqueName );
+
+ // #110559#
+ pDlgEdForm->UpdateTabOrderAndGroups();
+ }
+ }
+
+ // dialog model changed
+ pDlgEdForm->GetDlgEditor()->SetDialogModelChanged( TRUE );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK(DlgEdObj, OnCreate, void*, EMPTYTAG)
+{
+ (void)EMPTYTAG;
+ /*
+ if (pTempView)
+ pTempView->ObjectCreated(this);
+ */
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::StartListening()
+{
+ DBG_ASSERT(!isListening(), "DlgEdObj::StartListening: already listening!");
+
+ if (!isListening())
+ {
+ bIsListening = sal_True;
+
+ // XPropertyChangeListener
+ Reference< XPropertySet > xControlModel( GetUnoControlModel() , UNO_QUERY );
+ if (!m_xPropertyChangeListener.is() && xControlModel.is())
+ {
+ // create listener
+ m_xPropertyChangeListener = static_cast< ::com::sun::star::beans::XPropertyChangeListener*>( new DlgEdPropListenerImpl( (DlgEdObj*)this ) );
+
+ // register listener to properties
+ xControlModel->addPropertyChangeListener( ::rtl::OUString() , m_xPropertyChangeListener );
+ }
+
+ // XContainerListener
+ Reference< XScriptEventsSupplier > xEventsSupplier( GetUnoControlModel() , UNO_QUERY );
+ if( !m_xContainerListener.is() && xEventsSupplier.is() )
+ {
+ // create listener
+ m_xContainerListener = static_cast< ::com::sun::star::container::XContainerListener*>( new DlgEdEvtContListenerImpl( (DlgEdObj*)this ) );
+
+ // register listener to script event container
+ Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
+ DBG_ASSERT(xEventCont.is(), "DlgEdObj::StartListening: control model has no script event container!");
+ Reference< XContainer > xCont( xEventCont , UNO_QUERY );
+ if (xCont.is())
+ xCont->addContainerListener( m_xContainerListener );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::EndListening(sal_Bool bRemoveListener)
+{
+ DBG_ASSERT(isListening(), "DlgEdObj::EndListening: not listening currently!");
+
+ if (isListening())
+ {
+ bIsListening = sal_False;
+
+ if (bRemoveListener)
+ {
+ // XPropertyChangeListener
+ Reference< XPropertySet > xControlModel(GetUnoControlModel(), UNO_QUERY);
+ if ( m_xPropertyChangeListener.is() && xControlModel.is() )
+ {
+ // remove listener
+ xControlModel->removePropertyChangeListener( ::rtl::OUString() , m_xPropertyChangeListener );
+ }
+ m_xPropertyChangeListener.clear();
+
+ // XContainerListener
+ Reference< XScriptEventsSupplier > xEventsSupplier( GetUnoControlModel() , UNO_QUERY );
+ if( m_xContainerListener.is() && xEventsSupplier.is() )
+ {
+ // remove listener
+ Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
+ DBG_ASSERT(xEventCont.is(), "DlgEdObj::EndListening: control model has no script event container!");
+ Reference< XContainer > xCont( xEventCont , UNO_QUERY );
+ if (xCont.is())
+ xCont->removeContainerListener( m_xContainerListener );
+ }
+ m_xContainerListener.clear();
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdObj::_propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException)
+{
+ if (isListening())
+ {
+ DlgEdForm* pRealDlgEdForm = dynamic_cast< DlgEdForm* >(this);
+ if( pRealDlgEdForm == 0 )
+ pRealDlgEdForm = GetDlgEdForm();
+
+ DlgEditor* pDlgEditor = pRealDlgEdForm ? pRealDlgEdForm->GetDlgEditor() : 0;
+
+ if( !pDlgEditor || pDlgEditor->isInPaint() )
+ return;
+
+ // dialog model changed
+ pDlgEditor->SetDialogModelChanged(TRUE);
+
+ // update position and size
+ if ( evt.PropertyName == DLGED_PROP_POSITIONX || evt.PropertyName == DLGED_PROP_POSITIONY ||
+ evt.PropertyName == DLGED_PROP_WIDTH || evt.PropertyName == DLGED_PROP_HEIGHT ||
+ evt.PropertyName == DLGED_PROP_DECORATION )
+ {
+ PositionAndSizeChange( evt );
+
+ if ( evt.PropertyName == DLGED_PROP_DECORATION )
+ {
+ if ( ISA(DlgEdForm) )
+ ((DlgEdForm*)this)->GetDlgEditor()->ResetDialog();
+ else
+ GetDlgEdForm()->GetDlgEditor()->ResetDialog();
+ }
+ }
+ // change name of control in dialog model
+ else if ( evt.PropertyName == DLGED_PROP_NAME )
+ {
+ if ( !ISA(DlgEdForm) )
+ {
+ NameChange(evt);
+ }
+ }
+ // update step
+ else if ( evt.PropertyName == DLGED_PROP_STEP )
+ {
+ UpdateStep();
+ }
+ // change tabindex
+ else if ( evt.PropertyName == DLGED_PROP_TABINDEX )
+ {
+ if ( !ISA(DlgEdForm) )
+ {
+ TabIndexChange(evt);
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdObj::_elementInserted(const ::com::sun::star::container::ContainerEvent& ) throw(::com::sun::star::uno::RuntimeException)
+{
+ if (isListening())
+ {
+ // dialog model changed
+ if ( ISA(DlgEdForm) )
+ {
+ ((DlgEdForm*)this)->GetDlgEditor()->SetDialogModelChanged(TRUE);
+ }
+ else
+ {
+ GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(TRUE);
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdObj::_elementReplaced(const ::com::sun::star::container::ContainerEvent& ) throw(::com::sun::star::uno::RuntimeException)
+{
+ if (isListening())
+ {
+ // dialog model changed
+ if ( ISA(DlgEdForm) )
+ {
+ ((DlgEdForm*)this)->GetDlgEditor()->SetDialogModelChanged(TRUE);
+ }
+ else
+ {
+ GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(TRUE);
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdObj::_elementRemoved(const ::com::sun::star::container::ContainerEvent& ) throw(::com::sun::star::uno::RuntimeException)
+{
+ if (isListening())
+ {
+ // dialog model changed
+ if ( ISA(DlgEdForm) )
+ {
+ ((DlgEdForm*)this)->GetDlgEditor()->SetDialogModelChanged(TRUE);
+ }
+ else
+ {
+ GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(TRUE);
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::SetLayer(SdrLayerID nLayer)
+{
+ SdrLayerID nOldLayer = GetLayer();
+
+ if ( nLayer != nOldLayer )
+ {
+ SdrUnoObj::SetLayer( nLayer );
+
+ DlgEdHint aHint( DLGED_HINT_LAYERCHANGED, this );
+ GetDlgEdForm()->GetDlgEditor()->Broadcast( aHint );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+TYPEINIT1(DlgEdForm, DlgEdObj);
+DBG_NAME(DlgEdForm);
+
+//----------------------------------------------------------------------------
+
+DlgEdForm::DlgEdForm()
+ :DlgEdObj()
+{
+ DBG_CTOR(DlgEdForm, NULL);
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdForm::~DlgEdForm()
+{
+ DBG_DTOR(DlgEdForm, NULL);
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::SetDlgEditor( DlgEditor* pEditor )
+{
+ pDlgEditor = pEditor;
+ ImplInvalidateDeviceInfo();
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::ImplInvalidateDeviceInfo()
+{
+ mpDeviceInfo.reset();
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::SetRectFromProps()
+{
+ // get form position and size from properties
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ sal_Int32 nXIn = 0, nYIn = 0, nWidthIn = 0, nHeightIn = 0;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nXIn;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nYIn;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidthIn;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeightIn;
+
+ // transform coordinates
+ sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
+ if ( TransformFormToSdrCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
+ {
+ // set rectangle position and size
+ Point aPoint( nXOut, nYOut );
+ Size aSize( nWidthOut, nHeightOut );
+ SetSnapRect( Rectangle( aPoint, aSize ) );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::SetPropsFromRect()
+{
+ // get form position and size from rectangle
+ Rectangle aRect_ = GetSnapRect();
+ sal_Int32 nXIn = aRect_.Left();
+ sal_Int32 nYIn = aRect_.Top();
+ sal_Int32 nWidthIn = aRect_.GetWidth();
+ sal_Int32 nHeightIn = aRect_.GetHeight();
+
+ // transform coordinates
+ sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
+ if ( TransformSdrToFormCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
+ {
+ // set properties
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ Any aValue;
+ aValue <<= nXOut;
+ xPSet->setPropertyValue( DLGED_PROP_POSITIONX, aValue );
+ aValue <<= nYOut;
+ xPSet->setPropertyValue( DLGED_PROP_POSITIONY, aValue );
+ aValue <<= nWidthOut;
+ xPSet->setPropertyValue( DLGED_PROP_WIDTH, aValue );
+ aValue <<= nHeightOut;
+ xPSet->setPropertyValue( DLGED_PROP_HEIGHT, aValue );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::AddChild( DlgEdObj* pDlgEdObj )
+{
+ pChilds.push_back( pDlgEdObj );
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::RemoveChild( DlgEdObj* pDlgEdObj )
+{
+ pChilds.erase( ::std::find( pChilds.begin() , pChilds.end() , pDlgEdObj ) );
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::PositionAndSizeChange( const beans::PropertyChangeEvent& evt )
+{
+ DlgEditor* pEditor = GetDlgEditor();
+ DBG_ASSERT( pEditor, "DlgEdForm::PositionAndSizeChange: no dialog editor!" );
+ if ( pEditor )
+ {
+ DlgEdPage* pPage_ = pEditor->GetPage();
+ DBG_ASSERT( pPage_, "DlgEdForm::PositionAndSizeChange: no page!" );
+ if ( pPage_ )
+ {
+ sal_Int32 nPageXIn = 0;
+ sal_Int32 nPageYIn = 0;
+ Size aPageSize = pPage_->GetSize();
+ sal_Int32 nPageWidthIn = aPageSize.Width();
+ sal_Int32 nPageHeightIn = aPageSize.Height();
+ sal_Int32 nPageX, nPageY, nPageWidth, nPageHeight;
+ if ( TransformSdrToFormCoordinates( nPageXIn, nPageYIn, nPageWidthIn, nPageHeightIn, nPageX, nPageY, nPageWidth, nPageHeight ) )
+ {
+ Reference< beans::XPropertySet > xPSetForm( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSetForm.is() )
+ {
+ sal_Int32 nValue = 0;
+ evt.NewValue >>= nValue;
+ sal_Int32 nNewValue = nValue;
+
+ if ( evt.PropertyName == DLGED_PROP_POSITIONX )
+ {
+ if ( nNewValue < nPageX )
+ nNewValue = nPageX;
+ }
+ else if ( evt.PropertyName == DLGED_PROP_POSITIONY )
+ {
+ if ( nNewValue < nPageY )
+ nNewValue = nPageY;
+ }
+ else if ( evt.PropertyName == DLGED_PROP_WIDTH )
+ {
+ if ( nNewValue < 1 )
+ nNewValue = 1;
+ }
+ else if ( evt.PropertyName == DLGED_PROP_HEIGHT )
+ {
+ if ( nNewValue < 1 )
+ nNewValue = 1;
+ }
+
+ if ( nNewValue != nValue )
+ {
+ Any aNewValue;
+ aNewValue <<= nNewValue;
+ EndListening( sal_False );
+ xPSetForm->setPropertyValue( evt.PropertyName, aNewValue );
+ StartListening();
+ }
+ }
+ }
+
+ bool bAdjustedPageSize = pEditor->AdjustPageSize();
+ SetRectFromProps();
+ ::std::vector< DlgEdObj* >::iterator aIter;
+ ::std::vector< DlgEdObj* > aChildList = ((DlgEdForm*)this)->GetChilds();
+
+ if ( bAdjustedPageSize )
+ {
+ pEditor->InitScrollBars();
+ aPageSize = pPage_->GetSize();
+ nPageWidthIn = aPageSize.Width();
+ nPageHeightIn = aPageSize.Height();
+ if ( TransformSdrToControlCoordinates( nPageXIn, nPageYIn, nPageWidthIn, nPageHeightIn, nPageX, nPageY, nPageWidth, nPageHeight ) )
+ {
+ for ( aIter = aChildList.begin(); aIter != aChildList.end(); aIter++ )
+ {
+ Reference< beans::XPropertySet > xPSet( (*aIter)->GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ sal_Int32 nX = 0, nY = 0, nWidth = 0, nHeight = 0;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nX;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nY;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidth;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeight;
+
+ sal_Int32 nNewX = nX;
+ if ( nX + nWidth > nPageX + nPageWidth )
+ {
+ nNewX = nPageX + nPageWidth - nWidth;
+ if ( nNewX < nPageX )
+ nNewX = nPageX;
+ }
+ if ( nNewX != nX )
+ {
+ Any aValue;
+ aValue <<= nNewX;
+ EndListening( sal_False );
+ xPSet->setPropertyValue( DLGED_PROP_POSITIONX, aValue );
+ StartListening();
+ }
+
+ sal_Int32 nNewY = nY;
+ if ( nY + nHeight > nPageY + nPageHeight )
+ {
+ nNewY = nPageY + nPageHeight - nHeight;
+ if ( nNewY < nPageY )
+ nNewY = nPageY;
+ }
+ if ( nNewY != nY )
+ {
+ Any aValue;
+ aValue <<= nNewY;
+ EndListening( sal_False );
+ xPSet->setPropertyValue( DLGED_PROP_POSITIONY, aValue );
+ StartListening();
+ }
+ }
+ }
+ }
+ }
+
+ for ( aIter = aChildList.begin(); aIter != aChildList.end(); aIter++ )
+ {
+ (*aIter)->SetRectFromProps();
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::UpdateStep()
+{
+ ULONG nObjCount;
+ SdrPage* pSdrPage = GetPage();
+
+ if ( pSdrPage && ( ( nObjCount = pSdrPage->GetObjCount() ) > 0 ) )
+ {
+ for ( ULONG i = 0 ; i < nObjCount ; i++ )
+ {
+ SdrObject* pObj = pSdrPage->GetObj(i);
+ DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj);
+ if ( pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) )
+ pDlgEdObj->UpdateStep();
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::UpdateTabIndices()
+{
+ // stop listening with all children
+ ::std::vector<DlgEdObj*>::iterator aIter;
+ for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; ++aIter )
+ {
+ (*aIter)->EndListening( sal_False );
+ }
+
+ Reference< ::com::sun::star::container::XNameAccess > xNameAcc( GetUnoControlModel() , UNO_QUERY );
+ if ( xNameAcc.is() )
+ {
+ // get sequence of control names
+ Sequence< ::rtl::OUString > aNames = xNameAcc->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+
+ // create a map of tab indices and control names, sorted by tab index
+ IndexToNameMap aIndexToNameMap;
+ for ( sal_Int16 i = 0; i < nCtrls; ++i )
+ {
+ // get name
+ ::rtl::OUString aName( pNames[i] );
+
+ // get tab index
+ sal_Int16 nTabIndex = -1;
+ Any aCtrl = xNameAcc->getByName( aName );
+ Reference< ::com::sun::star::beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if ( xPSet.is() )
+ xPSet->getPropertyValue( DLGED_PROP_TABINDEX ) >>= nTabIndex;
+
+ // insert into map
+ aIndexToNameMap.insert( IndexToNameMap::value_type( nTabIndex, aName ) );
+ }
+
+ // set new tab indices
+ sal_Int16 nNewTabIndex = 0;
+ for ( IndexToNameMap::iterator aIt = aIndexToNameMap.begin(); aIt != aIndexToNameMap.end(); ++aIt )
+ {
+ Any aCtrl = xNameAcc->getByName( aIt->second );
+ Reference< beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if ( xPSet.is() )
+ {
+ Any aTabIndex;
+ aTabIndex <<= (sal_Int16) nNewTabIndex++;
+ xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
+ }
+ }
+
+ // #110559#
+ UpdateTabOrderAndGroups();
+ }
+
+ // start listening with all children
+ for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; ++aIter )
+ {
+ (*aIter)->StartListening();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::UpdateTabOrder()
+{
+ // #110559#
+ // When the tabindex of a control model changes, the dialog control is
+ // notified about those changes. Due to #109067# (bad performance of
+ // dialog editor) the dialog control doesn't activate the tab order
+ // in design mode. When the dialog editor has reordered all
+ // tabindices, this method allows to activate the taborder afterwards.
+
+ Reference< awt::XUnoControlContainer > xCont( GetControl(), UNO_QUERY );
+ if ( xCont.is() )
+ {
+ Sequence< Reference< awt::XTabController > > aSeqTabCtrls = xCont->getTabControllers();
+ const Reference< awt::XTabController >* pTabCtrls = aSeqTabCtrls.getConstArray();
+ sal_Int32 nCount = aSeqTabCtrls.getLength();
+ for ( sal_Int32 i = 0; i < nCount; ++i )
+ pTabCtrls[i]->activateTabOrder();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::UpdateGroups()
+{
+ // #110559#
+ // The grouping of radio buttons in a dialog is done by vcl.
+ // In the dialog editor we have two views (=controls) for one
+ // radio button model. One control is owned by the dialog control,
+ // but not visible in design mode. The other control is owned by
+ // the drawing layer object. Whereas the grouping of the first
+ // control is done by vcl, the grouping of the control in the
+ // drawing layer has to be done here.
+
+ Reference< awt::XTabControllerModel > xTabModel( GetUnoControlModel() , UNO_QUERY );
+ if ( xTabModel.is() )
+ {
+ // create a global list of controls that belong to the dialog
+ ::std::vector<DlgEdObj*> aChildList = GetChilds();
+ sal_uInt32 nSize = aChildList.size();
+ Sequence< Reference< awt::XControl > > aSeqControls( nSize );
+ for ( sal_uInt32 i = 0; i < nSize; ++i )
+ aSeqControls.getArray()[i] = Reference< awt::XControl >( aChildList[i]->GetControl(), UNO_QUERY );
+
+ sal_Int32 nGroupCount = xTabModel->getGroupCount();
+ for ( sal_Int32 nGroup = 0; nGroup < nGroupCount; ++nGroup )
+ {
+ // get a list of control models that belong to this group
+ ::rtl::OUString aName;
+ Sequence< Reference< awt::XControlModel > > aSeqModels;
+ xTabModel->getGroup( nGroup, aSeqModels, aName );
+ const Reference< awt::XControlModel >* pModels = aSeqModels.getConstArray();
+ sal_Int32 nModelCount = aSeqModels.getLength();
+
+ // create a list of peers that belong to this group
+ Sequence< Reference< awt::XWindow > > aSeqPeers( nModelCount );
+ for ( sal_Int32 nModel = 0; nModel < nModelCount; ++nModel )
+ {
+ // for each control model find the corresponding control in the global list
+ const Reference< awt::XControl >* pControls = aSeqControls.getConstArray();
+ sal_Int32 nControlCount = aSeqControls.getLength();
+ for ( sal_Int32 nControl = 0; nControl < nControlCount; ++nControl )
+ {
+ const Reference< awt::XControl > xCtrl( pControls[nControl] );
+ if ( xCtrl.is() )
+ {
+ Reference< awt::XControlModel > xCtrlModel( xCtrl->getModel() );
+ if ( (awt::XControlModel*)xCtrlModel.get() == (awt::XControlModel*)pModels[nModel].get() )
+ {
+ // get the control peer and insert into the list of peers
+ aSeqPeers.getArray()[ nModel ] = Reference< awt::XWindow >( xCtrl->getPeer(), UNO_QUERY );
+ break;
+ }
+ }
+ }
+ }
+
+ // set the group at the dialog peer
+ Reference< awt::XControl > xDlg( GetControl(), UNO_QUERY );
+ if ( xDlg.is() )
+ {
+ Reference< awt::XVclContainerPeer > xDlgPeer( xDlg->getPeer(), UNO_QUERY );
+ if ( xDlgPeer.is() )
+ xDlgPeer->setGroup( aSeqPeers );
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::UpdateTabOrderAndGroups()
+{
+ UpdateTabOrder();
+ UpdateGroups();
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::NbcMove( const Size& rSize )
+{
+ SdrUnoObj::NbcMove( rSize );
+
+ // set geometry properties of form
+ EndListening(sal_False);
+ SetPropsFromRect();
+ StartListening();
+
+ // set geometry properties of all childs
+ ::std::vector<DlgEdObj*>::iterator aIter;
+ for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; aIter++ )
+ {
+ (*aIter)->EndListening(sal_False);
+ (*aIter)->SetPropsFromRect();
+ (*aIter)->StartListening();
+ }
+
+ // dialog model changed
+ GetDlgEditor()->SetDialogModelChanged(TRUE);
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
+{
+ SdrUnoObj::NbcResize( rRef, xFract, yFract );
+
+ // set geometry properties of form
+ EndListening(sal_False);
+ SetPropsFromRect();
+ StartListening();
+
+ // set geometry properties of all childs
+ ::std::vector<DlgEdObj*>::iterator aIter;
+ for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; aIter++ )
+ {
+ (*aIter)->EndListening(sal_False);
+ (*aIter)->SetPropsFromRect();
+ (*aIter)->StartListening();
+ }
+
+ // dialog model changed
+ GetDlgEditor()->SetDialogModelChanged(TRUE);
+}
+
+//----------------------------------------------------------------------------
+
+bool DlgEdForm::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
+
+ // stop listening
+ EndListening(sal_False);
+
+ // set geometry properties
+ SetPropsFromRect();
+
+ // dialog model changed
+ GetDlgEditor()->SetDialogModelChanged(TRUE);
+
+ // start listening
+ StartListening();
+
+ return bResult;
+}
+
+//----------------------------------------------------------------------------
+
+awt::DeviceInfo DlgEdForm::getDeviceInfo() const
+{
+ awt::DeviceInfo aDeviceInfo;
+
+ DlgEditor* pEditor = GetDlgEditor();
+ DBG_ASSERT( pEditor, "DlgEdForm::getDeviceInfo: no editor associated with the form object!" );
+ if ( !pEditor )
+ return aDeviceInfo;
+
+ Window* pWindow = pEditor->GetWindow();
+ DBG_ASSERT( pWindow, "DlgEdForm::getDeviceInfo: no window associated with the editor!" );
+ if ( !pWindow )
+ return aDeviceInfo;
+
+ // obtain an XControl
+ ::utl::SharedUNOComponent< awt::XControl > xDialogControl; // ensures auto-disposal, if needed
+ xDialogControl.reset( GetControl(), ::utl::SharedUNOComponent< awt::XControl >::NoTakeOwnership );
+ if ( !xDialogControl.is() )
+ {
+ // don't create a temporary control all the time, this method here is called
+ // way too often. Instead, use a cached DeviceInfo.
+ // 2007-02-05 / i74065 / frank.schoenheit@sun.com
+ if ( !!mpDeviceInfo )
+ return *mpDeviceInfo;
+
+ Reference< awt::XControlContainer > xEditorControlContainer( pEditor->GetWindowControlContainer() );
+ xDialogControl.reset(
+ GetTemporaryControlForWindow( *pWindow, xEditorControlContainer ),
+ ::utl::SharedUNOComponent< awt::XControl >::TakeOwnership );
+ }
+
+ Reference< awt::XDevice > xDialogDevice;
+ if ( xDialogControl.is() )
+ xDialogDevice.set( xDialogControl->getPeer(), UNO_QUERY );
+ DBG_ASSERT( xDialogDevice.is(), "DlgEdForm::getDeviceInfo: no device!" );
+ if ( xDialogDevice.is() )
+ aDeviceInfo = xDialogDevice->getInfo();
+
+ mpDeviceInfo.reset( aDeviceInfo );
+
+ return aDeviceInfo;
+}
+
+//----------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedpage.cxx b/basctl/source/dlged/dlgedpage.cxx
new file mode 100644
index 000000000000..58fe333dfac3
--- /dev/null
+++ b/basctl/source/dlged/dlgedpage.cxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include "dlgedpage.hxx"
+#include "dlged.hxx"
+#include "dlgedmod.hxx"
+#include "dlgedobj.hxx"
+
+
+TYPEINIT1( DlgEdPage, SdrPage );
+
+//----------------------------------------------------------------------------
+
+DlgEdPage::DlgEdPage( DlgEdModel& rModel, bool bMasterPage )
+ :SdrPage( rModel, bMasterPage )
+{
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdPage::DlgEdPage( const DlgEdPage& rPage )
+ :SdrPage( rPage )
+{
+ pDlgEdForm = rPage.pDlgEdForm;
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdPage::~DlgEdPage()
+{
+ Clear();
+}
+
+//----------------------------------------------------------------------------
+
+SdrPage* DlgEdPage::Clone() const
+{
+ return new DlgEdPage( *this );
+}
+
+//----------------------------------------------------------------------------
+
+SdrObject* DlgEdPage::SetObjectOrdNum(ULONG nOldObjNum, ULONG nNewObjNum)
+{
+ SdrObject* pObj = SdrPage::SetObjectOrdNum( nOldObjNum, nNewObjNum );
+
+ DlgEdHint aHint( DLGED_HINT_OBJORDERCHANGED );
+ if ( pDlgEdForm )
+ {
+ DlgEditor* pDlgEditor = pDlgEdForm->GetDlgEditor();
+ if ( pDlgEditor )
+ pDlgEditor->Broadcast( aHint );
+ }
+
+ return pObj;
+}
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedview.cxx b/basctl/source/dlged/dlgedview.cxx
new file mode 100644
index 000000000000..d98967a3e776
--- /dev/null
+++ b/basctl/source/dlged/dlgedview.cxx
@@ -0,0 +1,217 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include "dlgedview.hxx"
+#include "dlged.hxx"
+#include <dlgedpage.hxx>
+
+#include <svx/svxids.hrc>
+#include <sfx2/viewfrm.hxx>
+
+#include <basidesh.hxx>
+#include <iderdll.hxx>
+#include "dlgedobj.hxx"
+
+TYPEINIT1( DlgEdView, SdrView );
+
+//----------------------------------------------------------------------------
+
+DlgEdView::DlgEdView( SdrModel* pModel, OutputDevice* pOut, DlgEditor* pEditor )
+ :SdrView( pModel, pOut )
+ ,pDlgEditor( pEditor )
+{
+ // #114898#
+ SetBufferedOutputAllowed(true);
+ SetBufferedOverlayAllowed(true);
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdView::~DlgEdView()
+{
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdView::MarkListHasChanged()
+{
+ SdrView::MarkListHasChanged();
+
+ DlgEdHint aHint( DLGED_HINT_SELECTIONCHANGED );
+ if ( pDlgEditor )
+ {
+ pDlgEditor->Broadcast( aHint );
+ pDlgEditor->UpdatePropertyBrowserDelayed();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdView::MakeVisible( const Rectangle& rRect, Window& rWin )
+{
+ // visible area
+ MapMode aMap( rWin.GetMapMode() );
+ Point aOrg( aMap.GetOrigin() );
+ Size aVisSize( rWin.GetOutputSize() );
+ Rectangle RectTmp( Point(-aOrg.X(),-aOrg.Y()), aVisSize );
+ Rectangle aVisRect( RectTmp );
+
+ // check, if rectangle is inside visible area
+ if ( !aVisRect.IsInside( rRect ) )
+ {
+ // calculate scroll distance; the rectangle must be inside the visible area
+ sal_Int32 nScrollX = 0, nScrollY = 0;
+
+ sal_Int32 nVisLeft = aVisRect.Left();
+ sal_Int32 nVisRight = aVisRect.Right();
+ sal_Int32 nVisTop = aVisRect.Top();
+ sal_Int32 nVisBottom = aVisRect.Bottom();
+
+ sal_Int32 nDeltaX = pDlgEditor->GetHScroll()->GetLineSize();
+ sal_Int32 nDeltaY = pDlgEditor->GetVScroll()->GetLineSize();
+
+ while ( rRect.Right() > nVisRight + nScrollX )
+ nScrollX += nDeltaX;
+
+ while ( rRect.Left() < nVisLeft + nScrollX )
+ nScrollX -= nDeltaX;
+
+ while ( rRect.Bottom() > nVisBottom + nScrollY )
+ nScrollY += nDeltaY;
+
+ while ( rRect.Top() < nVisTop + nScrollY )
+ nScrollY -= nDeltaY;
+
+ // don't scroll beyond the page size
+ Size aPageSize = pDlgEditor->GetPage()->GetSize();
+ sal_Int32 nPageWidth = aPageSize.Width();
+ sal_Int32 nPageHeight = aPageSize.Height();
+
+ if ( nVisRight + nScrollX > nPageWidth )
+ nScrollX = nPageWidth - nVisRight;
+
+ if ( nVisLeft + nScrollX < 0 )
+ nScrollX = -nVisLeft;
+
+ if ( nVisBottom + nScrollY > nPageHeight )
+ nScrollY = nPageHeight - nVisBottom;
+
+ if ( nVisTop + nScrollY < 0 )
+ nScrollY = -nVisTop;
+
+ // scroll window
+ rWin.Update();
+ rWin.Scroll( -nScrollX, -nScrollY );
+ aMap.SetOrigin( Point( aOrg.X() - nScrollX, aOrg.Y() - nScrollY ) );
+ rWin.SetMapMode( aMap );
+ rWin.Update();
+ rWin.Invalidate();
+
+ // update scroll bars
+ if ( pDlgEditor )
+ pDlgEditor->UpdateScrollBars();
+
+ DlgEdHint aHint( DLGED_HINT_WINDOWSCROLLED );
+ if ( pDlgEditor )
+ pDlgEditor->Broadcast( aHint );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+SdrObject* impLocalHitCorrection(SdrObject* pRetval, const Point& rPnt, USHORT nTol)
+{
+ DlgEdObj* pDlgEdObj = dynamic_cast< DlgEdObj* >(pRetval);
+
+ if(pDlgEdObj)
+ {
+ bool bExcludeInner(false);
+
+ if(0 != dynamic_cast< DlgEdForm* >(pRetval))
+ {
+ // from DlgEdForm::CheckHit; exclude inner for DlgEdForm
+ bExcludeInner = true;
+ }
+ else if(pDlgEdObj->supportsService("com.sun.star.awt.UnoControlGroupBoxModel"))
+ {
+ // from DlgEdObj::CheckHit; exclude inner for group shapes
+ bExcludeInner = true;
+ }
+
+ if(bExcludeInner)
+ {
+ // use direct model data; it's a DlgEdObj, so GetLastBoundRect()
+ // will access aOutRect directly
+ const Rectangle aOuterRectangle(pDlgEdObj->GetLastBoundRect());
+
+ if(!aOuterRectangle.IsEmpty()
+ && RECT_EMPTY != aOuterRectangle.Right()
+ && RECT_EMPTY != aOuterRectangle.Bottom())
+ {
+ basegfx::B2DRange aOuterRange(
+ aOuterRectangle.Left(), aOuterRectangle.Top(),
+ aOuterRectangle.Right(), aOuterRectangle.Bottom());
+
+ if(nTol)
+ {
+ aOuterRange.grow(-1.0 * nTol);
+ }
+
+ if(aOuterRange.isInside(basegfx::B2DPoint(rPnt.X(), rPnt.Y())))
+ {
+ pRetval = 0;
+ }
+ }
+ }
+ }
+
+ return pRetval;
+}
+
+SdrObject* DlgEdView::CheckSingleSdrObjectHit(const Point& rPnt, USHORT nTol, SdrObject* pObj, SdrPageView* pPV, ULONG nOptions, const SetOfByte* pMVisLay) const
+{
+ // call parent
+ SdrObject* pRetval = SdrView::CheckSingleSdrObjectHit(rPnt, nTol, pObj, pPV, nOptions, pMVisLay);
+
+ if(pRetval)
+ {
+ // check hitted object locally
+ pRetval = impLocalHitCorrection(pRetval, rPnt, nTol);
+ }
+
+ return pRetval;
+}
+
+//----------------------------------------------------------------------------
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgresid.src b/basctl/source/dlged/dlgresid.src
new file mode 100644
index 000000000000..ee37d82233e1
--- /dev/null
+++ b/basctl/source/dlged/dlgresid.src
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "dlgresid.hrc"
+
+// Dialog Controls ---------------------------------------------------------------
+
+String RID_STR_CLASS_CONTROL
+{
+ Text = "Control" ;
+};
+String RID_STR_CLASS_DIALOG
+{
+ Text = "Dialog" ;
+};
+String RID_STR_CLASS_BUTTON
+{
+ Text = "CommandButton" ;
+};
+String RID_STR_CLASS_RADIOBUTTON
+{
+ Text = "OptionButton" ;
+};
+String RID_STR_CLASS_CHECKBOX
+{
+ Text = "CheckBox" ;
+};
+String RID_STR_CLASS_LISTBOX
+{
+ Text = "ListBox" ;
+};
+String RID_STR_CLASS_COMBOBOX
+{
+ Text = "ComboBox" ;
+};
+String RID_STR_CLASS_GROUPBOX
+{
+ Text = "FrameControl" ;
+};
+String RID_STR_CLASS_EDIT
+{
+ Text = "TextField" ;
+};
+String RID_STR_CLASS_FIXEDTEXT
+{
+ Text = "Label" ;
+};
+String RID_STR_CLASS_IMAGECONTROL
+{
+ Text = "ImageControl" ;
+};
+String RID_STR_CLASS_PROGRESSBAR
+{
+ Text = "ProgressBar" ;
+};
+String RID_STR_CLASS_SCROLLBAR
+{
+ Text = "ScrollBar" ;
+};
+String RID_STR_CLASS_FIXEDLINE
+{
+ Text = "FixedLine" ;
+};
+String RID_STR_CLASS_DATEFIELD
+{
+ Text = "DateField" ;
+};
+String RID_STR_CLASS_TIMEFIELD
+{
+ Text = "TimeField" ;
+};
+String RID_STR_CLASS_NUMERICFIELD
+{
+ Text = "NumericField" ;
+};
+String RID_STR_CLASS_CURRENCYFIELD
+{
+ Text = "CurrencyField" ;
+};
+String RID_STR_CLASS_FORMATTEDFIELD
+{
+ Text = "FormattedField" ;
+};
+String RID_STR_CLASS_PATTERNFIELD
+{
+ Text = "PatternField" ;
+};
+String RID_STR_CLASS_FILECONTROL
+{
+ Text = "FileControl" ;
+};
+String RID_STR_CLASS_TREECONTROL
+{
+ Text = "TreeControl" ;
+};
+
+
+// Property Browser Headline ----------------------------------------------------------------
+
+String RID_STR_BRWTITLE_PROPERTIES
+{
+ Text [ en-US ] = "Properties: ";
+};
+String RID_STR_BRWTITLE_NO_PROPERTIES
+{
+ Text [ en-US ] = "No Control marked";
+};
+String RID_STR_BRWTITLE_MULTISELECT
+{
+ Text [ en-US ] = "Multiselection";
+};
+
+// -----------------------------------------------------------------------
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/basctl/source/dlged/makefile.mk b/basctl/source/dlged/makefile.mk
new file mode 100644
index 000000000000..1b765ad91ae4
--- /dev/null
+++ b/basctl/source/dlged/makefile.mk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=basctl
+TARGET=dlged
+AUTOSEG=true
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+EXCEPTIONSFILES=$(SLO)$/dlged.obj \
+ $(SLO)$/dlgedobj.obj \
+ $(SLO)$/dlgedfac.obj \
+ $(SLO)$/dlgedlist.obj \
+ $(SLO)$/dlgedclip.obj \
+ $(SLO)$/propbrw.obj
+
+SLOFILES= $(EXCEPTIONSFILES) \
+ $(SLO)$/dlgedfunc.obj \
+ $(SLO)$/dlgedmod.obj \
+ $(SLO)$/dlgedpage.obj \
+ $(SLO)$/dlgedview.obj \
+ $(SLO)$/managelang.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES= dlgresid.src \
+ managelang.src
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/basctl/source/dlged/managelang.cxx b/basctl/source/dlged/managelang.cxx
new file mode 100644
index 000000000000..e33e68c3dd67
--- /dev/null
+++ b/basctl/source/dlged/managelang.cxx
@@ -0,0 +1,427 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include "managelang.hxx"
+#include "iderid.hxx"
+#include "localizationmgr.hxx"
+#include "iderdll.hxx"
+#include "basidesh.hxx"
+#include "basobj.hxx"
+
+#include "managelang.hrc"
+#include "dlgresid.hrc"
+#include "helpid.hrc"
+
+#include <com/sun/star/i18n/XBreakIterator.hpp>
+#include <com/sun/star/i18n/WordType.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/resource/XStringResourceManager.hpp>
+#include <comphelper/processfactory.hxx>
+#include <vcl/unohelp.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <editeng/unolingu.hxx>
+
+#include <svtools/langtab.hxx>
+
+#include <sfx2/bindings.hxx>
+
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::resource;
+using namespace ::com::sun::star::uno;
+
+bool localesAreEqual( const Locale& rLocaleLeft, const Locale& rLocaleRight )
+{
+ bool bRet = ( rLocaleLeft.Language.equals( rLocaleRight.Language ) &&
+ rLocaleLeft.Country.equals( rLocaleRight.Country ) &&
+ rLocaleLeft.Variant.equals( rLocaleRight.Variant ) );
+ return bRet;
+}
+
+namespace {
+ long getLongestWordWidth( const String& rText, const Window& rWin )
+ {
+ long nWidth = 0;
+ Reference< XBreakIterator > xBreakIter( vcl::unohelper::CreateBreakIterator() );
+ sal_Int32 nStartPos = 0;
+ const Locale aLocale = Application::GetSettings().GetUILocale();
+ Boundary aBoundary = xBreakIter->getWordBoundary(
+ rText, nStartPos, aLocale, WordType::ANYWORD_IGNOREWHITESPACES, sal_True );
+
+ while ( aBoundary.startPos != aBoundary.endPos )
+ {
+ nStartPos = aBoundary.endPos;
+ String sWord( rText.Copy(
+ (USHORT)aBoundary.startPos,
+ (USHORT)aBoundary.endPos - (USHORT)aBoundary.startPos ) );
+ long nTemp = rWin.GetCtrlTextWidth( sWord );
+ if ( nTemp > nWidth )
+ nWidth = nTemp;
+ aBoundary = xBreakIter->nextWord(
+ rText, nStartPos, aLocale, WordType::ANYWORD_IGNOREWHITESPACES );
+ }
+
+ return nWidth;
+ }
+}
+
+ManageLanguageDialog::ManageLanguageDialog( Window* pParent, LocalizationMgr* _pLMgr ) :
+
+ ModalDialog( pParent, IDEResId( RID_DLG_MANAGE_LANGUAGE ) ),
+
+ m_aLanguageFT ( this, IDEResId( FT_LANGUAGE ) ),
+ m_aLanguageLB ( this, IDEResId( LB_LANGUAGE ) ),
+ m_aAddPB ( this, IDEResId( PB_ADD_LANG ) ),
+ m_aDeletePB ( this, IDEResId( PB_DEL_LANG ) ),
+ m_aMakeDefPB ( this, IDEResId( PB_MAKE_DEFAULT ) ),
+ m_aInfoFT ( this, IDEResId( FT_INFO ) ),
+ m_aBtnLine ( this, IDEResId( FL_BUTTONS ) ),
+ m_aHelpBtn ( this, IDEResId( PB_HELP ) ),
+ m_aCloseBtn ( this, IDEResId( PB_CLOSE ) ),
+ m_pLocalizationMgr ( _pLMgr ),
+ m_sDefLangStr ( IDEResId( STR_DEF_LANG ) ),
+ m_sDeleteStr ( IDEResId( STR_DELETE ) ),
+ m_sCreateLangStr ( IDEResId( STR_CREATE_LANG ) )
+
+{
+ FreeResource();
+
+ Init();
+ FillLanguageBox();
+ SelectHdl( NULL );
+}
+
+ManageLanguageDialog::~ManageLanguageDialog()
+{
+ ClearLanguageBox();
+}
+
+void ManageLanguageDialog::Init()
+{
+ // get current IDE
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ String sLibName = pIDEShell->GetCurLibName();
+ // set dialog title with library name
+ String sText = GetText();
+ sText.SearchAndReplace( String::CreateFromAscii("$1"), sLibName );
+ SetText( sText );
+ // set handler
+ m_aAddPB.SetClickHdl( LINK( this, ManageLanguageDialog, AddHdl ) );
+ m_aDeletePB.SetClickHdl( LINK( this, ManageLanguageDialog, DeleteHdl ) );
+ m_aMakeDefPB.SetClickHdl( LINK( this, ManageLanguageDialog, MakeDefHdl ) );
+ m_aLanguageLB.SetSelectHdl( LINK( this, ManageLanguageDialog, SelectHdl ) );
+
+ m_aLanguageLB.EnableMultiSelection( TRUE );
+ CalcInfoSize();
+}
+
+void ManageLanguageDialog::CalcInfoSize()
+{
+ String sInfoStr = m_aInfoFT.GetText();
+ long nInfoWidth = m_aInfoFT.GetSizePixel().Width();
+ long nLongWord = getLongestWordWidth( sInfoStr, m_aInfoFT );
+ long nTxtWidth = m_aInfoFT.GetCtrlTextWidth( sInfoStr ) + nLongWord;
+ long nLines = ( nTxtWidth / nInfoWidth ) + 1;
+ if ( nLines > INFO_LINES_COUNT )
+ {
+ Size aFTSize = m_aLanguageFT.GetSizePixel();
+ Size aSize = m_aInfoFT.GetSizePixel();
+ long nNewHeight = aFTSize.Height() * nLines;
+ long nDelta = nNewHeight - aSize.Height();
+ aSize.Height() = nNewHeight;
+ m_aInfoFT.SetSizePixel( aSize );
+
+ aSize = m_aLanguageLB.GetSizePixel();
+ aSize.Height() -= nDelta;
+ m_aLanguageLB.SetSizePixel( aSize );
+
+ Point aNewPos = m_aInfoFT.GetPosPixel();
+ aNewPos.Y() -= nDelta;
+ m_aInfoFT.SetPosPixel( aNewPos );
+ aNewPos = m_aMakeDefPB.GetPosPixel();
+ aNewPos.Y() -= nDelta;
+ m_aMakeDefPB.SetPosPixel( aNewPos );
+ }
+}
+
+void ManageLanguageDialog::FillLanguageBox()
+{
+ DBG_ASSERT( m_pLocalizationMgr, "ManageLanguageDialog::FillLanguageBox(): no localization manager" );
+
+ if ( m_pLocalizationMgr->isLibraryLocalized() )
+ {
+ SvtLanguageTable aLangTable;
+ Locale aDefaultLocale = m_pLocalizationMgr->getStringResourceManager()->getDefaultLocale();
+ Sequence< Locale > aLocaleSeq = m_pLocalizationMgr->getStringResourceManager()->getLocales();
+ const Locale* pLocale = aLocaleSeq.getConstArray();
+ INT32 i, nCount = aLocaleSeq.getLength();
+ for ( i = 0; i < nCount; ++i )
+ {
+ bool bIsDefault = localesAreEqual( aDefaultLocale, pLocale[i] );
+ LanguageType eLangType = SvxLocaleToLanguage( pLocale[i] );
+ String sLanguage = aLangTable.GetString( eLangType );
+ if ( bIsDefault )
+ {
+ sLanguage += ' ';
+ sLanguage += m_sDefLangStr;
+ }
+ USHORT nPos = m_aLanguageLB.InsertEntry( sLanguage );
+ m_aLanguageLB.SetEntryData( nPos, new LanguageEntry( sLanguage, pLocale[i], bIsDefault ) );
+ }
+ }
+ else
+ m_aLanguageLB.InsertEntry( m_sCreateLangStr );
+}
+
+void ManageLanguageDialog::ClearLanguageBox()
+{
+ USHORT i, nCount = m_aLanguageLB.GetEntryCount();
+ for ( i = 0; i < nCount; ++i )
+ {
+ LanguageEntry* pEntry = (LanguageEntry*)( m_aLanguageLB.GetEntryData(i) );
+ if ( pEntry )
+ delete pEntry;
+ }
+ m_aLanguageLB.Clear();
+}
+
+IMPL_LINK( ManageLanguageDialog, AddHdl, Button *, EMPTYARG )
+{
+ SetDefaultLanguageDialog aDlg( this, m_pLocalizationMgr );
+ if ( RET_OK == aDlg.Execute() )
+ {
+ // add new locales
+ Sequence< Locale > aLocaleSeq = aDlg.GetLocales();
+ m_pLocalizationMgr->handleAddLocales( aLocaleSeq );
+ // update listbox
+ ClearLanguageBox();
+ FillLanguageBox();
+
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
+ }
+ return 1;
+}
+
+IMPL_LINK( ManageLanguageDialog, DeleteHdl, Button *, EMPTYARG )
+{
+ QueryBox aQBox( this, IDEResId( RID_QRYBOX_LANGUAGE ) );
+ aQBox.SetButtonText( RET_OK, m_sDeleteStr );
+ if ( aQBox.Execute() == RET_OK )
+ {
+ USHORT i, nCount = m_aLanguageLB.GetSelectEntryCount();
+ USHORT nPos = m_aLanguageLB.GetSelectEntryPos();
+ // remove locales
+ Sequence< Locale > aLocaleSeq( nCount );
+ for ( i = 0; i < nCount; ++i )
+ {
+ USHORT nSelPos = m_aLanguageLB.GetSelectEntryPos(i);
+ LanguageEntry* pEntry = (LanguageEntry*)( m_aLanguageLB.GetEntryData( nSelPos ) );
+ if ( pEntry )
+ aLocaleSeq[i] = pEntry->m_aLocale;
+ }
+ m_pLocalizationMgr->handleRemoveLocales( aLocaleSeq );
+ // update listbox
+ ClearLanguageBox();
+ FillLanguageBox();
+ // reset selection
+ nCount = m_aLanguageLB.GetEntryCount();
+ if ( nCount <= nPos )
+ nPos = nCount - 1;
+ m_aLanguageLB.SelectEntryPos( nPos );
+ SelectHdl( NULL );
+ }
+ return 1;
+}
+
+IMPL_LINK( ManageLanguageDialog, MakeDefHdl, Button *, EMPTYARG )
+{
+ USHORT nPos = m_aLanguageLB.GetSelectEntryPos();
+ LanguageEntry* pSelectEntry = (LanguageEntry*)( m_aLanguageLB.GetEntryData( nPos ) );
+ if ( pSelectEntry && !pSelectEntry->m_bIsDefault )
+ {
+ // set new default entry
+ m_pLocalizationMgr->handleSetDefaultLocale( pSelectEntry->m_aLocale );
+ // update Listbox
+ ClearLanguageBox();
+ FillLanguageBox();
+ // reset selection
+ m_aLanguageLB.SelectEntryPos( nPos );
+ SelectHdl( NULL );
+ }
+
+ return 1;
+}
+
+IMPL_LINK( ManageLanguageDialog, SelectHdl, ListBox *, EMPTYARG )
+{
+ USHORT nCount = m_aLanguageLB.GetEntryCount();
+ bool bEmpty = ( !nCount ||
+ m_aLanguageLB.GetEntryPos( m_sCreateLangStr ) != LISTBOX_ENTRY_NOTFOUND );
+ bool bSelect = ( m_aLanguageLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND );
+ bool bEnable = ( !bEmpty && bSelect != false );
+
+ m_aDeletePB.Enable( bEnable != false );
+ m_aMakeDefPB.Enable( bEnable != false && nCount > 1 && m_aLanguageLB.GetSelectEntryCount() == 1 );
+
+ return 1;
+}
+
+// class SetDefaultLanguageDialog -----------------------------------------------
+
+SetDefaultLanguageDialog::SetDefaultLanguageDialog( Window* pParent, LocalizationMgr* _pLMgr ) :
+
+ ModalDialog( pParent, IDEResId( RID_DLG_SETDEF_LANGUAGE ) ),
+
+ m_aLanguageFT ( this, IDEResId( FT_DEF_LANGUAGE ) ),
+ m_pLanguageLB ( new SvxLanguageBox( this, IDEResId( LB_DEF_LANGUAGE ) ) ),
+ m_pCheckLangLB ( NULL ),
+ m_aInfoFT ( this, IDEResId( FT_DEF_INFO ) ),
+ m_aBtnLine ( this, IDEResId( FL_DEF_BUTTONS ) ),
+ m_aOKBtn ( this, IDEResId( PB_DEF_OK ) ),
+ m_aCancelBtn ( this, IDEResId( PB_DEF_CANCEL ) ),
+ m_aHelpBtn ( this, IDEResId( PB_DEF_HELP ) ),
+
+ m_pLocalizationMgr( _pLMgr )
+
+{
+ if ( m_pLocalizationMgr->isLibraryLocalized() )
+ {
+ // change to "Add Interface Language" mode
+ SetHelpId( HID_BASICIDE_ADDNEW_LANGUAGE );
+ m_pCheckLangLB = new SvxCheckListBox( this, IDEResId( LB_ADD_LANGUAGE ) );
+ SetText( String( IDEResId( STR_ADDLANG_TITLE ) ) );
+ m_aLanguageFT.SetText( String( IDEResId( STR_ADDLANG_LABEL ) ) );
+ m_aInfoFT.SetText( String( IDEResId( STR_ADDLANG_INFO ) ) );
+ }
+
+ FreeResource();
+
+ FillLanguageBox();
+ CalcInfoSize();
+}
+
+SetDefaultLanguageDialog::~SetDefaultLanguageDialog()
+{
+ delete m_pLanguageLB;
+ delete m_pCheckLangLB;
+}
+
+void SetDefaultLanguageDialog::FillLanguageBox()
+{
+ // fill list with all languages
+ m_pLanguageLB->SetLanguageList( LANG_LIST_ALL, FALSE );
+ // remove the already localized languages
+ Sequence< Locale > aLocaleSeq = m_pLocalizationMgr->getStringResourceManager()->getLocales();
+ const Locale* pLocale = aLocaleSeq.getConstArray();
+ INT32 i, nCount = aLocaleSeq.getLength();
+ for ( i = 0; i < nCount; ++i )
+ m_pLanguageLB->RemoveLanguage( SvxLocaleToLanguage( pLocale[i] ) );
+
+ // fill checklistbox if not in default mode
+ if ( m_pLocalizationMgr->isLibraryLocalized() )
+ {
+ USHORT j, nCount_ = m_pLanguageLB->GetEntryCount();
+ for ( j = 0; j < nCount_; ++j )
+ {
+ m_pCheckLangLB->InsertEntry(
+ m_pLanguageLB->GetEntry(j), LISTBOX_APPEND, m_pLanguageLB->GetEntryData(j) );
+ }
+ delete m_pLanguageLB;
+ m_pLanguageLB = NULL;
+ }
+ else
+ // preselect current UI language
+ m_pLanguageLB->SelectLanguage( Application::GetSettings().GetUILanguage() );
+}
+
+void SetDefaultLanguageDialog::CalcInfoSize()
+{
+ String sInfoStr = m_aInfoFT.GetText();
+ long nInfoWidth = m_aInfoFT.GetSizePixel().Width();
+ long nLongWord = getLongestWordWidth( sInfoStr, m_aInfoFT );
+ long nTxtWidth = m_aInfoFT.GetCtrlTextWidth( sInfoStr ) + nLongWord;
+ long nLines = ( nTxtWidth / nInfoWidth ) + 1;
+ if ( nLines > INFO_LINES_COUNT )
+ {
+ Size aFTSize = m_aLanguageFT.GetSizePixel();
+ Size aSize = m_aInfoFT.GetSizePixel();
+ long nNewHeight = aFTSize.Height() * nLines;
+ long nDelta = nNewHeight - aSize.Height();
+ aSize.Height() = nNewHeight;
+ m_aInfoFT.SetSizePixel( aSize );
+
+ Window* pWin = ( m_pLanguageLB != NULL ) ? dynamic_cast< Window* >( m_pLanguageLB )
+ : dynamic_cast< Window* >( m_pCheckLangLB );
+ aSize = pWin->GetSizePixel();
+ aSize.Height() -= nDelta;
+ pWin->SetSizePixel( aSize );
+
+ Point aNewPos = m_aInfoFT.GetPosPixel();
+ aNewPos.Y() -= nDelta;
+ m_aInfoFT.SetPosPixel( aNewPos );
+ }
+}
+
+Sequence< Locale > SetDefaultLanguageDialog::GetLocales() const
+{
+ bool bNotLocalized = !m_pLocalizationMgr->isLibraryLocalized();
+ INT32 nSize = bNotLocalized ? 1 : m_pCheckLangLB->GetCheckedEntryCount();
+ Sequence< Locale > aLocaleSeq( nSize );
+ if ( bNotLocalized )
+ {
+ Locale aLocale;
+ SvxLanguageToLocale( aLocale, m_pLanguageLB->GetSelectLanguage() );
+ aLocaleSeq[0] = aLocale;
+ }
+ else
+ {
+ USHORT i, nCount = static_cast< USHORT >( m_pCheckLangLB->GetEntryCount() );
+ INT32 j = 0;
+ for ( i = 0; i < nCount; ++i )
+ {
+ if ( m_pCheckLangLB->IsChecked(i) )
+ {
+ LanguageType eType = LanguageType( (ULONG)m_pCheckLangLB->GetEntryData(i) );
+ Locale aLocale;
+ SvxLanguageToLocale( aLocale, eType );
+ aLocaleSeq[j++] = aLocale;
+ }
+ }
+ DBG_ASSERT( nSize == j, "SetDefaultLanguageDialog::GetLocales(): invalid indexes" );
+ }
+ return aLocaleSeq;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/managelang.hrc b/basctl/source/dlged/managelang.hrc
new file mode 100644
index 000000000000..e3a7f7f1edde
--- /dev/null
+++ b/basctl/source/dlged/managelang.hrc
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_MANAGELANG_HRC
+#define _BASCTL_MANAGELANG_HRC
+
+// Include -----------------------------------------------------------------------
+
+#include <svtools/controldims.hrc>
+
+// Dialog Control Id's -----------------------------------------------------------
+
+#define FT_LANGUAGE 1
+#define LB_LANGUAGE 2
+#define PB_ADD_LANG 3
+#define PB_DEL_LANG 4
+#define PB_MAKE_DEFAULT 5
+#define FT_INFO 6
+#define FL_BUTTONS 7
+#define PB_HELP 8
+#define PB_CLOSE 9
+#define STR_DEF_LANG 10
+#define STR_DELETE 11
+#define STR_CREATE_LANG 12
+
+#define FT_DEF_LANGUAGE 1
+#define LB_DEF_LANGUAGE 2
+#define LB_ADD_LANGUAGE 3
+#define FT_DEF_INFO 4
+#define FL_DEF_BUTTONS 5
+#define PB_DEF_OK 6
+#define PB_DEF_CANCEL 7
+#define PB_DEF_HELP 8
+#define STR_ADDLANG_TITLE 9
+#define STR_ADDLANG_LABEL 10
+#define STR_ADDLANG_INFO 11
+
+// Metrics -----------------------------------------------------------------------
+
+#define MANAGE_DLG_WIDTH 240
+#define MANAGE_DLG_HEIGHT 180
+#define INFO_LINES_COUNT 3
+
+#define MANAGE_COL1 RSC_SP_DLG_INNERBORDER_LEFT
+#define MANAGE_COL2 (MANAGE_DLG_WIDTH - RSC_SP_DLG_INNERBORDER_RIGHT - 2*RSC_CD_PUSHBUTTON_WIDTH - RSC_SP_CTRL_X)
+#define MANAGE_COL3 (MANAGE_COL2 + RSC_CD_PUSHBUTTON_WIDTH + RSC_SP_CTRL_X)
+
+#define MANAGE_ROW1 RSC_SP_DLG_INNERBORDER_TOP
+#define MANAGE_ROW2 (MANAGE_ROW1 + RSC_CD_FIXEDTEXT_HEIGHT + RSC_SP_CTRL_DESC_Y)
+#define MANAGE_ROW3 (MANAGE_ROW2 + RSC_CD_PUSHBUTTON_HEIGHT + RSC_SP_CTRL_GROUP_Y)
+
+#define MANAGE_ROW7 (MANAGE_DLG_HEIGHT - RSC_SP_DLG_INNERBORDER_BOTTOM - RSC_CD_PUSHBUTTON_HEIGHT)
+#define MANAGE_ROW6 (MANAGE_ROW7 - RSC_SP_FLGR_SPACE_Y - RSC_CD_FIXEDLINE_HEIGHT)
+#define MANAGE_ROW5 (MANAGE_ROW6 - RSC_SP_FLGR_SPACE_Y - INFO_LINES_COUNT*RSC_CD_FIXEDTEXT_HEIGHT)
+#define MANAGE_ROW4 (MANAGE_ROW5 - RSC_SP_CTRL_GROUP_Y - RSC_CD_PUSHBUTTON_HEIGHT)
+#define MANAGE_ROW4A (MANAGE_ROW4 + RSC_CD_PUSHBUTTON_HEIGHT)
+
+#define MANAGE_LB_WIDTH (MANAGE_COL3 - RSC_SP_CTRL_X - RSC_SP_DLG_INNERBORDER_LEFT)
+#define MANAGE_LB_HEIGHT (MANAGE_ROW4A - MANAGE_ROW2)
+
+#define SETDEF_DLG_WIDTH 180
+#define SETDEF_DLG_HEIGHT 165
+
+#define SETDEF_COL1 RSC_SP_DLG_INNERBORDER_LEFT
+#define SETDEF_COL2 (SETDEF_DLG_WIDTH - RSC_SP_DLG_INNERBORDER_RIGHT - 3*RSC_CD_PUSHBUTTON_WIDTH - RSC_SP_CTRL_GROUP_X - RSC_SP_CTRL_X)
+#define SETDEF_COL3 (SETDEF_COL2 + RSC_CD_PUSHBUTTON_WIDTH + RSC_SP_CTRL_GROUP_X)
+#define SETDEF_COL4 (SETDEF_COL3 + RSC_CD_PUSHBUTTON_WIDTH + RSC_SP_CTRL_X)
+#define SETDEF_COL4A (SETDEF_COL4 + RSC_CD_PUSHBUTTON_WIDTH)
+
+#define SETDEF_ROW1 RSC_SP_DLG_INNERBORDER_TOP
+#define SETDEF_ROW2 (SETDEF_ROW1 + RSC_CD_FIXEDTEXT_HEIGHT + RSC_SP_CTRL_DESC_Y)
+
+#define SETDEF_ROW5 (SETDEF_DLG_HEIGHT - RSC_SP_DLG_INNERBORDER_BOTTOM - RSC_CD_PUSHBUTTON_HEIGHT)
+#define SETDEF_ROW4 (SETDEF_ROW5 - RSC_SP_FLGR_SPACE_Y - RSC_CD_FIXEDLINE_HEIGHT)
+#define SETDEF_ROW3 (SETDEF_ROW4 - RSC_SP_FLGR_SPACE_Y - INFO_LINES_COUNT*RSC_CD_FIXEDTEXT_HEIGHT)
+#define SETDEF_ROW3A (SETDEF_ROW3 - RSC_SP_CTRL_GROUP_Y)
+
+#define SETDEF_LB_WIDTH (SETDEF_COL4A - SETDEF_COL1)
+#define SETDEF_LB_HEIGHT (SETDEF_ROW3A - SETDEF_ROW2)
+
+#endif // _BASCTL_MANAGELANG_HRC
+
diff --git a/basctl/source/dlged/managelang.src b/basctl/source/dlged/managelang.src
new file mode 100644
index 000000000000..b03421e1aa22
--- /dev/null
+++ b/basctl/source/dlged/managelang.src
@@ -0,0 +1,232 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "dlgresid.hrc"
+#include "managelang.hrc"
+#include "helpid.hrc"
+
+ModalDialog RID_DLG_MANAGE_LANGUAGE
+{
+ HelpId = HID_BASICIDE_MANAGE_LANGUAGE ;
+ OutputSize = TRUE ;
+ Size = MAP_APPFONT ( MANAGE_DLG_WIDTH , MANAGE_DLG_HEIGHT ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text [ en-US ] = "Manage User Interface Languages [$1]" ;
+ FixedText FT_LANGUAGE
+ {
+ Pos = MAP_APPFONT ( MANAGE_COL1 , MANAGE_ROW1 ) ;
+ Size = MAP_APPFONT ( MANAGE_LB_WIDTH , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Present Languages" ;
+ };
+ ListBox LB_LANGUAGE
+ {
+ Pos = MAP_APPFONT ( MANAGE_COL1 , MANAGE_ROW2 ) ;
+ Size = MAP_APPFONT ( MANAGE_LB_WIDTH , MANAGE_LB_HEIGHT ) ;
+ Border = TRUE;
+ AutoHScroll = TRUE ;
+ };
+ PushButton PB_ADD_LANG
+ {
+ Pos = MAP_APPFONT ( MANAGE_COL3 , MANAGE_ROW2 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Add..." ;
+ };
+ PushButton PB_DEL_LANG
+ {
+ Pos = MAP_APPFONT ( MANAGE_COL3 , MANAGE_ROW3 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Delete" ;
+ };
+ PushButton PB_MAKE_DEFAULT
+ {
+ Pos = MAP_APPFONT ( MANAGE_COL3 , MANAGE_ROW4 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Default" ;
+ };
+ FixedText FT_INFO
+ {
+ Pos = MAP_APPFONT ( MANAGE_COL1 , MANAGE_ROW5 ) ;
+ Size = MAP_APPFONT ( MANAGE_DLG_WIDTH - 2*RSC_SP_FLGR_INNERBORDER_LEFT, INFO_LINES_COUNT*RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "The default language is used if no localization for a user interface locale is present. Furthermore all strings from the default language are copied to resources of newly added languages." ;
+ };
+ FixedLine FL_BUTTONS
+ {
+ Pos = MAP_APPFONT ( 0 , MANAGE_ROW6 ) ;
+ Size = MAP_APPFONT ( MANAGE_DLG_WIDTH, RSC_CD_FIXEDLINE_HEIGHT ) ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( MANAGE_COL2 , MANAGE_ROW7 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ OKButton PB_CLOSE
+ {
+ Pos = MAP_APPFONT ( MANAGE_COL3 , MANAGE_ROW7 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ Text [ en-US ] = "~Close" ;
+ };
+ String STR_DEF_LANG
+ {
+ Text [ en-US ] = "[Default Language]" ;
+ };
+ String STR_DELETE
+ {
+ Text [ en-US ] = "~Delete" ;
+ };
+ String STR_CREATE_LANG
+ {
+ Text [ en-US ] = "<Press 'Add' to create language resources>" ;
+ };
+};
+
+QueryBox RID_QRYBOX_LANGUAGE
+{
+ Title [ en-US ] = "Delete Language Resources" ;
+ Message [ en-US ] = "You are about to delete the resources for the selected language(s). All user interface strings for this language(s) will be deleted.\n\nDo you want to delete the resources of the selected language(s)?";
+ BUTTONS = WB_OK_CANCEL ;
+ DEFBUTTON = WB_DEF_CANCEL ;
+};
+
+ModalDialog RID_DLG_SETDEF_LANGUAGE
+{
+ HelpId = HID_BASICIDE_SETDEFAULT_LANGUAGE ;
+ OutputSize = TRUE ;
+ Size = MAP_APPFONT ( SETDEF_DLG_WIDTH , SETDEF_DLG_HEIGHT ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text [ en-US ] = "Set Default User Interface Language" ;
+ FixedText FT_DEF_LANGUAGE
+ {
+ Pos = MAP_APPFONT ( SETDEF_COL1 , SETDEF_ROW1 ) ;
+ Size = MAP_APPFONT ( SETDEF_LB_WIDTH , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Default language" ;
+ };
+ ListBox LB_DEF_LANGUAGE
+ {
+ Pos = MAP_APPFONT ( SETDEF_COL1 , SETDEF_ROW2 ) ;
+ Size = MAP_APPFONT ( SETDEF_LB_WIDTH , SETDEF_LB_HEIGHT ) ;
+ Border = TRUE;
+ AutoHScroll = TRUE ;
+ };
+ Control LB_ADD_LANGUAGE
+ {
+ HelpId = HID_BASICIDE_ADDNEW_CONTROL ;
+ Pos = MAP_APPFONT ( SETDEF_COL1 , SETDEF_ROW2 ) ;
+ Size = MAP_APPFONT ( SETDEF_LB_WIDTH , SETDEF_LB_HEIGHT ) ;
+ };
+ FixedText FT_DEF_INFO
+ {
+ Pos = MAP_APPFONT ( SETDEF_COL1 , SETDEF_ROW3 ) ;
+ Size = MAP_APPFONT ( SETDEF_LB_WIDTH, INFO_LINES_COUNT*RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "Select a language to define the default user interface language. All currently present strings will be assigned to the resources created for the selected language." ;
+ };
+ FixedLine FL_DEF_BUTTONS
+ {
+ Pos = MAP_APPFONT ( 0 , SETDEF_ROW4 ) ;
+ Size = MAP_APPFONT ( SETDEF_DLG_WIDTH, RSC_CD_FIXEDLINE_HEIGHT ) ;
+ };
+ OKButton PB_DEF_OK
+ {
+ Pos = MAP_APPFONT ( SETDEF_COL2 , SETDEF_ROW5 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton PB_DEF_CANCEL
+ {
+ Pos = MAP_APPFONT ( SETDEF_COL3 , SETDEF_ROW5 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton PB_DEF_HELP
+ {
+ Pos = MAP_APPFONT ( SETDEF_COL4 , SETDEF_ROW5 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ String STR_ADDLANG_TITLE
+ {
+ Text [ en-US ] = "Add User Interface Languages" ;
+ };
+ String STR_ADDLANG_LABEL
+ {
+ Text [ en-US ] = "Available Languages" ;
+ };
+ String STR_ADDLANG_INFO
+ {
+ Text [ en-US ] = "Select languages to be added. Resources for these languages will be created in the library. Strings of the current default user interface language will be copied to these new resources by default." ;
+ };
+};
+
+// -----------------------------------------------------------------------
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/basctl/source/dlged/propbrw.cxx b/basctl/source/dlged/propbrw.cxx
new file mode 100644
index 000000000000..d210482a8ef5
--- /dev/null
+++ b/basctl/source/dlged/propbrw.cxx
@@ -0,0 +1,624 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include <sal/macros.h>
+#include "propbrw.hxx"
+#include "dlgedobj.hxx"
+
+#include "basidesh.hxx"
+#include <iderid.hxx>
+
+#include <dlgresid.hrc>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <sfx2/bindings.hxx>
+#include <sfx2/childwin.hxx>
+#include <sfx2/objitem.hxx>
+
+#include <svx/svxids.hrc>
+#include <tools/shl.hxx>
+#include <vcl/stdtext.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svditer.hxx>
+#include <sfx2/viewsh.hxx>
+
+#include <toolkit/unohlp.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/composedprops.hxx>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/types.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/inspection/XObjectInspector.hpp>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/component_context.hxx>
+
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::comphelper;
+
+//============================================================================
+// PropBrwMgr
+//============================================================================
+
+SFX_IMPL_FLOATINGWINDOW(PropBrwMgr, SID_SHOW_PROPERTYBROWSER)
+
+//----------------------------------------------------------------------------
+
+PropBrwMgr::PropBrwMgr( Window* _pParent, sal_uInt16 nId,
+ SfxBindings *pBindings, SfxChildWinInfo* pInfo)
+ :SfxChildWindow( _pParent, nId )
+{
+ // set current selection
+ SfxViewShell* pShell = SfxViewShell::Current();
+ pWindow = new PropBrw(
+ ::comphelper::getProcessServiceFactory(),
+ pBindings,
+ this,
+ _pParent,
+ pShell ? pShell->GetCurrentDocument() : Reference< XModel >()
+ );
+
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+ ((SfxFloatingWindow*)pWindow)->Initialize( pInfo );
+
+ ((PropBrw*)pWindow)->Update( pShell );
+}
+
+//----------------------------------------------------------------------------
+void PropBrw::Update( const SfxViewShell* _pShell )
+{
+ const BasicIDEShell* pBasicIDEShell = dynamic_cast< const BasicIDEShell* >( _pShell );
+ OSL_ENSURE( pBasicIDEShell || !_pShell, "PropBrw::Update: invalid shell!" );
+ if ( pBasicIDEShell )
+ {
+ ImplUpdate( pBasicIDEShell->GetCurrentDocument(), pBasicIDEShell->GetCurDlgView() );
+ }
+ else if ( _pShell )
+ {
+ ImplUpdate( NULL, _pShell->GetDrawView() );
+ }
+ else
+ {
+ ImplUpdate( NULL, NULL );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+const long STD_WIN_SIZE_X = 300;
+const long STD_WIN_SIZE_Y = 350;
+
+const long STD_MIN_SIZE_X = 250;
+const long STD_MIN_SIZE_Y = 250;
+
+const long STD_WIN_POS_X = 50;
+const long STD_WIN_POS_Y = 50;
+const long WIN_BORDER = 2;
+const long MIN_WIN_SIZE_X = 50;
+const long MIN_WIN_SIZE_Y = 50;
+
+//----------------------------------------------------------------------------
+
+//============================================================================
+// PropBrw
+//============================================================================
+
+DBG_NAME(PropBrw)
+
+//----------------------------------------------------------------------------
+
+PropBrw::PropBrw( const Reference< XMultiServiceFactory >& _xORB, SfxBindings* _pBindings, PropBrwMgr* _pMgr, Window* _pParent,
+ const Reference< XModel >& _rxContextDocument )
+ :SfxFloatingWindow( _pBindings, _pMgr, _pParent, WinBits( WB_STDMODELESS | WB_SIZEABLE | WB_3DLOOK | WB_ROLLABLE ) )
+ ,m_bInitialStateChange(sal_True)
+ ,m_xORB(_xORB)
+ ,m_xContextDocument( _rxContextDocument )
+ ,pView( NULL )
+{
+ DBG_CTOR(PropBrw,NULL);
+
+ Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y);
+ SetMinOutputSizePixel(Size(STD_MIN_SIZE_X,STD_MIN_SIZE_Y));
+ SetOutputSizePixel(aPropWinSize);
+
+ try
+ {
+ // create a frame wrapper for myself
+ m_xMeAsFrame = Reference< XFrame >(m_xORB->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Frame")), UNO_QUERY);
+ if (m_xMeAsFrame.is())
+ {
+ m_xMeAsFrame->initialize( VCLUnoHelper::GetInterface ( this ) );
+ m_xMeAsFrame->setName(::rtl::OUString::createFromAscii("form property browser")); // change name!
+ }
+ }
+ catch (Exception&)
+ {
+ DBG_ERROR("PropBrw::PropBrw: could not create/initialize my frame!");
+ m_xMeAsFrame.clear();
+ }
+
+ ImplReCreateController();
+}
+
+//----------------------------------------------------------------------------
+
+void PropBrw::ImplReCreateController()
+{
+ OSL_PRECOND( m_xMeAsFrame.is(), "PropBrw::ImplCreateController: no frame for myself!" );
+ if ( !m_xMeAsFrame.is() )
+ return;
+
+ if ( m_xBrowserController.is() )
+ ImplDestroyController();
+
+ try
+ {
+ Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW );
+ Reference< XComponentContext > xOwnContext(
+ xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
+ UNO_QUERY_THROW );
+
+ // a ComponentContext for the
+ ::cppu::ContextEntry_Init aHandlerContextInfo[] =
+ {
+ ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( VCLUnoHelper::GetInterface ( this ) ) ),
+ ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ), makeAny( m_xContextDocument ) )
+ };
+ Reference< XComponentContext > xInspectorContext(
+ ::cppu::createComponentContext( aHandlerContextInfo, SAL_N_ELEMENTS( aHandlerContextInfo ), xOwnContext ) );
+
+ // create a property browser controller
+ Reference< XMultiComponentFactory > xFactory( xInspectorContext->getServiceManager(), UNO_QUERY_THROW );
+ static const ::rtl::OUString s_sControllerServiceName = ::rtl::OUString::createFromAscii("com.sun.star.awt.PropertyBrowserController");
+ m_xBrowserController = Reference< XPropertySet >(
+ xFactory->createInstanceWithContext( s_sControllerServiceName, xInspectorContext ), UNO_QUERY
+ );
+ if ( !m_xBrowserController.is() )
+ {
+ ShowServiceNotAvailableError( GetParent(), s_sControllerServiceName, sal_True );
+ }
+ else
+ {
+ Reference< XController > xAsXController( m_xBrowserController, UNO_QUERY );
+ DBG_ASSERT(xAsXController.is(), "PropBrw::PropBrw: invalid controller object!");
+ if (!xAsXController.is())
+ {
+ ::comphelper::disposeComponent(m_xBrowserController);
+ m_xBrowserController.clear();
+ }
+ else
+ {
+ xAsXController->attachFrame(m_xMeAsFrame);
+ m_xBrowserComponentWindow = m_xMeAsFrame->getComponentWindow();
+ DBG_ASSERT(m_xBrowserComponentWindow.is(), "PropBrw::PropBrw: attached the controller, but have no component window!");
+ }
+ }
+
+ Point aPropWinPos = Point( WIN_BORDER, WIN_BORDER );
+ Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y);
+ aPropWinSize.Width() -= (2*WIN_BORDER);
+ aPropWinSize.Height() -= (2*WIN_BORDER);
+
+ if ( m_xBrowserComponentWindow.is() )
+ {
+ m_xBrowserComponentWindow->setPosSize(aPropWinPos.X(), aPropWinPos.Y(), aPropWinSize.Width(), aPropWinSize.Height(),
+ ::com::sun::star::awt::PosSize::WIDTH | ::com::sun::star::awt::PosSize::HEIGHT |
+ ::com::sun::star::awt::PosSize::X | ::com::sun::star::awt::PosSize::Y);
+ m_xBrowserComponentWindow->setVisible(sal_True);
+ }
+ }
+ catch (Exception&)
+ {
+ DBG_ERROR("PropBrw::PropBrw: could not create/initialize the browser controller!");
+ try
+ {
+ ::comphelper::disposeComponent(m_xBrowserController);
+ ::comphelper::disposeComponent(m_xBrowserComponentWindow);
+ }
+ catch(Exception&)
+ {
+ }
+
+ m_xBrowserController.clear();
+ m_xBrowserComponentWindow.clear();
+ }
+
+ Resize();
+}
+
+//----------------------------------------------------------------------------
+
+PropBrw::~PropBrw()
+{
+ if ( m_xBrowserController.is() )
+ ImplDestroyController();
+
+ DBG_DTOR(PropBrw,NULL);
+}
+
+//----------------------------------------------------------------------------
+
+void PropBrw::ImplDestroyController()
+{
+ implSetNewObject( Reference< XPropertySet >() );
+
+ if ( m_xMeAsFrame.is() )
+ m_xMeAsFrame->setComponent( NULL, NULL );
+
+ Reference< XController > xAsXController( m_xBrowserController, UNO_QUERY );
+ if ( xAsXController.is() )
+ xAsXController->attachFrame( NULL );
+
+ try
+ {
+ ::comphelper::disposeComponent( m_xBrowserController );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_xBrowserController.clear();
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool PropBrw::Close()
+{
+ ImplDestroyController();
+
+ if( IsRollUp() )
+ RollDown();
+
+ sal_Bool bClose = SfxFloatingWindow::Close();
+
+ return bClose;
+}
+
+//----------------------------------------------------------------------------
+Sequence< Reference< XInterface > >
+ PropBrw::CreateMultiSelectionSequence( const SdrMarkList& _rMarkList )
+{
+ Sequence< Reference< XInterface > > aSeq;
+ InterfaceArray aInterfaces;
+
+ sal_uInt32 nMarkCount = _rMarkList.GetMarkCount();
+ for( sal_uInt32 i = 0 ; i < nMarkCount ; i++ )
+ {
+ SdrObject* pCurrent = _rMarkList.GetMark(i)->GetMarkedSdrObj();
+
+ SdrObjListIter* pGroupIterator = NULL;
+ if (pCurrent->IsGroupObject())
+ {
+ pGroupIterator = new SdrObjListIter(*pCurrent->GetSubList());
+ pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
+ }
+
+ while (pCurrent)
+ {
+ DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pCurrent);
+ if (pDlgEdObj)
+ {
+ Reference< XInterface > xControlInterface(pDlgEdObj->GetUnoControlModel(), UNO_QUERY);
+ if (xControlInterface.is())
+ aInterfaces.push_back(xControlInterface);
+ }
+
+ // next element
+ pCurrent = pGroupIterator && pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
+ }
+ if (pGroupIterator)
+ delete pGroupIterator;
+ }
+
+ sal_Int32 nCount = aInterfaces.size();
+ aSeq.realloc( nCount );
+ Reference< XInterface >* pInterfaces = aSeq.getArray();
+ for( sal_Int32 i = 0 ; i < nCount ; i++ )
+ pInterfaces[i] = aInterfaces[i];
+
+ return aSeq;
+}
+
+//----------------------------------------------------------------------------
+void PropBrw::implSetNewObjectSequence
+ ( const Sequence< Reference< XInterface > >& _rObjectSeq )
+{
+ Reference< inspection::XObjectInspector > xObjectInspector(m_xBrowserController, UNO_QUERY);
+ if ( xObjectInspector.is() )
+ {
+ xObjectInspector->inspect( _rObjectSeq );
+
+ ::rtl::OUString aText = ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_PROPERTIES)));
+ aText += ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_MULTISELECT)));
+ SetText( aText );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void PropBrw::implSetNewObject( const Reference< XPropertySet >& _rxObject )
+{
+ if ( m_xBrowserController.is() )
+ {
+ m_xBrowserController->setPropertyValue(
+ ::rtl::OUString::createFromAscii( "IntrospectedObject" ),
+ makeAny( _rxObject )
+ );
+
+ // set the new title according to the selected object
+ SetText( GetHeadlineName( _rxObject ) );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+::rtl::OUString PropBrw::GetHeadlineName( const Reference< XPropertySet >& _rxObject )
+{
+ ::rtl::OUString aName;
+ Reference< lang::XServiceInfo > xServiceInfo( _rxObject, UNO_QUERY );
+
+ if (xServiceInfo.is()) // single selection
+ {
+ sal_uInt16 nResId = 0;
+ aName = ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_PROPERTIES)));
+
+ if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_DIALOG;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_BUTTON;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_RADIOBUTTON;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_CHECKBOX;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_LISTBOX;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_COMBOBOX;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlGroupBoxModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_GROUPBOX;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEditModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_EDIT;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedTextModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_FIXEDTEXT;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlImageControlModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_IMAGECONTROL;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlProgressBarModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_PROGRESSBAR;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_SCROLLBAR;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedLineModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_FIXEDLINE;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDateFieldModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_DATEFIELD;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlTimeFieldModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_TIMEFIELD;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlNumericFieldModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_NUMERICFIELD;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCurrencyFieldModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_CURRENCYFIELD;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFormattedFieldModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_FORMATTEDFIELD;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlPatternFieldModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_PATTERNFIELD;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFileControlModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_FILECONTROL;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.tree.TreeControlModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_TREECONTROL;
+ }
+ else
+ {
+ nResId = RID_STR_CLASS_CONTROL;
+ }
+
+ if (nResId)
+ {
+ aName += ::rtl::OUString( String(IDEResId(nResId)) );
+ }
+ }
+ else if (!_rxObject.is()) // no properties
+ {
+ aName = ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_NO_PROPERTIES)));
+ }
+ // #i73075 Handled in implSetNewObjectSequence
+ //else // multiselection
+ //{
+ // aName = ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_PROPERTIES)));
+ // aName += ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_MULTISELECT)));
+ //}
+
+ return aName;
+}
+
+//----------------------------------------------------------------------------
+
+void PropBrw::FillInfo( SfxChildWinInfo& rInfo ) const
+{
+ rInfo.bVisible = sal_False;
+}
+
+//----------------------------------------------------------------------------
+
+void PropBrw::Resize()
+{
+ SfxFloatingWindow::Resize();
+
+ // adjust size
+ Size aSize_ = GetOutputSizePixel();
+ Size aPropWinSize( aSize_ );
+ aPropWinSize.Width() -= (2*WIN_BORDER);
+ aPropWinSize.Height() -= (2*WIN_BORDER);
+
+ if (m_xBrowserComponentWindow.is())
+ {
+ m_xBrowserComponentWindow->setPosSize(0, 0, aPropWinSize.Width(), aPropWinSize.Height(),
+ ::com::sun::star::awt::PosSize::WIDTH | ::com::sun::star::awt::PosSize::HEIGHT);
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void PropBrw::ImplUpdate( const Reference< XModel >& _rxContextDocument, SdrView* pNewView )
+{
+ Reference< XModel > xContextDocument( _rxContextDocument );
+
+ // if we should simply "empty" ourself, assume the context document didn't change
+ if ( !pNewView )
+ {
+ OSL_ENSURE( !_rxContextDocument.is(), "PropBrw::ImplUpdate: no view, but a document?!" );
+ xContextDocument = m_xContextDocument;
+ }
+
+ if ( xContextDocument != m_xContextDocument )
+ {
+ m_xContextDocument = xContextDocument;
+ ImplReCreateController();
+ }
+
+ try
+ {
+ if ( pView )
+ {
+ EndListening( *(pView->GetModel()) );
+ pView = NULL;
+ }
+
+ if ( !pNewView )
+ return;
+
+ pView = pNewView;
+
+ // set focus on initialization
+ if ( m_bInitialStateChange )
+ {
+ if ( m_xBrowserComponentWindow.is() )
+ m_xBrowserComponentWindow->setFocus();
+ m_bInitialStateChange = sal_False;
+ }
+
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ sal_uInt32 nMarkCount = rMarkList.GetMarkCount();
+
+ if ( nMarkCount == 0 )
+ {
+ EndListening( *(pView->GetModel()) );
+ pView = NULL;
+ implSetNewObject( NULL );
+ return;
+ }
+
+ Reference< XPropertySet > xNewObject;
+ Sequence< Reference< XInterface > > aNewObjects;
+ if ( nMarkCount == 1 )
+ {
+ DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, rMarkList.GetMark(0)->GetMarkedSdrObj() );
+ if ( pDlgEdObj )
+ {
+ if ( pDlgEdObj->IsGroupObject() ) // group object
+ aNewObjects = CreateMultiSelectionSequence( rMarkList );
+ else // single selection
+ xNewObject = xNewObject.query( pDlgEdObj->GetUnoControlModel() );
+ }
+ }
+ else if ( nMarkCount > 1 ) // multiple selection
+ {
+ aNewObjects = CreateMultiSelectionSequence( rMarkList );
+ }
+
+ if ( aNewObjects.getLength() )
+ implSetNewObjectSequence( aNewObjects );
+ else
+ implSetNewObject( xNewObject );
+
+ StartListening( *(pView->GetModel()) );
+ }
+ catch ( const PropertyVetoException& ) { /* silence */ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/accessibledialogcontrolshape.hxx b/basctl/source/inc/accessibledialogcontrolshape.hxx
new file mode 100644
index 000000000000..f45e4eb31e44
--- /dev/null
+++ b/basctl/source/inc/accessibledialogcontrolshape.hxx
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_ACCESSIBLEDIALOGCONTROLSHAPE_HXX_
+#define _BASCTL_ACCESSIBLEDIALOGCONTROLSHAPE_HXX_
+
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <comphelper/accessiblecomponenthelper.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <vector>
+
+class Window;
+class DialogWindow;
+class DlgEdObj;
+class VCLExternalSolarLock;
+
+namespace utl {
+class AccessibleStateSetHelper;
+}
+
+
+// ----------------------------------------------------
+// class AccessibleDialogControlShape
+// ----------------------------------------------------
+
+typedef ::comphelper::OAccessibleExtendedComponentHelper AccessibleExtendedComponentHelper_BASE;
+
+typedef ::cppu::ImplHelper3<
+ ::com::sun::star::accessibility::XAccessible,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::beans::XPropertyChangeListener > AccessibleDialogControlShape_BASE;
+
+class AccessibleDialogControlShape : public AccessibleExtendedComponentHelper_BASE,
+ public AccessibleDialogControlShape_BASE
+{
+ friend class AccessibleDialogWindow;
+
+private:
+ VCLExternalSolarLock* m_pExternalLock;
+ DialogWindow* m_pDialogWindow;
+ DlgEdObj* m_pDlgEdObj;
+ sal_Bool m_bFocused;
+ sal_Bool m_bSelected;
+
+ ::com::sun::star::awt::Rectangle m_aBounds;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xControlModel;
+
+protected:
+ sal_Bool IsFocused();
+ sal_Bool IsSelected();
+
+ void SetFocused( sal_Bool bFocused );
+ void SetSelected( sal_Bool bSelected );
+
+ ::com::sun::star::awt::Rectangle GetBounds();
+ void SetBounds( const ::com::sun::star::awt::Rectangle& aBounds );
+
+ Window* GetWindow() const;
+
+ ::rtl::OUString GetModelStringProperty( const sal_Char* pPropertyName );
+
+ virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet );
+
+ // OCommonAccessibleComponent
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ virtual void SAL_CALL disposing();
+
+public:
+ AccessibleDialogControlShape( DialogWindow* pDialogWindow, DlgEdObj* pDlgEdObj );
+ virtual ~AccessibleDialogControlShape();
+
+ // XInterface
+ DECLARE_XINTERFACE()
+
+ // XTypeProvider
+ DECLARE_XTYPEPROVIDER()
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rSource ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessible
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleContext
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleComponent
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleExtendedComponent
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL getFont( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTitledBorderText( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getToolTipText( ) throw (::com::sun::star::uno::RuntimeException);
+};
+
+
+#endif // _BASCTL_ACCESSIBLEDIALOGCONTROLSHAPE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/accessibledialogwindow.hxx b/basctl/source/inc/accessibledialogwindow.hxx
new file mode 100644
index 000000000000..ed8594a5c071
--- /dev/null
+++ b/basctl/source/inc/accessibledialogwindow.hxx
@@ -0,0 +1,177 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_ACCESSIBLEDIALOGWINDOW_HXX_
+#define _BASCTL_ACCESSIBLEDIALOGWINDOW_HXX_
+
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/accessiblecomponenthelper.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <tools/link.hxx>
+#include <svl/lstner.hxx>
+
+#include <vector>
+
+class DialogWindow;
+class DlgEditor;
+class DlgEdModel;
+class DlgEdObj;
+class VCLExternalSolarLock;
+class VclSimpleEvent;
+class VclWindowEvent;
+
+namespace utl {
+class AccessibleStateSetHelper;
+}
+
+
+// ----------------------------------------------------
+// class AccessibleDialogWindow
+// ----------------------------------------------------
+
+typedef ::comphelper::OAccessibleExtendedComponentHelper AccessibleExtendedComponentHelper_BASE;
+
+typedef ::cppu::ImplHelper3 <
+ ::com::sun::star::accessibility::XAccessible,
+ ::com::sun::star::accessibility::XAccessibleSelection,
+ ::com::sun::star::lang::XServiceInfo > AccessibleDialogWindow_BASE;
+
+class AccessibleDialogWindow : public AccessibleExtendedComponentHelper_BASE,
+ public AccessibleDialogWindow_BASE,
+ public SfxListener
+{
+private:
+
+ class ChildDescriptor
+ {
+ public:
+ DlgEdObj* pDlgEdObj;
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > rxAccessible;
+
+ ChildDescriptor( DlgEdObj* _pDlgEdObj );
+ ~ChildDescriptor();
+
+ ChildDescriptor( const ChildDescriptor& rDesc );
+ ChildDescriptor& operator=( const ChildDescriptor& rDesc );
+
+ bool operator==( const ChildDescriptor& rDesc );
+ bool operator<( const ChildDescriptor& rDesc ) const;
+ };
+
+ typedef ::std::vector< ChildDescriptor > AccessibleChildren;
+
+ AccessibleChildren m_aAccessibleChildren;
+ VCLExternalSolarLock* m_pExternalLock;
+ DialogWindow* m_pDialogWindow;
+ DlgEditor* m_pDlgEditor;
+ DlgEdModel* m_pDlgEdModel;
+
+protected:
+ void UpdateFocused();
+ void UpdateSelected();
+ void UpdateBounds();
+
+ sal_Bool IsChildVisible( const ChildDescriptor& rDesc );
+
+ void InsertChild( const ChildDescriptor& rDesc );
+ void RemoveChild( const ChildDescriptor& rDesc );
+ void UpdateChild( const ChildDescriptor& rDesc );
+ void UpdateChildren();
+ void SortChildren();
+
+ DECL_LINK( WindowEventListener, VclSimpleEvent* );
+
+ virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
+ virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet );
+
+ // OCommonAccessibleComponent
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ virtual void SAL_CALL disposing();
+
+public:
+ AccessibleDialogWindow( DialogWindow* pDialogWindow );
+ ~AccessibleDialogWindow();
+
+ // SfxListener
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ // XInterface
+ DECLARE_XINTERFACE()
+
+ // XTypeProvider
+ DECLARE_XTYPEPROVIDER()
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessible
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleContext
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleComponent
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleExtendedComponent
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL getFont( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTitledBorderText( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getToolTipText( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleSelection
+ virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearAccessibleSelection( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL selectAllAccessibleChildren( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+};
+
+
+#endif // _BASCTL_ACCESSIBLEDIALOGWINDOW_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/baside3.hxx b/basctl/source/inc/baside3.hxx
new file mode 100644
index 000000000000..505998d32bcb
--- /dev/null
+++ b/basctl/source/inc/baside3.hxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASIDE3_HXX
+#define _BASIDE3_HXX
+
+#include <bastypes.hxx>
+#include <svl/undo.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/fixed.hxx>
+
+#include <com/sun/star/script/XLibraryContainer.hpp>
+
+class Printer;
+class StarBASIC;
+class SfxItemSet;
+class DlgEditor;
+class DlgEdModel;
+class DlgEdPage;
+class DlgEdView;
+class SfxUndoManager;
+
+class DialogWindow: public IDEBaseWindow
+{
+private:
+ DlgEditor* pEditor;
+ SfxUndoManager* pUndoMgr;
+ Link aOldNotifyUndoActionHdl;
+ String aCurPath;
+
+protected:
+ virtual void Paint( const Rectangle& );
+ virtual void Resize();
+
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual void LoseFocus();
+
+ DECL_LINK( NotifyUndoActionHdl, SfxUndoAction * );
+ virtual void DoInit();
+ virtual void DoScroll( ScrollBar* pCurScrollBar );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+ void InitSettings(BOOL bFont,BOOL bForeground,BOOL bBackground);
+
+public:
+ TYPEINFO();
+ DialogWindow( Window* pParent, const ScriptDocument& rDocument, String aLibName, String aName,
+ const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >& xDialogModel );
+ DialogWindow( DialogWindow* pCurView ); // never implemented
+ ~DialogWindow();
+
+ virtual void ExecuteCommand( SfxRequest& rReq );
+ virtual void GetState( SfxItemSet& );
+ DlgEditor* GetEditor() const { return pEditor; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > GetDialog() const;
+ DlgEdModel* GetModel() const;
+ DlgEdPage* GetPage() const;
+ DlgEdView* GetView() const;
+ BOOL RenameDialog( const String& rNewName );
+ void DisableBrowser();
+ void UpdateBrowser();
+ BOOL SaveDialog();
+ BOOL ImportDialog();
+
+ virtual String GetTitle();
+ virtual BasicEntryDescriptor CreateEntryDescriptor();
+ virtual void SetReadOnly( BOOL bReadOnly );
+ virtual BOOL IsReadOnly();
+
+ virtual void StoreData();
+ virtual BOOL IsModified();
+ virtual BOOL IsPasteAllowed();
+
+ virtual SfxUndoManager* GetUndoManager();
+ // return number of pages to be printed
+ virtual sal_Int32 countPages( Printer* pPrinter );
+ // print page
+ virtual void printPage( sal_Int32 nPage, Printer* pPrinter );
+ virtual void Deactivating();
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+};
+
+#endif // _BASIDE3_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/basidectrlr.hxx b/basctl/source/inc/basidectrlr.hxx
new file mode 100644
index 000000000000..8532b7691c74
--- /dev/null
+++ b/basctl/source/inc/basidectrlr.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_BASICIDECTRLR_HXX
+#define _BASCTL_BASICIDECTRLR_HXX
+
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <sfx2/sfxbasecontroller.hxx>
+
+
+class BasicIDEShell;
+
+
+class BasicIDEController :public comphelper::OMutexAndBroadcastHelper
+ ,public ::comphelper::OPropertyContainer
+ ,public ::comphelper::OPropertyArrayUsageHelper< BasicIDEController >
+ ,public SfxBaseController
+{
+private:
+ // properties
+ sal_Int32 m_nIconId;
+
+public:
+ BasicIDEController( BasicIDEShell* pViewShell );
+ virtual ~BasicIDEController();
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XTypeProvider ( ::SfxBaseController )
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw( ::com::sun::star::uno::RuntimeException );
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+protected:
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+};
+
+#endif // _BASCTL_BASICIDECTRLR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/basidesh.hxx b/basctl/source/inc/basidesh.hxx
new file mode 100644
index 000000000000..9fb76f628f7b
--- /dev/null
+++ b/basctl/source/inc/basidesh.hxx
@@ -0,0 +1,239 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BASIDESH_HXX
+#define _BASIDESH_HXX
+
+#include "sbxitem.hxx"
+
+#include "scriptdocument.hxx"
+#include "doceventnotifier.hxx"
+#include <sfx2/viewfac.hxx>
+#include <sfx2/shell.hxx>
+#include <vcl/scrbar.hxx>
+#include <tools/table.hxx>
+#include <sfx2/viewsh.hxx>
+#include <svx/ifaceids.hxx>
+
+#include <com/sun/star/io/XInputStreamProvider.hpp>
+
+#include <com/sun/star/container/XContainerListener.hpp>
+
+//----------------------------------------------------------------------------
+
+const ULONG BASICIDE_UI_FEATURE_SHOW_BROWSER = 0x00000001;
+
+//----------------------------------------------------------------------------
+
+class ModulWindow;
+class ModulWindowLayout;
+class DialogWindow;
+class SdrView;
+class ObjectCatalog;
+class BasicIDETabBar;
+class TabBar;
+class IDEBaseWindow;
+class SbxObject;
+class SbModule;
+class StarBASIC;
+class LocalizationMgr;
+struct BasicIDEShell_Impl;
+
+#if _SOLAR__PRIVATE
+DECLARE_TABLE( IDEWindowTable, IDEBaseWindow* )
+#else
+typedef Table IDEWindowTable;
+#endif
+
+namespace BasicIDE
+{
+ bool RemoveDialog( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName );
+}
+
+class BasicIDEShell :public SfxViewShell
+ ,public ::basctl::DocumentEventListener
+{
+friend class JavaDebuggingListenerImpl;
+friend class LocalizationMgr;
+friend BOOL implImportDialog( Window* pWin, const String& rCurPath, const ScriptDocument& rDocument, const String& aLibName );
+friend bool BasicIDE::RemoveDialog( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName );
+
+ ObjectCatalog* pObjectCatalog;
+
+ IDEWindowTable aIDEWindowTable;
+ USHORT nCurKey;
+ IDEBaseWindow* pCurWin;
+ ScriptDocument m_aCurDocument;
+ String m_aCurLibName;
+ LocalizationMgr* m_pCurLocalizationMgr;
+
+ ScrollBar aHScrollBar;
+ ScrollBar aVScrollBar;
+ ScrollBarBox aScrollBarBox;
+ BasicIDETabBar* pTabBar;
+ BOOL bTabBarSplitted;
+ BOOL bCreatingWindow;
+ ModulWindowLayout* pModulLayout;
+ BOOL m_bAppBasicModified;
+ ::basctl::DocumentEventNotifier
+ m_aNotifier;
+friend class ContainerListenerImpl;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xLibListener;
+
+#if _SOLAR__PRIVATE
+ void Init();
+ void InitTabBar();
+ void InitScrollBars();
+ void CheckWindows();
+ void RemoveWindows( const ScriptDocument& rDocument, const String& rLibName, BOOL bDestroy );
+ void UpdateWindows();
+ void ShowObjectDialog( BOOL bShow, BOOL bCreateOrDestroy );
+ void InvalidateBasicIDESlots();
+ void StoreAllWindowData( BOOL bPersistent = TRUE );
+ void SetMDITitle();
+ void EnableScrollbars( BOOL bEnable );
+ void SetCurLib( const ScriptDocument& rDocument, String aLibName, bool bUpdateWindows = true , bool bCheck = true );
+ void SetCurLibForLocalization( const ScriptDocument& rDocument, String aLibName );
+
+ void ImplStartListening( StarBASIC* pBasic );
+
+ DECL_LINK( TabBarHdl, TabBar* );
+ DECL_LINK( AccelSelectHdl, Accelerator* );
+ DECL_LINK( ObjectDialogCancelHdl, ObjectCatalog * );
+ DECL_LINK( TabBarSplitHdl, TabBar * );
+#endif
+
+protected:
+ virtual void AdjustPosSizePixel( const Point &rPos, const Size &rSize );
+ virtual void OuterResizePixel( const Point &rPos, const Size &rSize );
+ virtual Size GetOptimalSizePixel() const;
+ USHORT InsertWindowInTable( IDEBaseWindow* pNewWin );
+ virtual USHORT PrepareClose( BOOL bUI, BOOL bForBrowsing );
+
+ void SetCurWindow( IDEBaseWindow* pNewWin, BOOL bUpdateTabBar = FALSE, BOOL bRememberAsCurrent = TRUE );
+ void ManageToolbars();
+ void RemoveWindow( IDEBaseWindow* pWindow, BOOL bDestroy, BOOL bAllowChangeCurWindow = TRUE );
+ void ArrangeTabBar();
+
+ ModulWindow* CreateBasWin( const ScriptDocument& rDocument, const String& rLibName, const String& rModName );
+ DialogWindow* CreateDlgWin( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName );
+
+ ModulWindow* FindBasWin( const ScriptDocument& rDocument, const String& rLibName, const String& rModName, BOOL bCreateIfNotExist, BOOL bFindSuspended = FALSE );
+ ModulWindow* ShowActiveModuleWindow( StarBASIC* pBasic );
+
+ virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
+ const SfxHint& rHint, const TypeId& rHintType );
+
+ virtual void Activate(BOOL bMDI);
+ virtual void Deactivate(BOOL bMDI);
+
+ virtual void Move();
+ virtual void ShowCursor( bool bOn = true );
+
+ void CreateModulWindowLayout();
+ void DestroyModulWindowLayout();
+ void UpdateModulWindowLayout( bool bBasicStopped );
+
+ // DocumentEventListener
+ virtual void onDocumentCreated( const ScriptDocument& _rDocument );
+ virtual void onDocumentOpened( const ScriptDocument& _rDocument );
+ virtual void onDocumentSave( const ScriptDocument& _rDocument );
+ virtual void onDocumentSaveDone( const ScriptDocument& _rDocument );
+ virtual void onDocumentSaveAs( const ScriptDocument& _rDocument );
+ virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument );
+ virtual void onDocumentClosed( const ScriptDocument& _rDocument );
+ virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument );
+ virtual void onDocumentModeChanged( const ScriptDocument& _rDocument );
+
+public:
+ TYPEINFO();
+ SFX_DECL_INTERFACE( SVX_INTERFACE_BASIDE_VIEWSH )
+ SFX_DECL_VIEWFACTORY(BasicIDEShell);
+
+ BasicIDEShell( SfxViewFrame *pFrame, SfxViewShell *pOldSh );
+ ~BasicIDEShell();
+
+ IDEBaseWindow* GetCurWindow() const { return pCurWin; }
+ const ScriptDocument&
+ GetCurDocument() const { return m_aCurDocument; }
+ const String& GetCurLibName() const { return m_aCurLibName; }
+ ObjectCatalog* GetObjectCatalog() const { return pObjectCatalog; }
+ LocalizationMgr* GetCurLocalizationMgr() const { return m_pCurLocalizationMgr; }
+
+ ScrollBar& GetHScrollBar() { return aHScrollBar; }
+ ScrollBar& GetVScrollBar() { return aVScrollBar; }
+ ScrollBarBox& GetScrollBarBox() { return aScrollBarBox; }
+ TabBar* GetTabBar() { return (TabBar*)pTabBar; }
+ IDEWindowTable& GetIDEWindowTable() { return aIDEWindowTable; }
+
+ SdrView* GetCurDlgView() const;
+
+ SfxUndoManager* GetUndoManager();
+
+ virtual com::sun::star::uno::Reference< com::sun::star::view::XRenderable > GetRenderable();
+
+ // virtual USHORT Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pPrintDialog = 0 );
+ virtual SfxPrinter* GetPrinter( BOOL bCreate );
+ virtual USHORT SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
+ virtual String GetSelectionText( BOOL bCompleteWords );
+ virtual BOOL HasSelection( BOOL bText ) const;
+
+ void GetState( SfxItemSet& );
+ void ExecuteGlobal( SfxRequest& rReq );
+ void ExecuteCurrent( SfxRequest& rReq );
+ void ExecuteBasic( SfxRequest& rReq );
+ void ExecuteDialog( SfxRequest& rReq );
+
+ virtual sal_Bool HasUIFeature( sal_uInt32 nFeature );
+
+ long CallBasicErrorHdl( StarBASIC* pBasic );
+ long CallBasicBreakHdl( StarBASIC* pBasic );
+
+ ModulWindowLayout* GetLayoutWindow() const { return pModulLayout; }
+
+ IDEBaseWindow* FindWindow( const ScriptDocument& rDocument, const String& rLibName = String(), const String& rName = String(), USHORT nType = BASICIDE_TYPE_UNKNOWN, BOOL bFindSuspended = FALSE );
+ DialogWindow* FindDlgWin( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName, BOOL bCreateIfNotExist, BOOL bFindSuspended = FALSE );
+ IDEBaseWindow* FindApplicationWindow();
+ BOOL NextPage( BOOL bPrev = FALSE );
+
+ BOOL IsAppBasicModified() const { return m_bAppBasicModified; }
+ void SetAppBasicModified( BOOL bModified = TRUE ) { m_bAppBasicModified = bModified; }
+
+ // For Dialog Drag&Drop in Dialog Organizer
+ static void CopyDialogResources(
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStreamProvider >& io_xISP,
+ const ScriptDocument& rSourceDoc, const String& rSourceLibName, const ScriptDocument& rDestDoc,
+ const String& rDestLibName, const String& rDlgName );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
+ GetCurrentDocument() const;
+
+};
+
+#endif // _BASIDESH_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/basobj.hxx b/basctl/source/inc/basobj.hxx
new file mode 100644
index 000000000000..c5c6f44587b9
--- /dev/null
+++ b/basctl/source/inc/basobj.hxx
@@ -0,0 +1,128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BASOBJ_HXX
+#define _BASOBJ_HXX
+
+#include "scriptdocument.hxx"
+#include <tools/string.hxx>
+#include <svl/lstner.hxx>
+
+#include <com/sun/star/io/XInputStreamProvider.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+
+class SfxMacro;
+class SbMethod;
+class SbModule;
+class SbxObject;
+class SbxVariable;
+class StarBASIC;
+class BasicManager;
+class SfxUInt16Item;
+class SfxBindings;
+class Window;
+struct BasicIDE_Impl;
+
+namespace BasicIDE
+{
+ void Organize( INT16 tabId );
+
+
+ // Hilfsmethoden fuer den allg. Gebrauch:
+ SbMethod* CreateMacro( SbModule* pModule, const String& rMacroName );
+ void RunMethod( SbMethod* pMethod );
+
+ StarBASIC* FindBasic( const SbxVariable* pVar );
+ void StopBasic();
+ long HandleBasicError( StarBASIC* pBasic );
+ void BasicStopped( BOOL* pbAppWindowDisabled = 0, BOOL* pbDispatcherLocked = 0, USHORT* pnWaitCount = 0,
+ SfxUInt16Item** ppSWActionCount = 0, SfxUInt16Item** ppSWLockViewCount = 0 );
+
+ BOOL IsValidSbxName( const String& rName );
+
+ BasicManager* FindBasicManager( StarBASIC* pLib );
+
+ SfxBindings* GetBindingsPtr();
+
+ void InvalidateDebuggerSlots();
+
+ // libraries
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > GetMergedLibraryNames(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >& xModLibContainer,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >& xDlgLibContainer );
+
+ // new methods for modules
+
+ ::rtl::OUString GetModule(
+ const ScriptDocument& rDocument, const String& rLibName, const String& rModName )
+ throw( ::com::sun::star::container::NoSuchElementException );
+
+ /** renames a module
+
+ Will show an error message when renaming fails because the new name is already used.
+ */
+ bool RenameModule(
+ Window* pErrorParent, const ScriptDocument& rDocument,
+ const String& rLibName, const String& rOldName, const String& rNewName );
+
+ // new methods for macros
+
+ ::rtl::OUString ChooseMacro( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxLimitToDocument,
+ BOOL bChooseOnly, const ::rtl::OUString& rMacroDesc );
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > GetMethodNames(
+ const ScriptDocument& rDocument, const String& rLibName, const String& rModName )
+ throw( ::com::sun::star::container::NoSuchElementException );
+
+ BOOL HasMethod(
+ const ScriptDocument& rDocument, const String& rLibName, const String& rModName, const String& rMethName );
+
+ // new methods for dialogs
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStreamProvider > GetDialog(
+ const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName )
+ throw( ::com::sun::star::container::NoSuchElementException );
+
+ /** renames a dialog
+
+ Will show an error message when renaming fails because the new name is already used.
+ */
+ bool RenameDialog(
+ Window* pErrorParent, const ScriptDocument& rDocument, const String& rLibName, const String& rOldName, const String& rNewName )
+ throw( ::com::sun::star::container::ElementExistException, ::com::sun::star::container::NoSuchElementException );
+
+ bool RemoveDialog(
+ const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName );
+
+ void MarkDocumentModified( const ScriptDocument& rDocument );
+}
+
+#endif // _BASOBJ_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx
new file mode 100644
index 000000000000..2d9ded65fef1
--- /dev/null
+++ b/basctl/source/inc/bastypes.hxx
@@ -0,0 +1,343 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BASTYPES_HXX
+#define _BASTYPES_HXX
+
+#include <svheader.hxx>
+
+#include <iderid.hxx>
+
+#include "scriptdocument.hxx"
+
+class ModulWindow;
+class SfxRequest;
+class SvTreeListBox;
+class SvLBoxEntry;
+class ScrollBar;
+class SbModule;
+class BasicManager;
+class SfxItemSet;
+#include <vcl/dockwin.hxx>
+#include <vcl/toolbox.hxx>
+#include <basic/sbstar.hxx>
+
+#include <iderid.hxx>
+
+#include <tools/table.hxx>
+
+#include <svtools/tabbar.hxx>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+
+#include <hash_map>
+
+#define LINE_SEP_CR 0x0D
+#define LINE_SEP 0x0A
+
+// Implementation: baside2b.cxx
+sal_Int32 searchEOL( const ::rtl::OUString& rStr, sal_Int32 fromIndex );
+
+
+// Bedeutung von bToBeKilled:
+// Wenn in Reschedule-Schleife, darf ich das Fenster nicht zerstoeren.
+// Es muss erst aus der Reschedule-Schleife Fallen, um sich dann
+// selbst zu zerstoeren.
+// Geht so leider nicht: Destroying Window with living Child!
+
+
+struct BasicStatus
+{
+// BOOL bCompiled : 1;
+ BOOL bIsRunning : 1;
+ BOOL bError : 1;
+ BOOL bIsInReschedule : 1;
+ USHORT nBasicFlags;
+
+ BasicStatus() {
+ bIsRunning = FALSE; bError = FALSE;
+ nBasicFlags = 0; bIsInReschedule = FALSE; }
+};
+
+struct BreakPoint
+{
+ BOOL bEnabled;
+ BOOL bTemp;
+ ULONG nLine;
+ ULONG nStopAfter;
+ ULONG nHitCount;
+
+ BreakPoint( ULONG nL ) { nLine = nL; nStopAfter = 0; nHitCount = 0; bEnabled = TRUE; bTemp = FALSE; }
+
+};
+
+class BasicDockingWindow : public DockingWindow
+{
+ Rectangle aFloatingPosAndSize;
+
+protected:
+ virtual BOOL Docking( const Point& rPos, Rectangle& rRect );
+ virtual void EndDocking( const Rectangle& rRect, BOOL bFloatMode );
+ virtual void ToggleFloatingMode();
+ virtual BOOL PrepareToggleFloatingMode();
+ virtual void StartDocking();
+
+public:
+ BasicDockingWindow( Window* pParent );
+};
+
+DECLARE_LIST( BreakPL, BreakPoint* )
+class BreakPointList : public BreakPL
+{
+private:
+ void operator =(BreakPointList); // not implemented
+
+public:
+ BreakPointList();
+
+ BreakPointList(BreakPointList const & rList);
+
+ ~BreakPointList();
+
+ void reset();
+
+ void transfer(BreakPointList & rList);
+
+ void InsertSorted( BreakPoint* pBrk );
+ BreakPoint* FindBreakPoint( ULONG nLine );
+ void AdjustBreakPoints( ULONG nLine, BOOL bInserted );
+ void SetBreakPointsInBasic( SbModule* pModule );
+ void ResetHitCount();
+};
+
+// helper class for sorting TabBar
+class TabBarSortHelper
+{
+public:
+ USHORT nPageId;
+ String aPageText;
+
+ bool operator<(const TabBarSortHelper& rComp) const { return (aPageText.CompareIgnoreCaseToAscii( rComp.aPageText ) == COMPARE_LESS); }
+};
+
+class BasicIDETabBar : public TabBar
+{
+protected:
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+
+ virtual long AllowRenaming();
+ virtual void EndRenaming();
+
+public:
+ BasicIDETabBar( Window* pParent );
+
+ void Sort();
+};
+
+#define BASWIN_OK 0x00
+#define BASWIN_RUNNINGBASIC 0x01
+#define BASWIN_TOBEKILLED 0x02
+#define BASWIN_SUSPENDED 0x04
+#define BASWIN_INRESCHEDULE 0x08
+
+class Printer;
+class SfxUndoManager;
+class BasicEntryDescriptor;
+
+class IDEBaseWindow : public Window
+{
+private:
+ ScrollBar* pShellHScrollBar;
+ ScrollBar* pShellVScrollBar;
+
+ DECL_LINK( ScrollHdl, ScrollBar * );
+ BYTE nStatus;
+
+ ScriptDocument m_aDocument;
+ String m_aLibName;
+ String m_aName;
+
+protected:
+ virtual void DoScroll( ScrollBar* pCurScrollBar );
+
+public:
+ TYPEINFO();
+ IDEBaseWindow( Window* pParent, const ScriptDocument& rDocument, String aLibName, String aName );
+ virtual ~IDEBaseWindow();
+
+ void Init();
+ virtual void DoInit();
+ virtual void Deactivating();
+ void GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll );
+
+ ScrollBar* GetHScrollBar() const { return pShellHScrollBar; }
+ ScrollBar* GetVScrollBar() const { return pShellVScrollBar; }
+
+ virtual void ExecuteCommand( SfxRequest& rReq );
+ virtual void GetState( SfxItemSet& );
+ virtual long Notify( NotifyEvent& rNEvt );
+
+ virtual void StoreData();
+ virtual void UpdateData();
+ virtual BOOL CanClose();
+
+ // return number of pages to be printed
+ virtual sal_Int32 countPages( Printer* pPrinter ) = 0;
+ // print page
+ virtual void printPage( sal_Int32 nPage, Printer* pPrinter ) = 0;
+
+ virtual String GetTitle();
+ String CreateQualifiedName();
+ virtual BasicEntryDescriptor CreateEntryDescriptor() = 0;
+
+ virtual BOOL IsModified();
+ virtual BOOL IsPasteAllowed();
+
+ virtual BOOL AllowUndo();
+
+ virtual void SetReadOnly( BOOL bReadOnly );
+ virtual BOOL IsReadOnly();
+
+ BYTE GetStatus() { return nStatus; }
+ void SetStatus( BYTE n ) { nStatus = n; }
+ void AddStatus( BYTE n ) { nStatus = nStatus | n; }
+ void ClearStatus( BYTE n ) { nStatus = nStatus & ~n; }
+
+ virtual Window* GetLayoutWindow();
+
+ virtual SfxUndoManager* GetUndoManager();
+
+ virtual USHORT GetSearchOptions();
+
+ virtual void BasicStarted();
+ virtual void BasicStopped();
+
+ BOOL IsSuspended() const
+ { return ( nStatus & BASWIN_SUSPENDED ) ? TRUE : FALSE; }
+
+ const ScriptDocument&
+ GetDocument() const { return m_aDocument; }
+ void SetDocument( const ScriptDocument& rDocument ) { m_aDocument = rDocument; }
+ bool IsDocument( const ScriptDocument& rDocument ) const { return rDocument == m_aDocument; }
+ const String& GetLibName() const { return m_aLibName; }
+ void SetLibName( const String& aLibName ) { m_aLibName = aLibName; }
+ const String& GetName() const { return m_aName; }
+ void SetName( const String& aName ) { m_aName = aName; }
+};
+
+class LibInfoKey
+{
+private:
+ ScriptDocument m_aDocument;
+ String m_aLibName;
+
+public:
+ LibInfoKey( const ScriptDocument& rDocument, const String& rLibName );
+ ~LibInfoKey();
+
+ LibInfoKey( const LibInfoKey& rKey );
+ LibInfoKey& operator=( const LibInfoKey& rKey );
+
+ bool operator==( const LibInfoKey& rKey ) const;
+
+ const ScriptDocument&
+ GetDocument() const { return m_aDocument; }
+ const String& GetLibName() const { return m_aLibName; }
+};
+
+class LibInfoItem
+{
+private:
+ ScriptDocument m_aDocument;
+ String m_aLibName;
+ String m_aCurrentName;
+ USHORT m_nCurrentType;
+
+public:
+ LibInfoItem( const ScriptDocument& rDocument, const String& rLibName, const String& rCurrentName, USHORT nCurrentType );
+ ~LibInfoItem();
+
+ LibInfoItem( const LibInfoItem& rItem );
+ LibInfoItem& operator=( const LibInfoItem& rItem );
+
+ const ScriptDocument&
+ GetDocument() const { return m_aDocument; }
+ const String& GetLibName() const { return m_aLibName; }
+ const String& GetCurrentName() const { return m_aCurrentName; }
+ USHORT GetCurrentType() const { return m_nCurrentType; }
+};
+
+class LibInfos
+{
+private:
+
+ struct LibInfoKeyHash
+ {
+ size_t operator()( const LibInfoKey& rKey ) const
+ {
+ size_t nHash = (size_t) rKey.GetDocument().hashCode();
+ nHash += (size_t) ::rtl::OUString( rKey.GetLibName() ).hashCode();
+ return nHash;
+ }
+ };
+
+ typedef ::std::hash_map< LibInfoKey, LibInfoItem*, LibInfoKeyHash, ::std::equal_to< LibInfoKey > > LibInfoMap;
+ LibInfoMap m_aLibInfoMap;
+
+public:
+ LibInfos();
+ ~LibInfos();
+
+ void InsertInfo( LibInfoItem* pItem );
+ void RemoveInfoFor( const ScriptDocument& _rDocument );
+
+ LibInfoItem* GetInfo( const LibInfoKey& rKey );
+};
+
+void CutLines( ::rtl::OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines, BOOL bEraseTrailingEmptyLines = FALSE );
+String CreateMgrAndLibStr( const String& rMgrName, const String& rLibName );
+ULONG CalcLineCount( SvStream& rStream );
+
+BOOL QueryReplaceMacro( const String& rName, Window* pParent = 0 );
+BOOL QueryDelMacro( const String& rName, Window* pParent = 0 );
+BOOL QueryDelDialog( const String& rName, Window* pParent = 0 );
+BOOL QueryDelModule( const String& rName, Window* pParent = 0 );
+BOOL QueryDelLib( const String& rName, BOOL bRef = FALSE, Window* pParent = 0 );
+BOOL QueryPassword( const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >& xLibContainer, const String& rLibName, String& rPassword, BOOL bRepeat = FALSE, BOOL bNewTitle = FALSE );
+
+class ModuleInfoHelper
+{
+ModuleInfoHelper();
+ModuleInfoHelper(const ModuleInfoHelper&);
+ModuleInfoHelper& operator = (const ModuleInfoHelper&);
+public:
+ static void getObjectName( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const String& rModName, String& rObjName );
+ static sal_Int32 getModuleType( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const String& rModName );
+};
+#endif // _BASTYPES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/dlged.hxx b/basctl/source/inc/dlged.hxx
new file mode 100644
index 000000000000..67cff8dc7232
--- /dev/null
+++ b/basctl/source/inc/dlged.hxx
@@ -0,0 +1,215 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_DLGED_HXX
+#define _BASCTL_DLGED_HXX
+
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/datatransfer/DataFlavor.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <tools/link.hxx>
+#include <tools/gen.hxx>
+#include <vcl/timer.hxx>
+#include <svl/hint.hxx>
+#include <svl/brdcst.hxx>
+
+#define DLGED_PAGE_WIDTH_MIN 1280
+#define DLGED_PAGE_HEIGHT_MIN 1024
+
+
+//============================================================================
+// DlgEdHint
+//============================================================================
+
+enum DlgEdHintKind
+{
+ DLGED_HINT_UNKNOWN,
+ DLGED_HINT_WINDOWSCROLLED,
+ DLGED_HINT_LAYERCHANGED,
+ DLGED_HINT_OBJORDERCHANGED,
+ DLGED_HINT_SELECTIONCHANGED
+};
+
+class DlgEdObj;
+
+class DlgEdHint: public SfxHint
+{
+private:
+ DlgEdHintKind eHintKind;
+ DlgEdObj* pDlgEdObj;
+
+public:
+ TYPEINFO();
+ DlgEdHint( DlgEdHintKind eHint );
+ DlgEdHint( DlgEdHintKind eHint, DlgEdObj* pObj );
+ virtual ~DlgEdHint();
+
+ DlgEdHintKind GetKind() const { return eHintKind; }
+ DlgEdObj* GetObject() const { return pDlgEdObj; }
+};
+
+
+//============================================================================
+// DlgEditor
+//============================================================================
+
+enum DlgEdMode { DLGED_INSERT, DLGED_SELECT, DLGED_TEST, DLGED_READONLY };
+
+class ScrollBar;
+class DlgEdModel;
+class DlgEdPage;
+class DlgEdView;
+class DlgEdForm;
+class DlgEdFactory;
+class DlgEdFunc;
+class Printer;
+class KeyEvent;
+class MouseEvent;
+class Timer;
+class Window;
+
+class DlgEditor: public SfxBroadcaster
+{
+private:
+ DECL_LINK( PaintTimeout, Timer * );
+ DECL_LINK( MarkTimeout, Timer * );
+
+ void Print( Printer* pPrinter, const String& rTitle );
+
+protected:
+ ScrollBar* pHScroll;
+ ScrollBar* pVScroll;
+ DlgEdModel* pDlgEdModel;
+ DlgEdPage* pDlgEdPage;
+ DlgEdView* pDlgEdView;
+ DlgEdForm* pDlgEdForm;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xUnoControlDialogModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > m_xControlContainer;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > m_ClipboardDataFlavors;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > m_ClipboardDataFlavorsResource;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > m_xSupplier;
+ DlgEdFactory* pObjFac;
+ Window* pWindow;
+ DlgEdFunc* pFunc;
+ DlgEdMode eMode;
+ USHORT eActObj;
+ BOOL bFirstDraw;
+ Size aGridSize;
+ BOOL bGridVisible;
+ BOOL bGridSnap;
+ BOOL bCreateOK;
+ Timer aPaintTimer;
+ Rectangle aPaintRect;
+ BOOL bDialogModelChanged;
+ Timer aMarkTimer;
+ long mnPaintGuard;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDocument;
+
+ DlgEditor(); // not implemented
+public:
+ DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel );
+ ~DlgEditor();
+
+ void SetWindow( Window* pWindow );
+ Window* GetWindow() const { return pWindow; }
+
+ /** returns the control container associated with our window
+ @see GetWindow
+ @see SetWindow
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+ GetWindowControlContainer();
+
+ void SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; }
+ DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; }
+
+ void SetScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll );
+ void InitScrollBars();
+ ScrollBar* GetHScroll() const { return pHScroll; }
+ ScrollBar* GetVScroll() const { return pVScroll; }
+ void DoScroll( ScrollBar* pActScroll );
+ void UpdateScrollBars();
+
+ void SetDialog( ::com::sun::star::uno::Reference<
+ ::com::sun::star::container::XNameContainer > xUnoControlDialogModel );
+ void ResetDialog( void );
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > GetDialog() const
+ {return m_xUnoControlDialogModel;}
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > const & GetNumberFormatsSupplier();
+
+ DlgEdModel* GetModel() const { return pDlgEdModel; }
+ DlgEdView* GetView() const { return pDlgEdView; }
+ DlgEdPage* GetPage() const { return pDlgEdPage; }
+
+ void ShowDialog();
+
+ BOOL UnmarkDialog();
+ BOOL RemarkDialog();
+
+ void SetDialogModelChanged( BOOL bChanged = TRUE ) { bDialogModelChanged = bChanged; }
+ BOOL IsDialogModelChanged() const { return bDialogModelChanged; }
+
+ BOOL IsModified() const;
+ void ClearModifyFlag();
+
+ void MouseButtonDown( const MouseEvent& rMEvt );
+ void MouseButtonUp( const MouseEvent& rMEvt );
+ void MouseMove( const MouseEvent& rMEvt );
+ void Paint( const Rectangle& rRect );
+ BOOL KeyInput( const KeyEvent& rKEvt );
+
+ void SetMode( DlgEdMode eMode );
+ void SetInsertObj( USHORT eObj );
+ USHORT GetInsertObj() const;
+ void CreateDefaultObject();
+ DlgEdMode GetMode() const { return eMode; }
+ BOOL IsCreateOK() const { return bCreateOK; }
+
+ void Cut();
+ void Copy();
+ void Paste();
+ void Delete();
+ BOOL IsPasteAllowed();
+
+ void ShowProperties();
+ void UpdatePropertyBrowserDelayed();
+
+ sal_Int32 countPages( Printer* pPrinter );
+ void printPage( sal_Int32 nPage, Printer* pPrinter, const String& );
+
+ bool AdjustPageSize();
+
+ bool isInPaint() const { return mnPaintGuard > 0; }
+};
+
+#endif //_BASCTL_DLGED_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/dlgedclip.hxx b/basctl/source/inc/dlgedclip.hxx
new file mode 100644
index 000000000000..605b6ee87e34
--- /dev/null
+++ b/basctl/source/inc/dlgedclip.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_DLGEDCLIP_HXX
+#define _BASCTL_DLGEDCLIP_HXX
+
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/datatransfer/DataFlavor.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
+
+
+//============================================================================
+// DlgEdTransferableImpl
+//============================================================================
+
+typedef ::cppu::WeakImplHelper2< ::com::sun::star::datatransfer::XTransferable, ::com::sun::star::datatransfer::clipboard::XClipboardOwner > DlgEdTransferableHelper;
+
+class DlgEdTransferableImpl : public DlgEdTransferableHelper
+{
+private:
+ ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > m_SeqFlavors;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_SeqData;
+
+protected:
+ virtual sal_Bool compareDataFlavors( const ::com::sun::star::datatransfer::DataFlavor& lFlavor, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+
+public:
+ DlgEdTransferableImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor >& aSeqFlavors, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aSeqData );
+ virtual ~DlgEdTransferableImpl();
+
+ // XTransferable
+ virtual ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) throw(::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XClipboardOwner
+ virtual void SAL_CALL lostOwnership( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& xClipboard, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw(::com::sun::star::uno::RuntimeException);
+};
+
+#endif // _BASCTL_DLGEDCLIP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/dlgeddef.hxx b/basctl/source/inc/dlgeddef.hxx
new file mode 100644
index 000000000000..ae7926b9fb20
--- /dev/null
+++ b/basctl/source/inc/dlgeddef.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_DLGEDDEF_HXX
+#define _BASCTL_DLGEDDEF_HXX
+
+#include <tools/solar.h>
+
+
+const UINT32 DlgInventor = UINT32('D')*0x00000001+
+ UINT32('L')*0x00000100+
+ UINT32('G')*0x00010000+
+ UINT32('1')*0x01000000;
+
+
+#define OBJ_DLG_CONTROL ((UINT16) 1)
+#define OBJ_DLG_DIALOG ((UINT16) 2)
+#define OBJ_DLG_PUSHBUTTON ((UINT16) 3)
+#define OBJ_DLG_RADIOBUTTON ((UINT16) 4)
+#define OBJ_DLG_CHECKBOX ((UINT16) 5)
+#define OBJ_DLG_LISTBOX ((UINT16) 6)
+#define OBJ_DLG_COMBOBOX ((UINT16) 7)
+#define OBJ_DLG_GROUPBOX ((UINT16) 8)
+#define OBJ_DLG_EDIT ((UINT16) 9)
+#define OBJ_DLG_FIXEDTEXT ((UINT16)10)
+#define OBJ_DLG_IMAGECONTROL ((UINT16)11)
+#define OBJ_DLG_PROGRESSBAR ((UINT16)12)
+#define OBJ_DLG_HSCROLLBAR ((UINT16)13)
+#define OBJ_DLG_VSCROLLBAR ((UINT16)14)
+#define OBJ_DLG_HFIXEDLINE ((UINT16)15)
+#define OBJ_DLG_VFIXEDLINE ((UINT16)16)
+#define OBJ_DLG_DATEFIELD ((UINT16)17)
+#define OBJ_DLG_TIMEFIELD ((UINT16)18)
+#define OBJ_DLG_NUMERICFIELD ((UINT16)19)
+#define OBJ_DLG_CURRENCYFIELD ((UINT16)20)
+#define OBJ_DLG_FORMATTEDFIELD ((UINT16)21)
+#define OBJ_DLG_PATTERNFIELD ((UINT16)22)
+#define OBJ_DLG_FILECONTROL ((UINT16)23)
+#define OBJ_DLG_TREECONTROL ((UINT16)24)
+
+// control properties
+#define DLGED_PROP_BACKGROUNDCOLOR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BackgroundColor" ) )
+#define DLGED_PROP_DROPDOWN ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dropdown" ) )
+#define DLGED_PROP_FORMATSSUPPLIER ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormatsSupplier" ) )
+#define DLGED_PROP_HEIGHT ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" ) )
+#define DLGED_PROP_LABEL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" ) )
+#define DLGED_PROP_NAME ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) )
+#define DLGED_PROP_ORIENTATION ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Orientation" ) )
+#define DLGED_PROP_POSITIONX ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) )
+#define DLGED_PROP_POSITIONY ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) )
+#define DLGED_PROP_STEP ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Step" ) )
+#define DLGED_PROP_TABINDEX ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TabIndex" ) )
+#define DLGED_PROP_TEXTCOLOR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextColor" ) )
+#define DLGED_PROP_TEXTLINECOLOR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextLineColor" ) )
+#define DLGED_PROP_WIDTH ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ) )
+#define DLGED_PROP_DECORATION ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Decoration" ) )
+
+
+#endif // _BASCTL_DLGEDDEF_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/dlgedfac.hxx b/basctl/source/inc/dlgedfac.hxx
new file mode 100644
index 000000000000..0b3debc5dbc2
--- /dev/null
+++ b/basctl/source/inc/dlgedfac.hxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _BASCTL_DLGEDFAC_HXX
+#define _BASCTL_DLGEDFAC_HXX
+
+#include <svx/svdobj.hxx>
+
+
+//============================================================================
+// DlgEdFactory
+//============================================================================
+
+class DlgEdFactory
+{
+public:
+ DlgEdFactory();
+ ~DlgEdFactory();
+
+ DECL_LINK( MakeObject, SdrObjFactory * );
+};
+
+#endif // _BASCTL_DLGEDFAC_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/dlgedfunc.hxx b/basctl/source/inc/dlgedfunc.hxx
new file mode 100644
index 000000000000..740485c801c8
--- /dev/null
+++ b/basctl/source/inc/dlgedfunc.hxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_DLGEDFUNC_HXX
+#define _BASCTL_DLGEDFUNC_HXX
+
+#include <vcl/timer.hxx>
+
+class DlgEditor;
+class Timer;
+class MouseEvent;
+class Point;
+
+//============================================================================
+// DlgEdFunc
+//============================================================================
+
+class DlgEdFunc /* : public LinkHdl */
+{
+protected:
+ DlgEditor* pParent;
+ Timer aScrollTimer;
+
+ DECL_LINK( ScrollTimeout, Timer * );
+ void ForceScroll( const Point& rPos );
+
+public:
+ DlgEdFunc( DlgEditor* pParent );
+ virtual ~DlgEdFunc();
+
+ virtual BOOL MouseButtonDown( const MouseEvent& rMEvt );
+ virtual BOOL MouseButtonUp( const MouseEvent& rMEvt );
+ virtual BOOL MouseMove( const MouseEvent& rMEvt );
+ virtual BOOL KeyInput( const KeyEvent& rKEvt );
+};
+
+//============================================================================
+// DlgEdFuncInsert
+//============================================================================
+
+class DlgEdFuncInsert : public DlgEdFunc
+{
+public:
+ DlgEdFuncInsert( DlgEditor* pParent );
+ ~DlgEdFuncInsert();
+
+ virtual BOOL MouseButtonDown( const MouseEvent& rMEvt );
+ virtual BOOL MouseButtonUp( const MouseEvent& rMEvt );
+ virtual BOOL MouseMove( const MouseEvent& rMEvt );
+};
+
+//============================================================================
+// DlgEdFuncSelect
+//============================================================================
+
+class DlgEdFuncSelect : public DlgEdFunc
+{
+protected:
+ BOOL bMarkAction;
+
+public:
+ DlgEdFuncSelect( DlgEditor* pParent );
+ ~DlgEdFuncSelect();
+
+ virtual BOOL MouseButtonDown( const MouseEvent& rMEvt );
+ virtual BOOL MouseButtonUp( const MouseEvent& rMEvt );
+ virtual BOOL MouseMove( const MouseEvent& rMEvt );
+};
+
+
+#endif //_BASCTL_DLGEDFUNC_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/dlgedlist.hxx b/basctl/source/inc/dlgedlist.hxx
new file mode 100644
index 000000000000..39b9473abba4
--- /dev/null
+++ b/basctl/source/inc/dlgedlist.hxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_DLGEDLIST_HXX
+#define _BASCTL_DLGEDLIST_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+
+class DlgEdObj;
+
+//============================================================================
+// DlgEdPropListenerImpl
+//============================================================================
+
+typedef ::cppu::WeakImplHelper1< ::com::sun::star::beans::XPropertyChangeListener > PropertyChangeListenerHelper;
+
+class DlgEdPropListenerImpl: public PropertyChangeListenerHelper
+{
+private:
+ DlgEdObj* pDlgEdObj;
+
+public:
+ DlgEdPropListenerImpl(DlgEdObj* pObj);
+ virtual ~DlgEdPropListenerImpl();
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
+
+};
+
+//============================================================================
+// DlgEdEvtContListenerImpl
+//============================================================================
+
+typedef ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener > ContainerListenerHelper;
+
+class DlgEdEvtContListenerImpl: public ContainerListenerHelper
+{
+private:
+ DlgEdObj* pDlgEdObj;
+
+public:
+ DlgEdEvtContListenerImpl(DlgEdObj* pObj);
+ virtual ~DlgEdEvtContListenerImpl();
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XContainerListener
+ virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
+};
+
+#endif // _BASCTL_DLGEDLIST_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/dlgedmod.hxx b/basctl/source/inc/dlgedmod.hxx
new file mode 100644
index 000000000000..f4abcaad49c3
--- /dev/null
+++ b/basctl/source/inc/dlgedmod.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _BASCTL_DLGEDMOD_HXX
+#define _BASCTL_DLGEDMOD_HXX
+
+#include <svx/svdmodel.hxx>
+
+
+//============================================================================
+// DlgEdModel
+//============================================================================
+
+class DlgEdPage;
+class Window;
+class SfxObjectShell;
+
+class DlgEdModel : public SdrModel
+{
+ friend class DlgEdPage;
+
+private:
+ DlgEdModel( const DlgEdModel& ); // not implemented
+ void operator=(const DlgEdModel& rSrcModel); // not implemented
+
+public:
+ TYPEINFO();
+
+ DlgEdModel();
+ virtual ~DlgEdModel();
+
+ virtual void DlgEdModelChanged( bool bChanged = true );
+
+ virtual SdrPage* AllocPage(bool bMasterPage);
+
+ virtual Window* GetCurDocViewWin();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/dlgedobj.hxx b/basctl/source/inc/dlgedobj.hxx
new file mode 100644
index 000000000000..ab8dbf3fa10e
--- /dev/null
+++ b/basctl/source/inc/dlgedobj.hxx
@@ -0,0 +1,198 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_DLGEDOBJ_HXX
+#define _BASCTL_DLGEDOBJ_HXX
+
+#include <svx/svdouno.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+
+#include <vector>
+#include <map>
+
+#include <boost/optional.hpp>
+
+typedef ::std::multimap< sal_Int16, ::rtl::OUString, ::std::less< sal_Int16 > > IndexToNameMap;
+
+
+class DlgEdForm;
+class DlgEditor;
+
+//============================================================================
+// DlgEdObj
+//============================================================================
+
+class DlgEdObj: public SdrUnoObj
+{
+ friend class DlgEditor;
+ friend class DlgEdFactory;
+ friend class DlgEdPropListenerImpl;
+ friend class DlgEdForm;
+
+private:
+ sal_Bool bIsListening;
+ DlgEdForm* pDlgEdForm;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener> m_xPropertyChangeListener;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener> m_xContainerListener;
+
+protected:
+ DlgEdObj();
+ DlgEdObj(const ::rtl::OUString& rModelName,
+ const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSFac);
+
+ virtual void NbcMove( const Size& rSize );
+ virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
+ virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
+
+ DECL_LINK(OnCreate, void* );
+
+ using SfxListener::StartListening;
+ void StartListening();
+ using SfxListener::EndListening;
+ void EndListening(sal_Bool bRemoveListener = sal_True);
+ sal_Bool isListening() const { return bIsListening; }
+
+ virtual bool TransformSdrToControlCoordinates(
+ sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
+ sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut );
+ virtual bool TransformSdrToFormCoordinates(
+ sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
+ sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut );
+ virtual bool TransformControlToSdrCoordinates(
+ sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
+ sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut );
+ virtual bool TransformFormToSdrCoordinates(
+ sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
+ sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut );
+
+public:
+ TYPEINFO();
+
+ virtual ~DlgEdObj();
+ virtual void SetPage(SdrPage* pNewPage);
+
+ virtual void SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; }
+ virtual DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; }
+
+ virtual sal_uInt32 GetObjInventor() const;
+ virtual sal_uInt16 GetObjIdentifier() const;
+
+ virtual SdrObject* Clone() const; // not working yet
+ virtual void operator= (const SdrObject& rObj); // not working yet
+ virtual void clonedFrom(const DlgEdObj* _pSource); // not working yet
+
+ // FullDrag support
+ virtual SdrObject* getFullDragClone() const;
+
+ virtual sal_Bool supportsService( const sal_Char* _pServiceName ) const;
+ virtual ::rtl::OUString GetDefaultName() const;
+ virtual ::rtl::OUString GetUniqueName() const;
+
+ virtual sal_Int32 GetStep() const;
+ virtual void UpdateStep();
+
+ virtual void SetDefaults();
+ virtual void SetRectFromProps();
+ virtual void SetPropsFromRect();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > GetControl() const;
+
+ virtual void PositionAndSizeChange( const ::com::sun::star::beans::PropertyChangeEvent& evt );
+ virtual void SAL_CALL NameChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL TabIndexChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException);
+
+ // PropertyChangeListener
+ virtual void SAL_CALL _propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
+
+ // ContainerListener
+ virtual void SAL_CALL _elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL _elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL _elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SetLayer(SdrLayerID nLayer);
+};
+
+
+//============================================================================
+// DlgEdForm
+//============================================================================
+
+class DlgEdForm: public DlgEdObj
+{
+ friend class DlgEditor;
+ friend class DlgEdFactory;
+
+private:
+ DlgEditor* pDlgEditor;
+ ::std::vector<DlgEdObj*> pChilds;
+
+ mutable ::boost::optional< ::com::sun::star::awt::DeviceInfo > mpDeviceInfo;
+
+
+protected:
+ DlgEdForm();
+
+ virtual void NbcMove( const Size& rSize );
+ virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
+ virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
+
+public:
+ TYPEINFO();
+
+ virtual ~DlgEdForm();
+
+ virtual void SetDlgEditor( DlgEditor* pEditor );
+ virtual DlgEditor* GetDlgEditor() const { return pDlgEditor; }
+
+ virtual void AddChild( DlgEdObj* pDlgEdObj );
+ virtual void RemoveChild( DlgEdObj* pDlgEdObj );
+ virtual ::std::vector<DlgEdObj*> GetChilds() const { return pChilds; }
+
+ virtual void UpdateStep();
+
+ virtual void SetRectFromProps();
+ virtual void SetPropsFromRect();
+
+ virtual void PositionAndSizeChange( const ::com::sun::star::beans::PropertyChangeEvent& evt );
+
+ virtual void UpdateTabIndices();
+ virtual void UpdateTabOrder();
+ virtual void UpdateGroups();
+ virtual void UpdateTabOrderAndGroups();
+
+ ::com::sun::star::awt::DeviceInfo getDeviceInfo() const;
+
+private:
+ void ImplInvalidateDeviceInfo();
+};
+
+#endif // _BASCTL_DLGEDOBJ_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/dlgedpage.hxx b/basctl/source/inc/dlgedpage.hxx
new file mode 100644
index 000000000000..ed8682c3339b
--- /dev/null
+++ b/basctl/source/inc/dlgedpage.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_DLGEDPAGE_HXX
+#define _BASCTL_DLGEDPAGE_HXX
+
+#include "svx/svdpage.hxx"
+
+//============================================================================
+// DlgEdPage
+//============================================================================
+
+class DlgEdModel;
+class DlgEdForm;
+
+class DlgEdPage : public SdrPage
+{
+private:
+ DlgEdForm* pDlgEdForm;
+
+public:
+ TYPEINFO();
+
+ DlgEdPage( DlgEdModel& rModel, bool bMasterPage = false );
+ DlgEdPage( const DlgEdPage& );
+ virtual ~DlgEdPage();
+
+ using SdrPage::Clone;
+ virtual SdrPage* Clone() const;
+
+ void SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; }
+ DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; }
+
+ virtual SdrObject* SetObjectOrdNum(ULONG nOldObjNum, ULONG nNewObjNum);
+};
+
+#endif //_BASCTL_DLGEDPAGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/dlgedview.hxx b/basctl/source/inc/dlgedview.hxx
new file mode 100644
index 000000000000..08da25932227
--- /dev/null
+++ b/basctl/source/inc/dlgedview.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _BASCTL_DLGEDVIEW_HXX
+#define _BASCTL_DLGEDVIEW_HXX
+
+#include <svx/svdview.hxx>
+
+class DlgEditor;
+
+//============================================================================
+// DlgEdView
+//============================================================================
+
+class DlgEdView : public SdrView
+{
+private:
+ DlgEditor* pDlgEditor;
+
+public:
+ TYPEINFO();
+
+ DlgEdView( SdrModel* pModel, OutputDevice* pOut, DlgEditor* pEditor );
+ virtual ~DlgEdView();
+
+ virtual void MarkListHasChanged();
+ virtual void MakeVisible( const Rectangle& rRect, Window& rWin );
+
+protected:
+ // overloaded to handle HitTest for some objects special
+ using SdrView::CheckSingleSdrObjectHit;
+ virtual SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, USHORT nTol, SdrObject* pObj, SdrPageView* pPV, ULONG nOptions, const SetOfByte* pMVisLay) const;
+};
+
+#endif //_BASCTL_DLGEDVIEW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/dlgresid.hrc b/basctl/source/inc/dlgresid.hrc
new file mode 100644
index 000000000000..3499cd5ed7c6
--- /dev/null
+++ b/basctl/source/inc/dlgresid.hrc
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_DLGRESID_HRC
+#define _BASCTL_DLGRESID_HRC
+
+// include -----------------------------------------------------------
+
+#include <svl/solar.hrc>
+
+// Dialog Control Id's -----------------------------------------------------------
+
+#define RID_STR_CLASS_CONTROL ( RID_DLG_START + 0 )
+#define RID_STR_CLASS_DIALOG ( RID_DLG_START + 1 )
+#define RID_STR_CLASS_BUTTON ( RID_DLG_START + 2 )
+#define RID_STR_CLASS_RADIOBUTTON ( RID_DLG_START + 3 )
+#define RID_STR_CLASS_CHECKBOX ( RID_DLG_START + 4 )
+#define RID_STR_CLASS_LISTBOX ( RID_DLG_START + 5 )
+#define RID_STR_CLASS_COMBOBOX ( RID_DLG_START + 6 )
+#define RID_STR_CLASS_GROUPBOX ( RID_DLG_START + 7 )
+#define RID_STR_CLASS_EDIT ( RID_DLG_START + 8 )
+#define RID_STR_CLASS_FIXEDTEXT ( RID_DLG_START + 9 )
+#define RID_STR_CLASS_IMAGECONTROL ( RID_DLG_START + 10 )
+#define RID_STR_CLASS_PROGRESSBAR ( RID_DLG_START + 11 )
+#define RID_STR_CLASS_SCROLLBAR ( RID_DLG_START + 12 )
+#define RID_STR_CLASS_FIXEDLINE ( RID_DLG_START + 13 )
+#define RID_STR_CLASS_DATEFIELD ( RID_DLG_START + 14 )
+#define RID_STR_CLASS_TIMEFIELD ( RID_DLG_START + 15 )
+#define RID_STR_CLASS_NUMERICFIELD ( RID_DLG_START + 16 )
+#define RID_STR_CLASS_CURRENCYFIELD ( RID_DLG_START + 17 )
+#define RID_STR_CLASS_FORMATTEDFIELD ( RID_DLG_START + 18 )
+#define RID_STR_CLASS_PATTERNFIELD ( RID_DLG_START + 19 )
+#define RID_STR_CLASS_FILECONTROL ( RID_DLG_START + 20 )
+#define RID_STR_TRANSLATION_NOTLOCALIZED ( RID_DLG_START + 21 )
+#define RID_STR_TRANSLATION_DEFAULT ( RID_DLG_START + 22 )
+#define RID_STR_CLASS_TREECONTROL ( RID_DLG_START + 23 )
+// Property Browser Headline Id's -----------------------------------------------------------
+
+#define RID_STR_BRWTITLE_PROPERTIES ( RID_DLG_START + 60 )
+#define RID_STR_BRWTITLE_NO_PROPERTIES ( RID_DLG_START + 61 )
+#define RID_STR_BRWTITLE_MULTISELECT ( RID_DLG_START + 62 )
+
+// Manage Language Dialogs
+
+#define RID_DLG_MANAGE_LANGUAGE ( RID_DLG_START + 70 )
+#define RID_QRYBOX_LANGUAGE ( RID_DLG_START + 71 )
+#define RID_DLG_SETDEF_LANGUAGE ( RID_DLG_START + 72 )
+#define RID_DLG_ADD_LANGUAGE ( RID_DLG_START + 73 )
+
+// -----------------------------------------------------------------------
+
+#endif // _BASCTL_DLGRESID_HRC
+
diff --git a/basctl/source/inc/doceventnotifier.hxx b/basctl/source/inc/doceventnotifier.hxx
new file mode 100644
index 000000000000..bad9f29c515b
--- /dev/null
+++ b/basctl/source/inc/doceventnotifier.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef BASCTL_DOCEVENTNOTIFIER_HXX
+#define BASCTL_DOCEVENTNOTIFIER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+/** === end UNO includes === **/
+
+#include <rtl/ref.hxx>
+
+#include <boost/noncopyable.hpp>
+
+//........................................................................
+namespace basctl
+{
+//........................................................................
+
+ class ScriptDocument;
+
+ //====================================================================
+ //= DocumentEventListener
+ //====================================================================
+ class SAL_NO_VTABLE DocumentEventListener : ::boost::noncopyable
+ {
+ public:
+ virtual void onDocumentCreated( const ScriptDocument& _rDocument ) = 0;
+ virtual void onDocumentOpened( const ScriptDocument& _rDocument ) = 0;
+ virtual void onDocumentSave( const ScriptDocument& _rDocument ) = 0;
+ virtual void onDocumentSaveDone( const ScriptDocument& _rDocument ) = 0;
+ virtual void onDocumentSaveAs( const ScriptDocument& _rDocument ) = 0;
+ virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument ) = 0;
+ virtual void onDocumentClosed( const ScriptDocument& _rDocument ) = 0;
+ virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument ) = 0;
+ virtual void onDocumentModeChanged( const ScriptDocument& _rDocument ) = 0;
+
+ virtual ~DocumentEventListener();
+ };
+
+ //====================================================================
+ //= DocumentEventNotifier
+ //====================================================================
+ class DocumentEventNotifier_Impl;
+ /** allows registering at the GlobalEventBroadcaster for global document events
+ */
+ class DocumentEventNotifier
+ {
+ public:
+ /** create a notifier instance which notifies about events of all documents in the whole application
+ */
+ DocumentEventNotifier( DocumentEventListener& _rListener );
+
+ /** creates a notifier instance which notifies about events at a single document
+ */
+ DocumentEventNotifier( DocumentEventListener& _rListener,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocument );
+
+ ~DocumentEventNotifier();
+
+ public:
+ void dispose();
+
+ private:
+ ::rtl::Reference< DocumentEventNotifier_Impl > m_pImpl;
+ };
+
+//........................................................................
+} // namespace basctl
+//........................................................................
+
+#endif // BASCTL_DOCEVENTNOTIFIER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/docsignature.hxx b/basctl/source/inc/docsignature.hxx
new file mode 100644
index 000000000000..941b76026041
--- /dev/null
+++ b/basctl/source/inc/docsignature.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef BASCTL_DOCSIGNATURE_HXX
+#define BASCTL_DOCSIGNATURE_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+/** === end UNO includes === **/
+
+#include <memory>
+
+//........................................................................
+namespace basctl
+{
+//........................................................................
+
+ class ScriptDocument;
+ //====================================================================
+ //= DocumentSignature
+ //====================================================================
+ struct DocumentSignature_Data;
+ /// encapsulates (actions on) the signature/state of a document
+ class DocumentSignature
+ {
+ public:
+ /** creates a DocumentSignature instance for the given document
+
+ If the given ScriptDocument instance refers to the application, or to a document
+ which does not support being signed, the DocumentSignature instance is invalid afterwards.
+ */
+ DocumentSignature( const ScriptDocument& _rDocument );
+ ~DocumentSignature();
+
+ /** determines whether the instance is valid
+
+ An instance is valid if and only if it has been constructed with a document
+ which supports signatures.
+ */
+ bool supportsSignatures() const;
+
+ /** signs the scripting content inside the document
+
+ @precond
+ isValid returns <TRUE/>
+ */
+ void signScriptingContent() const;
+
+ /** retrieves the state of the signature of the scripting content inside the document
+
+ If the instance is not valid, then SIGNATURESTATE_NOSIGNATURES is returned.
+ */
+ sal_uInt16 getScriptingSignatureState() const;
+
+ private:
+ DocumentSignature(); // not implemented
+
+ private:
+ ::std::auto_ptr< DocumentSignature_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace basctl
+//........................................................................
+
+#endif // BASCTL_DOCSIGNATURE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/iderid.hxx b/basctl/source/inc/iderid.hxx
new file mode 100644
index 000000000000..f8560ad45d00
--- /dev/null
+++ b/basctl/source/inc/iderid.hxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _IDERID_HXX
+#define _IDERID_HXX
+
+#include <tools/resid.hxx>
+
+class IDEResId: public ResId
+{
+public:
+ IDEResId( USHORT nId );
+};
+
+
+#endif //_IDERID_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/localizationmgr.hxx b/basctl/source/inc/localizationmgr.hxx
new file mode 100644
index 000000000000..7a61eeb132dc
--- /dev/null
+++ b/basctl/source/inc/localizationmgr.hxx
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _LOCALIZATIONMGR_HXX
+#define _LOCALIZATIONMGR_HXX
+
+#include <com/sun/star/resource/XStringResourceManager.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+
+#include "scriptdocument.hxx"
+
+class BasicIDEShell;
+class DlgEditor;
+
+class LocalizationMgr
+{
+ ::com::sun::star::uno::Reference
+ < ::com::sun::star::resource::XStringResourceManager > m_xStringResourceManager;
+
+ BasicIDEShell* m_pIDEShell;
+
+ ScriptDocument m_aDocument;
+ String m_aLibName;
+
+ ::com::sun::star::lang::Locale m_aLocaleBeforeBasicStart;
+
+ enum HandleResourceMode
+ {
+ SET_IDS,
+ RESET_IDS,
+ RENAME_DIALOG_IDS,
+ RENAME_CONTROL_IDS,
+ REMOVE_IDS_FROM_RESOURCE,
+ MOVE_RESOURCES,
+ COPY_RESOURCES
+ };
+ static sal_Int32 implHandleControlResourceProperties( ::com::sun::star::uno::Any aControlAny,
+ const ::rtl::OUString& aDialogName, const ::rtl::OUString& aCtrlName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >
+ xStringResourceManager, ::com::sun::star::uno::Reference< ::com::sun::star::resource::
+ XStringResourceResolver > xSourceStringResolver, HandleResourceMode eMode );
+
+ void enableResourceForAllLibraryDialogs( void )
+ {
+ implEnableDisableResourceForAllLibraryDialogs( SET_IDS );
+ }
+ void disableResourceForAllLibraryDialogs( void )
+ {
+ implEnableDisableResourceForAllLibraryDialogs( RESET_IDS );
+ }
+ void implEnableDisableResourceForAllLibraryDialogs( HandleResourceMode eMode );
+
+public:
+ LocalizationMgr( BasicIDEShell* pIDEShell, const ScriptDocument& rDocument, String aLibName,
+ const ::com::sun::star::uno::Reference
+ < ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager );
+ ::com::sun::star::uno::Reference
+ < ::com::sun::star::resource::XStringResourceManager >getStringResourceManager( void )
+ {
+ return m_xStringResourceManager;
+ }
+
+ bool isLibraryLocalized( void );
+
+ void handleTranslationbar( void );
+
+ void handleAddLocales( ::com::sun::star::uno::Sequence
+ < ::com::sun::star::lang::Locale > aLocaleSeq );
+
+ void handleRemoveLocales( ::com::sun::star::uno::Sequence
+ < ::com::sun::star::lang::Locale > aLocaleSeq );
+
+ void handleSetDefaultLocale( ::com::sun::star::lang::Locale aLocale );
+
+ void handleSetCurrentLocale( ::com::sun::star::lang::Locale aLocale );
+
+ void handleBasicStarted( void );
+
+ void handleBasicStopped( void );
+
+ static void setControlResourceIDsForNewEditorObject( DlgEditor* pEditor,
+ ::com::sun::star::uno::Any aControlAny, const ::rtl::OUString& aCtrlName );
+
+ static void renameControlResourceIDsForEditorObject( DlgEditor* pEditor,
+ ::com::sun::star::uno::Any aControlAny, const ::rtl::OUString& aNewCtrlName );
+
+ static void deleteControlResourceIDsForDeletedEditorObject( DlgEditor* pEditor,
+ ::com::sun::star::uno::Any aControlAny, const ::rtl::OUString& aCtrlName );
+
+ static void setStringResourceAtDialog( const ScriptDocument& rDocument, const String& aLibName, const String& aDlgName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xDialogModel );
+
+ static void renameStringResourceIDs( const ScriptDocument& rDocument, const String& aLibName, const String& aDlgName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xDialogModel );
+
+ static void removeResourceForDialog( const ScriptDocument& rDocument, const String& aLibName, const String& aDlgName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xDialogModel );
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >
+ getStringResourceFromDialogLibrary( ::com::sun::star::uno::Reference
+ < ::com::sun::star::container::XNameContainer > xDialogLib );
+
+ // Clipboard / Drag & Drop
+ static void resetResourceForDialog(
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xDialogModel,
+ ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > xStringResourceManager );
+
+ static void setResourceIDsForDialog(
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xDialogModel,
+ ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > xStringResourceManager );
+
+ static void copyResourcesForPastedEditorObject( DlgEditor* pEditor,
+ ::com::sun::star::uno::Any aControlAny, const ::rtl::OUString& aCtrlName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::resource::
+ XStringResourceResolver > xSourceStringResolver );
+
+ static void copyResourceForDroppedDialog(
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xDialogModel,
+ const ::rtl::OUString& aDialogName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > xStringResourceManager,
+ ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver > xSourceStringResolver );
+
+ static void copyResourceForDialog(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xDialogModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::resource::
+ XStringResourceResolver >& xSourceStringResolver,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::resource::
+ XStringResourceManager >& xTargetStringResourceManager );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/managelang.hxx b/basctl/source/inc/managelang.hxx
new file mode 100644
index 000000000000..ef030b4bcdf1
--- /dev/null
+++ b/basctl/source/inc/managelang.hxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_MANAGELANG_HXX
+#define _BASCTL_MANAGELANG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+#include <svx/langbox.hxx>
+#include <svx/checklbx.hxx>
+
+class LocalizationMgr;
+
+struct LanguageEntry
+{
+ String m_sLanguage;
+ ::com::sun::star::lang::Locale m_aLocale;
+ bool m_bIsDefault;
+
+ LanguageEntry( const String& _rLanguage,
+ const ::com::sun::star::lang::Locale& _rLocale,
+ bool _bIsDefault ) :
+ m_sLanguage( _rLanguage ),
+ m_aLocale( _rLocale ),
+ m_bIsDefault( _bIsDefault ) {}
+};
+
+extern bool localesAreEqual( const ::com::sun::star::lang::Locale& rLocaleLeft,
+ const ::com::sun::star::lang::Locale& rLocaleRight );
+
+class ManageLanguageDialog : public ModalDialog
+{
+private:
+ FixedText m_aLanguageFT;
+ ListBox m_aLanguageLB;
+ PushButton m_aAddPB;
+ PushButton m_aDeletePB;
+ PushButton m_aMakeDefPB;
+ FixedText m_aInfoFT;
+
+ FixedLine m_aBtnLine;
+ HelpButton m_aHelpBtn;
+ OKButton m_aCloseBtn;
+
+ LocalizationMgr* m_pLocalizationMgr;
+
+ String m_sDefLangStr;
+ String m_sDeleteStr;
+ String m_sCreateLangStr;
+
+ void Init();
+ void CalcInfoSize();
+ void FillLanguageBox();
+ void ClearLanguageBox();
+
+ DECL_LINK( AddHdl, Button * );
+ DECL_LINK( DeleteHdl, Button * );
+ DECL_LINK( MakeDefHdl, Button * );
+ DECL_LINK( SelectHdl, ListBox * );
+
+public:
+ ManageLanguageDialog( Window* pParent, LocalizationMgr* _pLMgr );
+ ~ManageLanguageDialog();
+};
+
+class SetDefaultLanguageDialog : public ModalDialog
+{
+private:
+ FixedText m_aLanguageFT;
+ SvxLanguageBox* m_pLanguageLB;
+ SvxCheckListBox* m_pCheckLangLB;
+ FixedText m_aInfoFT;
+
+ FixedLine m_aBtnLine;
+ OKButton m_aOKBtn;
+ CancelButton m_aCancelBtn;
+ HelpButton m_aHelpBtn;
+
+ bool m_bIsDefaultMode;
+ LocalizationMgr* m_pLocalizationMgr;
+
+ void FillLanguageBox();
+ void CalcInfoSize();
+
+public:
+ SetDefaultLanguageDialog( Window* pParent, LocalizationMgr* _pLMgr );
+ ~SetDefaultLanguageDialog();
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > GetLocales() const;
+};
+
+#endif //_BASCTL_MANAGELANG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/propbrw.hxx b/basctl/source/inc/propbrw.hxx
new file mode 100644
index 000000000000..9e0e1e334b0f
--- /dev/null
+++ b/basctl/source/inc/propbrw.hxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_PROPBRW_HXX
+#define _BASCTL_PROPBRW_HXX
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <comphelper/composedprops.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <svl/brdcst.hxx>
+#include <svl/lstner.hxx>
+#include <sfx2/childwin.hxx>
+#include <svx/svdmark.hxx>
+
+//============================================================================
+// PropBrwMgr
+//============================================================================
+
+class PropBrwMgr : public SfxChildWindow
+{
+public:
+ PropBrwMgr(Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo);
+ SFX_DECL_CHILDWINDOW(PropBrwMgr);
+};
+
+//============================================================================
+// PropBrw
+//============================================================================
+
+class SfxBindings;
+class SdrView;
+
+class PropBrw : public SfxFloatingWindow , public SfxListener, public SfxBroadcaster
+{
+private:
+ sal_Bool m_bInitialStateChange;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
+ m_xMeAsFrame;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xBrowserController;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >
+ m_xBrowserComponentWindow;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
+ m_xContextDocument;
+
+protected:
+ SdrView* pView;
+ virtual void Resize();
+ virtual void FillInfo( SfxChildWinInfo& rInfo ) const;
+ virtual sal_Bool Close();
+
+ DECLARE_STL_VECTOR(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>, InterfaceArray);
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >
+ CreateMultiSelectionSequence( const SdrMarkList& _rMarkList );
+ void implSetNewObjectSequence( const ::com::sun::star::uno::Sequence
+ < ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& _rObjectSeq );
+
+ void implSetNewObject(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject);
+
+ ::rtl::OUString GetHeadlineName(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject);
+
+public:
+ PropBrw( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB,
+ SfxBindings *pBindings,
+ PropBrwMgr* pMgr,
+ Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ );
+ virtual ~PropBrw();
+ using Window::Update;
+ // note: changing the Context document to an instance other than the one given in the ctor is not supported
+ // currently
+ void Update( const SfxViewShell* _pShell );
+ SdrView* GetCurView() const { return pView; }
+
+private:
+ void ImplUpdate( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument, SdrView* pView );
+ void ImplDestroyController();
+ void ImplReCreateController();
+};
+
+#endif // _BASCTL_PROPBRW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/sbxitem.hxx b/basctl/source/inc/sbxitem.hxx
new file mode 100644
index 000000000000..a3b0c907caf8
--- /dev/null
+++ b/basctl/source/inc/sbxitem.hxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SBXITEM_HXX
+#define _SBXITEM_HXX
+
+#include "scriptdocument.hxx"
+#include <svl/poolitem.hxx>
+
+const USHORT BASICIDE_TYPE_UNKNOWN = 0;
+const USHORT BASICIDE_TYPE_SHELL = 1;
+const USHORT BASICIDE_TYPE_LIBRARY = 2;
+const USHORT BASICIDE_TYPE_MODULE = 3;
+const USHORT BASICIDE_TYPE_DIALOG = 4;
+const USHORT BASICIDE_TYPE_METHOD = 5;
+
+
+class SbxItem : public SfxPoolItem
+{
+ ScriptDocument m_aDocument;
+ String m_aLibName;
+ String m_aName;
+ String m_aMethodName;
+ USHORT m_nType;
+
+public:
+ TYPEINFO();
+ SbxItem( USHORT nWhich, const ScriptDocument& rDocument, const String& aLibName, const String& aName, USHORT nType );
+ SbxItem( USHORT nWhich, const ScriptDocument& rDocument, const String& aLibName, const String& aName, const String& aMethodName, USHORT nType );
+ SbxItem( const SbxItem& );
+
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+ virtual int operator==( const SfxPoolItem& ) const;
+
+ const ScriptDocument&
+ GetDocument() const { return m_aDocument; }
+ void SetDocument( const ScriptDocument& rDocument ) { m_aDocument = rDocument; }
+
+ const String& GetLibName() const { return m_aLibName; }
+ void SetLibName( const String& aLibName ) { m_aLibName = aLibName; }
+
+ const String& GetName() const { return m_aName; }
+ void SetName( const String& aName ) { m_aName = aName; }
+
+ const String& GetMethodName() const { return m_aMethodName; }
+ void SetMethodName( const String& aMethodName ) { m_aMethodName = aMethodName; }
+
+ USHORT GetType() const { return m_nType; }
+ void SetType( USHORT nType ) { m_nType = nType; }
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/scriptdocument.hxx b/basctl/source/inc/scriptdocument.hxx
new file mode 100644
index 000000000000..5791971a57d8
--- /dev/null
+++ b/basctl/source/inc/scriptdocument.hxx
@@ -0,0 +1,540 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SCRIPTDOCUMENT_HXX
+#define SCRIPTDOCUMENT_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/io/XInputStreamProvider.hpp>
+/** === end UNO includes === **/
+
+#include <boost/shared_ptr.hpp>
+#include <vector>
+
+class BasicManager;
+class SfxListener;
+
+//........................................................................
+namespace basctl
+{
+//........................................................................
+
+ //====================================================================
+ //= LibraryContainerType
+ //====================================================================
+ enum LibraryContainerType
+ {
+ E_SCRIPTS,
+ E_DIALOGS
+ };
+
+ enum LibraryLocation
+ {
+ LIBRARY_LOCATION_UNKNOWN,
+ LIBRARY_LOCATION_USER,
+ LIBRARY_LOCATION_SHARE,
+ LIBRARY_LOCATION_DOCUMENT
+ };
+
+ enum LibraryType
+ {
+ LIBRARY_TYPE_UNKNOWN,
+ LIBRARY_TYPE_MODULE,
+ LIBRARY_TYPE_DIALOG,
+ LIBRARY_TYPE_ALL
+ };
+
+ //====================================================================
+ //= ScriptDocument
+ //====================================================================
+ class ScriptDocument_Impl;
+
+ class ScriptDocument;
+ typedef ::std::vector< ScriptDocument > ScriptDocuments;
+
+ /** encapsulates a document which contains Basic scripts and dialogs
+ */
+ class ScriptDocument
+ {
+ private:
+ ::boost::shared_ptr< ScriptDocument_Impl > m_pImpl;
+
+ private:
+ /** creates a ScriptDocument instance which operates on the application-wide
+ scripts and dialogs
+ */
+ ScriptDocument();
+
+ public:
+ enum SpecialDocument { NoDocument };
+ /** creates a ScriptDocument instance which does refers to neither the application-wide,
+ nor a specific real document's scripts.
+
+ This constructor might come handy when you need some kind of uninitialized
+ ScriptDocument, which you do not want to operate on (yet), but initialize later
+ by assignment.
+
+ <member>isValid</member> will return <FALSE/> for a ScriptDocument constructed
+ this way.
+ */
+ explicit ScriptDocument( SpecialDocument _eType );
+
+ /** creates a ScriptDocument instance which refers to a document given as
+ XModel
+
+ @param _rxDocument
+ the document. Must not be <NULL/>.
+ */
+ explicit ScriptDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocument );
+
+ /// copy constructor
+ ScriptDocument( const ScriptDocument& _rSource );
+
+ /// destructor
+ ~ScriptDocument();
+
+ /** returns a reference to a shared ScriptDocument instance which
+ operates on the application-wide scripts and dialogs
+ */
+ static const ScriptDocument&
+ getApplicationScriptDocument();
+
+ /** returns a (newly created) ScriptDocument instance for the document to
+ which a given BasicManager belongs
+
+ If the basic manager is the application's basic manager, then the (shared)
+ ScriptDocument instance which is responsible for the application is returned.
+
+ @see getApplicationScriptDocument
+ */
+ static ScriptDocument
+ getDocumentForBasicManager( const BasicManager* _pManager );
+
+ /** returns a (newly created) ScriptDocument instance for the document
+ with a given caption or URL
+
+ If there is no document with the given caption, then the (shared)
+ ScriptDocument instance which is responsible for the application is returned.
+
+ @see getApplicationScriptDocument
+ */
+ static ScriptDocument
+ getDocumentWithURLOrCaption( const ::rtl::OUString& _rUrlOrCaption );
+
+ /** operation mode for getAllScriptDocuments
+ */
+ enum ScriptDocumentList
+ {
+ /** all ScriptDocuments, including the dedicated one which represents
+ the application-wide scripts/dialogs.
+ */
+ AllWithApplication,
+ /** real documents only
+ */
+ DocumentsOnly,
+ /** real documents only, sorted lexicographically by their title (using the sys locale's default
+ collator)
+ */
+ DocumentsSorted
+ };
+
+ /** returns the set of ScriptDocument instances, one for each open document which
+ contains Basic/Dialog containers; plus an additional instance for
+ the application, if desired
+
+ Documents which are not visible - i.e. do not have a visible frame.
+
+ @param _bIncludingApplication
+ <TRUE/> if the application-wide scripts/dialogs should also be represented
+ by a ScriptDocument
+ */
+ static ScriptDocuments
+ getAllScriptDocuments( ScriptDocumentList _eListType );
+
+ // comparison
+ bool operator==( const ScriptDocument& _rhs ) const;
+ inline bool operator!=( const ScriptDocument& _rhs ) const { return !( *this == _rhs ); }
+
+ /// retrieves a (pretty simple) hash code for the document
+ sal_Int32 hashCode() const;
+
+ /** determines whether the document is actually able to contain Basic/Dialog libraries
+
+ Note that validity does not automatically imply the document can be used for active
+ work. Instead, it is possible the document is closed already (or being closed currently).
+ In this case, isValid will return <TRUE/>, but isAlive will return <FALSE/>.
+
+ @return
+ <TRUE/> if the instance refers to a document which contains Basic/Dialog libraries,
+ or the application as a whole, <FALSE/> otherwise.
+
+ @see isAlive
+ */
+ bool isValid() const;
+
+ /** determines whether the document instance is alive
+
+ If the instance is not valid, <FALSE/> is returned.
+
+ If the instance refers to a real document, which is already closed, or just being closed,
+ the method returns <FALSE/>.
+
+ If the instance refers to the application, <TRUE/> is returned.
+
+ @see isValid
+ */
+ bool isAlive() const;
+
+ bool isInVBAMode() const;
+ /// returns the BasicManager associated with this instance
+ BasicManager*
+ getBasicManager() const;
+
+ /** returns the UNO component representing the document which the instance operates on
+
+ Must not be used when the instance operates on the application-wide
+ Basic/Dialog libraries.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
+ getDocument() const;
+
+ /** returns the UNO component representing the document which the instance operates on
+
+ May be used when the instance operates on the application-wide
+ Basic/Dialog libraries, in this case it returns <NULL/>.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
+ getDocumentOrNull() const;
+
+ /** returns the Basic or Dialog library container of the document
+
+ If the document is not valid, <NULL/> is returned.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >
+ getLibraryContainer( LibraryContainerType _eType ) const;
+
+ /** determines whether there exists a library of the given type, with the given name
+ */
+ bool hasLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const;
+
+ /** returns a script or dialog library given by name
+
+ @param _eType
+ the type of library to load
+ @param _rLibName
+ the name of the script library
+ @param _bLoadLibrary
+ <TRUE/> if and only if the library should be loaded.
+
+ @throws NoSuchElementException
+ if there is no script library with the given name
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
+ getLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName, bool _bLoadLibrary ) const
+ SAL_THROW((::com::sun::star::container::NoSuchElementException));
+
+ /** creates a script or dialog library in the document, or returns an existing one
+
+ If <code>_rLibName</code> denotes an existing library which does not need to be created,
+ then this library will automatically be loaded, and then returned.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
+ getOrCreateLibrary( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const;
+
+ /** returns the names of the modules in a given script or dialog library of the document
+ */
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getObjectNames( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const;
+
+ /** retrieves a name for a newly to be created module or dialog
+ */
+ ::rtl::OUString
+ createObjectName( LibraryContainerType _eType, const ::rtl::OUString& _rLibName ) const;
+
+ /** loads a script or dialog library given by name, if there is such a library
+ */
+ void loadLibraryIfExists( LibraryContainerType _eType, const ::rtl::OUString& _rLibrary );
+
+ /// retrieves the (combined) names of all script and dialog libraries
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getLibraryNames() const;
+
+ /** removes a given script module from the document
+
+ @return
+ <TRUE/> if and only if the removal was successful. When <FALSE/> is returned,
+ this will reported as assertion in a non-product build.
+ */
+ bool removeModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModuleName ) const;
+
+ /** creates a module with the given name in the given library
+ @param _rLibName
+ the library name
+ @param _rModName
+ the name of the to-be-created module
+ @param _bCreateMain
+ determines whether or not a function Main should be created
+ @param _out_rNewModuleCode
+ the source code of the newly created module
+ @return
+ <TRUE/> if and only if the creation was successful
+ */
+ bool createModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, bool _bCreateMain, ::rtl::OUString& _out_rNewModuleCode ) const;
+
+ /** inserts a given piece as code as module
+ @param _rLibName
+ the name of the library to insert the module into. If a library with this name does
+ not yet exist, it will be created.
+ @param _rModName
+ the name of the module to insert the code as. Must denote a name which is not yet
+ used in the module library.
+ @param _rModuleCode
+ the code of the new module
+ @return
+ <TRUE/> if and only if the insertion was successful.
+ */
+ bool insertModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, const ::rtl::OUString& _rModuleCode ) const;
+
+ /** updates a given module with new code
+ @param _rLibName
+ the name of the library the modules lives in. Must denote an existing module library.
+ @param _rModName
+ the name of the module to update. Must denote an existing module in the given library.
+ @param _rModuleCode
+ the new module code.
+ @return
+ <TRUE/> if and only if the insertion was successful.
+ */
+ bool updateModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, const ::rtl::OUString& _rModuleCode ) const;
+
+ /// determines whether a module with the given name exists in the given library
+ bool hasModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName ) const;
+
+ /** retrieves a module's source
+ @param _rLibName
+ the library name where the module is located
+ @param _rModName
+ the module name
+ @param _out_rModuleSource
+ takes the module's source upon successful return
+ @return
+ <TRUE/> if and only if the code could be successfully retrieved, <FALSE/> otherwise
+ */
+ bool getModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rModName, ::rtl::OUString& _rModuleSource ) const;
+
+ /** renames a module
+ @param _rLibName
+ the library where the module lives in. Must denote an existing library.
+ @param _rOldName
+ the old module name. Must denote an existing module.
+ @param _rNewName
+ the new module name
+ @return
+ <TRUE/> if and only if renaming was successful.
+ */
+ bool renameModule( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rOldName, const ::rtl::OUString& _rNewName ) const;
+
+ /** removes a given dialog from the document
+
+ @return
+ <TRUE/> if and only if the removal was successful. When <FALSE/> is returned,
+ this will reported as assertion in a non-product build.
+ */
+ bool removeDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName ) const;
+
+ /// determines whether a dialog with the given name exists in the given library
+ bool hasDialog( const ::rtl::OUString& _rLibName, const ::rtl::OUString& _rDialogName ) const;
+
+ /** retrieves a dialog
+ @param _rLibName
+ the library name where the module is located
+ @param _rDialogName
+ the dialog's name
+ @param _out_rDialogSource
+ takes the provider for the dialog's desription, upon successful return
+ @return
+ <TRUE/> if and only if the dialog could be successfully retrieved, <FALSE/> otherwise
+ */
+ bool getDialog(
+ const ::rtl::OUString& _rLibName,
+ const ::rtl::OUString& _rDialogName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStreamProvider >& _out_rDialogProvider
+ ) const;
+
+ /** renames a dialog
+ @param _rLibName
+ the library where the dialog lives in. Must denote an existing library.
+ @param _rOldName
+ the old dialog name. Must denote an existing dialog.
+ @param _rNewName
+ the new dialog name
+ @param _rxExistingDialogModel
+ the existing model of the dialog, if already loaded in the IDE
+ @return
+ <TRUE/> if and only if renaming was successful.
+ */
+ bool renameDialog(
+ const ::rtl::OUString& _rLibName,
+ const ::rtl::OUString& _rOldName,
+ const ::rtl::OUString& _rNewName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxExistingDialogModel
+ ) const;
+
+ /** create a dialog
+ @param _rLibName
+ the library name where the module is located
+ @param _rDialogName
+ the dialog's name
+ @param _out_rDialogSource
+ takes the provider for the dialog's desription, upon successful return
+ @return
+ <TRUE/> if and only if the dialog could be successfully retrieved, <FALSE/> otherwise
+ */
+ bool createDialog(
+ const ::rtl::OUString& _rLibName,
+ const ::rtl::OUString& _rDialogName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStreamProvider >& _out_rDialogProvider
+ ) const;
+
+ /** inserts a given dialog into a given library
+
+ @param _rLibName
+ the name of the library to insert the dialog into. If a library with this name does
+ not yet exist, it will be created.
+ @param _rModName
+ the name of the dialog to insert. Must denote a name which is not yet
+ used in the dialog library.
+ @param _rDialogProvider
+ the provider of the dialog's description
+ @return
+ <TRUE/> if and only if the insertion was successful.
+ */
+ bool insertDialog(
+ const ::rtl::OUString& _rLibName,
+ const ::rtl::OUString& _rDialogName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStreamProvider >& _rDialogProvider
+ ) const;
+
+ /** determines whether the document is read-only
+
+ cannot be called if the document operates on the application-wide scripts
+ */
+ bool isReadOnly() const;
+
+ /** determines whether the ScriptDocument instance operates on the whole application,
+ as opposed to a real document
+ */
+ bool isApplication() const;
+
+ /** determines whether the ScriptDocument instance operates on a real document,
+ as opposed to the whole application
+ */
+ bool isDocument() const { return isValid() && !isApplication(); }
+
+ /** marks the document as modified
+ @precond
+ the instance operates on a real document, not on the application
+ @see isDocument
+ */
+ void setDocumentModified() const;
+
+ /** determines whether the document is modified
+ @precond
+ the instance operates on a real document, not on the application
+ @see isDocument
+ */
+ bool isDocumentModified() const;
+
+ /** saves the document, if the instance refers to a real document
+ @precond
+ <code>isApplication</code> returns <FALSE/>
+ */
+ bool saveDocument(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >& _rxStatusIndicator
+ ) const;
+
+ /// returns the location of a library given by name
+ LibraryLocation
+ getLibraryLocation( const ::rtl::OUString& _rLibName ) const;
+
+ /// returns the title for the document
+ ::rtl::OUString
+ getTitle( LibraryLocation _eLocation, LibraryType _eType = LIBRARY_TYPE_ALL ) const;
+
+ /** returns the title of the document
+
+ to be used for valid documents only
+ */
+ ::rtl::OUString
+ getTitle() const;
+
+ /** returns the URL of the document
+
+ to be used for valid documents only
+ */
+ ::rtl::OUString
+ getURL() const;
+
+ /** determines whether the document is currently the one-and-only application-wide active document
+ */
+ bool isActive() const;
+
+ /** determines whether macro execution for this document is allowed
+
+ only to be called for real documents (->isDocument)
+ */
+ bool allowMacros() const;
+ };
+
+//........................................................................
+} // namespace basctl
+//........................................................................
+
+// convenience ... better would be all classes in the project are in
+// the same namespace ...
+using ::basctl::ScriptDocument;
+using ::basctl::ScriptDocuments;
+using ::basctl::E_SCRIPTS;
+using ::basctl::E_DIALOGS;
+using ::basctl::LibraryLocation;
+using ::basctl::LIBRARY_LOCATION_UNKNOWN;
+using ::basctl::LIBRARY_LOCATION_USER;
+using ::basctl::LIBRARY_LOCATION_SHARE;
+using ::basctl::LIBRARY_LOCATION_DOCUMENT;
+using ::basctl::LibraryType;
+using ::basctl::LIBRARY_TYPE_UNKNOWN;
+using ::basctl::LIBRARY_TYPE_MODULE;
+using ::basctl::LIBRARY_TYPE_DIALOG;
+using ::basctl::LIBRARY_TYPE_ALL;
+
+#endif // SCRIPTDOCUMENT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/svheader.hxx b/basctl/source/inc/svheader.hxx
new file mode 100644
index 000000000000..152495d9ee8d
--- /dev/null
+++ b/basctl/source/inc/svheader.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SVHEADER_HXX
+#define _SVHEADER_HXX
+
+
+// SV
+#define _COLDLG_HXX
+#define _CONFIG_HXX
+#define _CURSOR_HXX
+#define _FONTDLG_HXX
+#define _PRVWIN_HXX
+//#define _SELENG_HXX
+#define _VIRTDEV_HXX
+
+// Wenn Brkdlg ohne PCH:
+// #define _SPIN_HXX
+// #define _FIELD_HXX
+
+// SVTOOLS
+#define _CTRLBOX_HXX
+#define _EXTATTR_HXX
+#define _CTRLTOOL_HXX
+#define _CTRLBOX_HXX
+#define _STDMENU_HXX
+#define _VALUESET_HXX
+#define _RULER_HXX
+#define _SCRWIN_HXX
+
+// SFX
+#define _SFXAPPWIN_HXX
+#define _SFX_RESMGR_HXX
+#define _SFX_PRNMON_HXX
+#define _INTRO_HXX
+#define _SFXMSGDESCR_HXX
+#define _SFXMSGPOOL_HXX
+// #define _PASSWD_HXX
+#define _SFXMNUMGR_HXX
+
+// SFXDLG
+// #define _SFXTABDLG_HXX
+// #define _SFX_DINFDLG_HXX
+#define _SFX_MGETEMPL_HXX
+#define _SFX_STYLEDLG_HXX
+#define _SFX_TPLPITEM_HXX
+#define _NEWSTYLE_HXX
+#define _SFXDOCTEMPL_HXX
+#define _SFXDOCTDLG_HXX
+#define _SFX_TEMPLDLG_HXX
+#define _SFXNEW_HXX
+
+// SFXDOC
+// #define _SFXDOCINF_HXX
+//#define _SFX_DOCFILT_HXX
+#define _SFX_IPFRM_HXX
+#define _SFX_INTERNO_HXX
+
+// SVCONTNR
+#define _SVICNVW_HXX
+
+#define _SBSTDOBJ1_HXX
+#define _SBXMSTRM_HXX
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */