summaryrefslogtreecommitdiff
path: root/basctl/source
diff options
context:
space:
mode:
Diffstat (limited to 'basctl/source')
-rw-r--r--basctl/source/accessibility/accessibledialogcontrolshape.cxx53
-rw-r--r--basctl/source/accessibility/accessibledialogwindow.cxx132
-rw-r--r--basctl/source/basicide/BasicColorConfig.cxx129
-rw-r--r--basctl/source/basicide/ColorSchemeDialog.cxx148
-rw-r--r--basctl/source/basicide/IDEComboBox.cxx47
-rw-r--r--basctl/source/basicide/LineStatusControl.cxx45
-rw-r--r--basctl/source/basicide/ObjectCatalog.cxx4
-rw-r--r--basctl/source/basicide/basdoc.cxx8
-rw-r--r--basctl/source/basicide/basdoc.hxx2
-rw-r--r--basctl/source/basicide/basicrenderable.cxx2
-rw-r--r--basctl/source/basicide/baside2.cxx285
-rw-r--r--basctl/source/basicide/baside2.hxx65
-rw-r--r--basctl/source/basicide/baside2b.cxx352
-rw-r--r--basctl/source/basicide/baside3.cxx361
-rw-r--r--basctl/source/basicide/basides1.cxx310
-rw-r--r--basctl/source/basicide/basides2.cxx15
-rw-r--r--basctl/source/basicide/basides3.cxx4
-rw-r--r--basctl/source/basicide/basidesh.cxx134
-rw-r--r--basctl/source/basicide/basobj2.cxx74
-rw-r--r--basctl/source/basicide/basobj3.cxx66
-rw-r--r--basctl/source/basicide/bastype2.cxx111
-rw-r--r--basctl/source/basicide/bastype3.cxx12
-rw-r--r--basctl/source/basicide/bastypes.cxx127
-rw-r--r--basctl/source/basicide/brkdlg.cxx14
-rw-r--r--basctl/source/basicide/doceventnotifier.cxx82
-rw-r--r--basctl/source/basicide/docsignature.cxx4
-rw-r--r--basctl/source/basicide/documentenumeration.cxx22
-rw-r--r--basctl/source/basicide/documentenumeration.hxx4
-rw-r--r--basctl/source/basicide/iderdll.cxx2
-rw-r--r--basctl/source/basicide/linenumberwindow.cxx46
-rw-r--r--basctl/source/basicide/linenumberwindow.hxx2
-rw-r--r--basctl/source/basicide/localizationmgr.cxx224
-rw-r--r--basctl/source/basicide/macrodlg.cxx49
-rw-r--r--basctl/source/basicide/moduldl2.cxx169
-rw-r--r--basctl/source/basicide/moduldlg.cxx95
-rw-r--r--basctl/source/basicide/moduldlg.hxx23
-rw-r--r--basctl/source/basicide/sbxitem.cxx29
-rw-r--r--basctl/source/basicide/scriptdocument.cxx48
-rw-r--r--basctl/source/basicide/textwindowpeer.cxx2
-rw-r--r--basctl/source/basicide/textwindowpeer.hxx4
-rw-r--r--basctl/source/basicide/uiobject.cxx3
-rw-r--r--basctl/source/basicide/unomodel.cxx54
-rw-r--r--basctl/source/basicide/unomodel.hxx3
-rw-r--r--basctl/source/dlged/dlged.cxx178
-rw-r--r--basctl/source/dlged/dlgedclip.cxx2
-rw-r--r--basctl/source/dlged/dlgedfac.cxx102
-rw-r--r--basctl/source/dlged/dlgedfunc.cxx16
-rw-r--r--basctl/source/dlged/dlgedmod.cxx5
-rw-r--r--basctl/source/dlged/dlgedobj.cxx123
-rw-r--r--basctl/source/dlged/dlgedview.cxx4
-rw-r--r--basctl/source/dlged/managelang.cxx39
-rw-r--r--basctl/source/dlged/propbrw.cxx30
-rw-r--r--basctl/source/inc/BasicColorConfig.hxx99
-rw-r--r--basctl/source/inc/ColorSchemeDialog.hxx57
-rw-r--r--basctl/source/inc/LineStatusControl.hxx30
-rw-r--r--basctl/source/inc/accessibledialogcontrolshape.hxx34
-rw-r--r--basctl/source/inc/accessibledialogwindow.hxx50
-rw-r--r--basctl/source/inc/baside3.hxx7
-rw-r--r--basctl/source/inc/basidesh.hxx34
-rw-r--r--basctl/source/inc/basobj.hxx5
-rw-r--r--basctl/source/inc/bastype2.hxx25
-rw-r--r--basctl/source/inc/bastypes.hxx34
-rw-r--r--basctl/source/inc/colorscheme.hxx45
-rw-r--r--basctl/source/inc/dlged.hxx19
-rw-r--r--basctl/source/inc/dlgeddef.hxx26
-rw-r--r--basctl/source/inc/dlgedfac.hxx4
-rw-r--r--basctl/source/inc/dlgedobj.hxx8
-rw-r--r--basctl/source/inc/docsignature.hxx2
-rw-r--r--basctl/source/inc/iderid.hxx4
-rw-r--r--basctl/source/inc/localizationmgr.hxx2
-rw-r--r--basctl/source/inc/managelang.hxx9
-rw-r--r--basctl/source/inc/sbxitem.hxx4
72 files changed, 2669 insertions, 1693 deletions
diff --git a/basctl/source/accessibility/accessibledialogcontrolshape.cxx b/basctl/source/accessibility/accessibledialogcontrolshape.cxx
index f885ff4bda1b..c19741c95afa 100644
--- a/basctl/source/accessibility/accessibledialogcontrolshape.cxx
+++ b/basctl/source/accessibility/accessibledialogcontrolshape.cxx
@@ -22,17 +22,18 @@
#include <dlgeddef.hxx>
#include <dlgedview.hxx>
#include <dlgedobj.hxx>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <unotools/accessiblestatesethelper.hxx>
#include <unotools/accessiblerelationsethelper.hxx>
#include <toolkit/awt/vclxfont.hxx>
#include <toolkit/helper/convert.hxx>
#include <toolkit/helper/vclunohelper.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/accessiblecontexthelper.hxx>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <i18nlangtag/languagetag.hxx>
@@ -200,25 +201,25 @@ OUString AccessibleDialogControlShape::GetModelStringProperty( OUString const &
}
-void AccessibleDialogControlShape::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+void AccessibleDialogControlShape::FillAccessibleStateSet( sal_Int64& rStateSet )
{
- rStateSet.AddState( AccessibleStateType::ENABLED );
+ rStateSet |= AccessibleStateType::ENABLED;
- rStateSet.AddState( AccessibleStateType::VISIBLE );
+ rStateSet |= AccessibleStateType::VISIBLE;
- rStateSet.AddState( AccessibleStateType::SHOWING );
+ rStateSet |= AccessibleStateType::SHOWING;
- rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+ rStateSet |= AccessibleStateType::FOCUSABLE;
if ( IsFocused() )
- rStateSet.AddState( AccessibleStateType::FOCUSED );
+ rStateSet |= AccessibleStateType::FOCUSED;
- rStateSet.AddState( AccessibleStateType::SELECTABLE );
+ rStateSet |= AccessibleStateType::SELECTABLE;
if ( IsSelected() )
- rStateSet.AddState( AccessibleStateType::SELECTED );
+ rStateSet |= AccessibleStateType::SELECTED;
- rStateSet.AddState( AccessibleStateType::RESIZABLE );
+ rStateSet |= AccessibleStateType::RESIZABLE;
}
// OCommonAccessibleComponent
@@ -227,12 +228,6 @@ awt::Rectangle AccessibleDialogControlShape::implGetBounds()
return GetBounds();
}
-// XInterface
-IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogControlShape, OAccessibleExtendedComponentHelper, AccessibleDialogControlShape_BASE )
-
-// XTypeProvider
-IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogControlShape, OAccessibleExtendedComponentHelper, AccessibleDialogControlShape_BASE )
-
// XComponent
void AccessibleDialogControlShape::disposing()
{
@@ -285,7 +280,7 @@ void AccessibleDialogControlShape::propertyChange( const beans::PropertyChangeEv
// XServiceInfo
OUString AccessibleDialogControlShape::getImplementationName()
{
- return "com.sun.star.comp.basctl.AccessibleShape";
+ return u"com.sun.star.comp.basctl.AccessibleShape"_ustr;
}
sal_Bool AccessibleDialogControlShape::supportsService( const OUString& rServiceName )
@@ -295,7 +290,7 @@ sal_Bool AccessibleDialogControlShape::supportsService( const OUString& rService
Sequence< OUString > AccessibleDialogControlShape::getSupportedServiceNames()
{
- return { "com.sun.star.drawing.AccessibleShape" };
+ return { u"com.sun.star.drawing.AccessibleShape"_ustr };
}
// XAccessible
@@ -305,13 +300,13 @@ Reference< XAccessibleContext > AccessibleDialogControlShape::getAccessibleConte
}
// XAccessibleContext
-sal_Int32 AccessibleDialogControlShape::getAccessibleChildCount()
+sal_Int64 AccessibleDialogControlShape::getAccessibleChildCount()
{
return 0;
}
-Reference< XAccessible > AccessibleDialogControlShape::getAccessibleChild( sal_Int32 i )
+Reference< XAccessible > AccessibleDialogControlShape::getAccessibleChild( sal_Int64 i )
{
OExternalLockGuard aGuard( this );
@@ -334,18 +329,18 @@ Reference< XAccessible > AccessibleDialogControlShape::getAccessibleParent( )
}
-sal_Int32 AccessibleDialogControlShape::getAccessibleIndexInParent( )
+sal_Int64 AccessibleDialogControlShape::getAccessibleIndexInParent( )
{
OExternalLockGuard aGuard( this );
- sal_Int32 nIndexInParent = -1;
+ sal_Int64 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 )
+ for ( sal_Int64 i = 0, nCount = xParentContext->getAccessibleChildCount(); i < nCount; ++i )
{
Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) );
if ( xChild.is() )
@@ -397,22 +392,22 @@ Reference< XAccessibleRelationSet > AccessibleDialogControlShape::getAccessibleR
}
-Reference< XAccessibleStateSet > AccessibleDialogControlShape::getAccessibleStateSet( )
+sal_Int64 AccessibleDialogControlShape::getAccessibleStateSet( )
{
OExternalLockGuard aGuard( this );
- rtl::Reference<utl::AccessibleStateSetHelper> pStateSetHelper = new utl::AccessibleStateSetHelper;
+ sal_Int64 nStateSet = 0;
if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
{
- FillAccessibleStateSet( *pStateSetHelper );
+ FillAccessibleStateSet( nStateSet );
}
else
{
- pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
+ nStateSet |= AccessibleStateType::DEFUNC;
}
- return pStateSetHelper;
+ return nStateSet;
}
diff --git a/basctl/source/accessibility/accessibledialogwindow.cxx b/basctl/source/accessibility/accessibledialogwindow.cxx
index 0b641c8aca5e..e9b4513294fb 100644
--- a/basctl/source/accessibility/accessibledialogwindow.cxx
+++ b/basctl/source/accessibility/accessibledialogwindow.cxx
@@ -26,13 +26,14 @@
#include <dlgedpage.hxx>
#include <dlgedview.hxx>
#include <dlgedobj.hxx>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <comphelper/accessiblecontexthelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <tools/debug.hxx>
-#include <unotools/accessiblestatesethelper.hxx>
#include <unotools/accessiblerelationsethelper.hxx>
#include <toolkit/awt/vclxfont.hxx>
#include <toolkit/helper/convert.hxx>
@@ -84,11 +85,10 @@ AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow* pDialogWin
return;
SdrPage& rPage = m_pDialogWindow->GetPage();
- const size_t nCount = rPage.GetObjCount();
- for ( size_t i = 0; i < nCount; ++i )
+ for (const rtl::Reference<SdrObject>& pObj : rPage)
{
- if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i)))
+ if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get()))
{
ChildDescriptor aDesc( pDlgEdObj );
if ( IsChildVisible( aDesc ) )
@@ -119,13 +119,8 @@ void AccessibleDialogWindow::UpdateFocused()
{
for (const ChildDescriptor & i : m_aAccessibleChildren)
{
- Reference< XAccessible > xChild( i.rxAccessible );
- if ( xChild.is() )
- {
- AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
- if ( pShape )
- pShape->SetFocused( pShape->IsFocused() );
- }
+ if ( i.mxAccessible )
+ i.mxAccessible->SetFocused( i.mxAccessible->IsFocused() );
}
}
@@ -136,13 +131,8 @@ void AccessibleDialogWindow::UpdateSelected()
for (const ChildDescriptor & i : m_aAccessibleChildren)
{
- Reference< XAccessible > xChild( i.rxAccessible );
- if ( xChild.is() )
- {
- AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
- if ( pShape )
- pShape->SetSelected( pShape->IsSelected() );
- }
+ if ( i.mxAccessible )
+ i.mxAccessible->SetSelected( i.mxAccessible->IsSelected() );
}
}
@@ -151,13 +141,8 @@ void AccessibleDialogWindow::UpdateBounds()
{
for (const ChildDescriptor & i : m_aAccessibleChildren)
{
- Reference< XAccessible > xChild( i.rxAccessible );
- if ( xChild.is() )
- {
- AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
- if ( pShape )
- pShape->SetBounds( pShape->GetBounds() );
- }
+ if ( i.mxAccessible )
+ i.mxAccessible->SetBounds( i.mxAccessible->GetBounds() );
}
}
@@ -194,7 +179,7 @@ bool AccessibleDialogWindow::IsChildVisible( const ChildDescriptor& rDesc )
// check, if the shape's bounding box intersects with the bounding box of its parent
tools::Rectangle aParentRect( Point( 0, 0 ), m_pDialogWindow->GetSizePixel() );
- if ( aParentRect.IsOver( aRect ) )
+ if ( aParentRect.Overlaps( aRect ) )
bVisible = true;
}
}
@@ -243,7 +228,7 @@ void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc )
return;
// get the accessible of the removed child
- Reference< XAccessible > xChild( aIter->rxAccessible );
+ rtl::Reference< AccessibleDialogControlShape > xChild( aIter->mxAccessible );
// remove entry from child list
m_aAccessibleChildren.erase( aIter );
@@ -252,12 +237,11 @@ void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc )
if ( xChild.is() )
{
Any aOldValue, aNewValue;
- aOldValue <<= xChild;
+ aOldValue <<= uno::Reference<XAccessible>(xChild);
NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
- Reference< XComponent > xComponent( xChild, UNO_QUERY );
- if ( xComponent.is() )
- xComponent->dispose();
+ if ( xChild )
+ xChild->dispose();
}
}
@@ -282,8 +266,8 @@ void AccessibleDialogWindow::UpdateChildren()
if ( m_pDialogWindow )
{
SdrPage& rPage = m_pDialogWindow->GetPage();
- for ( size_t i = 0, nCount = rPage.GetObjCount(); i < nCount; ++i )
- if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i)))
+ for (const rtl::Reference<SdrObject>& pObj : rPage)
+ if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get()))
UpdateChild( ChildDescriptor( pDlgEdObj ) );
}
}
@@ -379,9 +363,8 @@ void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindo
// dispose all children
for (const ChildDescriptor & i : m_aAccessibleChildren)
{
- Reference< XComponent > xComponent( i.rxAccessible, UNO_QUERY );
- if ( xComponent.is() )
- xComponent->dispose();
+ if ( i.mxAccessible )
+ i.mxAccessible->dispose();
}
m_aAccessibleChildren.clear();
}
@@ -395,27 +378,27 @@ void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindo
}
-void AccessibleDialogWindow::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+void AccessibleDialogWindow::FillAccessibleStateSet( sal_Int64& rStateSet )
{
if ( !m_pDialogWindow )
return;
if ( m_pDialogWindow->IsEnabled() )
- rStateSet.AddState( AccessibleStateType::ENABLED );
+ rStateSet |= AccessibleStateType::ENABLED;
- rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+ rStateSet |= AccessibleStateType::FOCUSABLE;
if ( m_pDialogWindow->HasFocus() )
- rStateSet.AddState( AccessibleStateType::FOCUSED );
+ rStateSet |= AccessibleStateType::FOCUSED;
- rStateSet.AddState( AccessibleStateType::VISIBLE );
+ rStateSet |= AccessibleStateType::VISIBLE;
if ( m_pDialogWindow->IsVisible() )
- rStateSet.AddState( AccessibleStateType::SHOWING );
+ rStateSet |= AccessibleStateType::SHOWING;
- rStateSet.AddState( AccessibleStateType::OPAQUE );
+ rStateSet |= AccessibleStateType::OPAQUE;
- rStateSet.AddState( AccessibleStateType::RESIZABLE );
+ rStateSet |= AccessibleStateType::RESIZABLE;
}
@@ -493,18 +476,6 @@ void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint )
}
-// XInterface
-
-
-IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogWindow, OAccessibleExtendedComponentHelper, AccessibleDialogWindow_BASE )
-
-
-// XTypeProvider
-
-
-IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogWindow, OAccessibleExtendedComponentHelper, AccessibleDialogWindow_BASE )
-
-
// XComponent
@@ -525,9 +496,8 @@ void AccessibleDialogWindow::disposing()
// dispose all children
for (const ChildDescriptor & i : m_aAccessibleChildren)
{
- Reference< XComponent > xComponent( i.rxAccessible, UNO_QUERY );
- if ( xComponent.is() )
- xComponent->dispose();
+ if ( i.mxAccessible )
+ i.mxAccessible->dispose();
}
m_aAccessibleChildren.clear();
}
@@ -535,7 +505,7 @@ void AccessibleDialogWindow::disposing()
// XServiceInfo
OUString AccessibleDialogWindow::getImplementationName()
{
- return "com.sun.star.comp.basctl.AccessibleWindow";
+ return u"com.sun.star.comp.basctl.AccessibleWindow"_ustr;
}
sal_Bool AccessibleDialogWindow::supportsService( const OUString& rServiceName )
@@ -545,7 +515,7 @@ sal_Bool AccessibleDialogWindow::supportsService( const OUString& rServiceName )
Sequence< OUString > AccessibleDialogWindow::getSupportedServiceNames()
{
- return { "com.sun.star.awt.AccessibleWindow" };
+ return { u"com.sun.star.awt.AccessibleWindow"_ustr };
}
// XAccessible
@@ -555,7 +525,7 @@ Reference< XAccessibleContext > AccessibleDialogWindow::getAccessibleContext( )
}
// XAccessibleContext
-sal_Int32 AccessibleDialogWindow::getAccessibleChildCount()
+sal_Int64 AccessibleDialogWindow::getAccessibleChildCount()
{
OExternalLockGuard aGuard( this );
@@ -563,14 +533,14 @@ sal_Int32 AccessibleDialogWindow::getAccessibleChildCount()
}
-Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int32 i )
+Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int64 i )
{
OExternalLockGuard aGuard( this );
if ( i < 0 || i >= getAccessibleChildCount() )
throw IndexOutOfBoundsException();
- Reference< XAccessible > xChild = m_aAccessibleChildren[i].rxAccessible;
+ rtl::Reference< AccessibleDialogControlShape > xChild = m_aAccessibleChildren[i].mxAccessible;
if ( !xChild.is() )
{
if ( m_pDialogWindow )
@@ -581,7 +551,7 @@ Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int32 i
xChild = new AccessibleDialogControlShape( m_pDialogWindow, pDlgEdObj );
// insert into child list
- m_aAccessibleChildren[i].rxAccessible = xChild;
+ m_aAccessibleChildren[i].mxAccessible = xChild;
}
}
}
@@ -606,11 +576,11 @@ Reference< XAccessible > AccessibleDialogWindow::getAccessibleParent( )
}
-sal_Int32 AccessibleDialogWindow::getAccessibleIndexInParent( )
+sal_Int64 AccessibleDialogWindow::getAccessibleIndexInParent( )
{
OExternalLockGuard aGuard( this );
- sal_Int32 nIndexInParent = -1;
+ sal_Int64 nIndexInParent = -1;
if ( m_pDialogWindow )
{
vcl::Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
@@ -672,22 +642,22 @@ Reference< XAccessibleRelationSet > AccessibleDialogWindow::getAccessibleRelatio
}
-Reference< XAccessibleStateSet > AccessibleDialogWindow::getAccessibleStateSet( )
+sal_Int64 AccessibleDialogWindow::getAccessibleStateSet( )
{
OExternalLockGuard aGuard( this );
- rtl::Reference<utl::AccessibleStateSetHelper> pStateSetHelper = new utl::AccessibleStateSetHelper;
+ sal_Int64 nStateSet = 0;
if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
{
- FillAccessibleStateSet( *pStateSetHelper );
+ FillAccessibleStateSet( nStateSet );
}
else
{
- pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
+ nStateSet |= AccessibleStateType::DEFUNC;
}
- return pStateSetHelper;
+ return nStateSet;
}
@@ -717,7 +687,7 @@ Reference< XAccessible > AccessibleDialogWindow::getAccessibleAtPoint( const awt
{
tools::Rectangle aRect = VCLRectangle( xComp->getBounds() );
Point aPos = VCLPoint( rPoint );
- if ( aRect.IsInside( aPos ) )
+ if ( aRect.Contains( aPos ) )
{
xChild = xAcc;
break;
@@ -831,7 +801,7 @@ OUString AccessibleDialogWindow::getToolTipText( )
// XAccessibleSelection
-void AccessibleDialogWindow::selectAccessibleChild( sal_Int32 nChildIndex )
+void AccessibleDialogWindow::selectAccessibleChild( sal_Int64 nChildIndex )
{
OExternalLockGuard aGuard( this );
@@ -850,7 +820,7 @@ void AccessibleDialogWindow::selectAccessibleChild( sal_Int32 nChildIndex )
}
-sal_Bool AccessibleDialogWindow::isAccessibleChildSelected( sal_Int32 nChildIndex )
+sal_Bool AccessibleDialogWindow::isAccessibleChildSelected( sal_Int64 nChildIndex )
{
OExternalLockGuard aGuard( this );
@@ -882,13 +852,13 @@ void AccessibleDialogWindow::selectAllAccessibleChildren( )
}
-sal_Int32 AccessibleDialogWindow::getSelectedAccessibleChildCount( )
+sal_Int64 AccessibleDialogWindow::getSelectedAccessibleChildCount( )
{
OExternalLockGuard aGuard( this );
- sal_Int32 nRet = 0;
+ sal_Int64 nRet = 0;
- for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
+ for ( sal_Int64 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
{
if ( isAccessibleChildSelected( i ) )
++nRet;
@@ -898,7 +868,7 @@ sal_Int32 AccessibleDialogWindow::getSelectedAccessibleChildCount( )
}
-Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex )
{
OExternalLockGuard aGuard( this );
@@ -907,7 +877,7 @@ Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal
Reference< XAccessible > xChild;
- for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
+ for ( sal_Int64 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
{
if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
{
@@ -920,7 +890,7 @@ Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal
}
-void AccessibleDialogWindow::deselectAccessibleChild( sal_Int32 nChildIndex )
+void AccessibleDialogWindow::deselectAccessibleChild( sal_Int64 nChildIndex )
{
OExternalLockGuard aGuard( this );
diff --git a/basctl/source/basicide/BasicColorConfig.cxx b/basctl/source/basicide/BasicColorConfig.cxx
new file mode 100644
index 000000000000..433c55b531ac
--- /dev/null
+++ b/basctl/source/basicide/BasicColorConfig.cxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <tools/solar.h>
+#include <BasicColorConfig.hxx>
+#include <officecfg/Office/BasicIDE.hxx>
+
+#include <sal/log.hxx>
+
+namespace basctl
+{
+BasicColorConfig::BasicColorConfig()
+ : ConfigItem("Office.BasicIDE/IDEColorSchemes")
+{
+ // Initially the active color scheme is the one defined in the registry
+ m_sCurrentColorScheme = officecfg::Office::BasicIDE::EditorSettings::ColorScheme::get();
+
+ // Initialize all available scheme names
+ m_aSchemeNames = GetNodeNames("");
+}
+
+BasicColorConfig::~BasicColorConfig() {}
+
+void BasicColorConfig::Notify(const css::uno::Sequence<OUString>&) {}
+
+void BasicColorConfig::ImplCommit() {}
+
+ColorScheme BasicColorConfig::GetColorScheme(const OUString& rScheme)
+{
+ // If the default scheme is being requested or the scheme does not exist, return the Application Colors scheme
+ if (rScheme == DEFAULT_SCHEME || comphelper::findValue(m_aSchemeNames, rScheme) == -1)
+ {
+ return GetAutomaticColorScheme();
+ }
+
+ std::vector<OUString> aVecPropNames = { OUString(rScheme + "/GenericColor/Color"),
+ OUString(rScheme + "/IdentifierColor/Color"),
+ OUString(rScheme + "/NumberColor/Color"),
+ OUString(rScheme + "/StringColor/Color"),
+ OUString(rScheme + "/CommentColor/Color"),
+ OUString(rScheme + "/ErrorColor/Color"),
+ OUString(rScheme + "/OperatorColor/Color"),
+ OUString(rScheme + "/KeywordColor/Color"),
+ OUString(rScheme + "/BackgroundColor/Color"),
+ OUString(rScheme + "/LineHighlightColor/Color") };
+
+ css::uno::Sequence<OUString> aPropNames(aVecPropNames.size());
+ OUString* pPropNames = aPropNames.getArray();
+ for (size_t i = 0; i < aVecPropNames.size(); i++)
+ {
+ pPropNames[i] = aVecPropNames[i];
+ }
+ css::uno::Sequence<css::uno::Any> aColors = GetProperties(aPropNames);
+
+ ColorScheme aColorScheme;
+ aColorScheme.m_sSchemeName = rScheme;
+ aColorScheme.m_bIsDefault = comphelper::findValue(m_aDefaultSchemes, rScheme) != -1;
+ aColors[0] >>= aColorScheme.m_aGenericFontColor;
+ aColors[1] >>= aColorScheme.m_aIdentifierColor;
+ aColors[2] >>= aColorScheme.m_aNumberColor;
+ aColors[3] >>= aColorScheme.m_aStringColor;
+ aColors[4] >>= aColorScheme.m_aCommentColor;
+ aColors[5] >>= aColorScheme.m_aErrorColor;
+ aColors[6] >>= aColorScheme.m_aOperatorColor;
+ aColors[7] >>= aColorScheme.m_aKeywordColor;
+ aColors[8] >>= aColorScheme.m_aBackgroundColor;
+ aColors[9] >>= aColorScheme.m_aLineHighlightColor;
+
+ return aColorScheme;
+}
+
+ColorScheme BasicColorConfig::GetAutomaticColorScheme()
+{
+ // Application Colors do not define a line highlight color, so here we adjust
+ // the background color to get a highlight color
+ Color aBackgroundColor = aColorConfig.GetColorValue(svtools::BASICEDITOR).nColor;
+ Color aHighlightColor(aBackgroundColor);
+ if (aBackgroundColor.IsDark())
+ aHighlightColor.ApplyTintOrShade(1000);
+ else
+ aHighlightColor.ApplyTintOrShade(-1000);
+
+ ColorScheme aScheme = { DEFAULT_SCHEME,
+ false,
+ aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor,
+ aColorConfig.GetColorValue(svtools::BASICIDENTIFIER).nColor,
+ aColorConfig.GetColorValue(svtools::BASICNUMBER).nColor,
+ aColorConfig.GetColorValue(svtools::BASICSTRING).nColor,
+ aColorConfig.GetColorValue(svtools::BASICCOMMENT).nColor,
+ aColorConfig.GetColorValue(svtools::BASICERROR).nColor,
+ aColorConfig.GetColorValue(svtools::BASICOPERATOR).nColor,
+ aColorConfig.GetColorValue(svtools::BASICKEYWORD).nColor,
+ aBackgroundColor,
+ aHighlightColor };
+
+ return aScheme;
+}
+
+OUString& BasicColorConfig::GetCurrentColorSchemeName()
+{
+ // Always return from the registry to get the most up-to-date value
+ m_sCurrentColorScheme = officecfg::Office::BasicIDE::EditorSettings::ColorScheme::get();
+ return m_sCurrentColorScheme;
+}
+
+TranslateId BasicColorConfig::GetSchemeTranslateId(const OUString& rScheme)
+{
+ return m_aTranslateIdsMap.find(rScheme)->second;
+}
+
+} // namespace basctl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/ColorSchemeDialog.cxx b/basctl/source/basicide/ColorSchemeDialog.cxx
new file mode 100644
index 000000000000..4351624e4298
--- /dev/null
+++ b/basctl/source/basicide/ColorSchemeDialog.cxx
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <basidesh.hxx>
+#include <iderdll.hxx>
+#include <ColorSchemeDialog.hxx>
+#include <strings.hrc>
+#include <vcl/weld.hxx>
+#include <vcl/settings.hxx>
+#include <tools/debug.hxx>
+#include "baside2.hxx"
+#include <officecfg/Office/BasicIDE.hxx>
+#include <BasicColorConfig.hxx>
+#include <memory>
+
+namespace basctl
+{
+ColorSchemeDialog::ColorSchemeDialog(weld::Window* pParent,
+ VclPtr<ModulWindowLayout> pModulWinLayout)
+ : GenericDialogController(pParent, "modules/BasicIDE/ui/colorscheme.ui", "ColorSchemeDialog")
+ , m_pModulWinLayout(std::move(pModulWinLayout))
+ , m_xSchemeList(m_xBuilder->weld_tree_view("schemelist"))
+ , m_xUseAppCollors(m_xBuilder->weld_radio_button("opt_appcolors"))
+ , m_xUseScheme(m_xBuilder->weld_radio_button("opt_usescheme"))
+ , m_xOk(m_xBuilder->weld_button("btn_ok"))
+{
+ m_pColorConfig = GetShell()->GetColorConfig();
+ m_sSelectedSchemeId = m_pColorConfig->GetCurrentColorSchemeName();
+
+ m_xSchemeList->set_size_request(m_xSchemeList->get_approximate_digit_width() * 30,
+ m_xSchemeList->get_height_rows(10));
+ m_xSchemeList->set_selection_mode(SelectionMode::Single);
+
+ Init();
+}
+
+ColorSchemeDialog::~ColorSchemeDialog() {}
+
+void ColorSchemeDialog::Init()
+{
+ m_xOk->connect_clicked(LINK(this, ColorSchemeDialog, BtnOkHdl));
+ m_xUseAppCollors->connect_toggled(LINK(this, ColorSchemeDialog, OptionHdl));
+ m_xUseScheme->connect_toggled(LINK(this, ColorSchemeDialog, OptionHdl));
+ m_xSchemeList->connect_changed(LINK(this, ColorSchemeDialog, SelectHdl));
+
+ // Populate the list with available color schemes
+ for (auto const& rName : m_pColorConfig->GetColorSchemeNames())
+ {
+ // Default schemes (preinstalled with LO) have TranslateIds
+ if (m_pColorConfig->IsDefaultScheme(rName))
+ {
+ m_xSchemeList->append(rName, IDEResId(m_pColorConfig->GetSchemeTranslateId(rName)));
+ }
+ else
+ {
+ m_xSchemeList->append(rName, rName);
+ }
+ }
+ m_xSchemeList->make_sorted();
+
+ // Set initial selection in the dialog
+ m_xUseAppCollors->set_active(true);
+ if (m_sSelectedSchemeId == DEFAULT_SCHEME)
+ {
+ // The "Application Colors" theme is being used
+ m_xSchemeList->set_sensitive(false);
+ }
+ else
+ {
+ // Check if the scheme exists
+ if (comphelper::findValue(m_pColorConfig->GetColorSchemeNames(), m_sSelectedSchemeId) != -1)
+ {
+ m_xUseScheme->set_active(true);
+ m_xSchemeList->select_id(m_sSelectedSchemeId);
+ }
+ else
+ {
+ m_xSchemeList->set_sensitive(false);
+ }
+ }
+}
+
+IMPL_LINK_NOARG(ColorSchemeDialog, BtnOkHdl, weld::Button&, void)
+{
+ // Collect selected theme
+ if (m_xUseAppCollors->get_active())
+ m_sSelectedSchemeId = DEFAULT_SCHEME;
+ else
+ m_sSelectedSchemeId = m_xSchemeList->get_selected_id();
+
+ m_xDialog->response(RET_OK);
+}
+
+IMPL_LINK_NOARG(ColorSchemeDialog, OptionHdl, weld::Toggleable&, void)
+{
+ if (m_xUseAppCollors->get_active())
+ {
+ m_xSchemeList->set_sensitive(false);
+ m_pModulWinLayout->ApplyColorSchemeToCurrentWindow(DEFAULT_SCHEME);
+ m_sSelectedSchemeId = DEFAULT_SCHEME;
+ }
+
+ if (m_xUseScheme->get_active())
+ {
+ m_xSchemeList->set_sensitive(true);
+ // Always select a item to avoid having nothing selected
+ if (m_sSelectedSchemeId == DEFAULT_SCHEME)
+ {
+ // If the default color scheme was selected, then choose first entry in the list
+ m_xSchemeList->select_id(m_xSchemeList->get_id(0));
+ m_pModulWinLayout->ApplyColorSchemeToCurrentWindow(m_xSchemeList->get_id(0));
+ }
+ else
+ {
+ // If a color scheme was active, select it in the list
+ m_xSchemeList->select_id(m_sSelectedSchemeId);
+ m_pModulWinLayout->ApplyColorSchemeToCurrentWindow(m_sSelectedSchemeId);
+ }
+ }
+}
+
+IMPL_LINK_NOARG(ColorSchemeDialog, SelectHdl, weld::TreeView&, void)
+{
+ // Apply the selected scheme only for the current ModulWinLayout for preview
+ // Only if the user presses OK the scheme will be applied to all ModulWinLayout(s)
+ m_sSelectedSchemeId = m_xSchemeList->get_selected_id();
+ m_pModulWinLayout->ApplyColorSchemeToCurrentWindow(m_sSelectedSchemeId);
+}
+
+} // namespace basctl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/IDEComboBox.cxx b/basctl/source/basicide/IDEComboBox.cxx
index 87a45e5a9c22..a4ad6c8ada95 100644
--- a/basctl/source/basicide/IDEComboBox.cxx
+++ b/basctl/source/basicide/IDEComboBox.cxx
@@ -34,6 +34,7 @@
#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/event.hxx>
+#include <svl/itemset.hxx>
namespace basctl
{
@@ -194,14 +195,20 @@ void LibBox::ReleaseFocus()
SfxViewShell* pCurSh = SfxViewShell::Current();
DBG_ASSERT(pCurSh, "Current ViewShell not found!");
- if (pCurSh)
- {
- vcl::Window* pShellWin = pCurSh->GetWindow();
- if (!pShellWin)
- pShellWin = Application::GetDefDialogParent();
+ if (!pCurSh)
+ return;
+ vcl::Window* pShellWin = pCurSh->GetWindow();
+ if (pShellWin)
+ {
pShellWin->GrabFocus();
+ return;
}
+
+ weld::Window* pWin = Application::GetDefDialogParent();
+ if (!pWin)
+ return;
+ pWin->grab_focus();
}
void LibBox::FillBox()
@@ -216,7 +223,7 @@ void LibBox::FillBox()
// create list box entries
LibEntry* pEntry = new LibEntry(ScriptDocument::getApplicationScriptDocument(),
LIBRARY_LOCATION_UNKNOWN, OUString());
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
+ OUString sId(weld::toId(pEntry));
m_xWidget->append(sId, IDEResId(RID_STR_ALL));
InsertEntries(ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER);
@@ -243,19 +250,14 @@ void LibBox::FillBox()
void LibBox::InsertEntries(const ScriptDocument& rDocument, LibraryLocation eLocation)
{
// get a sorted list of library names
- Sequence<OUString> aLibNames = rDocument.getLibraryNames();
- sal_Int32 nLibCount = aLibNames.getLength();
- const OUString* pLibNames = aLibNames.getConstArray();
-
- for (sal_Int32 i = 0; i < nLibCount; ++i)
+ for (auto& aLibName : rDocument.getLibraryNames())
{
- OUString aLibName = pLibNames[i];
if (eLocation == rDocument.getLibraryLocation(aLibName))
{
OUString aName(rDocument.getTitle(eLocation));
OUString aEntryText(CreateMgrAndLibStr(aName, aLibName));
LibEntry* pEntry = new LibEntry(rDocument, eLocation, aLibName);
- m_xWidget->append(OUString::number(reinterpret_cast<sal_Int64>(pEntry)), aEntryText);
+ m_xWidget->append(weld::toId(pEntry), aEntryText);
}
}
}
@@ -314,7 +316,7 @@ void LibBox::Select()
void LibBox::NotifyIDE()
{
- LibEntry* pEntry = reinterpret_cast<LibEntry*>(m_xWidget->get_active_id().toInt64());
+ LibEntry* pEntry = weld::fromId<LibEntry*>(m_xWidget->get_active_id());
if (pEntry)
{
const ScriptDocument& aDocument(pEntry->GetDocument());
@@ -334,7 +336,7 @@ void LibBox::ClearBox()
sal_Int32 nCount = m_xWidget->get_count();
for (sal_Int32 i = 0; i < nCount; ++i)
{
- LibEntry* pEntry = reinterpret_cast<LibEntry*>(m_xWidget->get_id(i).toInt64());
+ LibEntry* pEntry = weld::fromId<LibEntry*>(m_xWidget->get_id(i));
delete pEntry;
}
m_xWidget->clear();
@@ -421,20 +423,19 @@ void LanguageBox::FillBox()
Locale aDefaultLocale = pCurMgr->getStringResourceManager()->getDefaultLocale();
Locale aCurrentLocale = pCurMgr->getStringResourceManager()->getCurrentLocale();
Sequence<Locale> aLocaleSeq = pCurMgr->getStringResourceManager()->getLocales();
- const Locale* pLocale = aLocaleSeq.getConstArray();
sal_Int32 i, nCount = aLocaleSeq.getLength();
for (i = 0; i < nCount; ++i)
{
- bool bIsDefault = localesAreEqual(aDefaultLocale, pLocale[i]);
- bool bIsCurrent = localesAreEqual(aCurrentLocale, pLocale[i]);
- LanguageType eLangType = LanguageTag::convertToLanguageType(pLocale[i]);
+ bool bIsDefault = localesAreEqual(aDefaultLocale, aLocaleSeq[i]);
+ bool bIsCurrent = localesAreEqual(aCurrentLocale, aLocaleSeq[i]);
+ LanguageType eLangType = LanguageTag::convertToLanguageType(aLocaleSeq[i]);
OUString sLanguage = SvtLanguageTable::GetLanguageString(eLangType);
if (bIsDefault)
{
sLanguage += " " + msDefaultLanguageStr;
}
- LanguageEntry* pEntry = new LanguageEntry(pLocale[i], bIsDefault);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
+ LanguageEntry* pEntry = new LanguageEntry(aLocaleSeq[i], bIsDefault);
+ OUString sId(weld::toId(pEntry));
m_xWidget->append(sId, sLanguage);
if (bIsCurrent)
@@ -461,7 +462,7 @@ void LanguageBox::ClearBox()
sal_Int32 nCount = m_xWidget->get_count();
for (sal_Int32 i = 0; i < nCount; ++i)
{
- LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xWidget->get_id(i).toInt64());
+ LanguageEntry* pEntry = weld::fromId<LanguageEntry*>(m_xWidget->get_id(i));
delete pEntry;
}
m_xWidget->clear();
@@ -469,7 +470,7 @@ void LanguageBox::ClearBox()
void LanguageBox::SetLanguage()
{
- LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xWidget->get_active_id().toInt64());
+ LanguageEntry* pEntry = weld::fromId<LanguageEntry*>(m_xWidget->get_active_id());
if (pEntry)
GetShell()->GetCurLocalizationMgr()->handleSetCurrentLocale(pEntry->m_aLocale);
}
diff --git a/basctl/source/basicide/LineStatusControl.cxx b/basctl/source/basicide/LineStatusControl.cxx
new file mode 100644
index 000000000000..fd716b3901f7
--- /dev/null
+++ b/basctl/source/basicide/LineStatusControl.cxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <strings.hrc>
+#include <LineStatusControl.hxx>
+#include <svl/stritem.hxx>
+#include <vcl/status.hxx>
+#include <iderid.hxx>
+
+namespace basctl
+{
+SFX_IMPL_STATUSBAR_CONTROL(LineStatusControl, SfxStringItem);
+
+LineStatusControl::LineStatusControl(sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& rStb)
+ : SfxStatusBarControl(_nSlotId, _nId, rStb)
+{
+}
+
+LineStatusControl::~LineStatusControl() {}
+
+void LineStatusControl::StateChangedAtStatusBarControl(sal_uInt16 /*nSID*/, SfxItemState eState,
+ const SfxPoolItem* pState)
+{
+ if (eState == SfxItemState::DEFAULT)
+ {
+ // Can access pState
+ GetStatusBar().SetItemText(GetId(), static_cast<const SfxStringItem*>(pState)->GetValue());
+ GetStatusBar().SetQuickHelpText(GetId(), IDEResId(RID_LINE_STATUS_CONTROL));
+ }
+ else
+ {
+ GetStatusBar().SetItemText(GetId(), u""_ustr);
+ GetStatusBar().SetQuickHelpText(GetId(), u""_ustr);
+ }
+}
+
+} // namespace basctl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/ObjectCatalog.cxx b/basctl/source/basicide/ObjectCatalog.cxx
index 89b3f4e2b824..13069ed46621 100644
--- a/basctl/source/basicide/ObjectCatalog.cxx
+++ b/basctl/source/basicide/ObjectCatalog.cxx
@@ -67,7 +67,9 @@ void ObjectCatalog::ToggleFloatingMode()
DockingWindow::ToggleFloatingMode();
bool const bFloating = IsFloatingMode();
- m_xTitle->set_visible(!bFloating);
+ // tdf#152154: m_xTitle will be null during disposing
+ if (m_xTitle)
+ m_xTitle->set_visible(!bFloating);
}
void ObjectCatalog::SetCurrentEntry(BaseWindow* pCurWin)
diff --git a/basctl/source/basicide/basdoc.cxx b/basctl/source/basicide/basdoc.cxx
index 58c4097284e4..ffd22b9063c7 100644
--- a/basctl/source/basicide/basdoc.cxx
+++ b/basctl/source/basicide/basdoc.cxx
@@ -62,9 +62,9 @@ DocShell::~DocShell()
SfxPrinter* DocShell::GetPrinter( bool bCreate )
{
if ( !pPrinter && bCreate )
- pPrinter.disposeAndReset(VclPtr<SfxPrinter>::Create(std::make_unique<SfxItemSet>(
- GetPool(), svl::Items<SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN>{}
- )));
+ pPrinter.disposeAndReset(VclPtr<SfxPrinter>::Create(std::make_unique<SfxItemSetFixed
+ <SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN>>(GetPool())
+ ));
return pPrinter.get();
}
@@ -82,7 +82,7 @@ void DocShell::FillClass( SvGlobalName*, SotClipboardFormatId*, OUString*, sal_I
DBG_ASSERT( !bTemplate, "No template for Basic" );
}
-void DocShell::Draw( OutputDevice *, const JobSetup &, sal_uInt16 )
+void DocShell::Draw( OutputDevice *, const JobSetup &, sal_uInt16, bool )
{}
} // namespace basctl
diff --git a/basctl/source/basicide/basdoc.hxx b/basctl/source/basicide/basdoc.hxx
index d5b3aabcf961..bb847a0a9b1a 100644
--- a/basctl/source/basicide/basdoc.hxx
+++ b/basctl/source/basicide/basdoc.hxx
@@ -34,7 +34,7 @@ class DocShell: public SfxObjectShell
protected:
virtual void Draw( OutputDevice *, const JobSetup & rSetup,
- sal_uInt16 nAspect ) override;
+ sal_uInt16 nAspect, bool bOutputForScreen ) override;
virtual void FillClass( SvGlobalName * pClassName,
SotClipboardFormatId * pFormat,
OUString * pFullTypeName,
diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx
index 12bb90610877..648f234cbdb0 100644
--- a/basctl/source/basicide/basicrenderable.cxx
+++ b/basctl/source/basicide/basicrenderable.cxx
@@ -88,7 +88,7 @@ VclPtr< Printer > Renderable::getPrinter() const
if( aValue >>= xRenderDevice )
{
- VCLXDevice* pDevice = comphelper::getUnoTunnelImplementation<VCLXDevice>(xRenderDevice);
+ VCLXDevice* pDevice = dynamic_cast<VCLXDevice*>(xRenderDevice.get());
VclPtr< OutputDevice > pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >();
pPrinter = dynamic_cast<Printer*>(pOut.get());
}
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index ce654b998904..62bbaa799815 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -25,7 +25,9 @@
#include <iderdll.hxx>
#include <iderid.hxx>
#include "moduldlg.hxx"
+#include <sfx2/dispatch.hxx>
#include <docsignature.hxx>
+#include <colorscheme.hxx>
#include <officecfg/Office/BasicIDE.hxx>
#include <helpids.h>
@@ -38,13 +40,14 @@
#include <com/sun/star/script/ModuleType.hpp>
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
-#include <com/sun/star/ui/dialogs/FilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
#include <comphelper/SetFlagContextHelper.hxx>
#include <comphelper/string.hxx>
#include <svl/srchdefs.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/docfile.hxx>
+#include <sfx2/filedlghelper.hxx>
#include <sfx2/request.hxx>
#include <sfx2/viewfrm.hxx>
#include <sot/exchange.hxx>
@@ -55,6 +58,7 @@
#include <svl/whiter.hxx>
#include <svx/svxids.hrc>
#include <tools/debug.hxx>
+#include <utility>
#include <vcl/locktoplevels.hxx>
#include <vcl/errinf.hxx>
#include <vcl/event.hxx>
@@ -67,6 +71,7 @@
#include <cassert>
#include <osl/diagnose.h>
#include <officecfg/Office/Common.hxx>
+#include <BasicColorConfig.hxx>
namespace basctl
{
@@ -93,7 +98,7 @@ short const ValidWindow = 0x1234;
#if defined(OW) || defined(MTF)
char const FilterMask_All[] = "*";
#else
-constexpr OUStringLiteral FilterMask_All = u"*.*";
+constexpr OUString FilterMask_All = u"*.*"_ustr;
#endif
} // end anonymous namespace
@@ -181,7 +186,7 @@ void lcl_ConvertTabsToSpaces( OUString& rLine )
OUStringBuffer aBlanker;
string::padToLength(aBlanker, ( 4 - ( nPos % 4 ) ), ' ');
aResult.remove( nPos, 1 );
- aResult.insert( nPos, aBlanker.makeStringAndClear() );
+ aResult.insert( nPos, aBlanker );
nMax = aResult.getLength();
}
++nPos;
@@ -189,27 +194,19 @@ void lcl_ConvertTabsToSpaces( OUString& rLine )
rLine = aResult.makeStringAndClear();
}
-void DetectUTF8BOMCharset(SvStream& pStream)
-{
- sal_uInt8 pBuf[3];
- sal_Int32 nRead = pStream.ReadBytes(pBuf, 3);
- unsigned char const BOM[3] = { 0xEF, 0xBB, 0xBF };
- if (nRead == 3 && memcmp(pBuf, BOM, 3) == 0)
- pStream.SetStreamCharSet(RTL_TEXTENCODING_UTF8);
- else
- pStream.Seek(0);
-}
-
} // namespace
ModulWindow::ModulWindow (ModulWindowLayout* pParent, ScriptDocument const& rDocument,
- const OUString& aLibName, const OUString& aName, OUString const & aModule)
+ const OUString& aLibName, const OUString& aName, OUString aModule)
: BaseWindow(pParent, rDocument, aLibName, aName)
, m_rLayout(*pParent)
, m_nValid(ValidWindow)
, m_aXEditorWindow(VclPtr<ComplexEditorWindow>::Create(this))
- , m_aModule(aModule)
+ , m_aModule(std::move(aModule))
{
+ // Active editor color scheme
+ m_sWinColorScheme = GetShell()->GetColorConfig()->GetCurrentColorSchemeName();
+
m_aXEditorWindow->Show();
SetBackground();
}
@@ -264,9 +261,6 @@ void ModulWindow::GetFocus()
void ModulWindow::DoInit()
{
- if (GetVScrollBar())
- GetVScrollBar()->Hide();
- GetHScrollBar()->Show();
GetEditorWindow().InitScrollBars();
}
@@ -294,7 +288,7 @@ void ModulWindow::CheckCompileBasic()
bool bDone = false;
- GetShell()->GetViewFrame()->GetWindow().EnterWait();
+ GetShell()->GetViewFrame().GetWindow().EnterWait();
AssertValidEditEngine();
GetEditorWindow().SetSourceInBasic();
@@ -314,7 +308,7 @@ void ModulWindow::CheckCompileBasic()
GetBreakPoints().SetBreakPointsInBasic( m_xModule.get() );
}
- GetShell()->GetViewFrame()->GetWindow().LeaveWait();
+ GetShell()->GetViewFrame().GetWindow().LeaveWait();
m_aStatus.bError = !bDone;
m_aStatus.bIsRunning = false;
@@ -423,22 +417,20 @@ void ModulWindow::BasicStop()
void ModulWindow::LoadBasic()
{
- Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
- Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_SIMPLE);
-
- if ( !m_sCurPath.isEmpty() )
- xFP->setDisplayDirectory ( m_sCurPath );
+ sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
+ FileDialogFlags::NONE, this->GetFrameWeld());
+ aDlg.SetContext(sfx2::FileDialogHelper::BasicImportSource);
+ Reference<XFilePicker3> xFP = aDlg.GetFilePicker();
xFP->appendFilter( "BASIC" , "*.bas" );
xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All );
xFP->setCurrentFilter( "BASIC" );
- if( xFP->execute() != RET_OK )
+ if( aDlg.Execute() != ERRCODE_NONE )
return;
Sequence< OUString > aPaths = xFP->getSelectedFiles();
- m_sCurPath = aPaths[0];
- SfxMedium aMedium( m_sCurPath, StreamMode::READ | StreamMode::SHARE_DENYWRITE | StreamMode::NOCREATE );
+ SfxMedium aMedium( aPaths[0], StreamMode::READ | StreamMode::SHARE_DENYWRITE | StreamMode::NOCREATE );
SvStream* pStream = aMedium.GetInStream();
if ( pStream )
{
@@ -448,13 +440,15 @@ void ModulWindow::LoadBasic()
GetEditorWindow().CreateProgress( IDEResId(RID_STR_GENERATESOURCE), nLines*4 );
GetEditEngine()->SetUpdateMode( false );
// tdf#139196 - import macros using either default or utf-8 text encoding
- DetectUTF8BOMCharset(*pStream);
+ pStream->StartReadingUnicodeText(RTL_TEXTENCODING_UTF8);
+ if (pStream->Tell() == 3)
+ pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
GetEditView()->Read( *pStream );
GetEditEngine()->SetUpdateMode( true );
GetEditorWindow().PaintImmediately();
GetEditorWindow().ForceSyntaxTimeout();
GetEditorWindow().DestroyProgress();
- ErrCode nError = aMedium.GetError();
+ ErrCodeMsg nError = aMedium.GetErrorIgnoreWarning();
if ( nError )
ErrorHandler::HandleError( nError );
}
@@ -469,28 +463,22 @@ void ModulWindow::LoadBasic()
void ModulWindow::SaveBasicSource()
{
- Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
- Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD);
-
- Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
- xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false);
- Any aValue;
- aValue <<= true;
- xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
+ sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
+ FileDialogFlags::NONE, this->GetFrameWeld());
+ aDlg.SetContext(sfx2::FileDialogHelper::BasicExportSource);
+ const Reference<XFilePicker3>& xFP = aDlg.GetFilePicker();
- if ( !m_sCurPath.isEmpty() )
- xFP->setDisplayDirectory ( m_sCurPath );
+ xFP.queryThrow<XFilePickerControlAccess>()->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, Any(true));
xFP->appendFilter( "BASIC", "*.bas" );
xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All );
xFP->setCurrentFilter( "BASIC" );
- if( xFP->execute() != RET_OK )
+ if( aDlg.Execute() != ERRCODE_NONE )
return;
Sequence< OUString > aPaths = xFP->getSelectedFiles();
- m_sCurPath = aPaths[0];
- SfxMedium aMedium( m_sCurPath, StreamMode::WRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC );
+ SfxMedium aMedium( aPaths[0], StreamMode::WRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC );
SvStream* pStream = aMedium.GetOutStream();
if ( pStream )
{
@@ -502,7 +490,7 @@ void ModulWindow::SaveBasicSource()
GetEditEngine()->Write( *pStream );
aMedium.Commit();
LeaveWait();
- ErrCode nError = aMedium.GetError();
+ ErrCodeMsg nError = aMedium.GetErrorIgnoreWarning();
if ( nError )
ErrorHandler::HandleError( nError );
}
@@ -518,7 +506,7 @@ void ModulWindow::ImportDialog()
{
const ScriptDocument& rDocument = GetDocument();
OUString aLibName = GetLibName();
- implImportDialog(GetFrameWeld(), m_sCurPath, rDocument, aLibName);
+ implImportDialog(GetFrameWeld(), rDocument, aLibName);
}
void ModulWindow::ToggleBreakPoint( sal_uInt16 nLine )
@@ -626,7 +614,7 @@ void ModulWindow::ManageBreakPoints()
void ModulWindow::BasicErrorHdl( StarBASIC const * pBasic )
{
- GetShell()->GetViewFrame()->ToTop();
+ GetShell()->GetViewFrame().ToTop();
// Return value: BOOL
// FALSE: cancel
@@ -1040,12 +1028,15 @@ void ModulWindow::ExecuteCommand (SfxRequest& rReq)
break;
case SID_GOTOLINE:
{
- GotoLineDialog aGotoDlg(GetFrameWeld());
+ sal_uInt32 nCurLine = GetEditView()->GetSelection().GetStart().GetPara() + 1;
+ sal_uInt32 nLineCount = GetEditEngine()->GetParagraphCount();
+ GotoLineDialog aGotoDlg(GetFrameWeld(), nCurLine, nLineCount);
if (aGotoDlg.run() == RET_OK)
{
if (sal_Int32 const nLine = aGotoDlg.GetLineNumber())
{
TextSelection const aSel(TextPaM(nLine - 1, 0), TextPaM(nLine - 1, 0));
+ GrabFocus();
GetEditView()->SetSelection(aSel);
}
}
@@ -1069,6 +1060,18 @@ void ModulWindow::ExecuteGlobal (SfxRequest& rReq)
}
}
break;
+
+ case SID_BASICIDE_STAT_POS:
+ {
+ GetDispatcher()->Execute(SID_GOTOLINE);
+ }
+ break;
+
+ case SID_TOGGLE_COMMENT:
+ {
+ GetEditView()->ToggleComment();
+ }
+ break;
}
}
@@ -1144,6 +1147,9 @@ void ModulWindow::GetState( SfxItemSet &rSet )
if (!sProcName.isEmpty())
aTitle += "." + sProcName;
+ if (IsReadOnly())
+ aTitle += " (" + IDEResId(RID_STR_READONLY) + ")";
+
SfxStringItem aTitleItem( SID_BASICIDE_STAT_TITLE, aTitle );
rSet.Put( aTitleItem );
}
@@ -1175,7 +1181,7 @@ void ModulWindow::GetState( SfxItemSet &rSet )
}
}
-void ModulWindow::DoScroll( ScrollBar* pCurScrollBar )
+void ModulWindow::DoScroll( Scrollable* pCurScrollBar )
{
if ( ( pCurScrollBar == GetHScrollBar() ) && GetEditView() )
{
@@ -1392,12 +1398,7 @@ bool ModulWindow::IsPasteAllowed()
if ( xClipboard.is() )
{
- Reference< datatransfer::XTransferable > xTransf;
- {
- SolarMutexReleaser aReleaser;
- // get clipboard content
- xTransf = xClipboard->getContents();
- }
+ Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
if ( xTransf.is() )
{
datatransfer::DataFlavor aFlavor;
@@ -1416,7 +1417,7 @@ void ModulWindow::OnNewDocument ()
m_aXEditorWindow->SetLineNumberDisplay(bLineNumbers);
}
-char const* ModulWindow::GetHid () const
+OUString ModulWindow::GetHid () const
{
return HID_BASICIDE_MODULWINDOW;
}
@@ -1448,13 +1449,43 @@ void ModulWindow::UpdateModule ()
MarkDocumentModified(m_aDocument);
}
+void ModulWindow::SetEditorColorScheme(const OUString& rColorScheme)
+{
+ m_sWinColorScheme = rColorScheme;
+ EditorWindow& rEditWindow = GetEditorWindow();
+ Wallpaper aBackgroundColor(GetLayout().GetSyntaxBackgroundColor());
+ rEditWindow.SetBackground(aBackgroundColor);
+ rEditWindow.GetWindow(GetWindowType::Border)->SetBackground(aBackgroundColor);
+ rEditWindow.SetLineHighlightColor(GetShell()->GetColorConfig()->GetColorScheme(rColorScheme).m_aLineHighlightColor);
+
+ // The EditEngine is created only when the module is actually opened for the first time,
+ // therefore we need to check if it actually exists before updating its syntax highlighting
+ ExtTextEngine* pEditEngine = GetEditEngine();
+ if (pEditEngine)
+ rEditWindow.UpdateSyntaxHighlighting();
+}
+
ModulWindowLayout::ModulWindowLayout (vcl::Window* pParent, ObjectCatalog& rObjectCatalog_) :
Layout(pParent),
pChild(nullptr),
aWatchWindow(VclPtr<WatchWindow>::Create(this)),
aStackWindow(VclPtr<StackWindow>::Create(this)),
rObjectCatalog(rObjectCatalog_)
-{ }
+{
+ // Get active color scheme from the registry
+ m_sColorSchemeId = GetShell()->GetColorConfig()->GetCurrentColorSchemeName();
+ aSyntaxColors.ApplyColorScheme(m_sColorSchemeId, true);
+
+ // Initialize the visibility of the Stack Window
+ bool bStackVisible = ::officecfg::Office::BasicIDE::EditorSettings::StackWindow::get();
+ if (!bStackVisible)
+ aStackWindow->Show(bStackVisible);
+
+ // Initialize the visibility of the Watched Expressions window
+ bool bWatchVisible = ::officecfg::Office::BasicIDE::EditorSettings::WatchWindow::get();
+ if (!bWatchVisible)
+ aWatchWindow->Show(bWatchVisible);
+}
ModulWindowLayout::~ModulWindowLayout()
{
@@ -1491,6 +1522,7 @@ void ModulWindowLayout::Activating (BaseWindow& rChild)
rObjectCatalog.UpdateEntries();
Layout::Activating(rChild);
aSyntaxColors.SetActiveEditor(&pChild->GetEditorWindow());
+ aSyntaxColors.SetActiveColorSchemeId(m_sColorSchemeId);
}
void ModulWindowLayout::Deactivating ()
@@ -1527,6 +1559,18 @@ void ModulWindowLayout::BasicRemoveWatch ()
aWatchWindow->RemoveSelectedWatch();
}
+void ModulWindowLayout::ShowWatchWindow(bool bVisible)
+{
+ aWatchWindow->Show(bVisible);
+ ArrangeWindows();
+}
+
+void ModulWindowLayout::ShowStackWindow(bool bVisible)
+{
+ aStackWindow->Show(bVisible);
+ ArrangeWindows();
+}
+
void ModulWindowLayout::OnFirstSize (tools::Long const nWidth, tools::Long const nHeight)
{
AddToLeft(&rObjectCatalog, Size(nWidth * 0.20, nHeight * 0.75));
@@ -1534,12 +1578,19 @@ void ModulWindowLayout::OnFirstSize (tools::Long const nWidth, tools::Long const
AddToBottom(aStackWindow.get(), Size(nWidth * 0.33, nHeight * 0.25));
}
-ModulWindowLayout::SyntaxColors::SyntaxColors () :
- pEditor(nullptr)
+// Applies the color scheme to the current window and updates color definitions;
+// note that other ModulWindow instances are not affected by calling this method
+void ModulWindowLayout::ApplyColorSchemeToCurrentWindow(const OUString& rSchemeId)
{
- aConfig.AddListener(this);
+ // Apply new color scheme to the UI
+ m_sColorSchemeId = rSchemeId;
+ aSyntaxColors.ApplyColorScheme(m_sColorSchemeId, false);
+}
- NewConfig(true);
+ModulWindowLayout::SyntaxColors::SyntaxColors ()
+ : pEditor(nullptr)
+{
+ aConfig.AddListener(this);
}
ModulWindowLayout::SyntaxColors::~SyntaxColors ()
@@ -1550,62 +1601,88 @@ ModulWindowLayout::SyntaxColors::~SyntaxColors ()
// virtual
void ModulWindowLayout::SyntaxColors::ConfigurationChanged (utl::ConfigurationBroadcaster*, ConfigurationHints)
{
- NewConfig(false);
+ // The color scheme only needs to be applied when configuration changed if the "default" color
+ // scheme (based on Application Colors) is being used
+ if (m_sActiveSchemeId == DEFAULT_SCHEME)
+ ApplyColorScheme(DEFAULT_SCHEME, false);
}
-// when a new configuration has to be set
-void ModulWindowLayout::SyntaxColors::NewConfig (bool bFirst)
+// Applies an entire new color scheme; when bFirst is true, then the checks to see if the color scheme
+// has changed are ignored to make sure the color scheme is applied
+void ModulWindowLayout::SyntaxColors::ApplyColorScheme(OUString aSchemeId, bool bFirst)
{
- static struct
- {
- TokenType eTokenType;
- svtools::ColorConfigEntry eEntry;
- }
- const vIds[] =
+ const TokenType vTokenTypes[] =
{
- { TokenType::Unknown, svtools::FONTCOLOR },
- { TokenType::Identifier, svtools::BASICIDENTIFIER },
- { TokenType::Whitespace, svtools::FONTCOLOR },
- { TokenType::Number, svtools::BASICNUMBER },
- { TokenType::String, svtools::BASICSTRING },
- { TokenType::EOL, svtools::FONTCOLOR },
- { TokenType::Comment, svtools::BASICCOMMENT },
- { TokenType::Error, svtools::BASICERROR },
- { TokenType::Operator, svtools::BASICOPERATOR },
- { TokenType::Keywords, svtools::BASICKEYWORD },
+ TokenType::Unknown,
+ TokenType::Identifier,
+ TokenType::Whitespace,
+ TokenType::Number,
+ TokenType::String,
+ TokenType::EOL,
+ TokenType::Comment,
+ TokenType::Error,
+ TokenType::Operator,
+ TokenType::Keywords
};
- Color aDocColor = aConfig.GetColorValue(svtools::DOCCOLOR).nColor;
- if (bFirst || aDocColor != m_aBackgroundColor)
- {
- m_aBackgroundColor = aDocColor;
- if (!bFirst && pEditor)
- {
- pEditor->SetBackground(Wallpaper(m_aBackgroundColor));
- pEditor->Invalidate();
- }
- }
-
- Color aFontColor = aConfig.GetColorValue(svtools::FONTCOLOR).nColor;
- if (bFirst || aFontColor != m_aFontColor)
+ m_sActiveSchemeId = aSchemeId;
+ ColorScheme aColorScheme = GetShell()->GetColorConfig()->GetColorScheme(aSchemeId);
+ Color aFontColor = aColorScheme.m_aGenericFontColor;
+ m_aFontColor = aFontColor;
+ Color aDocColor = aColorScheme.m_aBackgroundColor;
+ m_aBackgroundColor = aDocColor;
+ if (!bFirst && pEditor)
{
- m_aFontColor = aFontColor;
- if (!bFirst && pEditor)
- pEditor->ChangeFontColor(m_aFontColor);
+ pEditor->ChangeFontColor(aFontColor);
+ pEditor->SetBackground(Wallpaper(aDocColor));
+ pEditor->SetLineHighlightColor(aColorScheme.m_aLineHighlightColor);
+ pEditor->Invalidate();
}
- bool bChanged = false;
- for (unsigned i = 0; i != SAL_N_ELEMENTS(vIds); ++i)
+ for (const auto& aToken: vTokenTypes)
{
- Color const aColor = aConfig.GetColorValue(vIds[i].eEntry).nColor;
- Color& rMyColor = aColors[vIds[i].eTokenType];
- if (bFirst || aColor != rMyColor)
+ // Retrieves the new color to be set from the color scheme
+ Color aNewColor;
+ switch (aToken)
{
- rMyColor = aColor;
- bChanged = true;
+ case TokenType::EOL:
+ case TokenType::Whitespace:
+ case TokenType::Unknown:
+ aNewColor = aColorScheme.m_aGenericFontColor;
+ break;
+ case TokenType::Identifier:
+ aNewColor = aColorScheme.m_aIdentifierColor;
+ break;
+ case TokenType::Number:
+ aNewColor = aColorScheme.m_aNumberColor;
+ break;
+ case TokenType::String:
+ aNewColor = aColorScheme.m_aStringColor;
+ break;
+ case TokenType::Comment:
+ aNewColor = aColorScheme.m_aCommentColor;
+ break;
+ case TokenType::Error:
+ aNewColor = aColorScheme.m_aErrorColor;
+ break;
+ case TokenType::Operator:
+ aNewColor = aColorScheme.m_aOperatorColor;
+ break;
+ case TokenType::Keywords:
+ aNewColor = aColorScheme.m_aKeywordColor;
+ break;
+ default:
+ SAL_WARN("basctl.basicide", "Unexpected token type for color scheme");
+ aNewColor = aColorScheme.m_aGenericFontColor;
}
+
+ Color& rCurrentColor = aColors[aToken];
+ rCurrentColor = aNewColor;
}
- if (bChanged && !bFirst && pEditor)
+
+ // This check is needed because the EditEngine will only exist in the EditorWindow when the
+ // module is actually opened
+ if (!bFirst && pEditor)
pEditor->UpdateSyntaxHighlighting();
}
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 06045356bccb..cd0485c46b4b 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -20,9 +20,11 @@
#pragma once
#include <memory>
+#include <mutex>
#include <layout.hxx>
#include "breakpoint.hxx"
#include "linenumberwindow.hxx"
+#include <colorscheme.hxx>
#include <basic/sbmod.hxx>
#include <basic/sbstar.hxx>
@@ -31,10 +33,12 @@
#include <vcl/weld.hxx>
#include <svtools/colorcfg.hxx>
+#include <svtools/scrolladaptor.hxx>
#include <o3tl/enumarray.hxx>
#include <rtl/ustrbuf.hxx>
#include <set>
+#include <map>
#include <string_view>
#include <vcl/textdata.hxx>
@@ -73,7 +77,7 @@ private:
ModulWindow& rModulWindow;
rtl::Reference< ChangesListener > listener_;
- osl::Mutex mutex_;
+ std::mutex mutex_;
css::uno::Reference< css::beans::XMultiPropertySet >
notifier_;
@@ -93,17 +97,23 @@ private:
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
- void ImpDoHighlight( sal_uLong nLineOff );
+ void ImpDoHighlight( sal_uInt32 nLineOff );
void ImplSetFont();
+ sal_uInt16 nCurrentZoomLevel;
bool bHighlighting;
bool bDoSyntaxHighlight;
bool bDelayHighlight;
- virtual css::uno::Reference< css::awt::XWindowPeer > GetComponentInterface(bool bCreate = true) override;
+ // Used to determine if the highlighted line has changed, which would require redrawing the highlight
+ sal_uInt32 m_nLastHighlightPara;
+
+ Color m_aLineHighlightColor;
+
+ virtual css::uno::Reference< css::awt::XVclWindowPeer > GetComponentInterface(bool bCreate = true) override;
CodeCompleteDataCache aCodeCompleteCache;
VclPtr<CodeCompleteWindow> pCodeCompleteWnd;
- OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number
+ OUString GetActualSubName( sal_uInt32 nLine ); // gets the actual subroutine name according to line number
void SetupAndShowCodeCompleteWnd(const std::vector< OUString >& aEntryVect, TextSelection aSel );
void HandleAutoCorrect();
void HandleAutoCloseParen();
@@ -122,9 +132,10 @@ private:
virtual void LoseFocus() override;
virtual void RequestHelp( const HelpEvent& rHEvt ) override;
- void DoSyntaxHighlight( sal_uLong nPara );
+ void DoSyntaxHighlight( sal_uInt32 nPara );
OUString GetWordAtCursor();
bool ImpCanModify();
+ void HighlightCurrentLine(vcl::RenderContext& rRenderContext);
public:
EditorWindow (vcl::Window* pParent, ModulWindow*);
@@ -137,8 +148,8 @@ public:
void CreateProgress( const OUString& rText, sal_uInt32 nRange );
void DestroyProgress();
- void ParagraphInsertedDeleted( sal_uLong nNewPara, bool bInserted );
- void DoDelayedSyntaxHighlight( sal_uLong nPara );
+ void ParagraphInsertedDeleted( sal_uInt32 nNewPara, bool bInserted );
+ void DoDelayedSyntaxHighlight( sal_uInt32 nPara );
void CreateEditEngine();
void SetScrollBarRanges();
@@ -151,8 +162,12 @@ public:
void ChangeFontColor( Color aColor );
void UpdateSyntaxHighlighting ();
+ void SetLineHighlightColor(Color aColor);
- bool GetProcedureName(OUString const & rLine, OUString& rProcType, OUString& rProcName) const;
+ void SetEditorZoomLevel(sal_uInt16 nNewZoomLevel);
+ sal_uInt16 GetCurrentZoom() { return nCurrentZoomLevel; }
+
+ bool GetProcedureName(std::u16string_view rLine, OUString& rProcType, OUString& rProcName) const;
FactoryFunction GetUITestFactory() const override;
};
@@ -252,12 +267,13 @@ private:
VclPtr<BreakPointWindow> aBrkWindow;
VclPtr<LineNumberWindow> aLineNumberWindow;
VclPtr<EditorWindow> aEdtWindow;
- VclPtr<ScrollBar> aEWVScrollBar;
+ VclPtr<ScrollAdaptor> aEWVScrollBar;
+ VclPtr<ScrollAdaptor> aEWHScrollBar;
virtual void DataChanged(DataChangedEvent const & rDCEvt) override;
virtual void Resize() override;
- DECL_LINK( ScrollHdl, ScrollBar*, void );
+ DECL_LINK(ScrollHdl, weld::Scrollbar&, void);
public:
explicit ComplexEditorWindow( ModulWindow* pParent );
@@ -266,7 +282,8 @@ public:
BreakPointWindow& GetBrkWindow() { return *aBrkWindow; }
LineNumberWindow& GetLineNumberWindow() { return *aLineNumberWindow; }
EditorWindow& GetEdtWindow() { return *aEdtWindow; }
- ScrollBar& GetEWVScrollBar() { return *aEWVScrollBar; }
+ ScrollAdaptor& GetEWVScrollBar() { return *aEWVScrollBar; }
+ ScrollAdaptor& GetEWHScrollBar() { return *aEWHScrollBar; }
void SetLineNumberDisplay(bool b);
};
@@ -281,8 +298,8 @@ private:
VclPtr<ComplexEditorWindow> m_aXEditorWindow;
BasicStatus m_aStatus;
SbModuleRef m_xModule;
- OUString m_sCurPath;
OUString m_aModule;
+ OUString m_sWinColorScheme;
void CheckCompileBasic();
void BasicExecute();
@@ -294,10 +311,10 @@ protected:
virtual void GetFocus() override;
virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
virtual void DoInit() override;
- virtual void DoScroll( ScrollBar* pCurScrollBar ) override;
+ virtual void DoScroll(Scrollable* pCurScrollBar) override;
public:
- ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, OUString const & aModule );
+ ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, OUString aModule );
virtual ~ModulWindow() override;
virtual void dispose() override;
@@ -360,7 +377,8 @@ public:
EditorWindow& GetEditorWindow() { return m_aXEditorWindow->GetEdtWindow(); }
BreakPointWindow& GetBreakPointWindow() { return m_aXEditorWindow->GetBrkWindow(); }
LineNumberWindow& GetLineNumberWindow() { return m_aXEditorWindow->GetLineNumberWindow(); }
- ScrollBar& GetEditVScrollBar() { return m_aXEditorWindow->GetEWVScrollBar(); }
+ ScrollAdaptor& GetEditVScrollBar() { return m_aXEditorWindow->GetEWVScrollBar(); }
+ ScrollAdaptor& GetEditHScrollBar() { return m_aXEditorWindow->GetEWHScrollBar(); }
ExtTextEngine* GetEditEngine() { return GetEditorWindow().GetEditEngine(); }
TextView* GetEditView() { return GetEditorWindow().GetEditView(); }
BreakPointList& GetBreakPoints() { return GetBreakPointWindow().GetBreakPoints(); }
@@ -379,11 +397,13 @@ public:
virtual void Deactivating () override;
virtual void OnNewDocument () override;
- virtual char const* GetHid () const override;
+ virtual OUString GetHid () const override;
virtual ItemType GetType () const override;
virtual bool HasActiveEditor () const override;
void UpdateModule ();
+ OUString GetEditorColorScheme() { return m_sWinColorScheme; }
+ void SetEditorColorScheme(const OUString& rColorScheme);
};
class ModulWindowLayout: public Layout
@@ -401,9 +421,15 @@ public:
public:
void BasicAddWatch (OUString const&);
void BasicRemoveWatch ();
+ void ShowWatchWindow(bool bVisible);
+ void ShowStackWindow(bool bVisible);
+ bool IsWatchWindowVisible() { return aWatchWindow->IsVisible(); }
+ bool IsStackWindowVisible() { return aStackWindow->IsVisible(); }
Color const & GetSyntaxBackgroundColor () const { return aSyntaxColors.GetBackgroundColor(); }
Color const & GetFontColor () const { return aSyntaxColors.GetFontColor(); }
Color const & GetSyntaxColor (TokenType eType) const { return aSyntaxColors.GetColor(eType); }
+ OUString GetActiveColorSchemeId() { return m_sColorSchemeId; }
+ void ApplyColorSchemeToCurrentWindow(const OUString& rSchemeId);
protected:
// Window:
@@ -418,6 +444,8 @@ private:
VclPtr<WatchWindow> aWatchWindow;
VclPtr<StackWindow> aStackWindow;
ObjectCatalog& rObjectCatalog;
+ // Active color scheme ID
+ OUString m_sColorSchemeId;
// SyntaxColors -- stores Basic syntax highlighting colors
class SyntaxColors : public utl::ConfigurationListener
@@ -427,25 +455,26 @@ private:
virtual ~SyntaxColors () override;
public:
void SetActiveEditor (EditorWindow* pEditor_) { pEditor = pEditor_; }
+ void SetActiveColorSchemeId(const OUString& rColorSchemeId) { m_sActiveSchemeId = rColorSchemeId; }
public:
Color const & GetBackgroundColor () const { return m_aBackgroundColor; };
Color const & GetFontColor () const { return m_aFontColor; }
Color const & GetColor(TokenType eType) const { return aColors[eType]; }
+ void ApplyColorScheme(OUString aSchemeId, bool bFirst);
private:
virtual void ConfigurationChanged (utl::ConfigurationBroadcaster*, ConfigurationHints) override;
- void NewConfig (bool bFirst);
private:
Color m_aBackgroundColor;
Color m_aFontColor;
+ OUString m_sActiveSchemeId;
// the color values (the indexes are TokenType, see comphelper/syntaxhighlight.hxx)
o3tl::enumarray<TokenType, Color> aColors;
// the configuration
svtools::ColorConfig aConfig;
// the active editor
VclPtr<EditorWindow> pEditor;
-
} aSyntaxColors;
};
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 3335424583a0..e5fd31d22a21 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -40,11 +40,14 @@
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/script/XLibraryContainer2.hpp>
#include <comphelper/string.hxx>
+#include <comphelper/diagnose_ex.hxx>
+#include <o3tl/string_view.hxx>
#include <officecfg/Office/Common.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/progress.hxx>
#include <sfx2/viewfrm.hxx>
#include <tools/debug.hxx>
+#include <utility>
#include <vcl/image.hxx>
#include <vcl/weld.hxx>
#include <vcl/weldutils.hxx>
@@ -66,6 +69,9 @@
#include <unotools/charclass.hxx>
#include "textwindowpeer.hxx"
#include "uiobject.hxx"
+#include <basegfx/utils/zoomtools.hxx>
+#include <svl/itemset.hxx>
+#include <BasicColorConfig.hxx>
namespace basctl
{
@@ -175,13 +181,13 @@ void lcl_SeparateNameAndIndex( const OUString& rVName, OUString& rVar, OUString&
{
sal_uInt16 nLastChar = rVar.getLength()-1;
if ( cSuffixes.find(rVar[ nLastChar ] ) != std::u16string_view::npos )
- rVar = rVar.replaceAt( nLastChar, 1, "" );
+ rVar = rVar.replaceAt( nLastChar, 1, u"" );
}
if ( !rIndex.isEmpty() )
{
sal_uInt16 nLastChar = rIndex.getLength()-1;
if ( cSuffixes.find(rIndex[ nLastChar ] ) != std::u16string_view::npos )
- rIndex = rIndex.replaceAt( nLastChar, 1, "" );
+ rIndex = rIndex.replaceAt( nLastChar, 1, u"" );
}
}
@@ -202,7 +208,7 @@ private:
virtual void SAL_CALL disposing(lang::EventObject const &) override
{
- osl::MutexGuard g(editor_.mutex_);
+ std::unique_lock g(editor_.mutex_);
editor_.notifier_.clear();
}
@@ -230,7 +236,7 @@ public:
}
private:
- sal_uLong nCurState;
+ sal_uInt32 nCurState;
};
EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) :
@@ -239,13 +245,18 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) :
nCurTextWidth(0),
m_nSetSourceInBasicId(nullptr),
aHighlighter(HighlighterLanguage::Basic),
+ aSyntaxIdle( "basctl EditorWindow aSyntaxIdle" ),
bHighlighting(false),
bDoSyntaxHighlight(true),
bDelayHighlight(true),
+ m_nLastHighlightPara(0),
pCodeCompleteWnd(VclPtr<CodeCompleteWindow>::Create(this))
{
set_id("EditorWindow");
- SetBackground(Wallpaper(rModulWindow.GetLayout().GetSyntaxBackgroundColor()));
+ const Wallpaper aBackground(rModulWindow.GetLayout().GetSyntaxBackgroundColor());
+ SetBackground(aBackground);
+ GetWindow(GetWindowType::Border)->SetBackground(aBackground);
+ SetLineHighlightColor(GetShell()->GetColorConfig()->GetCurrentColorScheme().m_aLineHighlightColor);
SetPointer( PointerStyle::Text );
SetHelpId( HID_BASICIDE_EDITORWINDOW );
@@ -254,9 +265,13 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) :
officecfg::Office::Common::Font::SourceViewFont::get(),
UNO_QUERY_THROW);
{
- osl::MutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
notifier_ = n;
}
+
+ // The zoom level applied to the editor window is the zoom slider value in the shell
+ nCurrentZoomLevel = GetShell()->GetCurrentZoomSliderValue();
+
const Sequence<OUString> aPropertyNames{"FontHeight", "FontName"};
n->addPropertiesChangeListener(aPropertyNames, listener_);
}
@@ -277,7 +292,7 @@ void EditorWindow::dispose()
Reference< beans::XMultiPropertySet > n;
{
- osl::MutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
n = notifier_;
}
if (n.is()) {
@@ -372,7 +387,7 @@ void EditorWindow::RequestHelp( const HelpEvent& rHEvt )
{
sal_uInt16 nLastChar = aWord.getLength() - 1;
if ( cSuffixes.find(aWord[ nLastChar ] ) != std::u16string_view::npos )
- aWord = aWord.replaceAt( nLastChar, 1, "" );
+ aWord = aWord.replaceAt( nLastChar, 1, u"" );
SbxBase* pSBX = StarBASIC::FindSBXInCurrentScope( aWord );
if (SbxVariable const* pVar = IsSbxVariable(pSBX))
{
@@ -401,8 +416,7 @@ void EditorWindow::RequestHelp( const HelpEvent& rHEvt )
Point aTopLeft = GetEditView()->GetWindowPos(aHelpRect.TopLeft());
aTopLeft = GetEditView()->GetWindow()->OutputToScreenPixel(aTopLeft);
- aHelpRect.setX(aTopLeft.X());
- aHelpRect.setY(aTopLeft.Y());
+ aHelpRect.SetPos(aTopLeft);
}
}
}
@@ -467,8 +481,9 @@ void EditorWindow::MouseButtonUp( const MouseEvent &rEvt )
void EditorWindow::MouseButtonDown( const MouseEvent &rEvt )
{
GrabFocus();
- if ( pEditView )
- pEditView->MouseButtonDown( rEvt );
+ if (!pEditView)
+ return;
+ pEditView->MouseButtonDown(rEvt);
if( pCodeCompleteWnd->IsVisible() )
{
if (pEditView->GetSelection() != pCodeCompleteWnd->GetTextSelection())
@@ -489,8 +504,25 @@ void EditorWindow::Command( const CommandEvent& rCEvt )
( rCEvt.GetCommand() == CommandEventId::StartAutoScroll ) ||
( rCEvt.GetCommand() == CommandEventId::AutoScroll ) )
{
- HandleScrollCommand( rCEvt, rModulWindow.GetHScrollBar(), &rModulWindow.GetEditVScrollBar() );
- } else if ( rCEvt.GetCommand() == CommandEventId::ContextMenu ) {
+ const CommandWheelData* pData = rCEvt.GetWheelData();
+
+ // Check if it is a Ctrl+Wheel zoom command
+ if (pData && pData->IsMod1())
+ {
+ const sal_uInt16 nOldZoom = GetCurrentZoom();
+ sal_uInt16 nNewZoom;
+ if( pData->GetDelta() < 0 )
+ nNewZoom = std::max<sal_uInt16>(basctl::Shell::GetMinZoom(),
+ basegfx::zoomtools::zoomOut(nOldZoom));
+ else
+ nNewZoom = std::min<sal_uInt16>(basctl::Shell::GetMaxZoom(),
+ basegfx::zoomtools::zoomIn(nOldZoom));
+ GetShell()->SetGlobalEditorZoomLevel(nNewZoom);
+ }
+ else
+ HandleScrollCommand(rCEvt, &rModulWindow.GetEditHScrollBar(), &rModulWindow.GetEditVScrollBar());
+ }
+ else if ( rCEvt.GetCommand() == CommandEventId::ContextMenu ) {
SfxDispatcher* pDispatcher = GetDispatcher();
if ( pDispatcher )
{
@@ -534,7 +566,11 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
if (pCodeCompleteWnd->IsVisible() && CodeCompleteOptions::IsCodeCompleteOn())
{
- if (pCodeCompleteWnd->HandleKeyInput(rKEvt))
+ pCodeCompleteWnd->HandleKeyInput(rKEvt);
+ if( rKEvt.GetKeyCode().GetCode() == KEY_UP
+ || rKEvt.GetKeyCode().GetCode() == KEY_DOWN
+ || rKEvt.GetKeyCode().GetCode() == KEY_TAB
+ || rKEvt.GetKeyCode().GetCode() == KEY_POINT)
return;
}
@@ -599,6 +635,13 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
pBindings->Update( SID_BASICIDE_STAT_POS );
pBindings->Update( SID_BASICIDE_STAT_TITLE );
}
+ if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_ALPHA ||
+ rKEvt.GetKeyCode().GetGroup() == KEYGROUP_NUM )
+ {
+ // If the module is read-only, warn that it can't be edited
+ if ( rModulWindow.IsReadOnly() )
+ rModulWindow.ShowReadOnlyInfoBar();
+ }
if ( !bWasModified && pEditEngine->IsModified() )
{
pBindings->Invalidate( SID_SAVEDOC );
@@ -689,6 +732,11 @@ void EditorWindow::HandleAutoCorrect()
}
}
+void EditorWindow::SetLineHighlightColor(Color aColor)
+{
+ m_aLineHighlightColor = aColor;
+}
+
TextSelection EditorWindow::GetLastHighlightPortionTextSelection() const
{//creates a text selection from the highlight portion on the cursor
const sal_uInt32 nLine = GetEditView()->GetSelection().GetStart().GetPara();
@@ -714,9 +762,9 @@ TextSelection EditorWindow::GetLastHighlightPortionTextSelection() const
if( aPortions.empty() )
return TextSelection();
- OUString sStr = aLine.copy( r.nBegin, r.nEnd - r.nBegin );
+ std::u16string_view sStr = aLine.subView( r.nBegin, r.nEnd - r.nBegin );
TextPaM aStart( nLine, r.nBegin );
- TextPaM aEnd( nLine, r.nBegin + sStr.getLength() );
+ TextPaM aEnd( nLine, r.nBegin + sStr.size() );
return TextSelection( aStart, aEnd );
}
@@ -792,17 +840,17 @@ void EditorWindow::HandleProcedureCompletion()
if( aCurrPortions.size() >= 3 )
{//at least 3 tokens: (sub|function) whitespace identifier...
HighlightPortion& r = aCurrPortions.front();
- OUString sStr = aCurrLine.copy(r.nBegin, r.nEnd - r.nBegin);
+ std::u16string_view sStr = aCurrLine.subView(r.nBegin, r.nEnd - r.nBegin);
if( r.tokenType == TokenType::Keywords )
{
- if( sStr.equalsIgnoreAsciiCase("sub") || sStr.equalsIgnoreAsciiCase("function") )
+ if( o3tl::equalsIgnoreAsciiCase(sStr, u"sub") || o3tl::equalsIgnoreAsciiCase(sStr, u"function") )
{
pEditView->InsertText( sText );//append to the end
GetEditView()->SetSelection(aSel);
break;
}
- if( sStr.equalsIgnoreAsciiCase("end") )
+ if( o3tl::equalsIgnoreAsciiCase(sStr, u"end") )
break;
}
}
@@ -810,7 +858,7 @@ void EditorWindow::HandleProcedureCompletion()
}
}
-bool EditorWindow::GetProcedureName(OUString const & rLine, OUString& rProcType, OUString& rProcName) const
+bool EditorWindow::GetProcedureName(std::u16string_view rLine, OUString& rProcType, OUString& rProcName) const
{
std::vector<HighlightPortion> aPortions;
aHighlighter.getHighlightPortions(rLine, aPortions);
@@ -823,10 +871,10 @@ bool EditorWindow::GetProcedureName(OUString const & rLine, OUString& rProcType,
for (auto const& portion : aPortions)
{
- OUString sTokStr = rLine.copy(portion.nBegin, portion.nEnd - portion.nBegin);
+ std::u16string_view sTokStr = rLine.substr(portion.nBegin, portion.nEnd - portion.nBegin);
- if( portion.tokenType == TokenType::Keywords && ( sTokStr.equalsIgnoreAsciiCase("sub")
- || sTokStr.equalsIgnoreAsciiCase("function")) )
+ if( portion.tokenType == TokenType::Keywords && ( o3tl::equalsIgnoreAsciiCase(sTokStr, u"sub")
+ || o3tl::equalsIgnoreAsciiCase(sTokStr, u"function")) )
{
rProcType = sTokStr;
bFoundType = true;
@@ -936,9 +984,34 @@ void EditorWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan
if (!pEditEngine) // We need it now at latest
CreateEditEngine();
+ HighlightCurrentLine(rRenderContext);
+
pEditView->Paint(rRenderContext, rRect);
}
+void EditorWindow::HighlightCurrentLine(vcl::RenderContext& rRenderContext)
+{
+ // If the cursor is in a single line and nothing is selected, then a highlight color
+ // is applied to the background of the current line
+ TextPaM aStartPaM = pEditView->GetSelection().GetStart();
+ TextPaM aEndPaM = pEditView->GetSelection().GetEnd();
+ if (aStartPaM == aEndPaM)
+ {
+ Size aWinSize(GetOutputSizePixel());
+ sal_Int16 nDocPosY = pEditView->GetStartDocPos().Y();
+ sal_Int16 nY1 = pEditEngine->PaMtoEditCursor(aStartPaM).TopLeft().Y();
+ sal_Int16 nY2 = pEditEngine->PaMtoEditCursor(aStartPaM).BottomRight().Y();
+ // Only draw if the cursor is in a visible position
+ if ((nY1 >= nDocPosY && nY1 <= nDocPosY + aWinSize.Height())
+ || (nY2 >= nDocPosY && nY2 <= nDocPosY + aWinSize.Height()))
+ {
+ tools::Rectangle aRect(Point(0, nY1 - nDocPosY), Point(aWinSize.Width(), nY2 - nDocPosY));
+ rRenderContext.SetFillColor(m_aLineHighlightColor);
+ rRenderContext.DrawRect(aRect);
+ }
+ }
+}
+
void EditorWindow::LoseFocus()
{
// tdf#114258 wait until the next event loop cycle to do this so it doesn't
@@ -970,20 +1043,14 @@ void EditorWindow::SetSourceInBasic()
// 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 OUString& rStr, sal_Int32 fromIndex )
+sal_Int32 searchEOL( std::u16string_view rStr, sal_Int32 fromIndex )
{
- sal_Int32 iRetPos = -1;
+ size_t iLF = rStr.find( LINE_SEP, fromIndex );
+ if( iLF != std::u16string_view::npos )
+ return iLF;
- sal_Int32 iLF = rStr.indexOf( LINE_SEP, fromIndex );
- if( iLF != -1 )
- {
- iRetPos = iLF;
- }
- else
- {
- iRetPos = rStr.indexOf( LINE_SEP_CR, fromIndex );
- }
- return iRetPos;
+ size_t iCR = rStr.find( LINE_SEP_CR, fromIndex );
+ return iCR == std::u16string_view::npos ? -1 : iCR;
}
void EditorWindow::CreateEditEngine()
@@ -1000,7 +1067,6 @@ void EditorWindow::CreateEditEngine()
ImplSetFont();
aSyntaxIdle.SetInvokeHandler( LINK( this, EditorWindow, SyntaxTimerHdl ) );
- aSyntaxIdle.SetDebugName( "basctl EditorWindow aSyntaxIdle" );
bool bWasDoSyntaxHighlight = bDoSyntaxHighlight;
bDoSyntaxHighlight = false; // too slow for large texts...
@@ -1017,7 +1083,7 @@ void EditorWindow::CreateEditEngine()
// nLines*4: SetText+Formatting+DoHighlight+Formatting
// it could be cut down on one formatting but you would wait even longer
// for the text then if the source code is long...
- pProgress.reset(new ProgressInfo(GetShell()->GetViewFrame()->GetObjectShell(),
+ pProgress.reset(new ProgressInfo(GetShell()->GetViewFrame().GetObjectShell(),
IDEResId(RID_STR_GENERATESOURCE),
nLines * 4));
setTextEngineText(*pEditEngine, aOUSource);
@@ -1079,9 +1145,8 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
TextHint const& rTextHint = *pTextHint;
if( rTextHint.GetId() == SfxHintId::TextViewScrolled )
{
- if ( rModulWindow.GetHScrollBar() )
- rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
rModulWindow.GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() );
+ rModulWindow.GetEditHScrollBar().SetThumbPos( pEditView->GetStartDocPos().X() );
rModulWindow.GetBreakPointWindow().DoScroll
( rModulWindow.GetBreakPointWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() );
rModulWindow.GetLineNumberWindow().DoScroll
@@ -1103,15 +1168,13 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
}
else if( rTextHint.GetId() == SfxHintId::TextFormatted )
{
- if ( rModulWindow.GetHScrollBar() )
+
+ const tools::Long nWidth = pEditEngine->CalcTextWidth();
+ if ( nWidth != nCurTextWidth )
{
- const tools::Long nWidth = pEditEngine->CalcTextWidth();
- if ( nWidth != nCurTextWidth )
- {
- nCurTextWidth = nWidth;
- rModulWindow.GetHScrollBar()->SetRange( Range( 0, nCurTextWidth-1) );
- rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
- }
+ nCurTextWidth = nWidth;
+ rModulWindow.GetEditHScrollBar().SetRange( Range( 0, nCurTextWidth-1) );
+ rModulWindow.GetEditHScrollBar().SetThumbPos( pEditView->GetStartDocPos().X() );
}
tools::Long nPrevTextWidth = nCurTextWidth;
nCurTextWidth = pEditEngine->CalcTextWidth();
@@ -1139,9 +1202,27 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
pBindings->Invalidate( SID_COPY );
}
}
+ else if( rTextHint.GetId() == SfxHintId::TextViewCaretChanged )
+ {
+ // Check whether the line number where the caret is has changed and the
+ // highlight needs to be redrawn
+ sal_uInt32 nStartPara = pEditView->GetSelection().GetStart().GetPara();
+ sal_uInt32 nEndPara = pEditView->GetSelection().GetEnd().GetPara();
+ if (nStartPara == nEndPara && nStartPara != m_nLastHighlightPara)
+ {
+ m_nLastHighlightPara = nStartPara;
+ Invalidate();
+ rModulWindow.GetLineNumberWindow().Invalidate();
+ }
+ else if (nStartPara != nEndPara)
+ {
+ // If multiple lines are selected, then update the line number window
+ rModulWindow.GetLineNumberWindow().Invalidate();
+ }
+ }
}
-OUString EditorWindow::GetActualSubName( sal_uLong nLine )
+OUString EditorWindow::GetActualSubName( sal_uInt32 nLine )
{
SbxArrayRef pMethods = rModulWindow.GetSbModule()->GetMethods();
for (sal_uInt32 i = 0; i < pMethods->Count(); i++)
@@ -1166,10 +1247,8 @@ void EditorWindow::SetScrollBarRanges()
if ( !pEditEngine )
return;
- if ( rModulWindow.GetHScrollBar() )
- rModulWindow.GetHScrollBar()->SetRange( Range( 0, nCurTextWidth-1 ) );
-
rModulWindow.GetEditVScrollBar().SetRange( Range( 0, pEditEngine->GetTextHeight()-1 ) );
+ rModulWindow.GetEditHScrollBar().SetRange( Range( 0, nCurTextWidth-1 ) );
}
void EditorWindow::InitScrollBars()
@@ -1185,17 +1264,14 @@ void EditorWindow::InitScrollBars()
rModulWindow.GetEditVScrollBar().SetThumbPos(pEditView->GetStartDocPos().Y());
rModulWindow.GetEditVScrollBar().Show();
- if (rModulWindow.GetHScrollBar())
- {
- rModulWindow.GetHScrollBar()->SetVisibleSize(aOutSz.Width());
- rModulWindow.GetHScrollBar()->SetPageSize(aOutSz.Width() * 8 / 10);
- rModulWindow.GetHScrollBar()->SetLineSize(GetTextWidth( "x" ) );
- rModulWindow.GetHScrollBar()->SetThumbPos(pEditView->GetStartDocPos().X());
- rModulWindow.GetHScrollBar()->Show();
- }
+ rModulWindow.GetEditHScrollBar().SetVisibleSize(aOutSz.Width());
+ rModulWindow.GetEditHScrollBar().SetPageSize(aOutSz.Width() * 8 / 10);
+ rModulWindow.GetEditHScrollBar().SetLineSize(GetTextWidth( "x" ));
+ rModulWindow.GetEditHScrollBar().SetThumbPos(pEditView->GetStartDocPos().X());
+ rModulWindow.GetEditHScrollBar().Show();
}
-void EditorWindow::ImpDoHighlight( sal_uLong nLine )
+void EditorWindow::ImpDoHighlight( sal_uInt32 nLine )
{
if ( !bDoSyntaxHighlight )
return;
@@ -1227,13 +1303,17 @@ void EditorWindow::ChangeFontColor( Color aColor )
void EditorWindow::UpdateSyntaxHighlighting ()
{
- const sal_uInt32 nCount = pEditEngine->GetParagraphCount();
- for (sal_uInt32 i = 0; i < nCount; ++i)
- DoDelayedSyntaxHighlight(i);
+ if (pEditEngine)
+ {
+ const sal_uInt32 nCount = pEditEngine->GetParagraphCount();
+ for (sal_uInt32 i = 0; i < nCount; ++i)
+ DoDelayedSyntaxHighlight(i);
+ }
}
void EditorWindow::ImplSetFont()
{
+ // Get default font name and height defined in the Options dialog
OUString sFontName(officecfg::Office::Common::Font::SourceViewFont::FontName::get().value_or(OUString()));
if (sFontName.isEmpty())
{
@@ -1242,7 +1322,12 @@ void EditorWindow::ImplSetFont()
GetDefaultFontFlags::NONE, GetOutDev()));
sFontName = aTmpFont.GetFamilyName();
}
- Size aFontSize(0, officecfg::Office::Common::Font::SourceViewFont::FontHeight::get());
+ sal_uInt16 nDefaultFontHeight = officecfg::Office::Common::Font::SourceViewFont::FontHeight::get();
+
+ // Calculate font size considering zoom level
+ sal_uInt16 nNewFontHeight = nDefaultFontHeight * (static_cast<float>(nCurrentZoomLevel) / 100);
+ Size aFontSize(0, nNewFontHeight);
+
vcl::Font aFont(sFontName, aFontSize);
aFont.SetColor(rModulWindow.GetLayout().GetFontColor());
SetPointFont(*GetOutDev(), aFont); // FIXME RenderContext
@@ -1250,6 +1335,7 @@ void EditorWindow::ImplSetFont()
rModulWindow.GetBreakPointWindow().SetFont(aFont);
rModulWindow.GetLineNumberWindow().SetFont(aFont);
+ rModulWindow.Invalidate();
if (pEditEngine)
{
@@ -1257,9 +1343,28 @@ void EditorWindow::ImplSetFont()
pEditEngine->SetFont(aFont);
pEditEngine->SetModified(bModified);
}
+
+ // Update controls
+ if (SfxBindings* pBindings = GetBindingsPtr())
+ {
+ pBindings->Invalidate( SID_BASICIDE_CURRENT_ZOOM );
+ pBindings->Invalidate( SID_ATTR_ZOOMSLIDER );
+ }
+}
+
+void EditorWindow::SetEditorZoomLevel(sal_uInt16 nNewZoomLevel)
+{
+ if (nCurrentZoomLevel == nNewZoomLevel)
+ return;
+
+ if (nNewZoomLevel < MIN_ZOOM_LEVEL || nNewZoomLevel > MAX_ZOOM_LEVEL)
+ return;
+
+ nCurrentZoomLevel = nNewZoomLevel;
+ ImplSetFont();
}
-void EditorWindow::DoSyntaxHighlight( sal_uLong nPara )
+void EditorWindow::DoSyntaxHighlight( sal_uInt32 nPara )
{
// because of the DelayedSyntaxHighlight it's possible
// that this line does not exist anymore!
@@ -1272,7 +1377,7 @@ void EditorWindow::DoSyntaxHighlight( sal_uLong nPara )
}
}
-void EditorWindow::DoDelayedSyntaxHighlight( sal_uLong nPara )
+void EditorWindow::DoDelayedSyntaxHighlight( sal_uInt32 nPara )
{
// line is only added to list, processed in TimerHdl
// => don't manipulate breaks while EditEngine is formatting
@@ -1314,7 +1419,7 @@ IMPL_LINK_NOARG(EditorWindow, SyntaxTimerHdl, Timer *, void)
bHighlighting = false;
}
-void EditorWindow::ParagraphInsertedDeleted( sal_uLong nPara, bool bInserted )
+void EditorWindow::ParagraphInsertedDeleted( sal_uInt32 nPara, bool bInserted )
{
if ( pProgress )
pProgress->StepProgress();
@@ -1347,7 +1452,7 @@ void EditorWindow::CreateProgress( const OUString& rText, sal_uInt32 nRange )
{
DBG_ASSERT( !pProgress, "ProgressInfo exists already" );
pProgress.reset(new ProgressInfo(
- GetShell()->GetViewFrame()->GetObjectShell(),
+ GetShell()->GetViewFrame().GetObjectShell(),
rText,
nRange
));
@@ -1420,7 +1525,7 @@ void BreakPointWindow::ShowMarker(vcl::RenderContext& rRenderContext)
Size const aOutSz = GetOutDev()->GetOutputSize();
tools::Long const nLineHeight = GetTextHeight();
- Image aMarker = GetImage(OUString(bErrorMarker ? std::u16string_view(u"" RID_BMP_ERRORMARKER) : std::u16string_view(u"" RID_BMP_STEPMARKER)));
+ Image aMarker = GetImage(bErrorMarker ? RID_BMP_ERRORMARKER : RID_BMP_STEPMARKER);
Size aMarkerSz(aMarker.GetSizePixel());
aMarkerSz = rRenderContext.PixelToLogic(aMarkerSz);
@@ -1428,7 +1533,7 @@ void BreakPointWindow::ShowMarker(vcl::RenderContext& rRenderContext)
aMarkerOff.setX( (aOutSz.Width() - aMarkerSz.Width()) / 2 );
aMarkerOff.setY( (nLineHeight - aMarkerSz.Height()) / 2 );
- sal_uLong nY = nMarkerPos * nLineHeight - nCurYOffset;
+ tools::Long nY = nMarkerPos * nLineHeight - nCurYOffset;
Point aPos(0, nY);
aPos += aMarkerOff;
@@ -1483,7 +1588,7 @@ void BreakPointWindow::MouseButtonDown( const MouseEvent& rMEvt )
{
tools::Long nYPos = aMousePos.Y() + nCurYOffset;
tools::Long nLine = nYPos / nLineHeight + 1;
- rModulWindow.ToggleBreakPoint( static_cast<sal_uLong>(nLine) );
+ rModulWindow.ToggleBreakPoint( static_cast<sal_uInt16>(nLine) );
Invalidate();
}
}
@@ -1507,7 +1612,7 @@ void BreakPointWindow::Command( const CommandEvent& rCEvt )
// test if break point is enabled...
std::unique_ptr<weld::Menu> xBrkPropMenu = xUIBuilder->weld_menu("breakmenu");
xBrkPropMenu->set_active("active", pBrk->bEnabled);
- OString sCommand = xBrkPropMenu->popup_at_rect(pPopupParent, aRect);
+ OUString sCommand = xBrkPropMenu->popup_at_rect(pPopupParent, aRect);
if (sCommand == "active")
{
pBrk->bEnabled = !pBrk->bEnabled;
@@ -1525,7 +1630,7 @@ void BreakPointWindow::Command( const CommandEvent& rCEvt )
else
{
std::unique_ptr<weld::Menu> xBrkListMenu = xUIBuilder->weld_menu("breaklistmenu");
- OString sCommand = xBrkListMenu->popup_at_rect(pPopupParent, aRect);
+ OUString sCommand = xBrkListMenu->popup_at_rect(pPopupParent, aRect);
if (sCommand == "manage")
{
BreakPointDialog aBrkDlg(pPopupParent, GetBreakPoints());
@@ -1589,8 +1694,8 @@ struct WatchItem
WatchItem* mpArrayParentItem;
- explicit WatchItem (OUString const& rName):
- maName(rName),
+ explicit WatchItem (OUString aName):
+ maName(std::move(aName)),
nDimLevel(0),
nDimCount(0),
mpArrayParentItem(nullptr)
@@ -1669,7 +1774,7 @@ void WatchWindow::dispose()
// Destroy user data
m_xTreeListBox->all_foreach([this](weld::TreeIter& rEntry){
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rEntry));
delete pItem;
return false;
});
@@ -1730,7 +1835,7 @@ void WatchWindow::AddWatch( const OUString& rVName )
lcl_SeparateNameAndIndex( rVName, aVar, aIndex );
WatchItem* pWatchItem = new WatchItem(aVar);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pWatchItem)));
+ OUString sId(weld::toId(pWatchItem));
std::unique_ptr<weld::TreeIter> xRet = m_xTreeListBox->make_iterator();
m_xTreeListBox->insert(nullptr, -1, &aVar, &sId, nullptr, nullptr, false, xRet.get());
m_xTreeListBox->set_text(*xRet, "", 1);
@@ -1753,7 +1858,7 @@ void WatchWindow::RemoveSelectedWatch()
m_xTreeListBox->remove(*xEntry);
bEntry = m_xTreeListBox->get_cursor(xEntry.get());
if (bEntry)
- m_xEdit->set_text(reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(*xEntry).toInt64())->maName);
+ m_xEdit->set_text(weld::fromId<WatchItem*>(m_xTreeListBox->get_id(*xEntry))->maName);
else
m_xEdit->set_text(OUString());
if ( !m_xTreeListBox->n_children() )
@@ -1773,7 +1878,7 @@ IMPL_LINK_NOARG(WatchWindow, TreeListHdl, weld::TreeView&, void)
bool bCurEntry = m_xTreeListBox->get_cursor(xCurEntry.get());
if (!bCurEntry)
return;
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(*xCurEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(*xCurEntry));
if (!pItem)
return;
m_xEdit->set_text(pItem->maName);
@@ -1942,8 +2047,13 @@ ComplexEditorWindow::ComplexEditorWindow( ModulWindow* pParent ) :
aBrkWindow(VclPtr<BreakPointWindow>::Create(this, pParent)),
aLineNumberWindow(VclPtr<LineNumberWindow>::Create(this, pParent)),
aEdtWindow(VclPtr<EditorWindow>::Create(this, pParent)),
- aEWVScrollBar( VclPtr<ScrollBar>::Create(this, WB_VSCROLL | WB_DRAG) )
+ aEWVScrollBar(VclPtr<ScrollAdaptor>::Create(this, false)),
+ aEWHScrollBar(VclPtr<ScrollAdaptor>::Create(this, true))
{
+ // tdf#153853 The line numbering and breakpoint windows should appear on
+ // the left, even on RTL locales
+ EnableRTL(false);
+
aEdtWindow->Show();
aBrkWindow->Show();
@@ -1951,6 +2061,11 @@ ComplexEditorWindow::ComplexEditorWindow( ModulWindow* pParent ) :
aEWVScrollBar->SetPageSize(nScrollPage);
aEWVScrollBar->SetScrollHdl( LINK( this, ComplexEditorWindow, ScrollHdl ) );
aEWVScrollBar->Show();
+
+ aEWHScrollBar->SetLineSize(nScrollLine);
+ aEWHScrollBar->SetPageSize(nScrollPage);
+ aEWHScrollBar->SetScrollHdl( LINK( this, ComplexEditorWindow, ScrollHdl ) );
+ aEWHScrollBar->Show();
}
ComplexEditorWindow::~ComplexEditorWindow()
@@ -1964,6 +2079,7 @@ void ComplexEditorWindow::dispose()
aLineNumberWindow.disposeAndClear();
aEdtWindow.disposeAndClear();
aEWVScrollBar.disposeAndClear();
+ aEWHScrollBar.disposeAndClear();
vcl::Window::dispose();
}
@@ -1975,39 +2091,42 @@ void ComplexEditorWindow::Resize()
aSz.AdjustHeight( -(2*DWBORDER) );
tools::Long nBrkWidth = 20;
tools::Long nSBWidth = aEWVScrollBar->GetSizePixel().Width();
+ tools::Long nSBHeight = aEWHScrollBar->GetSizePixel().Height();
- Size aBrkSz(nBrkWidth, aSz.Height());
-
- Size aLnSz(aLineNumberWindow->GetWidth(), aSz.Height());
+ Size aBrkSz(nBrkWidth, aSz.Height() - nSBHeight);
if (aLineNumberWindow->IsVisible())
{
- aBrkWindow->SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz );
- aLineNumberWindow->SetPosSizePixel(Point(DWBORDER + aBrkSz.Width() - 1, DWBORDER), aLnSz);
- Size aEWSz(aSz.Width() - nBrkWidth - aLineNumberWindow->GetWidth() - nSBWidth + 2, aSz.Height());
- aEdtWindow->SetPosSizePixel( Point( DWBORDER + aBrkSz.Width() + aLnSz.Width() - 1, DWBORDER ), aEWSz );
+ Size aLnSz(aLineNumberWindow->GetWidth(), aSz.Height() - nSBHeight);
+ Size aEWSz(aSz.Width() - nBrkWidth - aLineNumberWindow->GetWidth() - nSBWidth, aSz.Height() - nSBHeight);
+ aBrkWindow->SetPosSizePixel(Point(DWBORDER, DWBORDER), aBrkSz);
+ aLineNumberWindow->SetPosSizePixel(Point(DWBORDER + nBrkWidth, DWBORDER), aLnSz);
+ aEdtWindow->SetPosSizePixel(Point(DWBORDER + nBrkWidth + aLnSz.Width(), DWBORDER), aEWSz);
}
else
{
+ Size aEWSz(aSz.Width() - nBrkWidth - nSBWidth, aSz.Height() - nSBHeight);
aBrkWindow->SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz );
- Size aEWSz(aSz.Width() - nBrkWidth - nSBWidth + 2, aSz.Height());
- aEdtWindow->SetPosSizePixel(Point(DWBORDER + aBrkSz.Width() - 1, DWBORDER), aEWSz);
+ aEdtWindow->SetPosSizePixel(Point(DWBORDER + nBrkWidth, DWBORDER), aEWSz);
}
- aEWVScrollBar->SetPosSizePixel( Point( aOutSz.Width() - DWBORDER - nSBWidth, DWBORDER ), Size( nSBWidth, aSz.Height() ) );
+ aEWVScrollBar->SetPosSizePixel(Point(aOutSz.Width() - DWBORDER - nSBWidth, DWBORDER),
+ Size(nSBWidth, aSz.Height() - nSBHeight));
+ aEWHScrollBar->SetPosSizePixel(Point(DWBORDER, aOutSz.Height() - DWBORDER - nSBHeight),
+ Size(aSz.Width() - nSBWidth, nSBHeight));
}
-IMPL_LINK(ComplexEditorWindow, ScrollHdl, ScrollBar *, pCurScrollBar, void )
+IMPL_LINK_NOARG(ComplexEditorWindow, ScrollHdl, weld::Scrollbar&, void)
{
if (aEdtWindow->GetEditView())
{
- DBG_ASSERT( pCurScrollBar == aEWVScrollBar.get(), "Who is scrolling?" );
- tools::Long nDiff = aEdtWindow->GetEditView()->GetStartDocPos().Y() - pCurScrollBar->GetThumbPos();
- aEdtWindow->GetEditView()->Scroll( 0, nDiff );
- aBrkWindow->DoScroll( nDiff );
- aLineNumberWindow->DoScroll( nDiff );
+ tools::Long nXDiff = aEdtWindow->GetEditView()->GetStartDocPos().X() - aEWHScrollBar->GetThumbPos();
+ tools::Long nYDiff = aEdtWindow->GetEditView()->GetStartDocPos().Y() - aEWVScrollBar->GetThumbPos();
+ aEdtWindow->GetEditView()->Scroll(nXDiff, nYDiff);
+ aBrkWindow->DoScroll( nYDiff );
+ aLineNumberWindow->DoScroll( nYDiff );
aEdtWindow->GetEditView()->ShowCursor(false);
- pCurScrollBar->SetThumbPos( aEdtWindow->GetEditView()->GetStartDocPos().Y() );
+ aEWVScrollBar->SetThumbPos( aEdtWindow->GetEditView()->GetStartDocPos().Y() );
}
}
@@ -2033,10 +2152,10 @@ void ComplexEditorWindow::SetLineNumberDisplay(bool b)
Resize();
}
-uno::Reference< awt::XWindowPeer >
+uno::Reference< awt::XVclWindowPeer >
EditorWindow::GetComponentInterface(bool bCreate)
{
- uno::Reference< awt::XWindowPeer > xPeer(
+ uno::Reference< awt::XVclWindowPeer > xPeer(
Window::GetComponentInterface(false));
if (!xPeer.is() && bCreate)
{
@@ -2070,7 +2189,7 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo
if (m_xTreeListBox->iter_has_child(rParent))
return true;
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rParent).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rParent));
std::unique_ptr<weld::TreeIter> xRet = m_xTreeListBox->make_iterator();
SbxDimArray* pArray = pItem->mpArray.get();
@@ -2098,7 +2217,7 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo
OUString const& rName = pItem->maMemberList.back();
WatchItem* pWatchItem = new WatchItem(rName);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pWatchItem)));
+ OUString sId(weld::toId(pWatchItem));
m_xTreeListBox->insert(&rParent, -1, &rName, &sId, nullptr, nullptr, false, xRet.get());
m_xTreeListBox->set_text(*xRet, "", 1);
@@ -2149,7 +2268,7 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo
aDisplayName += aIndexStr;
pChildItem->maDisplayName = aDisplayName;
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pChildItem)));
+ OUString sId(weld::toId(pChildItem));
m_xTreeListBox->insert(&rParent, -1, &aDisplayName, &sId, nullptr, nullptr, false,
xRet.get());
@@ -2179,12 +2298,12 @@ SbxBase* WatchWindow::ImplGetSBXForEntry(const weld::TreeIter& rEntry, bool& rbA
SbxBase* pSBX = nullptr;
rbArrayElement = false;
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rEntry));
OUString aVName( pItem->maName );
std::unique_ptr<weld::TreeIter> xParentEntry = m_xTreeListBox->make_iterator(&rEntry);
bool bParentEntry = m_xTreeListBox->iter_parent(*xParentEntry);
- WatchItem* pParentItem = bParentEntry ? reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(*xParentEntry).toInt64()) : nullptr;
+ WatchItem* pParentItem = bParentEntry ? weld::fromId<WatchItem*>(m_xTreeListBox->get_id(*xParentEntry)) : nullptr;
if( pParentItem )
{
SbxObject* pObj = pParentItem->mpObject.get();
@@ -2217,7 +2336,7 @@ SbxBase* WatchWindow::ImplGetSBXForEntry(const weld::TreeIter& rEntry, bool& rbA
IMPL_LINK(WatchWindow, EditingEntryHdl, const weld::TreeIter&, rIter, bool)
{
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rIter).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rIter));
bool bEdit = false;
if (StarBASIC::IsRunning() && StarBASIC::GetActiveMethod() && !SbxBase::IsError())
@@ -2284,7 +2403,7 @@ IMPL_LINK(WatchWindow, EditedEntryHdl, const IterString&, rIterString, bool)
namespace
{
-void implCollapseModifiedObjectEntry(weld::TreeIter& rParent, weld::TreeView& rTree)
+void implCollapseModifiedObjectEntry(const weld::TreeIter& rParent, weld::TreeView& rTree)
{
rTree.collapse_row(rParent);
@@ -2294,7 +2413,7 @@ void implCollapseModifiedObjectEntry(weld::TreeIter& rParent, weld::TreeView& rT
{
implCollapseModifiedObjectEntry(*xDeleteEntry, rTree);
- WatchItem* pItem = reinterpret_cast<WatchItem*>(rTree.get_id(*xDeleteEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(rTree.get_id(*xDeleteEntry));
delete pItem;
rTree.remove(*xDeleteEntry);
rTree.copy_iterator(rParent, *xDeleteEntry);
@@ -2353,7 +2472,7 @@ void WatchWindow::UpdateWatches(bool bBasicStopped)
setBasicWatchMode( true );
m_xTreeListBox->all_foreach([this, pCurMethod, bBasicStopped](weld::TreeIter& rEntry){
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rEntry));
DBG_ASSERT( !pItem->maName.isEmpty(), "Var? - Must not be empty!" );
OUString aWatchStr;
OUString aTypeStr;
@@ -2374,7 +2493,7 @@ void WatchWindow::UpdateWatches(bool bBasicStopped)
eEnableChildren = TRISTATE_TRUE;
}
- if (SbxVariable const* pVar = IsSbxVariable(pSBX))
+ if (SbxVariable* pVar = dynamic_cast<SbxVariable*>(pSBX))
{
// extra treatment of arrays
SbxDataType eType = pVar->GetType();
@@ -2487,7 +2606,11 @@ void WatchWindow::UpdateWatches(bool bBasicStopped)
{
aWatchStr += aStrStr;
}
+ // tdf#57308 - avoid a second call to retrieve the data
+ const SbxFlagBits nFlags = pVar->GetFlags();
+ pVar->SetFlag(SbxFlagBits::NoBroadcast);
aWatchStr += pVar->GetOUString();
+ pVar->SetFlags(nFlags);
if( bString )
{
aWatchStr += aStrStr;
@@ -2588,7 +2711,7 @@ void CodeCompleteWindow::SetMatchingEntries()
for (sal_Int32 i = 0, nEntryCount = m_xListBox->n_children(); i< nEntryCount; ++i)
{
OUString sEntry = m_xListBox->get_text(i);
- if (sEntry.startsWithIgnoreAsciiCase(aFuncBuffer.toString()))
+ if (sEntry.startsWithIgnoreAsciiCase(aFuncBuffer))
{
m_xListBox->select(i);
break;
@@ -2654,8 +2777,8 @@ bool CodeCompleteWindow::HandleKeyInput( const KeyEvent& rKeyEvt )
for (sal_Int32 i = nInd; i != nEntryCount; ++i)
{
OUString sEntry = m_xListBox->get_text(i);
- if( sEntry.startsWithIgnoreAsciiCase( aFuncBuffer.toString() )
- && (aFuncBuffer.toString() != sTypedText) && (i != nInd) )
+ if( sEntry.startsWithIgnoreAsciiCase( aFuncBuffer )
+ && (std::u16string_view(aFuncBuffer) != sTypedText) && (i != nInd) )
{
m_xListBox->select(i);
bFound = true;
@@ -2685,7 +2808,7 @@ bool CodeCompleteWindow::HandleKeyInput( const KeyEvent& rKeyEvt )
OUString aTabInsertedStr( GetParentEditView()->GetSelected() );
GetParentEditView()->SetSelection( aSel );
- if( !aTabInsertedStr.isEmpty() && aTabInsertedStr != aFuncBuffer.toString() )
+ if( !aTabInsertedStr.isEmpty() && aTabInsertedStr != std::u16string_view(aFuncBuffer) )
{
aFuncBuffer = aTabInsertedStr;
}
@@ -2739,6 +2862,7 @@ CodeCompleteWindow::CodeCompleteWindow(EditorWindow* pPar)
m_xListBox->connect_changed(LINK(this, CodeCompleteWindow, ImplSelectHdl));
m_xListBox->connect_key_press(LINK(this, CodeCompleteWindow, KeyInputHdl));
m_xListBox->make_sorted();
+ m_xListBox->set_direction(false);
m_xListBox->set_size_request(150, 150); // default, this will adopt the line length
SetSizePixel(m_xContainer->get_preferred_size());
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
index b2ed314ebf25..4a6b1dfbfb5c 100644
--- a/basctl/source/basicide/baside3.cxx
+++ b/basctl/source/basicide/baside3.cxx
@@ -39,17 +39,18 @@
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
-#include <com/sun/star/ui/dialogs/FilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
#include <comphelper/processfactory.hxx>
#include <sfx2/dispatch.hxx>
+#include <sfx2/filedlghelper.hxx>
#include <sfx2/request.hxx>
#include <sfx2/viewfrm.hxx>
#include <svl/visitem.hxx>
#include <svl/whiter.hxx>
#include <svx/svdundo.hxx>
#include <svx/svxids.hrc>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <tools/urlobj.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/weld.hxx>
@@ -69,9 +70,9 @@ using namespace ::com::sun::star::resource;
using namespace ::com::sun::star::ui::dialogs;
#ifdef _WIN32
-OUStringLiteral const FilterMask_All = u"*.*";
+constexpr OUString FilterMask_All = u"*.*"_ustr;
#else
-constexpr OUStringLiteral FilterMask_All = u"*";
+constexpr OUString FilterMask_All = u"*"_ustr;
#endif
DialogWindow::DialogWindow(DialogWindowLayout* pParent, ScriptDocument const& rDocument,
@@ -231,12 +232,10 @@ void DialogWindow::NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> )
void DialogWindow::DoInit()
{
- GetHScrollBar()->Show();
- GetVScrollBar()->Show();
m_pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
}
-void DialogWindow::DoScroll( ScrollBar* )
+void DialogWindow::DoScroll( Scrollable* )
{
m_pEditor->DoScroll();
}
@@ -314,7 +313,7 @@ void DialogWindow::GetState( SfxItemSet& rSet )
case SID_SHOW_PROPERTYBROWSER:
{
Shell* pShell = GetShell();
- SfxViewFrame* pViewFrame = pShell ? pShell->GetViewFrame() : nullptr;
+ SfxViewFrame* pViewFrame = pShell ? &pShell->GetViewFrame() : nullptr;
if ( pViewFrame && !pViewFrame->HasChildWindow( SID_SHOW_PROPERTYBROWSER ) && !m_pEditor->GetView().AreObjectsMarked() )
rSet.DisableItem( nWh );
@@ -391,7 +390,7 @@ void DialogWindow::GetState( SfxItemSet& rSet )
void DialogWindow::ExecuteCommand( SfxRequest& rReq )
{
const sal_uInt16 nSlotId(rReq.GetSlot());
- SdrObjKind nInsertObj(OBJ_NONE);
+ SdrObjKind nInsertObj(SdrObjKind::NONE);
switch ( nSlotId )
{
@@ -424,100 +423,100 @@ void DialogWindow::ExecuteCommand( SfxRequest& rReq )
break;
case SID_INSERT_FORM_RADIO:
- nInsertObj = OBJ_DLG_FORMRADIO;
+ nInsertObj = SdrObjKind::BasicDialogFormRadio;
break;
case SID_INSERT_FORM_CHECK:
- nInsertObj = OBJ_DLG_FORMCHECK;
+ nInsertObj = SdrObjKind::BasicDialogFormCheck;
break;
case SID_INSERT_FORM_LIST:
- nInsertObj = OBJ_DLG_FORMLIST;
+ nInsertObj = SdrObjKind::BasicDialogFormList;
break;
case SID_INSERT_FORM_COMBO:
- nInsertObj = OBJ_DLG_FORMCOMBO;
+ nInsertObj = SdrObjKind::BasicDialogFormCombo;
break;
case SID_INSERT_FORM_SPIN:
- nInsertObj = OBJ_DLG_FORMSPIN;
+ nInsertObj = SdrObjKind::BasicDialogFormSpin;
break;
case SID_INSERT_FORM_VSCROLL:
- nInsertObj = OBJ_DLG_FORMVSCROLL;
+ nInsertObj = SdrObjKind::BasicDialogFormVerticalScroll;
break;
case SID_INSERT_FORM_HSCROLL:
- nInsertObj = OBJ_DLG_FORMHSCROLL;
+ nInsertObj = SdrObjKind::BasicDialogFormHorizontalScroll;
break;
case SID_INSERT_PUSHBUTTON:
- nInsertObj = OBJ_DLG_PUSHBUTTON;
+ nInsertObj = SdrObjKind::BasicDialogPushButton;
break;
case SID_INSERT_RADIOBUTTON:
- nInsertObj = OBJ_DLG_RADIOBUTTON;
+ nInsertObj = SdrObjKind::BasicDialogRadioButton;
break;
case SID_INSERT_CHECKBOX:
- nInsertObj = OBJ_DLG_CHECKBOX;
+ nInsertObj = SdrObjKind::BasicDialogCheckbox;
break;
case SID_INSERT_LISTBOX:
- nInsertObj = OBJ_DLG_LISTBOX;
+ nInsertObj = SdrObjKind::BasicDialogListbox;
break;
case SID_INSERT_COMBOBOX:
- nInsertObj = OBJ_DLG_COMBOBOX;
+ nInsertObj = SdrObjKind::BasicDialogCombobox;
break;
case SID_INSERT_GROUPBOX:
- nInsertObj = OBJ_DLG_GROUPBOX;
+ nInsertObj = SdrObjKind::BasicDialogGroupBox;
break;
case SID_INSERT_EDIT:
- nInsertObj = OBJ_DLG_EDIT;
+ nInsertObj = SdrObjKind::BasicDialogEdit;
break;
case SID_INSERT_FIXEDTEXT:
- nInsertObj = OBJ_DLG_FIXEDTEXT;
+ nInsertObj = SdrObjKind::BasicDialogFixedText;
break;
case SID_INSERT_IMAGECONTROL:
- nInsertObj = OBJ_DLG_IMAGECONTROL;
+ nInsertObj = SdrObjKind::BasicDialogImageControl;
break;
case SID_INSERT_PROGRESSBAR:
- nInsertObj = OBJ_DLG_PROGRESSBAR;
+ nInsertObj = SdrObjKind::BasicDialogProgressbar;
break;
case SID_INSERT_HSCROLLBAR:
- nInsertObj = OBJ_DLG_HSCROLLBAR;
+ nInsertObj = SdrObjKind::BasicDialogHorizontalScrollbar;
break;
case SID_INSERT_VSCROLLBAR:
- nInsertObj = OBJ_DLG_VSCROLLBAR;
+ nInsertObj = SdrObjKind::BasicDialogVerticalScrollbar;
break;
case SID_INSERT_HFIXEDLINE:
- nInsertObj = OBJ_DLG_HFIXEDLINE;
+ nInsertObj = SdrObjKind::BasicDialogHorizontalFixedLine;
break;
case SID_INSERT_VFIXEDLINE:
- nInsertObj = OBJ_DLG_VFIXEDLINE;
+ nInsertObj = SdrObjKind::BasicDialogVerticalFixedLine;
break;
case SID_INSERT_DATEFIELD:
- nInsertObj = OBJ_DLG_DATEFIELD;
+ nInsertObj = SdrObjKind::BasicDialogDateField;
break;
case SID_INSERT_TIMEFIELD:
- nInsertObj = OBJ_DLG_TIMEFIELD;
+ nInsertObj = SdrObjKind::BasicDialogTimeField;
break;
case SID_INSERT_NUMERICFIELD:
- nInsertObj = OBJ_DLG_NUMERICFIELD;
+ nInsertObj = SdrObjKind::BasicDialogNumericField;
break;
case SID_INSERT_CURRENCYFIELD:
- nInsertObj = OBJ_DLG_CURRENCYFIELD;
+ nInsertObj = SdrObjKind::BasicDialogCurencyField;
break;
case SID_INSERT_FORMATTEDFIELD:
- nInsertObj = OBJ_DLG_FORMATTEDFIELD;
+ nInsertObj = SdrObjKind::BasicDialogFormattedField;
break;
case SID_INSERT_PATTERNFIELD:
- nInsertObj = OBJ_DLG_PATTERNFIELD;
+ nInsertObj = SdrObjKind::BasicDialogPatternField;
break;
case SID_INSERT_FILECONTROL:
- nInsertObj = OBJ_DLG_FILECONTROL;
+ nInsertObj = SdrObjKind::BasicDialogFileControl;
break;
case SID_INSERT_SPINBUTTON:
- nInsertObj = OBJ_DLG_SPINBUTTON;
+ nInsertObj = SdrObjKind::BasicDialogSpinButton;
break;
case SID_INSERT_GRIDCONTROL:
- nInsertObj = OBJ_DLG_GRIDCONTROL;
+ nInsertObj = SdrObjKind::BasicDialogGridControl;
break;
case SID_INSERT_HYPERLINKCONTROL:
- nInsertObj = OBJ_DLG_HYPERLINKCONTROL;
+ nInsertObj = SdrObjKind::BasicDialogHyperlinkControl;
break;
case SID_INSERT_TREECONTROL:
- nInsertObj = OBJ_DLG_TREECONTROL;
+ nInsertObj = SdrObjKind::BasicDialogTreeControl;
break;
case SID_INSERT_SELECT:
m_nControlSlotId = nSlotId;
@@ -555,7 +554,7 @@ void DialogWindow::ExecuteCommand( SfxRequest& rReq )
break;
}
- if ( nInsertObj )
+ if ( nInsertObj != SdrObjKind::NONE )
{
m_nControlSlotId = nSlotId;
GetEditor().SetMode( DlgEditor::INSERT );
@@ -602,18 +601,12 @@ void DialogWindow::UpdateBrowser()
void DialogWindow::SaveDialog()
{
- Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
- Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD);
-
- Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
- xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false);
- Any aValue;
- aValue <<= true;
- xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
-
- if ( !m_sCurPath.isEmpty() )
- xFP->setDisplayDirectory ( m_sCurPath );
+ sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
+ FileDialogFlags::NONE, this->GetFrameWeld());
+ aDlg.SetContext(sfx2::FileDialogHelper::BasicExportDialog);
+ Reference<XFilePicker3> xFP = aDlg.GetFilePicker();
+ xFP.queryThrow<XFilePickerControlAccess>()->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, Any(true));
xFP->setDefaultName( GetName() );
OUString aDialogStr(IDEResId(RID_STR_STDDIALOGNAME));
@@ -621,137 +614,112 @@ void DialogWindow::SaveDialog()
xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All );
xFP->setCurrentFilter( aDialogStr );
- if( xFP->execute() != RET_OK )
+ if( aDlg.Execute() != ERRCODE_NONE )
return;
- Sequence< OUString > aPaths = xFP->getSelectedFiles();
- m_sCurPath = aPaths[0];
-
- // export dialog model to xml
- Reference< container::XNameContainer > xDialogModel = GetDialog();
- Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() );
- Reference< XInputStream > xInput( xISP->createInputStream() );
+ OUString aSelectedFileURL = xFP->getSelectedFiles()[0];
+ Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) );
Reference< XOutputStream > xOutput;
try
{
- if( xSFI->exists( m_sCurPath ) )
- xSFI->kill( m_sCurPath );
- xOutput = xSFI->openFileWrite( m_sCurPath );
+ if( xSFI->exists(aSelectedFileURL) )
+ xSFI->kill(aSelectedFileURL);
+ xOutput = xSFI->openFileWrite(aSelectedFileURL);
}
catch(const Exception& )
{}
- if( xOutput.is() )
+ if (!xOutput)
{
- Sequence< sal_Int8 > bytes;
- sal_Int32 nRead = xInput->readBytes( bytes, xInput->available() );
- for (;;)
- {
- if( nRead )
- xOutput->writeBytes( bytes );
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
+ VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTWRITE)));
+ xBox->run();
+ return;
+ }
- nRead = xInput->readBytes( bytes, 1024 );
- if (! nRead)
- break;
- }
+ // export dialog model to xml
+ auto xInput(xmlscript::exportDialogModel(GetDialog(), xContext, GetDocument().getDocumentOrNull())->createInputStream());
- // With resource?
- Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY );
- Reference< resource::XStringResourceResolver > xStringResourceResolver;
- if( xDialogModelPropSet.is() )
- {
- try
- {
- Any aResourceResolver = xDialogModelPropSet->getPropertyValue( "ResourceResolver" );
- aResourceResolver >>= xStringResourceResolver;
- }
- catch(const beans::UnknownPropertyException& )
- {}
- }
+ for (Sequence<sal_Int8> bytes; xInput->readBytes(bytes, xInput->available());)
+ xOutput->writeBytes(bytes);
- bool bResource = false;
- if( xStringResourceResolver.is() )
+ // With resource?
+ Reference< resource::XStringResourceResolver > xStringResourceResolver;
+ if (auto xDialogModelPropSet = GetDialog().query<beans::XPropertySet>())
+ {
+ try
{
- Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales();
- if( aLocaleSeq.hasElements() )
- bResource = true;
+ Any aResourceResolver = xDialogModelPropSet->getPropertyValue( "ResourceResolver" );
+ aResourceResolver >>= xStringResourceResolver;
}
+ catch(const beans::UnknownPropertyException& )
+ {}
+ }
- if( bResource )
+ Sequence<lang::Locale> aLocaleSeq;
+ if (xStringResourceResolver)
+ aLocaleSeq = xStringResourceResolver->getLocales();
+ if (aLocaleSeq.hasElements())
+ {
+ INetURLObject aURLObj(aSelectedFileURL);
+ aURLObj.removeExtension();
+ OUString aDialogName( aURLObj.getName() );
+ aURLObj.removeSegment();
+ OUString aURL( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+ OUString aComment = "# " + aDialogName + " strings" ;
+ Reference< task::XInteractionHandler > xDummyHandler;
+
+ // Remove old properties files in case of overwriting Dialog files
+ if( xSFI->isFolder( aURL ) )
{
- INetURLObject aURLObj( m_sCurPath );
- aURLObj.removeExtension();
- OUString aDialogName( aURLObj.getName() );
- aURLObj.removeSegment();
- OUString aURL( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
- OUString aComment = "# " + aDialogName + " strings" ;
- Reference< task::XInteractionHandler > xDummyHandler;
+ Sequence< OUString > aContentSeq = xSFI->getFolderContents( aURL, false );
- // Remove old properties files in case of overwriting Dialog files
- if( xSFI->isFolder( aURL ) )
+ OUString aDialogName_ = aDialogName + "_" ;
+ for( const OUString& rCompleteName : aContentSeq )
{
- Sequence< OUString > aContentSeq = xSFI->getFolderContents( aURL, false );
-
- OUString aDialogName_ = aDialogName + "_" ;
- sal_Int32 nCount = aContentSeq.getLength();
- const OUString* pFiles = aContentSeq.getConstArray();
- for( int i = 0 ; i < nCount ; i++ )
+ OUString aPureName;
+ OUString aExtension;
+ sal_Int32 iDot = rCompleteName.lastIndexOf( '.' );
+ if( iDot != -1 )
{
- OUString aCompleteName = pFiles[i];
- OUString aPureName;
- OUString aExtension;
- sal_Int32 iDot = aCompleteName.lastIndexOf( '.' );
- sal_Int32 iSlash = aCompleteName.lastIndexOf( '/' );
- if( iDot != -1 )
- {
- sal_Int32 iCopyFrom = (iSlash != -1) ? iSlash + 1 : 0;
- aPureName = aCompleteName.copy( iCopyFrom, iDot-iCopyFrom );
- aExtension = aCompleteName.copy( iDot + 1 );
- }
+ sal_Int32 iSlash = rCompleteName.lastIndexOf( '/' );
+ sal_Int32 iCopyFrom = (iSlash != -1) ? iSlash + 1 : 0;
+ aPureName = rCompleteName.copy( iCopyFrom, iDot-iCopyFrom );
+ aExtension = rCompleteName.copy( iDot + 1 );
+ }
- if( aExtension == "properties" || aExtension == "default" )
+ if( aExtension == "properties" || aExtension == "default" )
+ {
+ if( aPureName.startsWith( aDialogName_ ) )
{
- if( aPureName.startsWith( aDialogName_ ) )
+ try
{
- try
- {
- xSFI->kill( aCompleteName );
- }
- catch(const uno::Exception& )
- {}
+ xSFI->kill( rCompleteName );
}
+ catch(const uno::Exception& )
+ {}
}
}
}
+ }
- Reference< XStringResourceWithLocation > xStringResourceWithLocation =
- StringResourceWithLocation::create( xContext, aURL, false/*bReadOnly*/,
- xStringResourceResolver->getDefaultLocale(), aDialogName, aComment, xDummyHandler );
+ Reference< XStringResourceWithLocation > xStringResourceWithLocation =
+ StringResourceWithLocation::create( xContext, aURL, false/*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 );
- }
+ // Add locales
+ for( const lang::Locale& rLocale : aLocaleSeq )
+ {
+ xStringResourceWithLocation->newLocale( rLocale );
+ }
- LocalizationMgr::copyResourceForDialog( xDialogModel,
- xStringResourceResolver, xStringResourceWithLocation );
+ LocalizationMgr::copyResourceForDialog( GetDialog(),
+ xStringResourceResolver, xStringResourceWithLocation );
- xStringResourceWithLocation->store();
- }
- }
- else
- {
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
- VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTWRITE)));
- xBox->run();
+ xStringResourceWithLocation->store();
}
}
@@ -760,32 +728,15 @@ static std::vector< lang::Locale > implGetLanguagesOnlyContainedInFirstSeq
{
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 );
- }
-
+ std::copy_if(aFirstSeq.begin(), aFirstSeq.end(),
+ std::back_inserter(avRet),
+ [&aSecondSeq](const lang::Locale& rFirstLocale) {
+ return std::none_of(
+ aSecondSeq.begin(), aSecondSeq.end(),
+ [&rFirstLocale](const lang::Locale& rSecondLocale) {
+ return localesAreEqual(rFirstLocale, rSecondLocale);
+ });
+ });
return avRet;
}
@@ -830,35 +781,27 @@ public:
}
-bool implImportDialog(weld::Window* pWin, const OUString& rCurPath, const ScriptDocument& rDocument, const OUString& aLibName)
+bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const OUString& aLibName)
{
bool bDone = false;
- Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
- Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_SIMPLE);
-
- Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
- xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false);
- Any aValue;
- aValue <<= true;
- xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
-
- OUString aCurPath( rCurPath );
- if ( !aCurPath.isEmpty() )
- xFP->setDisplayDirectory ( aCurPath );
+ Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext());
+ sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
+ FileDialogFlags::NONE, pWin);
+ aDlg.SetContext(sfx2::FileDialogHelper::BasicImportDialog);
+ Reference<XFilePicker3> xFP = aDlg.GetFilePicker();
OUString aDialogStr(IDEResId(RID_STR_STDDIALOGNAME));
xFP->appendFilter( aDialogStr, "*.xdl" );
xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All );
xFP->setCurrentFilter( aDialogStr );
- if( xFP->execute() == RET_OK )
+ if( aDlg.Execute() == ERRCODE_NONE )
{
Sequence< OUString > aPaths = xFP->getSelectedFiles();
- aCurPath = aPaths[0];
OUString aBasePath;
- OUString aOUCurPath( aCurPath );
+ OUString aOUCurPath( aPaths[0] );
sal_Int32 iSlash = aOUCurPath.lastIndexOf( '/' );
if( iSlash != -1 )
aBasePath = aOUCurPath.copy( 0, iSlash + 1 );
@@ -873,8 +816,8 @@ bool implImportDialog(weld::Window* pWin, const OUString& rCurPath, const Script
Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) );
Reference< XInputStream > xInput;
- if( xSFI->exists( aCurPath ) )
- xInput = xSFI->openFileRead( aCurPath );
+ if( xSFI->exists( aOUCurPath ) )
+ xInput = xSFI->openFileRead( aOUCurPath );
::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() );
@@ -995,15 +938,13 @@ bool implImportDialog(weld::Window* pWin, const OUString& rCurPath, const Script
{
// 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 )
+
+ if (std::any_of(aOnlyInImportLanguages.begin(), aOnlyInImportLanguages.end(),
+ [&aImportDefaultLocale](const lang::Locale& aTmpLocale) {
+ return localesAreEqual(aImportDefaultLocale, aTmpLocale);
+ }))
{
- aTmpLocale = aOnlyInImportLanguages[i];
- if( localesAreEqual( aImportDefaultLocale, aTmpLocale ) )
- {
- aFirstLocale = aImportDefaultLocale;
- break;
- }
+ aFirstLocale = aImportDefaultLocale;
}
}
@@ -1012,13 +953,12 @@ bool implImportDialog(weld::Window* pWin, const OUString& rCurPath, const Script
if( nOnlyInImportLanguageCount > 1 )
{
Sequence< lang::Locale > aRemainingLocaleSeq( nOnlyInImportLanguageCount - 1 );
- lang::Locale aTmpLocale;
+ auto pRemainingLocaleSeq = aRemainingLocaleSeq.getArray();
int iSeq = 0;
- for( int i = 0 ; i < nOnlyInImportLanguageCount ; ++i )
+ for( const lang::Locale& rLocale : aOnlyInImportLanguages )
{
- aTmpLocale = aOnlyInImportLanguages[i];
- if( !localesAreEqual( aFirstLocale, aTmpLocale ) )
- aRemainingLocaleSeq[iSeq++] = aTmpLocale;
+ if( !localesAreEqual( aFirstLocale, rLocale ) )
+ pRemainingLocaleSeq[iSeq++] = rLocale;
}
pCurMgr->handleAddLocales( aRemainingLocaleSeq );
}
@@ -1106,7 +1046,7 @@ void DialogWindow::ImportDialog()
{
const ScriptDocument& rDocument = GetDocument();
OUString aLibName = GetLibName();
- implImportDialog(GetFrameWeld(), m_sCurPath, rDocument, aLibName);
+ implImportDialog(GetFrameWeld(), rDocument, aLibName);
}
DlgEdModel& DialogWindow::GetModel() const
@@ -1237,7 +1177,7 @@ void DialogWindow::InitSettings()
SetTextColor( rStyleSettings.GetFieldTextColor() );
SetTextFillColor();
- SetBackground( rStyleSettings.GetFieldColor() );
+ SetBackground(rStyleSettings.GetFaceColor());
}
css::uno::Reference< css::accessibility::XAccessible > DialogWindow::CreateAccessible()
@@ -1245,10 +1185,11 @@ css::uno::Reference< css::accessibility::XAccessible > DialogWindow::CreateAcces
return new AccessibleDialogWindow(this);
}
-char const* DialogWindow::GetHid () const
+OUString DialogWindow::GetHid () const
{
return HID_BASICIDE_DIALOGWINDOW;
}
+
ItemType DialogWindow::GetType () const
{
return TYPE_DIALOG;
diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx
index 8942d87f4ae0..b5ac6852986f 100644
--- a/basctl/source/basicide/basides1.cxx
+++ b/basctl/source/basicide/basides1.cxx
@@ -31,6 +31,7 @@
#include "iderdll2.hxx"
#include <localizationmgr.hxx>
#include <managelang.hxx>
+#include <ColorSchemeDialog.hxx>
#include <basic/basmgr.hxx>
#include <com/sun/star/script/ModuleType.hpp>
@@ -56,6 +57,10 @@
#include <vcl/textview.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
+#include <svx/zoomsliderctrl.hxx>
+#include <svx/zoomslideritem.hxx>
+#include <basegfx/utils/zoomtools.hxx>
+#include <officecfg/Office/BasicIDE.hxx>
constexpr sal_Int32 TAB_HEIGHT_MARGIN = 10;
@@ -66,6 +71,17 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::frame;
+static void lcl_InvalidateZoomSlots(SfxBindings* pBindings)
+{
+ if (!pBindings)
+ return;
+
+ static sal_uInt16 const aInval[] = {
+ SID_ZOOM_OUT, SID_ZOOM_IN, SID_ATTR_ZOOMSLIDER, 0
+ };
+ pBindings->Invalidate(aInval);
+}
+
void Shell::ExecuteSearch( SfxRequest& rReq )
{
if ( !pCurWin )
@@ -90,7 +106,7 @@ void Shell::ExecuteSearch( SfxRequest& rReq )
break;
case FID_SEARCH_ON:
mbJustOpened = true;
- GetViewFrame()->GetBindings().Invalidate(SID_SEARCH_ITEM);
+ GetViewFrame().GetBindings().Invalidate(SID_SEARCH_ITEM);
break;
case SID_BASICIDE_REPEAT_SEARCH:
case FID_SEARCH_NOW:
@@ -173,8 +189,8 @@ void Shell::ExecuteSearch( SfxRequest& rReq )
{
if ( !pWin )
{
- SfxViewFrame* pViewFrame = GetViewFrame();
- SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow( SID_SEARCH_DLG ) : nullptr;
+ SfxViewFrame& rViewFrame = GetViewFrame();
+ SfxChildWindow* pChildWin = rViewFrame.GetChildWindow(SID_SEARCH_DLG);
auto xParent = pChildWin ? pChildWin->GetController() : nullptr;
std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(xParent ? xParent->getDialog() : nullptr,
@@ -258,7 +274,7 @@ void Shell::ExecuteCurrent( SfxRequest& rReq )
case SID_UNDO:
case SID_REDO:
if ( GetUndoManager() && pCurWin->AllowUndo() )
- GetViewFrame()->ExecuteSlot( rReq );
+ GetViewFrame().ExecuteSlot( rReq );
break;
default:
pCurWin->ExecuteCommand( rReq );
@@ -338,10 +354,10 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
if ( rReq.GetArgs() )
{
const SfxUInt16Item &rTabId = rReq.GetArgs()->Get(SID_BASICIDE_ARG_TABID );
- Organize(rReq.GetFrameWeld(), rTabId.GetValue());
+ Organize(rReq.GetFrameWeld(), nullptr, rTabId.GetValue());
}
else
- Organize(rReq.GetFrameWeld(), 0);
+ Organize(rReq.GetFrameWeld(), nullptr, 0);
}
break;
case SID_BASICIDE_CHOOSEMACRO:
@@ -397,9 +413,8 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
if ( pModule && !pModule->GetMethods()->Find( rInfo.GetMethod(), SbxClassType::Method ) )
CreateMacro( pModule, rInfo.GetMethod() );
}
- SfxViewFrame* pViewFrame = GetViewFrame();
- if ( pViewFrame )
- pViewFrame->ToTop();
+ SfxViewFrame& rViewFrame = GetViewFrame();
+ rViewFrame.ToTop();
VclPtr<ModulWindow> pWin = FindBasWin( aDocument, aLibName, rInfo.GetModule(), true );
DBG_ASSERT( pWin, "Edit/Create Macro: Window was not created/found!" );
SetCurWindow( pWin, true );
@@ -408,14 +423,55 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
break;
case SID_BASICIDE_OBJCAT:
- // toggling object catalog
- aObjectCatalog->Show(!aObjectCatalog->IsVisible());
+ {
+ // Toggle the visibility of the object catalog
+ bool bVisible = aObjectCatalog->IsVisible();
+ aObjectCatalog->Show(!bVisible);
if (pLayout)
pLayout->ArrangeWindows();
// refresh the button state
if (SfxBindings* pBindings = GetBindingsPtr())
pBindings->Invalidate(SID_BASICIDE_OBJCAT);
- break;
+
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
+ officecfg::Office::BasicIDE::EditorSettings::ObjectCatalog::set(!bVisible, batch);
+ batch->commit();
+ }
+ break;
+
+ case SID_BASICIDE_WATCH:
+ {
+ // Toggling the watch window can only be done from a ModulWindow
+ if (!dynamic_cast<ModulWindowLayout*>(pLayout.get()))
+ return;
+
+ bool bVisible = pModulLayout->IsWatchWindowVisible();
+ pModulLayout->ShowWatchWindow(!bVisible);
+ if (SfxBindings* pBindings = GetBindingsPtr())
+ pBindings->Invalidate(SID_BASICIDE_WATCH);
+
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
+ officecfg::Office::BasicIDE::EditorSettings::WatchWindow::set(!bVisible, batch);
+ batch->commit();
+ }
+ break;
+
+ case SID_BASICIDE_STACK:
+ {
+ // Toggling the stack window can only be done from a ModulWindow
+ if (!dynamic_cast<ModulWindowLayout*>(pLayout.get()))
+ return;
+
+ bool bVisible = pModulLayout->IsStackWindowVisible();
+ pModulLayout->ShowStackWindow(!bVisible);
+ if (SfxBindings* pBindings = GetBindingsPtr())
+ pBindings->Invalidate(SID_BASICIDE_STACK);
+
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
+ officecfg::Office::BasicIDE::EditorSettings::StackWindow::set(!bVisible, batch);
+ batch->commit();
+ }
+ break;
case SID_BASICIDE_NAMECHANGEDONTAB:
{
@@ -752,17 +808,87 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
}
break;
+ case SID_BASICIDE_COLOR_SCHEME_DLG:
+ {
+ ModulWindowLayout* pMyLayout = dynamic_cast<ModulWindowLayout*>(pLayout.get());
+ if (!pMyLayout)
+ return;
+
+ OUString curScheme = pMyLayout->GetActiveColorSchemeId();
+ auto xDlg = std::make_shared<ColorSchemeDialog>(pCurWin ? pCurWin->GetFrameWeld() : nullptr,
+ pMyLayout);
+ weld::DialogController::runAsync(xDlg, [xDlg, pMyLayout, curScheme](sal_Int32 nResult){
+ OUString sNewScheme(xDlg->GetColorSchemeId());
+ // If the user canceled the dialog, restores the original color scheme
+ if (nResult != RET_OK)
+ {
+ if (curScheme != sNewScheme)
+ pMyLayout->ApplyColorSchemeToCurrentWindow(curScheme);
+ }
+
+ // If the user selects OK, apply the color scheme to all open ModulWindow
+ if (nResult == RET_OK)
+ {
+ // Set the global color scheme in ModulWindowLayout and update definitions in SyntaxColors
+ pMyLayout->ApplyColorSchemeToCurrentWindow(sNewScheme);
+
+ // Update color scheme for all windows
+ for (auto const& window : GetShell()->GetWindowTable())
+ {
+ ModulWindow* pModuleWindow = dynamic_cast<ModulWindow*>(window.second.get());
+ if (pModuleWindow)
+ {
+ // We need to set the current scheme for each window
+ pModuleWindow->SetEditorColorScheme(sNewScheme);
+ }
+ }
+
+ // Update registry with the new color scheme ID
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
+ officecfg::Office::BasicIDE::EditorSettings::ColorScheme::set(sNewScheme, batch);
+ batch->commit();
+ }
+ });
+ }
+ break;
+
case SID_BASICIDE_MANAGE_LANG:
{
- auto pRequest = std::make_shared<SfxRequest>(rReq);
+ auto xRequest = std::make_shared<SfxRequest>(rReq);
rReq.Ignore(); // the 'old' request is not relevant any more
auto xDlg = std::make_shared<ManageLanguageDialog>(pCurWin ? pCurWin->GetFrameWeld() : nullptr, m_pCurLocalizationMgr);
- weld::DialogController::runAsync(xDlg, [=](sal_Int32 /*nResult*/){
- pRequest->Done();
+ weld::DialogController::runAsync(xDlg, [xRequest=std::move(xRequest)](sal_Int32 /*nResult*/){
+ xRequest->Done();
});
}
break;
+ case SID_ATTR_ZOOMSLIDER:
+ {
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+
+ if (pArgs && pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, true, &pItem ) == SfxItemState::SET)
+ SetGlobalEditorZoomLevel(static_cast<const SvxZoomSliderItem*>(pItem)->GetValue());
+
+ lcl_InvalidateZoomSlots(GetBindingsPtr());
+ }
+ break;
+
+ case SID_ZOOM_IN:
+ case SID_ZOOM_OUT:
+ {
+ const sal_uInt16 nOldZoom = GetCurrentZoomSliderValue();
+ sal_uInt16 nNewZoom;
+ if (nSlot == SID_ZOOM_IN)
+ nNewZoom = std::min<sal_uInt16>(GetMaxZoom(), basegfx::zoomtools::zoomIn(nOldZoom));
+ else
+ nNewZoom = std::max<sal_uInt16>(GetMinZoom(), basegfx::zoomtools::zoomOut(nOldZoom));
+ SetGlobalEditorZoomLevel(nNewZoom);
+ lcl_InvalidateZoomSlots(GetBindingsPtr());
+ }
+ break;
+
default:
if (pLayout)
pLayout->ExecuteGlobal(rReq);
@@ -836,12 +962,44 @@ void Shell::GetState(SfxItemSet &rSet)
rSet.DisableItem( nWh );
}
break;
+
case SID_BASICIDE_OBJCAT:
+ {
if (pLayout)
rSet.Put(SfxBoolItem(nWh, aObjectCatalog->IsVisible()));
else
rSet.Put(SfxVisibilityItem(nWh, false));
- break;
+ }
+ break;
+
+ case SID_BASICIDE_WATCH:
+ {
+ if (pLayout)
+ {
+ rSet.Put(SfxBoolItem(nWh, pModulLayout->IsWatchWindowVisible()));
+ // Disable command if the visible window is not a ModulWindow
+ if (!dynamic_cast<ModulWindowLayout*>(pLayout.get()))
+ rSet.DisableItem(nWh);
+ }
+ else
+ rSet.Put(SfxVisibilityItem(nWh, false));
+ }
+ break;
+
+ case SID_BASICIDE_STACK:
+ {
+ if (pLayout)
+ {
+ rSet.Put(SfxBoolItem(nWh, pModulLayout->IsStackWindowVisible()));
+ // Disable command if the visible window is not a ModulWindow
+ if (!dynamic_cast<ModulWindowLayout*>(pLayout.get()))
+ rSet.DisableItem(nWh);
+ }
+ else
+ rSet.Put(SfxVisibilityItem(nWh, false));
+ }
+ break;
+
case SID_BASICIDE_SHOWSBX:
case SID_BASICIDE_CREATEMACRO:
case SID_BASICIDE_EDITMACRO:
@@ -1007,11 +1165,26 @@ void Shell::GetState(SfxItemSet &rSet)
if ( pCurWin )
{
OUString aTitle = pCurWin->CreateQualifiedName();
+ if (pCurWin->IsReadOnly())
+ aTitle += " (" + IDEResId(RID_STR_READONLY) + ")";
SfxStringItem aItem( SID_BASICIDE_STAT_TITLE, aTitle );
rSet.Put( aItem );
}
}
break;
+ case SID_BASICIDE_CURRENT_ZOOM:
+ {
+ // The current zoom value is only visible in a module window
+ ModulWindow* pModuleWindow = dynamic_cast<ModulWindow*>(pCurWin.get());
+ if (pModuleWindow)
+ {
+ OUString sZoom;
+ sZoom = OUString::number(m_nCurrentZoomSliderValue) + "%";
+ SfxStringItem aItem( SID_BASICIDE_CURRENT_ZOOM, sZoom );
+ rSet.Put( aItem );
+ }
+ }
+ break;
// are interpreted by the controller:
case SID_ATTR_SIZE:
case SID_ATTR_INSERT:
@@ -1020,7 +1193,7 @@ void Shell::GetState(SfxItemSet &rSet)
case SID_REDO:
{
if( GetUndoManager() ) // recursive GetState else
- GetViewFrame()->GetSlotState( nWh, nullptr, &rSet );
+ GetViewFrame().GetSlotState( nWh, nullptr, &rSet );
}
break;
case SID_BASICIDE_CURRENT_LANG:
@@ -1034,7 +1207,6 @@ void Shell::GetState(SfxItemSet &rSet)
if ( pCurMgr->isLibraryLocalized() )
{
Sequence< lang::Locale > aLocaleSeq = pCurMgr->getStringResourceManager()->getLocales();
- const lang::Locale* pLocale = aLocaleSeq.getConstArray();
sal_Int32 i, nCount = aLocaleSeq.getLength();
// Force different results for any combination of locales and default locale
@@ -1043,7 +1215,7 @@ void Shell::GetState(SfxItemSet &rSet)
{
lang::Locale aLocale;
if( i < nCount )
- aLocale = pLocale[i];
+ aLocale = aLocaleSeq[i];
else
aLocale = pCurMgr->getStringResourceManager()->getDefaultLocale();
@@ -1062,6 +1234,13 @@ void Shell::GetState(SfxItemSet &rSet)
rSet.DisableItem( nWh );
}
break;
+ case SID_TOGGLE_COMMENT:
+ {
+ // Only available in a ModulWindow if the document can be edited
+ if (pCurWin && (!dynamic_cast<ModulWindow*>(pCurWin.get()) || pCurWin->IsReadOnly()))
+ rSet.DisableItem(nWh);
+ }
+ break;
case SID_GOTOLINE:
{
// if this is not a module window hide the
@@ -1110,6 +1289,37 @@ void Shell::GetState(SfxItemSet &rSet)
rSet.DisableItem(nWh);
}
break;
+
+ case SID_ZOOM_IN:
+ case SID_ZOOM_OUT:
+ {
+ const sal_uInt16 nCurrentZoom = GetCurrentZoomSliderValue();
+ if ((nWh == SID_ZOOM_IN && nCurrentZoom >= GetMaxZoom()) ||
+ (nWh == SID_ZOOM_OUT && nCurrentZoom <= GetMinZoom()))
+ rSet.DisableItem(nWh);
+ }
+ break;
+
+ case SID_BASICIDE_COLOR_SCHEME_DLG:
+ {
+ if (!dynamic_cast<ModulWindowLayout*>(pLayout.get()))
+ rSet.DisableItem(nWh);
+ }
+ break;
+
+ case SID_ATTR_ZOOMSLIDER:
+ {
+ // The zoom slider is only visible in a module window
+ ModulWindow* pModuleWindow = dynamic_cast<ModulWindow*>(pCurWin.get());
+ if (pModuleWindow)
+ {
+ SvxZoomSliderItem aZoomSliderItem(GetCurrentZoomSliderValue(), GetMinZoom(), GetMaxZoom());
+ aZoomSliderItem.AddSnappingPoint(100);
+ rSet.Put( aZoomSliderItem );
+ }
+ }
+ break;
+
default:
if (pLayout)
pLayout->GetState(rSet, nWh);
@@ -1148,17 +1358,17 @@ void Shell::SetCurWindow( BaseWindow* pNewWin, bool bUpdateTabBar, bool bRemembe
pLayout = pModulLayout.get();
else
pLayout = pDialogLayout.get();
- AdjustPosSizePixel(Point(0, 0), GetViewFrame()->GetWindow().GetOutputSizePixel());
+ AdjustPosSizePixel(Point(0, 0), GetViewFrame().GetWindow().GetOutputSizePixel());
pLayout->Activating(*pCurWin);
- GetViewFrame()->GetWindow().SetHelpId(pCurWin->GetHid());
+ GetViewFrame().GetWindow().SetHelpId(pCurWin->GetHid());
if (bRememberAsCurrent)
pCurWin->InsertLibInfo();
- if (GetViewFrame()->GetWindow().IsVisible()) // SFX will do it later otherwise
+ if (GetViewFrame().GetWindow().IsVisible()) // SFX will do it later otherwise
pCurWin->Show();
pCurWin->Init();
if (!GetExtraData()->ShellInCriticalSection())
{
- vcl::Window* pFrameWindow = &GetViewFrame()->GetWindow();
+ vcl::Window* pFrameWindow = &GetViewFrame().GetWindow();
vcl::Window* pFocusWindow = Application::GetFocusWindow();
while ( pFocusWindow && ( pFocusWindow != pFrameWindow ) )
pFocusWindow = pFocusWindow->GetParent();
@@ -1189,14 +1399,13 @@ void Shell::SetCurWindow( BaseWindow* pNewWin, bool bUpdateTabBar, bool bRemembe
else if (pLayout)
{
SetWindow(pLayout);
- GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW );
+ GetViewFrame().GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW );
SfxObjectShell::SetCurrentComponent(nullptr);
}
aObjectCatalog->SetCurrentEntry(pCurWin);
SetUndoManager( pCurWin ? pCurWin->GetUndoManager() : nullptr );
InvalidateBasicIDESlots();
InvalidateControlSlots();
- EnableScrollbars(pCurWin != nullptr);
if ( m_pCurLocalizationMgr )
m_pCurLocalizationMgr->handleTranslationbar();
@@ -1209,18 +1418,18 @@ void Shell::SetCurWindow( BaseWindow* pNewWin, bool bUpdateTabBar, bool bRemembe
void Shell::ManageToolbars()
{
- static constexpr OUStringLiteral aMacroBarResName = u"private:resource/toolbar/macrobar";
- static constexpr OUStringLiteral aDialogBarResName = u"private:resource/toolbar/dialogbar";
- static constexpr OUStringLiteral aInsertControlsBarResName
- = u"private:resource/toolbar/insertcontrolsbar";
- static constexpr OUStringLiteral aFormControlsBarResName
- = u"private:resource/toolbar/formcontrolsbar";
+ static constexpr OUString aMacroBarResName = u"private:resource/toolbar/macrobar"_ustr;
+ static constexpr OUString aDialogBarResName = u"private:resource/toolbar/dialogbar"_ustr;
+ static constexpr OUString aInsertControlsBarResName
+ = u"private:resource/toolbar/insertcontrolsbar"_ustr;
+ static constexpr OUString aFormControlsBarResName
+ = u"private:resource/toolbar/formcontrolsbar"_ustr;
if( !pCurWin )
return;
Reference< beans::XPropertySet > xFrameProps
- ( GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
+ ( GetViewFrame().GetFrame().GetFrameInterface(), uno::UNO_QUERY );
if ( !xFrameProps.is() )
return;
@@ -1295,13 +1504,13 @@ BasicDebugFlags Shell::CallBasicBreakHdl( StarBASIC const * pBasic )
if ( StarBASIC::IsRunning() ) // if cancelled...
{
if ( bAppWindowDisabled )
- Application::GetDefDialogParent()->Enable(false);
+ Application::GetDefDialogParent()->set_sensitive(false);
if ( nWaitCount )
{
Shell* pShell = GetShell();
for ( sal_uInt16 n = 0; n < nWaitCount; n++ )
- pShell->GetViewFrame()->GetWindow().EnterWait();
+ pShell->GetViewFrame().GetWindow().EnterWait();
}
}
}
@@ -1345,27 +1554,38 @@ VclPtr<ModulWindow> Shell::ShowActiveModuleWindow( StarBASIC const * pBasic )
void Shell::AdjustPosSizePixel( const Point &rPos, const Size &rSize )
{
// not if iconified because the whole text would be displaced then at restore
- if ( GetViewFrame()->GetWindow().GetOutputSizePixel().Height() == 0 )
+ if ( GetViewFrame().GetWindow().GetOutputSizePixel().Height() == 0 )
return;
Size aTabBarSize;
- aTabBarSize.setHeight( GetViewFrame()->GetWindow().GetFont().GetFontHeight() + TAB_HEIGHT_MARGIN );
+ aTabBarSize.setHeight( GetViewFrame().GetWindow().GetFont().GetFontHeight() + TAB_HEIGHT_MARGIN );
aTabBarSize.setWidth( rSize.Width() );
Size aSz( rSize );
- Size aScrollBarBoxSz( aScrollBarBox->GetSizePixel() );
- aSz.AdjustHeight( -(aScrollBarBoxSz.Height()) );
- aSz.AdjustHeight( -(aTabBarSize.Height()) );
+ auto nScrollBarSz(Application::GetSettings().GetStyleSettings().GetScrollBarSize());
+ aSz.AdjustHeight(-aTabBarSize.Height());
Size aOutSz( aSz );
- aSz.AdjustWidth( -(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() ) );
- aHScrollBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( aSz.Width(), aScrollBarBoxSz.Height() ) );
- pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aScrollBarBoxSz.Height()+aSz.Height()), aTabBarSize );
+ aSz.AdjustWidth(-nScrollBarSz);
+ aSz.AdjustHeight(-nScrollBarSz);
+ aVScrollBar->SetPosSizePixel( Point( rPos.X()+aSz.Width(), rPos.Y() ), Size( nScrollBarSz, aSz.Height() ) );
+ aHScrollBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( aOutSz.Width(), nScrollBarSz ) );
+ pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y() + nScrollBarSz + aSz.Height()), aTabBarSize );
+ // The size to be applied depends on whether it is a DialogWindow or a ModulWindow
if (pLayout)
- pLayout->SetPosSizePixel(rPos, dynamic_cast<DialogWindow*>(pCurWin.get()) ? aSz : aOutSz);
+ {
+ if (dynamic_cast<DialogWindow*>(pCurWin.get()))
+ {
+ pCurWin->ShowShellScrollBars();
+ pLayout->SetPosSizePixel(rPos, aSz);
+ }
+ else
+ {
+ pCurWin->ShowShellScrollBars(false);
+ pLayout->SetPosSizePixel(rPos, aOutSz);
+ }
+ }
}
Reference< XModel > Shell::GetCurrentDocument() const
diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx
index fedebcb1d98b..5bd69b76f380 100644
--- a/basctl/source/basicide/basides2.cxx
+++ b/basctl/source/basicide/basides2.cxx
@@ -56,7 +56,7 @@ bool Shell::HasSelection( bool /* bText */ ) const
return false;
}
-OUString Shell::GetSelectionText( bool bWholeWord )
+OUString Shell::GetSelectionText( bool bWholeWord, bool /*bOnlyASample*/ )
{
OUString aText;
if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get()))
@@ -82,7 +82,7 @@ SfxPrinter* Shell::GetPrinter( bool bCreate )
{
if ( pCurWin )
{
- DocShell* pDocShell = static_cast<DocShell*>(GetViewFrame()->GetObjectShell());
+ DocShell* pDocShell = static_cast<DocShell*>(GetViewFrame().GetObjectShell());
assert(pDocShell && "DocShell ?!");
return pDocShell->GetPrinter( bCreate );
}
@@ -91,7 +91,7 @@ SfxPrinter* Shell::GetPrinter( bool bCreate )
sal_uInt16 Shell::SetPrinter( SfxPrinter *pNewPrinter, SfxPrinterChangeFlags )
{
- DocShell* pDocShell = static_cast<DocShell*>(GetViewFrame()->GetObjectShell());
+ DocShell* pDocShell = static_cast<DocShell*>(GetViewFrame().GetObjectShell());
assert(pDocShell && "DocShell ?!");
pDocShell->SetPrinter( pNewPrinter );
return 0;
@@ -114,11 +114,8 @@ void Shell::SetMDITitle()
aTitle += " " + IDEResId(RID_STR_SIGNED) + " ";
}
- SfxViewFrame* pViewFrame = GetViewFrame();
- if ( !pViewFrame )
- return;
-
- SfxObjectShell* pShell = pViewFrame->GetObjectShell();
+ SfxViewFrame& rViewFrame = GetViewFrame();
+ SfxObjectShell* pShell = rViewFrame.GetObjectShell();
if ( pShell && pShell->GetTitle( SFX_TITLE_CAPTION ) != aTitle )
{
pShell->SetTitle( aTitle );
@@ -168,7 +165,7 @@ VclPtr<ModulWindow> Shell::CreateBasWin( const ScriptDocument& rDocument, const
{
// new module window
if (!pModulLayout)
- pModulLayout.reset(VclPtr<ModulWindowLayout>::Create(&GetViewFrame()->GetWindow(), *aObjectCatalog));
+ pModulLayout.reset(VclPtr<ModulWindowLayout>::Create(&GetViewFrame().GetWindow(), *aObjectCatalog));
pWin = VclPtr<ModulWindow>::Create(pModulLayout.get(), rDocument, aLibName, aModName, aModule);
nKey = InsertWindowInTable( pWin );
}
diff --git a/basctl/source/basicide/basides3.cxx b/basctl/source/basicide/basides3.cxx
index fb827a5104cc..44bc54ba624f 100644
--- a/basctl/source/basicide/basides3.cxx
+++ b/basctl/source/basicide/basides3.cxx
@@ -27,7 +27,7 @@
#include <sfx2/sfxsids.hrc>
#include <sfx2/viewfrm.hxx>
#include <tools/debug.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
@@ -81,7 +81,7 @@ VclPtr<DialogWindow> Shell::CreateDlgWin( const ScriptDocument& rDocument, const
// new dialog window
if (!pDialogLayout)
- pDialogLayout.reset(VclPtr<DialogWindowLayout>::Create(&GetViewFrame()->GetWindow(), *aObjectCatalog));
+ pDialogLayout.reset(VclPtr<DialogWindowLayout>::Create(&GetViewFrame().GetWindow(), *aObjectCatalog));
pWin = VclPtr<DialogWindow>::Create(pDialogLayout.get(), rDocument, aLibName, aDlgName, xDialogModel);
nKey = InsertWindowInTable( pWin );
}
diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx
index 0e85219824b2..9f08b9b00a8b 100644
--- a/basctl/source/basicide/basidesh.cxx
+++ b/basctl/source/basicide/basidesh.cxx
@@ -19,8 +19,10 @@
#include <config_options.h>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <basic/basmgr.hxx>
+#include <svx/zoomsliderctrl.hxx>
+#include <svx/zoomslideritem.hxx>
#include <svx/svxids.hrc>
#include <iderid.hxx>
#include <strings.hrc>
@@ -43,6 +45,7 @@
#include <sfx2/viewfrm.hxx>
#include <svl/srchitem.hxx>
#include <tools/debug.hxx>
+#include <unotools/viewoptions.hxx>
#if defined(DISABLE_DYNLOADING) || ENABLE_MERGELIBS
/* Avoid clash with the ones from svx/source/form/typemap.cxx */
@@ -71,9 +74,14 @@
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
#include <cppuhelper/implbase.hxx>
+#include <BasicColorConfig.hxx>
+#include <officecfg/Office/BasicIDE.hxx>
+#include <LineStatusControl.hxx>
namespace basctl
{
+constexpr OUString BASIC_IDE_EDITOR_WINDOW = u"BasicIDEEditorWindow"_ustr;
+constexpr OUString BASIC_IDE_CURRENT_ZOOM = u"CurrentZoom"_ustr;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
@@ -156,14 +164,13 @@ void basctl_Shell::InitInterface_Impl()
unsigned Shell::nShellCount = 0;
-Shell::Shell( SfxViewFrame* pFrame_, SfxViewShell* /* pOldShell */ ) :
- SfxViewShell( pFrame_, SfxViewShellFlags::NO_NEWWINDOW ),
+Shell::Shell( SfxViewFrame& rFrame_, SfxViewShell* /* pOldShell */ ) :
+ SfxViewShell( rFrame_, SfxViewShellFlags::NO_NEWWINDOW ),
m_aCurDocument( ScriptDocument::getApplicationScriptDocument() ),
- aHScrollBar( VclPtr<ScrollBar>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_HSCROLL | WB_DRAG )) ),
- aVScrollBar( VclPtr<ScrollBar>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_VSCROLL | WB_DRAG )) ),
- aScrollBarBox( VclPtr<ScrollBarBox>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_SIZEABLE )) ),
+ aHScrollBar( VclPtr<ScrollAdaptor>::Create(&GetViewFrame().GetWindow(), true) ),
+ aVScrollBar( VclPtr<ScrollAdaptor>::Create(&GetViewFrame().GetWindow(), false) ),
pLayout(nullptr),
- aObjectCatalog(VclPtr<ObjectCatalog>::Create(&GetViewFrame()->GetWindow())),
+ aObjectCatalog(VclPtr<ObjectCatalog>::Create(&GetViewFrame().GetWindow())),
m_bAppBasicModified( false ),
m_aNotifier( *this )
{
@@ -186,20 +193,31 @@ void Shell::Init()
LibBoxControl::RegisterControl( SID_BASICIDE_LIBSELECTOR );
LanguageBoxControl::RegisterControl( SID_BASICIDE_CURRENT_LANG );
+ SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER );
+ LineStatusControl::RegisterControl(SID_BASICIDE_STAT_POS);
- GetViewFrame()->GetWindow().SetBackground(
- GetViewFrame()->GetWindow().GetSettings().GetStyleSettings().GetWindowColor()
+ GetViewFrame().GetWindow().SetBackground(
+ GetViewFrame().GetWindow().GetSettings().GetStyleSettings().GetWindowColor()
);
+ // Used to access color settings of the Basic code editor
+ m_aColorConfig = std::make_shared<BasicColorConfig>();
+
pCurWin = nullptr;
m_aCurDocument = ScriptDocument::getApplicationScriptDocument();
bCreatingWindow = false;
- pTabBar.reset(VclPtr<TabBar>::Create(&GetViewFrame()->GetWindow()));
+ pTabBar.reset(VclPtr<TabBar>::Create(&GetViewFrame().GetWindow()));
nCurKey = 100;
InitScrollBars();
InitTabBar();
+ InitZoomLevel();
+
+ // Initialize the visibility of the Object Catalog
+ bool bObjCatVisible = ::officecfg::Office::BasicIDE::EditorSettings::ObjectCatalog::get();
+ if (!bObjCatVisible)
+ aObjectCatalog->Show(bObjCatVisible);
SetCurLib( ScriptDocument::getApplicationScriptDocument(), "Standard", false, false );
@@ -231,7 +249,6 @@ Shell::~Shell()
SetCurWindow( nullptr );
aObjectCatalog.disposeAndClear();
- aScrollBarBox.disposeAndClear();
aVScrollBar.disposeAndClear();
aHScrollBar.disposeAndClear();
@@ -255,6 +272,10 @@ Shell::~Shell()
pDialogLayout.disposeAndClear();
pModulLayout.disposeAndClear();
pTabBar.disposeAndClear();
+
+ // Remember current zoom level
+ SvtViewOptions(EViewType::Window, BASIC_IDE_EDITOR_WINDOW).SetUserItem(
+ BASIC_IDE_CURRENT_ZOOM, Any(m_nCurrentZoomSliderValue));
}
void Shell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
@@ -357,12 +378,50 @@ void Shell::onDocumentModeChanged( const ScriptDocument& _rDocument )
}
}
+void Shell::InitZoomLevel()
+{
+ m_nCurrentZoomSliderValue = DEFAULT_ZOOM_LEVEL;
+ SvtViewOptions aWinOpt(EViewType::Window, BASIC_IDE_EDITOR_WINDOW);
+ if (aWinOpt.Exists())
+ {
+ try
+ {
+ aWinOpt.GetUserItem(BASIC_IDE_CURRENT_ZOOM) >>= m_nCurrentZoomSliderValue;
+ }
+ catch(const css::container::NoSuchElementException&)
+ { TOOLS_WARN_EXCEPTION("basctl.basicide", "Zoom level not defined"); }
+ }
+}
+
+// Applies the new zoom level to all open editor windows
+void Shell::SetGlobalEditorZoomLevel(sal_uInt16 nNewZoomLevel)
+{
+ for (auto const& window : aWindowTable)
+ {
+ ModulWindow* pModuleWindow = dynamic_cast<ModulWindow*>(window.second.get());
+ if (pModuleWindow)
+ {
+ EditorWindow& pEditorWindow = pModuleWindow->GetEditorWindow();
+ pEditorWindow.SetEditorZoomLevel(nNewZoomLevel);
+ }
+ }
+
+ // Update the zoom slider value based on the new global zoom level
+ m_nCurrentZoomSliderValue = nNewZoomLevel;
+
+ if (SfxBindings* pBindings = GetBindingsPtr())
+ {
+ pBindings->Invalidate( SID_BASICIDE_CURRENT_ZOOM );
+ pBindings->Invalidate( SID_ATTR_ZOOMSLIDER );
+ }
+}
+
void Shell::StoreAllWindowData( bool bPersistent )
{
for (auto const& window : aWindowTable)
{
BaseWindow* pWin = window.second;
- DBG_ASSERT( pWin, "PrepareClose: NULL-Pointer in Table?" );
+ assert(pWin && "PrepareClose: NULL-Pointer in Table?");
if ( !pWin->IsSuspended() )
pWin->StoreData();
}
@@ -380,17 +439,16 @@ void Shell::StoreAllWindowData( bool bPersistent )
}
}
-
bool Shell::PrepareClose( bool bUI )
{
// reset here because it's modified after printing etc. (DocInfo)
- GetViewFrame()->GetObjectShell()->SetModified(false);
+ GetViewFrame().GetObjectShell()->SetModified(false);
if ( StarBASIC::IsRunning() )
{
if( bUI )
{
- std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetViewFrame()->GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetViewFrame().GetFrameWeld(),
VclMessageType::Info, VclButtonsType::Ok,
IDEResId(RID_STR_CANNOTCLOSE)));
xInfoBox->run();
@@ -410,14 +468,8 @@ void Shell::InitScrollBars()
aVScrollBar->SetPageSize( 2000 );
aHScrollBar->SetLineSize( 300 );
aHScrollBar->SetPageSize( 2000 );
- aHScrollBar->Enable();
- aVScrollBar->Enable();
- aVScrollBar->Show();
- aHScrollBar->Show();
- aScrollBarBox->Show();
}
-
void Shell::InitTabBar()
{
pTabBar->Enable();
@@ -425,13 +477,11 @@ void Shell::InitTabBar()
pTabBar->SetSelectHdl( LINK( this, Shell, TabBarHdl ) );
}
-
void Shell::OuterResizePixel( const Point &rPos, const Size &rSize )
{
AdjustPosSizePixel( rPos, rSize );
}
-
IMPL_LINK( Shell, TabBarHdl, ::TabBar *, pCurTabBar, void )
{
sal_uInt16 nCurId = pCurTabBar->GetCurPageId();
@@ -589,6 +639,9 @@ void Shell::UpdateWindows()
{
// remove all windows that may not be displayed
bool bChangeCurWindow = pCurWin == nullptr;
+ // stores the total number of modules and dialogs visible
+ sal_uInt16 nTotalTabs = 0;
+
if ( !m_aCurLibName.isEmpty() )
{
std::vector<VclPtr<BaseWindow> > aDeleteVec;
@@ -625,14 +678,8 @@ void Shell::UpdateWindows()
StartListening(*doc.getBasicManager(), DuplicateHandling::Prevent /* log on only once */);
// libraries
- Sequence< OUString > aLibNames( doc.getLibraryNames() );
- sal_Int32 nLibCount = aLibNames.getLength();
- const OUString* pLibNames = aLibNames.getConstArray();
-
- for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+ for (auto& aLibName : doc.getLibraryNames())
{
- OUString aLibName = pLibNames[ i ];
-
if ( m_aCurLibName.isEmpty() || ( doc == m_aCurDocument && aLibName == m_aCurLibName ) )
{
// check, if library is password protected and not verified
@@ -663,12 +710,10 @@ void Shell::UpdateWindows()
try
{
Sequence< OUString > aModNames( doc.getObjectNames( E_SCRIPTS, aLibName ) );
- sal_Int32 nModCount = aModNames.getLength();
- const OUString* pModNames = aModNames.getConstArray();
+ nTotalTabs += aModNames.getLength();
- for ( sal_Int32 j = 0 ; j < nModCount ; j++ )
+ for (auto& aModName : aModNames)
{
- OUString aModName = pModNames[ j ];
VclPtr<ModulWindow> pWin = FindBasWin( doc, aLibName, aModName );
if ( !pWin )
pWin = CreateBasWin( doc, aLibName, aModName );
@@ -692,12 +737,10 @@ void Shell::UpdateWindows()
try
{
Sequence< OUString > aDlgNames = doc.getObjectNames( E_DIALOGS, aLibName );
- sal_Int32 nDlgCount = aDlgNames.getLength();
- const OUString* pDlgNames = aDlgNames.getConstArray();
+ nTotalTabs += aDlgNames.getLength();
- for ( sal_Int32 j = 0 ; j < nDlgCount ; j++ )
+ for (auto& aDlgName : aDlgNames)
{
- OUString aDlgName = pDlgNames[ j ];
// this find only looks for non-suspended windows;
// suspended windows are handled in CreateDlgWin
VclPtr<DialogWindow> pWin = FindDlgWin( doc, aLibName, aDlgName );
@@ -722,7 +765,12 @@ void Shell::UpdateWindows()
if ( bChangeCurWindow )
{
- if ( !pNextActiveWindow )
+ if ( nTotalTabs == 0 )
+ {
+ // If no tabs are opened, create a generic module and make it visible
+ pNextActiveWindow = CreateBasWin( m_aCurDocument, m_aCurLibName, OUString() );
+ }
+ else if ( !pNextActiveWindow )
{
pNextActiveWindow = FindApplicationWindow().get();
}
@@ -734,7 +782,7 @@ void Shell::RemoveWindow( BaseWindow* pWindow_, bool bDestroy, bool bAllowChange
{
VclPtr<BaseWindow> pWindowTmp( pWindow_ );
- DBG_ASSERT( pWindow_, "Cannot delete NULL-Pointer!" );
+ assert(pWindow_ && "Cannot delete NULL-Pointer!");
sal_uInt16 nKey = GetWindowId( pWindow_ );
pTabBar->RemovePage( nKey );
aWindowTable.erase( nKey );
@@ -891,12 +939,6 @@ void Shell::InvalidateControlSlots()
pBindings->Invalidate( SID_CHOOSE_CONTROLS );
}
-void Shell::EnableScrollbars( bool bEnable )
-{
- aHScrollBar->Enable(bEnable);
- aVScrollBar->Enable(bEnable);
-}
-
void Shell::SetCurLib( const ScriptDocument& rDocument, const OUString& aLibName, bool bUpdateWindows, bool bCheck )
{
if ( bCheck && rDocument == m_aCurDocument && aLibName == m_aCurLibName )
diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx
index 9748b24ccd2f..0aa3b8b37bf5 100644
--- a/basctl/source/basicide/basobj2.cxx
+++ b/basctl/source/basicide/basobj2.cxx
@@ -34,7 +34,7 @@
#include <comphelper/sequence.hxx>
#include <framework/documentundoguard.hxx>
#include <sal/log.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <unotools/moduleoptions.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
@@ -62,24 +62,25 @@ extern "C" {
return pScriptURL;
}
- SAL_DLLPUBLIC_EXPORT void basicide_macro_organizer(void *pParent, sal_Int16 nTabId)
+ SAL_DLLPUBLIC_EXPORT void basicide_macro_organizer(void *pParent, void* pDocFrame_AsXFrame, sal_Int16 nTabId)
{
SAL_INFO("basctl.basicide","in basicide_macro_organizer");
- basctl::Organize(static_cast<weld::Window*>(pParent), nTabId);
+ Reference< frame::XFrame > aDocFrame( static_cast< frame::XFrame* >( pDocFrame_AsXFrame ) );
+ basctl::Organize(static_cast<weld::Window*>(pParent), aDocFrame, nTabId);
}
}
-void Organize(weld::Window* pParent, sal_Int16 tabId)
+void Organize(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 tabId)
{
EnsureIde();
- auto xDlg(std::make_shared<OrganizeDialog>(pParent, tabId));
+ auto xDlg(std::make_shared<OrganizeDialog>(pParent, xDocFrame, tabId));
weld::DialogController::runAsync(xDlg, [](int) {});
}
-bool IsValidSbxName( const OUString& rName )
+bool IsValidSbxName( std::u16string_view rName )
{
- for ( sal_Int32 nChar = 0; nChar < rName.getLength(); nChar++ )
+ for ( size_t nChar = 0; nChar < rName.size(); nChar++ )
{
sal_Unicode c = rName[nChar];
bool bValid = (
@@ -100,21 +101,15 @@ Sequence< OUString > GetMergedLibraryNames( const Reference< script::XLibraryCon
std::vector<OUString> aLibList;
if ( xModLibContainer.is() )
{
- Sequence< OUString > aModLibNames = xModLibContainer->getElementNames();
- sal_Int32 nModLibCount = aModLibNames.getLength();
- const OUString* pModLibNames = aModLibNames.getConstArray();
- for ( sal_Int32 i = 0 ; i < nModLibCount ; i++ )
- aLibList.push_back( pModLibNames[ i ] );
+ const Sequence< OUString > aModLibNames = xModLibContainer->getElementNames();
+ aLibList.insert( aLibList.end(), aModLibNames.begin(), aModLibNames.end() );
}
// create a list of dialog library names
if ( xDlgLibContainer.is() )
{
- Sequence< OUString > aDlgLibNames = xDlgLibContainer->getElementNames();
- sal_Int32 nDlgLibCount = aDlgLibNames.getLength();
- const OUString* pDlgLibNames = aDlgLibNames.getConstArray();
- for ( sal_Int32 i = 0 ; i < nDlgLibCount ; i++ )
- aLibList.push_back( pDlgLibNames[ i ] );
+ const Sequence< OUString > aDlgLibNames = xDlgLibContainer->getElementNames();
+ aLibList.insert( aLibList.end(), aDlgLibNames.begin(), aDlgLibNames.end() );
}
// sort list
@@ -166,27 +161,28 @@ bool RenameModule (
if ( !rDocument.renameModule( rLibName, rOldName, rNewName ) )
return false;
- if (Shell* pShell = GetShell())
- {
- if (VclPtr<ModulWindow> pWin = pShell->FindBasWin(rDocument, rLibName, rNewName, false, true))
- {
- // set new name in window
- pWin->SetName( rNewName );
+ Shell* pShell = GetShell();
+ if (!pShell)
+ return true;
+ VclPtr<ModulWindow> pWin = pShell->FindBasWin(rDocument, rLibName, rNewName, false, true);
+ if (!pWin)
+ return true;
- // set new module in module window
- pWin->SetSbModule( pWin->GetBasic()->FindModule( rNewName ) );
+ // set new name in window
+ pWin->SetName( rNewName );
- // update tabwriter
- sal_uInt16 nId = pShell->GetWindowId( pWin );
- SAL_WARN_IF( nId == 0 , "basctl.basicide", "No entry in Tabbar!");
- if ( nId )
- {
- TabBar& rTabBar = pShell->GetTabBar();
- rTabBar.SetPageText(nId, rNewName);
- rTabBar.Sort();
- rTabBar.MakeVisible(rTabBar.GetCurPageId());
- }
- }
+ // set new module in module window
+ pWin->SetSbModule( pWin->GetBasic()->FindModule( rNewName ) );
+
+ // update tabwriter
+ sal_uInt16 nId = pShell->GetWindowId( pWin );
+ SAL_WARN_IF( nId == 0 , "basctl.basicide", "No entry in Tabbar!");
+ if ( nId )
+ {
+ TabBar& rTabBar = pShell->GetTabBar();
+ rTabBar.SetPageText(nId, rNewName);
+ rTabBar.Sort();
+ rTabBar.MakeVisible(rTabBar.GetCurPageId());
}
return true;
}
@@ -221,9 +217,9 @@ namespace
// in case this is a document-local macro, try to protect the document's Undo Manager from
// flawed scripts
- std::unique_ptr< ::framework::DocumentUndoGuard > pUndoGuard;
+ std::optional< ::framework::DocumentUndoGuard > pUndoGuard;
if ( pData->aDocument.isDocument() )
- pUndoGuard.reset( new ::framework::DocumentUndoGuard( pData->aDocument.getDocument() ) );
+ pUndoGuard.emplace( pData->aDocument.getDocument() );
RunMethod( pData->xMethod.get() );
}
@@ -395,7 +391,7 @@ Sequence< OUString > GetMethodNames( const ScriptDocument& rDocument, const OUSt
SbMethod* pMethod = static_cast<SbMethod*>(pMod->GetMethods()->Get(i));
if( pMethod->IsHidden() )
continue;
- SAL_WARN_IF( !pMethod, "basctl.basicide","Method not found! (NULL)" );
+ assert(pMethod && "Method not found! (NULL)");
aSeqMethods.getArray()[ iTarget++ ] = pMethod->GetName();
}
}
diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx
index fa7c2fc3d220..f8af9e037b60 100644
--- a/basctl/source/basicide/basobj3.cxx
+++ b/basctl/source/basicide/basobj3.cxx
@@ -48,7 +48,6 @@
namespace basctl
{
-using namespace comphelper;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::container;
@@ -105,9 +104,7 @@ SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName )
aOUSource = aOUSource.copy( 0, nSourceLen-1 );
}
- OUString aSubStr = "Sub " + aMacroName + "\n\nEnd Sub";
-
- aOUSource += aSubStr;
+ aOUSource += "Sub " + aMacroName + "\n\nEnd Sub";
// update module in library
StarBASIC* pBasic = dynamic_cast<StarBASIC*>(pModule->GetParent());
@@ -119,6 +116,7 @@ SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName )
if (aDocument.isValid())
{
+ assert(pBasic && "isValid cannot be false with !pBasic");
const OUString& aLibName = pBasic->GetName();
const OUString& aModName = pModule->GetName();
OSL_VERIFY( aDocument.updateModule( aLibName, aModName, aOUSource ) );
@@ -180,24 +178,24 @@ bool RenameDialog (
if ( !rDocument.renameDialog( rLibName, rOldName, rNewName, xExistingDialog ) )
return false;
- if (pWin && pShell)
- {
- // set new name in window
- pWin->SetName( rNewName );
+ if (!pWin || !pShell)
+ return true;
- // update property browser
- pWin->UpdateBrowser();
+ // set new name in window
+ pWin->SetName( rNewName );
- // update tabwriter
- sal_uInt16 nId = pShell->GetWindowId( pWin );
- DBG_ASSERT( nId, "No entry in Tabbar!" );
- if ( nId )
- {
- TabBar& rTabBar = pShell->GetTabBar();
- rTabBar.SetPageText( nId, rNewName );
- rTabBar.Sort();
- rTabBar.MakeVisible( rTabBar.GetCurPageId() );
- }
+ // update property browser
+ pWin->UpdateBrowser();
+
+ // update tabwriter
+ sal_uInt16 nId = pShell->GetWindowId( pWin );
+ DBG_ASSERT( nId, "No entry in Tabbar!" );
+ if ( nId )
+ {
+ TabBar& rTabBar = pShell->GetTabBar();
+ rTabBar.SetPageText( nId, rNewName );
+ rTabBar.Sort();
+ rTabBar.MakeVisible( rTabBar.GetCurPageId() );
}
return true;
}
@@ -234,13 +232,9 @@ BasicManager* FindBasicManager( StarBASIC const * pLib )
if ( !pBasicMgr )
continue;
- Sequence< OUString > aLibNames( doc.getLibraryNames() );
- sal_Int32 nLibCount = aLibNames.getLength();
- const OUString* pLibNames = aLibNames.getConstArray();
-
- for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+ for (auto& rLibName : doc.getLibraryNames())
{
- StarBASIC* pL = pBasicMgr->GetLib( pLibNames[ i ] );
+ StarBASIC* pL = pBasicMgr->GetLib(rLibName);
if ( pL == pLib )
return pBasicMgr;
}
@@ -323,19 +317,19 @@ void BasicStopped(
if (Shell* pShell = GetShell())
{
sal_uInt16 nWait = 0;
- while ( pShell->GetViewFrame()->GetWindow().IsWait() )
+ while ( pShell->GetViewFrame().GetWindow().IsWait() )
{
- pShell->GetViewFrame()->GetWindow().LeaveWait();
+ pShell->GetViewFrame().GetWindow().LeaveWait();
nWait++;
}
if ( pnWaitCount )
*pnWaitCount = nWait;
}
- vcl::Window* pDefParent = Application::GetDefDialogParent();
- if ( pDefParent && !pDefParent->IsEnabled() )
+ weld::Window* pDefParent = Application::GetDefDialogParent();
+ if (pDefParent && !pDefParent->get_sensitive())
{
- pDefParent->Enable();
+ pDefParent->set_sensitive(true);
if ( pbAppWindowDisabled )
*pbAppWindowDisabled = true;
}
@@ -432,7 +426,7 @@ SfxBindings* GetBindingsPtr()
SfxViewFrame* pFrame = nullptr;
if (Shell* pShell = GetShell())
{
- pFrame = pShell->GetViewFrame();
+ pFrame = &pShell->GetViewFrame();
}
else
{
@@ -456,9 +450,11 @@ SfxBindings* GetBindingsPtr()
SfxDispatcher* GetDispatcher ()
{
if (Shell* pShell = GetShell())
- if (SfxViewFrame* pViewFrame = pShell->GetViewFrame())
- if (SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher())
- return pDispatcher;
+ {
+ SfxViewFrame& rViewFrame = pShell->GetViewFrame();
+ if (SfxDispatcher* pDispatcher = rViewFrame.GetDispatcher())
+ return pDispatcher;
+ }
return nullptr;
}
} // namespace basctl
diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
index eed521ce3fd6..352742be8a4e 100644
--- a/basctl/source/basicide/bastype2.cxx
+++ b/basctl/source/basicide/bastype2.cxx
@@ -25,13 +25,14 @@
#include <bitmaps.hlst>
#include <iderid.hxx>
#include <tools/urlobj.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <svtools/imagemgr.hxx>
#include <com/sun/star/script/XLibraryContainerPassword.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <comphelper/processfactory.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/sfxsids.hrc>
+#include <svl/itemset.hxx>
#include <initializer_list>
#include <memory>
@@ -41,6 +42,7 @@
#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/container/XNamed.hpp>
+#include <utility>
namespace basctl
{
@@ -87,12 +89,12 @@ Entry::~Entry()
{ }
DocumentEntry::DocumentEntry (
- ScriptDocument const& rDocument,
+ ScriptDocument aDocument,
LibraryLocation eLocation,
EntryType eType
) :
Entry(eType),
- m_aDocument(rDocument),
+ m_aDocument(std::move(aDocument)),
m_eLocation(eLocation)
{
OSL_ENSURE( m_aDocument.isValid(), "DocumentEntry::DocumentEntry: illegal document!" );
@@ -104,10 +106,10 @@ DocumentEntry::~DocumentEntry()
LibEntry::LibEntry (
ScriptDocument const& rDocument,
LibraryLocation eLocation,
- OUString const& rLibName
+ OUString aLibName
) :
DocumentEntry(rDocument, eLocation, OBJ_TYPE_LIBRARY),
- m_aLibName(rLibName)
+ m_aLibName(std::move(aLibName))
{ }
LibEntry::~LibEntry()
@@ -120,38 +122,38 @@ EntryDescriptor::EntryDescriptor () :
{ }
EntryDescriptor::EntryDescriptor (
- ScriptDocument const& rDocument,
+ ScriptDocument aDocument,
LibraryLocation eLocation,
- OUString const& rLibName,
- OUString const& rLibSubName,
- OUString const& rName,
+ OUString aLibName,
+ OUString aLibSubName,
+ OUString aName,
EntryType eType
) :
- m_aDocument(rDocument),
+ m_aDocument(std::move(aDocument)),
m_eLocation(eLocation),
- m_aLibName(rLibName),
- m_aLibSubName(rLibSubName),
- m_aName(rName),
+ m_aLibName(std::move(aLibName)),
+ m_aLibSubName(std::move(aLibSubName)),
+ m_aName(std::move(aName)),
m_eType(eType)
{
OSL_ENSURE( m_aDocument.isValid(), "EntryDescriptor::EntryDescriptor: invalid document!" );
}
EntryDescriptor::EntryDescriptor (
- ScriptDocument const& rDocument,
+ ScriptDocument aDocument,
LibraryLocation eLocation,
- OUString const& rLibName,
- OUString const& rLibSubName,
- OUString const& rName,
- OUString const& rMethodName,
+ OUString aLibName,
+ OUString aLibSubName,
+ OUString aName,
+ OUString aMethodName,
EntryType eType
) :
- m_aDocument(rDocument),
+ m_aDocument(std::move(aDocument)),
m_eLocation(eLocation),
- m_aLibName(rLibName),
- m_aLibSubName(rLibSubName),
- m_aName(rName),
- m_aMethodName(rMethodName),
+ m_aLibName(std::move(aLibName)),
+ m_aLibSubName(std::move(aLibSubName)),
+ m_aName(std::move(aName)),
+ m_aMethodName(std::move(aMethodName)),
m_eType(eType)
{
OSL_ENSURE( m_aDocument.isValid(), "EntryDescriptor::EntryDescriptor: invalid document!" );
@@ -176,7 +178,7 @@ SbTreeListBox::~SbTreeListBox()
bool bValidIter = m_xControl->get_iter_first(*m_xScratchIter);
while (bValidIter)
{
- Entry* pBasicEntry = reinterpret_cast<Entry*>(m_xControl->get_id(*m_xScratchIter).toInt64());
+ Entry* pBasicEntry = weld::fromId<Entry*>(m_xControl->get_id(*m_xScratchIter));
delete pBasicEntry;
bValidIter = m_xControl->iter_next(*m_xScratchIter);
}
@@ -206,14 +208,8 @@ void SbTreeListBox::ScanEntry( const ScriptDocument& rDocument, LibraryLocation
void SbTreeListBox::ImpCreateLibEntries(const weld::TreeIter& rIter, const ScriptDocument& rDocument, LibraryLocation eLocation)
{
// get a sorted list of library names
- Sequence< OUString > aLibNames( rDocument.getLibraryNames() );
- sal_Int32 nLibCount = aLibNames.getLength();
- const OUString* pLibNames = aLibNames.getConstArray();
-
- for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+ for (auto& aLibName : rDocument.getLibraryNames())
{
- OUString aLibName = pLibNames[ i ];
-
if ( eLocation == rDocument.getLibraryLocation( aLibName ) )
{
// check, if the module library is loaded
@@ -243,9 +239,9 @@ void SbTreeListBox::ImpCreateLibEntries(const weld::TreeIter& rIter, const Scrip
// create tree list box entry
OUString sId;
if ( ( nMode & BrowseMode::Dialogs ) && !( nMode & BrowseMode::Modules ) )
- sId = bLoaded ? std::u16string_view(u"" RID_BMP_DLGLIB) : std::u16string_view(u"" RID_BMP_DLGLIBNOTLOADED);
+ sId = bLoaded ? RID_BMP_DLGLIB : RID_BMP_DLGLIBNOTLOADED;
else
- sId = bLoaded ? OUStringLiteral(u"" RID_BMP_MODLIB) : OUStringLiteral(u"" RID_BMP_MODLIBNOTLOADED);
+ sId = bLoaded ? RID_BMP_MODLIB : RID_BMP_MODLIBNOTLOADED;
std::unique_ptr<weld::TreeIter> xLibRootEntry(m_xControl->make_iterator(&rIter));
bool bLibRootEntry = FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xLibRootEntry);
if (bLibRootEntry)
@@ -282,15 +278,10 @@ void SbTreeListBox::ImpCreateLibSubEntries(const weld::TreeIter& rLibRootEntry,
else
{
// get a sorted list of module names
- Sequence< OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
- sal_Int32 nModCount = aModNames.getLength();
- const OUString* pModNames = aModNames.getConstArray();
-
auto xTreeIter = m_xControl->make_iterator();
- for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
+ for (auto& aModName : rDocument.getObjectNames(E_SCRIPTS, rLibName))
{
- OUString aModName = pModNames[ i ];
m_xControl->copy_iterator(rLibRootEntry, *xTreeIter);
bool bModuleEntry = FindEntry(aModName, OBJ_TYPE_MODULE, *xTreeIter);
if (!bModuleEntry)
@@ -301,15 +292,10 @@ void SbTreeListBox::ImpCreateLibSubEntries(const weld::TreeIter& rLibRootEntry,
// methods
if ( nMode & BrowseMode::Subs )
{
- Sequence< OUString > aNames = GetMethodNames( rDocument, rLibName, aModName );
- sal_Int32 nCount = aNames.getLength();
- const OUString* pNames = aNames.getConstArray();
-
auto xSubTreeIter = m_xControl->make_iterator();
- for ( sal_Int32 j = 0 ; j < nCount ; j++ )
+ for (auto& aName : GetMethodNames(rDocument, rLibName, aModName))
{
- OUString aName = pNames[ j ];
m_xControl->copy_iterator(*xTreeIter, *xSubTreeIter);
bool bEntry = FindEntry(aName, OBJ_TYPE_METHOD, *xSubTreeIter);
if (!bEntry)
@@ -340,15 +326,10 @@ void SbTreeListBox::ImpCreateLibSubEntries(const weld::TreeIter& rLibRootEntry,
try
{
// get a sorted list of dialog names
- Sequence< OUString > aDlgNames( rDocument.getObjectNames( E_DIALOGS, rLibName ) );
- sal_Int32 nDlgCount = aDlgNames.getLength();
- const OUString* pDlgNames = aDlgNames.getConstArray();
-
auto xTreeIter = m_xControl->make_iterator();
- for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
+ for (auto& aDlgName : rDocument.getObjectNames(E_DIALOGS, rLibName))
{
- OUString aDlgName = pDlgNames[ i ];
m_xControl->copy_iterator(rLibRootEntry, *xTreeIter);
bool bDialogEntry = FindEntry(aDlgName, OBJ_TYPE_DIALOG, *xTreeIter);
if (!bDialogEntry)
@@ -399,16 +380,11 @@ void SbTreeListBox::ImpCreateLibSubSubEntriesInVBAMode(const weld::TreeIter& rLi
try
{
// get a sorted list of module names
- Sequence< OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
- sal_Int32 nModCount = aModNames.getLength();
- const OUString* pModNames = aModNames.getConstArray();
-
EntryDescriptor aDesc(GetEntryDescriptor(&rLibSubRootEntry));
EntryType eCurrentType(aDesc.GetType());
- for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
+ for (auto& aModName : rDocument.getObjectNames(E_SCRIPTS, rLibName))
{
- OUString aModName = pModNames[ i ];
EntryType eType = OBJ_TYPE_UNKNOWN;
switch( ModuleInfoHelper::getModuleType( xLib, aModName ) )
{
@@ -452,13 +428,8 @@ void SbTreeListBox::ImpCreateLibSubSubEntriesInVBAMode(const weld::TreeIter& rLi
// methods
if ( nMode & BrowseMode::Subs )
{
- Sequence< OUString > aNames = GetMethodNames( rDocument, rLibName, aModName );
- sal_Int32 nCount = aNames.getLength();
- const OUString* pNames = aNames.getConstArray();
-
- for ( sal_Int32 j = 0 ; j < nCount ; j++ )
+ for (auto& aName : GetMethodNames(rDocument, rLibName, aModName))
{
- OUString aName = pNames[ j ];
std::unique_ptr<weld::TreeIter> xEntry(m_xControl->make_iterator(xModuleEntry.get()));
bool bEntry = FindEntry(aName, OBJ_TYPE_METHOD, *xEntry);
if (!bEntry)
@@ -577,7 +548,7 @@ void SbTreeListBox::RemoveEntry(const weld::TreeIter& rIter)
}
// removing the associated user data
- Entry* pBasicEntry = reinterpret_cast<Entry*>(m_xControl->get_id(rIter).toInt64());
+ Entry* pBasicEntry = weld::fromId<Entry*>(m_xControl->get_id(rIter));
delete pBasicEntry;
// removing the entry
m_xControl->remove(rIter);
@@ -604,7 +575,7 @@ bool SbTreeListBox::FindEntry(std::u16string_view rText, EntryType eType, weld::
bool bValidIter = m_xControl->iter_children(rIter);
while (bValidIter)
{
- Entry* pBasicEntry = reinterpret_cast<Entry*>(m_xControl->get_id(rIter).toInt64());
+ Entry* pBasicEntry = weld::fromId<Entry*>(m_xControl->get_id(rIter));
assert(pBasicEntry && "FindEntry: no Entry ?!");
if (pBasicEntry->GetType() == eType && rText == m_xControl->get_text(rIter))
return true;
@@ -654,7 +625,7 @@ void SbTreeListBox::AddEntry(
std::unique_ptr<weld::TreeIter> xScratch = pRet ? nullptr : m_xControl->make_iterator();
if (!pRet)
pRet = xScratch.get();
- OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(rUserData.release())));
+ OUString sId(weld::toId(rUserData.release()));
m_xControl->insert(pParent, -1, &rText, &sId, nullptr, nullptr, bChildrenOnDemand, pRet);
m_xControl->set_image(*pRet, rImage);
}
@@ -695,13 +666,11 @@ OUString SbTreeListBox::GetRootEntryBitmaps(const ScriptDocument& rDocument)
OUString sModule( xModuleManager->identify( rDocument.getDocument() ) );
Sequence< beans::PropertyValue > aModuleDescr;
xModuleManager->getByName( sModule ) >>= aModuleDescr;
- sal_Int32 nCount = aModuleDescr.getLength();
- const beans::PropertyValue* pModuleDescr = aModuleDescr.getConstArray();
- for ( sal_Int32 i = 0; i < nCount; ++i )
+ for (auto& rModuleDescr : aModuleDescr)
{
- if ( pModuleDescr[ i ].Name == "ooSetupFactoryEmptyDocumentURL" )
+ if (rModuleDescr.Name == "ooSetupFactoryEmptyDocumentURL")
{
- pModuleDescr[ i ].Value >>= sFactoryURL;
+ rModuleDescr.Value >>= sFactoryURL;
break;
}
}
diff --git a/basctl/source/basicide/bastype3.cxx b/basctl/source/basicide/bastype3.cxx
index 5e409a267423..d26ae83252f6 100644
--- a/basctl/source/basicide/bastype3.cxx
+++ b/basctl/source/basicide/bastype3.cxx
@@ -101,8 +101,8 @@ IMPL_LINK(SbTreeListBox, RequestingChildrenHdl, const weld::TreeIter&, rEntry, b
// exchange image
const bool bDlgMode = (nMode & BrowseMode::Dialogs) && !(nMode & BrowseMode::Modules);
- auto const aImage(bDlgMode ? std::u16string_view(u"" RID_BMP_DLGLIB) : std::u16string_view(u"" RID_BMP_MODLIB));
- SetEntryBitmaps(rEntry, OUString(aImage));
+ auto const aImage(bDlgMode ? RID_BMP_DLGLIB : RID_BMP_MODLIB);
+ SetEntryBitmaps(rEntry, aImage);
}
else
{
@@ -156,7 +156,7 @@ SbxVariable* SbTreeListBox::FindVariable(const weld::TreeIter* pEntry)
do
{
sal_uInt16 nDepth = m_xControl->get_iter_depth(*xIter);
- Entry* pBE = reinterpret_cast<Entry*>(m_xControl->get_id(*xIter).toInt64());
+ Entry* pBE = weld::fromId<Entry*>(m_xControl->get_id(*xIter));
switch (nDepth)
{
case 4:
@@ -257,7 +257,7 @@ EntryDescriptor SbTreeListBox::GetEntryDescriptor(const weld::TreeIter* pEntry)
do
{
sal_uInt16 nDepth = m_xControl->get_iter_depth(*xIter);
- Entry* pBE = reinterpret_cast<Entry*>(m_xControl->get_id(*xIter).toInt64());
+ Entry* pBE = weld::fromId<Entry*>(m_xControl->get_id(*xIter));
switch (nDepth)
{
case 4:
@@ -355,7 +355,7 @@ ItemType SbTreeListBox::ConvertType (EntryType eType)
}
}
-bool SbTreeListBox::IsValidEntry(weld::TreeIter& rEntry)
+bool SbTreeListBox::IsValidEntry(const weld::TreeIter& rEntry)
{
bool bIsValid = false;
@@ -421,7 +421,7 @@ bool SbTreeListBox::FindRootEntry( const ScriptDocument& rDocument, LibraryLocat
bool bValidIter = m_xControl->get_iter_first(rIter);
while (bValidIter)
{
- DocumentEntry* pBDEntry = reinterpret_cast<DocumentEntry*>(m_xControl->get_id(rIter).toInt64());
+ DocumentEntry* pBDEntry = weld::fromId<DocumentEntry*>(m_xControl->get_id(rIter));
if (pBDEntry && pBDEntry->GetDocument() == rDocument && pBDEntry->GetLocation() == eLocation)
return true;
bValidIter = m_xControl->iter_next_sibling(rIter);
diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx
index 34f17ea7677f..e436bc9f7e0a 100644
--- a/basctl/source/basicide/bastypes.cxx
+++ b/basctl/source/basicide/bastypes.cxx
@@ -35,11 +35,15 @@
#include <com/sun/star/script/XLibraryContainerPassword.hpp>
#include <sal/log.hxx>
#include <sfx2/dispatch.hxx>
+#include <sfx2/infobar.hxx>
#include <sfx2/passwd.hxx>
#include <sfx2/sfxsids.hrc>
+#include <sfx2/viewfrm.hxx>
#include <svl/intitem.hxx>
#include <svl/stritem.hxx>
#include <svl/srchdefs.hxx>
+#include <svl/itemset.hxx>
+#include <utility>
#include <vcl/commandevent.hxx>
#include <vcl/event.hxx>
#include <vcl/svapp.hxx>
@@ -50,17 +54,20 @@
namespace basctl
{
+// ID used for the read-only infobar
+constexpr OUString BASIC_IDE_READONLY_INFOBAR = u"readonly"_ustr;
+
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
-BaseWindow::BaseWindow( vcl::Window* pParent, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName )
+BaseWindow::BaseWindow( vcl::Window* pParent, ScriptDocument aDocument, OUString aLibName, OUString aName )
:Window( pParent, WinBits( WB_3DLOOK ) )
,pShellHScrollBar( nullptr)
,pShellVScrollBar( nullptr)
,nStatus( 0)
- ,m_aDocument( rDocument )
- ,m_aLibName( aLibName )
- ,m_aName( aName )
+ ,m_aDocument(std::move( aDocument ))
+ ,m_aLibName(std::move( aLibName ))
+ ,m_aName(std::move( aName ))
{
}
@@ -71,55 +78,63 @@ BaseWindow::~BaseWindow()
void BaseWindow::dispose()
{
- if ( pShellVScrollBar )
- pShellVScrollBar->SetScrollHdl( Link<ScrollBar*,void>() );
- if ( pShellHScrollBar )
- pShellHScrollBar->SetScrollHdl( Link<ScrollBar*,void>() );
+ if (pShellVScrollBar && !pShellVScrollBar->isDisposed())
+ pShellVScrollBar->SetScrollHdl( Link<weld::Scrollbar&,void>() );
+ if (pShellHScrollBar && !pShellHScrollBar->isDisposed())
+ pShellHScrollBar->SetScrollHdl( Link<weld::Scrollbar&,void>() );
pShellVScrollBar.clear();
pShellHScrollBar.clear();
vcl::Window::dispose();
}
-
void BaseWindow::Init()
{
if ( pShellVScrollBar )
- pShellVScrollBar->SetScrollHdl( LINK( this, BaseWindow, ScrollHdl ) );
+ pShellVScrollBar->SetScrollHdl( LINK( this, BaseWindow, VertScrollHdl ) );
if ( pShellHScrollBar )
- pShellHScrollBar->SetScrollHdl( LINK( this, BaseWindow, ScrollHdl ) );
+ pShellHScrollBar->SetScrollHdl( LINK( this, BaseWindow, HorzScrollHdl ) );
+
+ // Show the read-only infobar if the module/dialog is read-only
+ GetShell()->GetViewFrame().RemoveInfoBar(BASIC_IDE_READONLY_INFOBAR);
+ if (IsReadOnly())
+ ShowReadOnlyInfoBar();
+
DoInit(); // virtual...
}
-
void BaseWindow::DoInit()
-{ }
-
+{
+}
-void BaseWindow::GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll )
+void BaseWindow::GrabScrollBars(ScrollAdaptor* pHScroll, ScrollAdaptor* pVScroll)
{
pShellHScrollBar = pHScroll;
pShellVScrollBar = pVScroll;
-// Init(); // does not make sense, leads to flickering and errors...
}
+IMPL_LINK_NOARG(BaseWindow, VertScrollHdl, weld::Scrollbar&, void)
+{
+ DoScroll(pShellVScrollBar);
+}
-IMPL_LINK( BaseWindow, ScrollHdl, ScrollBar *, pCurScrollBar, void )
+IMPL_LINK_NOARG(BaseWindow, HorzScrollHdl, weld::Scrollbar&, void)
{
- DoScroll( pCurScrollBar );
+ DoScroll(pShellHScrollBar);
}
void BaseWindow::ExecuteCommand (SfxRequest&)
-{ }
+{
+}
void BaseWindow::ExecuteGlobal (SfxRequest&)
-{ }
-
+{
+}
bool BaseWindow::EventNotify( NotifyEvent& rNEvt )
{
bool bDone = false;
- if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
+ if ( rNEvt.GetType() == NotifyEventType::KEYINPUT )
{
KeyEvent aKEvt = *rNEvt.GetKeyEvent();
vcl::KeyCode aCode = aKEvt.GetKeyCode();
@@ -144,11 +159,39 @@ bool BaseWindow::EventNotify( NotifyEvent& rNEvt )
return bDone || Window::EventNotify( rNEvt );
}
-
-void BaseWindow::DoScroll( ScrollBar* )
+void BaseWindow::ShowShellScrollBars(bool bVisible)
{
+ if (bVisible)
+ {
+ if (pShellHScrollBar)
+ {
+ pShellHScrollBar->Enable();
+ pShellHScrollBar->Show();
+ }
+ if (pShellVScrollBar)
+ {
+ pShellVScrollBar->Enable();
+ pShellVScrollBar->Show();
+ }
+ }
+ else
+ {
+ if (pShellHScrollBar)
+ {
+ pShellHScrollBar->Disable();
+ pShellHScrollBar->Hide();
+ }
+ if (pShellVScrollBar)
+ {
+ pShellVScrollBar->Disable();
+ pShellVScrollBar->Hide();
+ }
+ }
}
+void BaseWindow::DoScroll( Scrollable* )
+{
+}
void BaseWindow::StoreData()
{
@@ -159,7 +202,6 @@ bool BaseWindow::AllowUndo()
return true;
}
-
void BaseWindow::UpdateData()
{
}
@@ -190,6 +232,19 @@ bool BaseWindow::IsReadOnly ()
return false;
}
+// Show the read-only warning messages for module and dialog windows
+void BaseWindow::ShowReadOnlyInfoBar()
+{
+ OUString aMsg;
+ if (dynamic_cast<ModulWindow*>(this))
+ aMsg = IDEResId(RID_STR_MODULE_READONLY);
+ else
+ aMsg = IDEResId(RID_STR_DIALOG_READONLY);
+
+ GetShell()->GetViewFrame().AppendInfoBar(BASIC_IDE_READONLY_INFOBAR, OUString(),
+ aMsg, InfobarType::INFO, true);
+}
+
void BaseWindow::BasicStarted()
{
}
@@ -259,12 +314,12 @@ WinBits const DockingWindow::StyleBits =
WB_BORDER | WB_3DLOOK | WB_CLIPCHILDREN |
WB_MOVEABLE | WB_SIZEABLE | WB_DOCKABLE;
-DockingWindow::DockingWindow(vcl::Window* pParent, const OUString& rUIXMLDescription, const OString& rID)
+DockingWindow::DockingWindow(vcl::Window* pParent, const OUString& rUIXMLDescription, const OUString& rID)
: ResizableDockingWindow(pParent)
+ , m_xBuilder(Application::CreateInterimBuilder(m_xBox.get(), rUIXMLDescription, true))
, pLayout(nullptr)
, nShowCount(0)
{
- m_xBuilder.reset(Application::CreateInterimBuilder(m_xBox.get(), rUIXMLDescription, true));
m_xContainer = m_xBuilder->weld_container(rID);
}
@@ -341,7 +396,7 @@ void DockingWindow::Hide ()
bool DockingWindow::Docking( const Point& rPos, tools::Rectangle& rRect )
{
- if (aDockingRect.IsInside(rPos))
+ if (aDockingRect.Contains(rPos))
{
rRect.SetSize(aDockingRect.GetSize());
return false; // dock
@@ -583,9 +638,7 @@ void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines )
else
nEndPos++;
- OUString aEndStr = rStr.copy( nEndPos );
- rStr = rStr.copy( 0, nStartPos );
- rStr += aEndStr;
+ rStr = OUString::Concat(rStr.subView( 0, nStartPos )) + rStr.subView( nEndPos );
// erase trailing empty lines
{
@@ -599,9 +652,7 @@ void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines )
if ( n > nStartPos )
{
- aEndStr = rStr.copy( n );
- rStr = rStr.copy( 0, nStartPos );
- rStr += aEndStr;
+ rStr = OUString::Concat(rStr.subView( 0, nStartPos )) + rStr.subView( n );
}
}
}
@@ -667,8 +718,8 @@ LibInfo::Item const* LibInfo::GetInfo (
return it != m_aMap.end() ? &it->second : nullptr;
}
-LibInfo::Key::Key (ScriptDocument const& rDocument, OUString const& rLibName) :
- m_aDocument(rDocument), m_aLibName(rLibName)
+LibInfo::Key::Key (ScriptDocument aDocument, OUString aLibName) :
+ m_aDocument(std::move(aDocument)), m_aLibName(std::move(aLibName))
{ }
bool LibInfo::Key::operator == (Key const& rKey) const
@@ -685,10 +736,10 @@ size_t LibInfo::Key::Hash::operator () (Key const& rKey) const
}
LibInfo::Item::Item (
- OUString const& rCurrentName,
+ OUString aCurrentName,
ItemType eCurrentType
) :
- m_aCurrentName(rCurrentName),
+ m_aCurrentName(std::move(aCurrentName)),
m_eCurrentType(eCurrentType)
{ }
diff --git a/basctl/source/basicide/brkdlg.cxx b/basctl/source/basicide/brkdlg.cxx
index 6a79d0e1da54..f39255371b19 100644
--- a/basctl/source/basicide/brkdlg.cxx
+++ b/basctl/source/basicide/brkdlg.cxx
@@ -25,18 +25,15 @@
#include <sfx2/dispatch.hxx>
#include <sfx2/sfxsids.hrc>
+#include <svl/itemset.hxx>
namespace basctl
{
-// FIXME Why does BreakPointDialog allow only sal_uInt16 for break-point line
-// numbers, whereas BreakPoint supports sal_uLong?
-
namespace
{
bool lcl_ParseText(OUString const& rText, size_t& rLineNr)
{
- // aText should look like "# n" where
- // n > 0 && n < std::numeric_limits< sal_uInt16 >::max().
+ // aText should look like "# n" where n > 0
// 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.)
@@ -48,7 +45,6 @@ bool lcl_ParseText(OUString const& rText, size_t& rLineNr)
return false;
if (cFirst == '#')
aText = aText.copy(1);
- // XXX Assumes that sal_uInt16 is contained within sal_Int32:
sal_Int32 n = aText.toInt32();
if (n <= 0)
return false;
@@ -125,16 +121,14 @@ void BreakPointDialog::CheckButtons()
m_xNewButton->set_sensitive(true);
m_xOKButton->set_sensitive(false);
m_xDelButton->set_sensitive(false);
- m_xDelButton->set_has_default(false);
- m_xNewButton->set_has_default(true);
+ m_xDialog->change_default_widget(m_xDelButton.get(), m_xNewButton.get());
}
else
{
m_xNewButton->set_sensitive(false);
m_xOKButton->set_sensitive(true);
m_xDelButton->set_sensitive(true);
- m_xNewButton->set_has_default(false);
- m_xDelButton->set_has_default(true);
+ m_xDialog->change_default_widget(m_xNewButton.get(), m_xDelButton.get());
}
}
diff --git a/basctl/source/basicide/doceventnotifier.cxx b/basctl/source/basicide/doceventnotifier.cxx
index 83d2ea04dff3..254c719bb5cc 100644
--- a/basctl/source/basicide/doceventnotifier.cxx
+++ b/basctl/source/basicide/doceventnotifier.cxx
@@ -24,13 +24,10 @@
#include <vcl/svapp.hxx>
-#include <tools/diagnose_ex.h>
-
+#include <comphelper/compbase.hxx>
+#include <comphelper/diagnose_ex.hxx>
#include <comphelper/processfactory.hxx>
-#include <cppuhelper/compbase.hxx>
-#include <cppuhelper/basemutex.hxx>
-
namespace basctl
{
@@ -47,7 +44,7 @@ namespace basctl
// DocumentEventNotifier::Impl
- typedef ::cppu::WeakComponentImplHelper< XDocumentEventListener
+ typedef ::comphelper::WeakComponentImplHelper< XDocumentEventListener
> DocumentEventNotifier_Impl_Base;
namespace {
@@ -62,8 +59,7 @@ namespace basctl
/** impl class for DocumentEventNotifier
*/
- class DocumentEventNotifier::Impl :public ::cppu::BaseMutex
- ,public DocumentEventNotifier_Impl_Base
+ class DocumentEventNotifier::Impl : public DocumentEventNotifier_Impl_Base
{
public:
// noncopyable
@@ -79,18 +75,18 @@ namespace basctl
// XEventListener
virtual void SAL_CALL disposing( const css::lang::EventObject& Event ) override;
- // ComponentHelper
- virtual void SAL_CALL disposing() override;
+ // WeakComponentImplHelper
+ virtual void disposing(std::unique_lock<std::mutex>&) override;
private:
/// determines whether the instance is already disposed
- bool impl_isDisposed_nothrow() const { return m_pListener == nullptr; }
+ bool impl_isDisposed_nothrow(std::unique_lock<std::mutex>& /*rGuard*/) const { return m_pListener == nullptr; }
/// disposes the instance
- void impl_dispose_nothrow();
+ void impl_dispose_nothrow(std::unique_lock<std::mutex>& rGuard);
/// registers or revokes the instance as listener at the global event broadcaster
- void impl_listenerAction_nothrow( ListenerAction _eAction );
+ void impl_listenerAction_nothrow( std::unique_lock<std::mutex>& rGuard, ListenerAction _eAction );
private:
DocumentEventListener* m_pListener;
@@ -98,18 +94,19 @@ namespace basctl
};
DocumentEventNotifier::Impl::Impl (DocumentEventListener& rListener, Reference<XModel> const& rxDocument) :
- DocumentEventNotifier_Impl_Base(m_aMutex),
m_pListener(&rListener),
m_xModel(rxDocument)
{
+ std::unique_lock aGuard(m_aMutex);
osl_atomic_increment( &m_refCount );
- impl_listenerAction_nothrow( RegisterListener );
+ impl_listenerAction_nothrow( aGuard, RegisterListener );
osl_atomic_decrement( &m_refCount );
}
DocumentEventNotifier::Impl::~Impl ()
{
- if ( !impl_isDisposed_nothrow() )
+ std::unique_lock aGuard(m_aMutex);
+ if ( !impl_isDisposed_nothrow(aGuard) )
{
acquire();
dispose();
@@ -118,10 +115,10 @@ namespace basctl
void SAL_CALL DocumentEventNotifier::Impl::documentEventOccured( const DocumentEvent& _rEvent )
{
- ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
- OSL_PRECOND( !impl_isDisposed_nothrow(), "DocumentEventNotifier::Impl::notifyEvent: disposed, but still getting events?" );
- if ( impl_isDisposed_nothrow() )
+ OSL_PRECOND( !impl_isDisposed_nothrow(aGuard), "DocumentEventNotifier::Impl::notifyEvent: disposed, but still getting events?" );
+ if ( impl_isDisposed_nothrow(aGuard) )
return;
Reference< XModel > xDocument( _rEvent.Source, UNO_QUERY );
@@ -151,20 +148,26 @@ namespace basctl
if ( !_rEvent.EventName.equalsAscii( aEvent.pEventName ) )
continue;
+ // Listener implementations require that we hold the mutex, but to avoid lock ordering issues,
+ // we need to take the solar mutex before we take our own mutex.
+ aGuard.unlock();
+
+ // Listener implements require that we hold the solar mutex.
+ SolarMutexGuard aSolarGuard;
+
+ // Take the lock again, so we can check our local fields.
+ aGuard.lock();
+ if ( impl_isDisposed_nothrow(aGuard) )
+ // somebody took the chance to dispose us -> bail out
+ return;
+ DocumentEventListener* pListener = m_pListener;
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 );
+ // We cannot call the listener while holding our mutex because the listener
+ // call might trigger an event which call back into us.
+ aGuard.unlock();
- if ( impl_isDisposed_nothrow() )
- // somebody took the chance to dispose us -> bail out
- return;
+ (pListener->*aEvent.listenerMethod)( aDocument );
- (m_pListener->*aEvent.listenerMethod)( aDocument );
- }
break;
}
}
@@ -172,25 +175,25 @@ namespace basctl
void SAL_CALL DocumentEventNotifier::Impl::disposing( const css::lang::EventObject& /*Event*/ )
{
SolarMutexGuard aSolarGuard;
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
- if ( !impl_isDisposed_nothrow() )
- impl_dispose_nothrow();
+ if ( !impl_isDisposed_nothrow(aGuard) )
+ impl_dispose_nothrow(aGuard);
}
- void SAL_CALL DocumentEventNotifier::Impl::disposing()
+ void DocumentEventNotifier::Impl::disposing(std::unique_lock<std::mutex>& rGuard)
{
- impl_listenerAction_nothrow( RemoveListener );
- impl_dispose_nothrow();
+ impl_listenerAction_nothrow( rGuard, RemoveListener );
+ impl_dispose_nothrow(rGuard);
}
- void DocumentEventNotifier::Impl::impl_dispose_nothrow()
+ void DocumentEventNotifier::Impl::impl_dispose_nothrow(std::unique_lock<std::mutex>& /*rGuard*/)
{
m_pListener = nullptr;
m_xModel.clear();
}
- void DocumentEventNotifier::Impl::impl_listenerAction_nothrow( ListenerAction _eAction )
+ void DocumentEventNotifier::Impl::impl_listenerAction_nothrow( std::unique_lock<std::mutex>& rGuard, ListenerAction _eAction )
{
try
{
@@ -206,7 +209,10 @@ namespace basctl
void ( SAL_CALL XDocumentEventBroadcaster::*listenerAction )( const Reference< XDocumentEventListener >& ) =
( _eAction == RegisterListener ) ? &XDocumentEventBroadcaster::addDocumentEventListener : &XDocumentEventBroadcaster::removeDocumentEventListener;
+
+ rGuard.unlock();
(xBroadcaster.get()->*listenerAction)( this );
+ rGuard.lock();
}
catch( const Exception& )
{
diff --git a/basctl/source/basicide/docsignature.cxx b/basctl/source/basicide/docsignature.cxx
index 701c9d478f1a..08d7a1ab9c13 100644
--- a/basctl/source/basicide/docsignature.cxx
+++ b/basctl/source/basicide/docsignature.cxx
@@ -51,10 +51,6 @@ namespace basctl
m_pShell = pShell;
}
- DocumentSignature::~DocumentSignature()
- {
- }
-
bool DocumentSignature::supportsSignatures() const
{
return ( m_pShell != nullptr );
diff --git a/basctl/source/basicide/documentenumeration.cxx b/basctl/source/basicide/documentenumeration.cxx
index e3acf9d4587a..d71e02139e02 100644
--- a/basctl/source/basicide/documentenumeration.cxx
+++ b/basctl/source/basicide/documentenumeration.cxx
@@ -27,7 +27,7 @@
#include <com/sun/star/frame/XModel2.hpp>
#include <com/sun/star/frame/FrameSearchFlag.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
namespace basctl::docs {
@@ -48,22 +48,10 @@ namespace basctl::docs {
namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag;
- // DocumentEnumeration_Data
- struct DocumentEnumeration_Data
- {
- Reference< css::uno::XComponentContext > aContext;
- const IDocumentDescriptorFilter* pFilter;
-
- DocumentEnumeration_Data( Reference< css::uno::XComponentContext > const & _rContext, const IDocumentDescriptorFilter* _pFilter )
- :aContext( _rContext )
- ,pFilter( _pFilter )
- {
- }
- };
-
// DocumentEnumeration
DocumentEnumeration::DocumentEnumeration( Reference< css::uno::XComponentContext > const & _rContext, const IDocumentDescriptorFilter* _pFilter )
- :m_pData( new DocumentEnumeration_Data( _rContext, _pFilter ) )
+ : m_xContext( _rContext )
+ , m_pFilter( _pFilter )
{
}
@@ -152,11 +140,11 @@ namespace basctl::docs {
try
{
- const Reference< XDesktop2 > xDesktop = Desktop::create( m_pData->aContext );
+ const Reference< XDesktop2 > xDesktop = Desktop::create( m_xContext );
const Reference< XFrames > xFrames( xDesktop->getFrames(), UNO_SET_THROW );
const Sequence< Reference< XFrame > > aFrames( xFrames->queryFrames( FrameSearchFlag::ALL ) );
- lcl_getDocuments_nothrow( aFrames, _out_rDocuments, m_pData->pFilter );
+ lcl_getDocuments_nothrow( aFrames, _out_rDocuments, m_pFilter );
}
catch( const Exception& )
{
diff --git a/basctl/source/basicide/documentenumeration.hxx b/basctl/source/basicide/documentenumeration.hxx
index 084a4aa0cf09..dfd4d2e8172f 100644
--- a/basctl/source/basicide/documentenumeration.hxx
+++ b/basctl/source/basicide/documentenumeration.hxx
@@ -51,7 +51,6 @@ namespace basctl::docs {
};
- 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
@@ -81,7 +80,8 @@ namespace basctl::docs {
) const;
private:
- std::unique_ptr< DocumentEnumeration_Data > m_pData;
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+ const IDocumentDescriptorFilter* m_pFilter;
};
diff --git a/basctl/source/basicide/iderdll.cxx b/basctl/source/basicide/iderdll.cxx
index a6f3abd68edb..022045050e9a 100644
--- a/basctl/source/basicide/iderdll.cxx
+++ b/basctl/source/basicide/iderdll.cxx
@@ -105,7 +105,7 @@ ExtraData* GetExtraData()
return nullptr;
}
-OUString IDEResId(std::string_view aId)
+OUString IDEResId(TranslateId aId)
{
return Translate::get(aId, SfxApplication::GetModule(SfxToolsModule::Basic)->GetResLocale());
}
diff --git a/basctl/source/basicide/linenumberwindow.cxx b/basctl/source/basicide/linenumberwindow.cxx
index be9fe3752045..80fff0872f10 100644
--- a/basctl/source/basicide/linenumberwindow.cxx
+++ b/basctl/source/basicide/linenumberwindow.cxx
@@ -21,7 +21,14 @@ LineNumberWindow::LineNumberWindow(vcl::Window* pParent, ModulWindow* pModulWind
, m_pModulWindow(pModulWindow)
, m_nCurYOffset(0)
{
- SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor()));
+ // tdf#153853 The line number window does not need to be affected by RTL
+ EnableRTL(false);
+
+ const Wallpaper aBackground(GetSettings().GetStyleSettings().GetWindowColor());
+ SetBackground(aBackground);
+ GetWindow(GetWindowType::Border)->SetBackground(aBackground);
+ m_FontColor = GetSettings().GetStyleSettings().GetWindowTextColor();
+ m_HighlightColor = GetSettings().GetStyleSettings().GetFaceColor();
m_nBaseWidth = GetTextWidth("8");
m_nWidth = m_nBaseWidth * 3 + m_nBaseWidth / 2;
}
@@ -47,9 +54,8 @@ void LineNumberWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Re
if (!txtView)
return;
- GetParent()->Resize();
-
int windowHeight = rRenderContext.GetOutputSize().Height();
+ int windowWidth = rRenderContext.GetOutputSize().Width();
int nLineHeight = rRenderContext.GetTextHeight();
if (!nLineHeight)
{
@@ -77,9 +83,41 @@ void LineNumberWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Re
m_nWidth += m_nBaseWidth;
}
+ vcl::Font aNormalFont = rRenderContext.GetFont();
+ vcl::Font aBoldFont(aNormalFont);
+ aBoldFont.SetWeight(FontWeight::WEIGHT_BOLD);
+
+ sal_uInt32 nParaEnd = txtView->GetSelection().GetEnd().GetPara() + 1;
sal_Int64 y = (nStartLine - 1) * static_cast<sal_Int64>(nLineHeight);
+
for (sal_uInt32 n = nStartLine; n <= nEndLine; ++n, y += nLineHeight)
- rRenderContext.DrawText(Point(0, y - m_nCurYOffset), OUString::number(n));
+ {
+ // Font weight for the selected lines is bold
+ if (n == nParaEnd)
+ {
+ tools::Rectangle aRect(Point(0, y - m_nCurYOffset),
+ Point(windowWidth, y - m_nCurYOffset + nLineHeight));
+ rRenderContext.SetFillColor(m_HighlightColor);
+ rRenderContext.DrawRect(aRect);
+ rRenderContext.SetFont(aBoldFont);
+ }
+ else
+ {
+ rRenderContext.SetFont(aNormalFont);
+ }
+
+ rRenderContext.SetTextColor(m_FontColor);
+ const OUString aLineNumber = OUString::number(n);
+ // tdf#153798 - align line numbers to the right
+ rRenderContext.DrawText(
+ Point(m_nWidth - GetTextWidth(aLineNumber) - m_nBaseWidth / 2, y - m_nCurYOffset),
+ aLineNumber);
+ }
+ // Restore the original font
+ rRenderContext.SetFont(aNormalFont);
+
+ // Resize the parent after calculating the new width and height values
+ GetParent()->Resize();
}
void LineNumberWindow::DataChanged(DataChangedEvent const& rDCEvt)
diff --git a/basctl/source/basicide/linenumberwindow.hxx b/basctl/source/basicide/linenumberwindow.hxx
index 14305116ef10..5f5ab744f0f0 100644
--- a/basctl/source/basicide/linenumberwindow.hxx
+++ b/basctl/source/basicide/linenumberwindow.hxx
@@ -22,6 +22,8 @@ private:
int m_nWidth;
tools::Long m_nCurYOffset;
int m_nBaseWidth;
+ Color m_FontColor;
+ Color m_HighlightColor;
virtual void DataChanged(DataChangedEvent const& rDCEvt) override;
protected:
diff --git a/basctl/source/basicide/localizationmgr.cxx b/basctl/source/basicide/localizationmgr.cxx
index 6dd07a021d32..e978e1ca130f 100644
--- a/basctl/source/basicide/localizationmgr.cxx
+++ b/basctl/source/basicide/localizationmgr.cxx
@@ -37,7 +37,9 @@
#include <sfx2/sfxsids.hrc>
#include <sfx2/viewfrm.hxx>
#include <tools/debug.hxx>
+#include <utility>
#include <osl/diagnose.h>
+#include <o3tl/string_view.hxx>
namespace basctl
{
@@ -51,22 +53,22 @@ using namespace ::com::sun::star::resource;
namespace
{
-constexpr OUStringLiteral aDot(u".");
-constexpr OUStringLiteral aEsc(u"&");
-constexpr OUStringLiteral aSemi(u";");
+constexpr OUString aDot(u"."_ustr);
+constexpr OUString aEsc(u"&"_ustr);
+constexpr OUString aSemi(u";"_ustr);
} // namespace
LocalizationMgr::LocalizationMgr(
Shell* pShell,
- ScriptDocument const& rDocument,
- OUString const& aLibName,
+ ScriptDocument aDocument,
+ OUString aLibName,
Reference<XStringResourceManager> const& xStringResourceManager
) :
m_xStringResourceManager(xStringResourceManager),
m_pShell(pShell),
- m_aDocument(rDocument),
- m_aLibName(aLibName)
+ m_aDocument(std::move(aDocument)),
+ m_aLibName(std::move(aLibName))
{ }
bool LocalizationMgr::isLibraryLocalized ()
@@ -78,10 +80,10 @@ bool LocalizationMgr::isLibraryLocalized ()
void LocalizationMgr::handleTranslationbar ()
{
- static constexpr OUStringLiteral aToolBarResName = u"private:resource/toolbar/translationbar";
+ static constexpr OUString aToolBarResName = u"private:resource/toolbar/translationbar"_ustr;
Reference< beans::XPropertySet > xFrameProps
- ( m_pShell->GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
+ ( m_pShell->GetViewFrame().GetFrame().GetFrameInterface(), uno::UNO_QUERY );
if ( !xFrameProps.is() )
return;
@@ -106,7 +108,7 @@ void LocalizationMgr::handleTranslationbar ()
// TODO: -> export from toolkit
-static bool isLanguageDependentProperty( const OUString& aName )
+static bool isLanguageDependentProperty( std::u16string_view aName )
{
static struct Prop
{
@@ -125,7 +127,7 @@ static bool isLanguageDependentProperty( const OUString& aName )
};
for (Prop const* pProp = vProp; pProp->sName; ++pProp)
- if (aName.equalsAsciiL(pProp->sName, pProp->nNameLength))
+ if (o3tl::equalsAscii(aName, std::string_view(pProp->sName, pProp->nNameLength)))
return true;
return false;
}
@@ -133,14 +135,9 @@ static bool isLanguageDependentProperty( const OUString& aName )
void LocalizationMgr::implEnableDisableResourceForAllLibraryDialogs( HandleResourceMode eMode )
{
- Sequence< OUString > aDlgNames = m_aDocument.getObjectNames( E_DIALOGS, m_aLibName );
- sal_Int32 nDlgCount = aDlgNames.getLength();
- const OUString* pDlgNames = aDlgNames.getConstArray();
-
Reference< XStringResourceResolver > xDummyStringResolver;
- for( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
+ for (auto& aDlgName : m_aDocument.getObjectNames(E_DIALOGS, m_aLibName))
{
- OUString aDlgName = pDlgNames[ i ];
if (VclPtr<DialogWindow> pWin = m_pShell->FindDlgWin(m_aDocument, m_aLibName, aDlgName))
{
Reference< container::XNameContainer > xDialog = pWin->GetDialog();
@@ -153,12 +150,8 @@ void LocalizationMgr::implEnableDisableResourceForAllLibraryDialogs( HandleResou
std::u16string_view(), m_xStringResourceManager, xDummyStringResolver, eMode );
// Handle all controls
- Sequence< OUString > aNames = xDialog->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 nCtrls = aNames.getLength();
- for( sal_Int32 j = 0 ; j < nCtrls ; ++j )
+ for (auto& aCtrlName : xDialog->getElementNames())
{
- OUString aCtrlName( pNames[j] );
Any aCtrl = xDialog->getByName( aCtrlName );
implHandleControlResourceProperties( aCtrl, aDlgName,
aCtrlName, m_xStringResourceManager, xDummyStringResolver, eMode );
@@ -202,22 +195,16 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
if( xPropertySet.is() && xStringResourceManager.is())
{
Sequence< Locale > aLocaleSeq = xStringResourceManager->getLocales();
- sal_Int32 nLocaleCount = aLocaleSeq.getLength();
- if( nLocaleCount == 0 )
+ if (!aLocaleSeq.hasElements())
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 )
+ for (auto& rProp : xPropertySetInfo->getProperties())
{
- const Property& rProp = pProps[j];
OUString aPropName = rProp.Name;
TypeClass eType = rProp.Type.getTypeClass();
bool bLanguageDependentProperty =
@@ -243,10 +230,8 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
( aDialogName, aCtrlName, aPropName, xStringResourceManager );
// Set Id for all locales
- const Locale* pLocales = aLocaleSeq.getConstArray();
- for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
+ for (auto& rLocale : aLocaleSeq)
{
- const Locale& rLocale = pLocales[ i ];
xStringResourceManager->setStringForLocale( aPureIdStr, aPropStr, rLocale );
}
@@ -279,10 +264,8 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
{
OUString aPureIdStr = aPropStr.copy( 1 );
- const Locale* pLocales = aLocaleSeq.getConstArray();
- for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
+ for (auto& rLocale : aLocaleSeq)
{
- const Locale& rLocale = pLocales[ i ];
try
{
xStringResourceManager->removeIdForLocale( aPureIdStr, rLocale );
@@ -302,10 +285,8 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
( 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++ )
+ for (auto& rLocale : aLocaleSeq)
{
- const Locale& rLocale = pLocales[ i ];
try
{
OUString aResStr = xStringResourceManager->resolveStringForLocale
@@ -333,10 +314,8 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
const Locale& rDefaultLocale = xSourceStringResolver->getDefaultLocale();
// Set Id for all locales
- const Locale* pLocales = aLocaleSeq.getConstArray();
- for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
+ for (auto& rLocale : aLocaleSeq)
{
- const Locale& rLocale = pLocales[ i ];
OUString aResStr;
try
{
@@ -364,10 +343,8 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
const Locale& rDefaultLocale = xSourceStringResolver->getDefaultLocale();
// Copy Id for all locales
- const Locale* pLocales = aLocaleSeq.getConstArray();
- for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
+ for (auto& rLocale : aLocaleSeq)
{
- const Locale& rLocale = pLocales[ i ];
OUString aResStr;
try
{
@@ -392,7 +369,6 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
Sequence< OUString > aPropStrings;
aPropAny >>= aPropStrings;
- const OUString* pPropStrings = aPropStrings.getConstArray();
sal_Int32 nPropStringCount = aPropStrings.getLength();
if( nPropStringCount == 0 )
continue;
@@ -400,8 +376,7 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
// Replace string by id, add id+string to StringResource
if( eMode == SET_IDS )
{
- Sequence< OUString > aIdStrings;
- aIdStrings.realloc( nPropStringCount );
+ Sequence< OUString > aIdStrings(nPropStringCount);
OUString* pIdStrings = aIdStrings.getArray();
OUString aIdStrBase = aDot
@@ -409,11 +384,10 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
+ aDot
+ aPropName;
- const Locale* pLocales = aLocaleSeq.getConstArray();
sal_Int32 i;
for ( i = 0; i < nPropStringCount; ++i )
{
- OUString aPropStr = pPropStrings[i];
+ OUString aPropStr = aPropStrings[i];
bool bEscAlreadyExisting = aPropStr.startsWith("&");
if( bEscAlreadyExisting )
{
@@ -426,28 +400,24 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
+ aIdStrBase;
// Set Id for all locales
- for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
+ for (auto& rLocale : aLocaleSeq)
{
- const Locale& rLocale = pLocales[ iLocale ];
xStringResourceManager->setStringForLocale( aPureIdStr, aPropStr, rLocale );
}
- OUString aPropIdStr = aEsc + aPureIdStr;
- pIdStrings[i] = aPropIdStr;
+ pIdStrings[i] = aEsc + aPureIdStr;
}
xPropertySet->setPropertyValue( aPropName, Any(aIdStrings) );
}
// Replace id by string from StringResource
else if( eMode == RESET_IDS )
{
- Sequence< OUString > aNewPropStrings;
- aNewPropStrings.realloc( nPropStringCount );
+ Sequence<OUString> aNewPropStrings(nPropStringCount);
OUString* pNewPropStrings = aNewPropStrings.getArray();
- sal_Int32 i;
- for ( i = 0; i < nPropStringCount; ++i )
+ for (sal_Int32 i = 0; i < nPropStringCount; ++i)
{
- OUString aIdStr = pPropStrings[i];
+ OUString aIdStr = aPropStrings[i];
OUString aNewPropStr = aIdStr;
if( aIdStr.getLength() > 1 )
{
@@ -467,18 +437,14 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
// Remove Id for all locales
else if( eMode == REMOVE_IDS_FROM_RESOURCE )
{
- const Locale* pLocales = aLocaleSeq.getConstArray();
- sal_Int32 i;
- for ( i = 0; i < nPropStringCount; ++i )
+ for (auto& aIdStr : aPropStrings)
{
- OUString aIdStr = pPropStrings[i];
if( aIdStr.getLength() > 1 )
{
OUString aPureIdStr = aIdStr.copy( 1 );
- for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
+ for (auto& rLocale : aLocaleSeq)
{
- const Locale& rLocale = pLocales[iLocale];
try
{
xStringResourceManager->removeIdForLocale( aPureIdStr, rLocale );
@@ -493,8 +459,7 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
// Rename resource id
else if( eMode == RENAME_CONTROL_IDS )
{
- Sequence< OUString > aIdStrings;
- aIdStrings.realloc( nPropStringCount );
+ Sequence<OUString> aIdStrings(nPropStringCount);
OUString* pIdStrings = aIdStrings.getArray();
OUString aIdStrBase = aDot
@@ -502,11 +467,9 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
+ aDot
+ aPropName;
- const Locale* pLocales = aLocaleSeq.getConstArray();
- sal_Int32 i;
- for ( i = 0; i < nPropStringCount; ++i )
+ for (sal_Int32 i = 0; i < nPropStringCount; ++i)
{
- OUString aSourceIdStr = pPropStrings[i];
+ OUString aSourceIdStr = aPropStrings[i];
OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
sal_Int32 nUniqueId = xStringResourceManager->getUniqueNumericId();
@@ -514,10 +477,8 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
+ aIdStrBase;
// Set Id for all locales
- for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
+ for (auto& rLocale : aLocaleSeq)
{
- const Locale& rLocale = pLocales[ iLocale ];
-
try
{
OUString aResStr = xStringResourceManager->resolveStringForLocale
@@ -529,16 +490,14 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
{}
}
- OUString aPropIdStr = aEsc + aPureIdStr;
- pIdStrings[i] = aPropIdStr;
+ pIdStrings[i] = aEsc + aPureIdStr;
}
xPropertySet->setPropertyValue( aPropName, Any(aIdStrings) );
}
// Replace string by string from source StringResourceResolver
else if( eMode == MOVE_RESOURCES && xSourceStringResolver.is() )
{
- Sequence< OUString > aIdStrings;
- aIdStrings.realloc( nPropStringCount );
+ Sequence<OUString> aIdStrings(nPropStringCount);
OUString* pIdStrings = aIdStrings.getArray();
OUString aIdStrBase = aDot
@@ -548,11 +507,9 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
const Locale& rDefaultLocale = xSourceStringResolver->getDefaultLocale();
- const Locale* pLocales = aLocaleSeq.getConstArray();
- sal_Int32 i;
- for ( i = 0; i < nPropStringCount; ++i )
+ for (sal_Int32 i = 0; i < nPropStringCount; ++i)
{
- OUString aSourceIdStr = pPropStrings[i];
+ OUString aSourceIdStr = aPropStrings[i];
OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
sal_Int32 nUniqueId = xStringResourceManager->getUniqueNumericId();
@@ -560,10 +517,8 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
+ aIdStrBase;
// Set Id for all locales
- for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
+ for (auto& rLocale : aLocaleSeq)
{
- const Locale& rLocale = pLocales[ iLocale ];
-
OUString aResStr;
try
{
@@ -578,8 +533,7 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale );
}
- OUString aPropIdStr = aEsc + aPureIdStr;
- pIdStrings[i] = aPropIdStr;
+ pIdStrings[i] = aEsc + aPureIdStr;
}
xPropertySet->setPropertyValue( aPropName, Any(aIdStrings) );
}
@@ -588,18 +542,13 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
{
const Locale& rDefaultLocale = xSourceStringResolver->getDefaultLocale();
- const Locale* pLocales = aLocaleSeq.getConstArray();
- sal_Int32 i;
- for ( i = 0; i < nPropStringCount; ++i )
+ for (auto& aSourceIdStr : aPropStrings)
{
- OUString aSourceIdStr = pPropStrings[i];
OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
// Set Id for all locales
- for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
+ for (auto& rLocale : aLocaleSeq)
{
- const Locale& rLocale = pLocales[ iLocale ];
-
OUString aResStr;
try
{
@@ -626,22 +575,18 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
void LocalizationMgr::handleAddLocales( const Sequence< Locale >& aLocaleSeq )
{
- const Locale* pLocales = aLocaleSeq.getConstArray();
- sal_Int32 nLocaleCount = aLocaleSeq.getLength();
-
if( isLibraryLocalized() )
{
- for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
+ for (auto& rLocale : aLocaleSeq)
{
- const Locale& rLocale = pLocales[ i ];
m_xStringResourceManager->newLocale( rLocale );
}
}
else
{
- DBG_ASSERT( nLocaleCount==1, "LocalizationMgr::handleAddLocales(): Only one first locale allowed" );
+ DBG_ASSERT( aLocaleSeq.getLength()==1, "LocalizationMgr::handleAddLocales(): Only one first locale allowed" );
- const Locale& rLocale = pLocales[ 0 ];
+ const Locale& rLocale = aLocaleSeq[0];
m_xStringResourceManager->newLocale( rLocale );
enableResourceForAllLibraryDialogs();
}
@@ -658,21 +603,18 @@ void LocalizationMgr::handleAddLocales( const Sequence< Locale >& aLocaleSeq )
void LocalizationMgr::handleRemoveLocales( const Sequence< Locale >& aLocaleSeq )
{
- const Locale* pLocales = aLocaleSeq.getConstArray();
- sal_Int32 nLocaleCount = aLocaleSeq.getLength();
bool bConsistent = true;
bool bModified = false;
- for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
+ for (auto& rLocale : aLocaleSeq)
{
- 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 ];
+ const Locale& rLastResLocale = aResLocaleSeq[0];
if( localesAreEqual( rLocale, rLastResLocale ) )
{
disableResourceForAllLibraryDialogs();
@@ -924,15 +866,10 @@ void LocalizationMgr::renameStringResourceIDs( const ScriptDocument& rDocument,
xDummyStringResolver, RENAME_DIALOG_IDS );
// Handle all controls
- Sequence< OUString > aNames = xDialogModel->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 nCtrls = aNames.getLength();
- for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
- {
- OUString aCtrlName( pNames[i] );
- Any aCtrl = xDialogModel->getByName( aCtrlName );
+ for(const auto& rCtrlName : xDialogModel->getElementNames()) {
+ Any aCtrl = xDialogModel->getByName( rCtrlName );
implHandleControlResourceProperties( aCtrl, aDlgName,
- aCtrlName, xStringResourceManager,
+ rCtrlName, xStringResourceManager,
xDummyStringResolver, RENAME_DIALOG_IDS );
}
}
@@ -955,15 +892,10 @@ void LocalizationMgr::removeResourceForDialog( const ScriptDocument& rDocument,
xDummyStringResolver, REMOVE_IDS_FROM_RESOURCE );
// Handle all controls
- Sequence< OUString > aNames = xDialogModel->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 nCtrls = aNames.getLength();
- for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
- {
- OUString aCtrlName( pNames[i] );
- Any aCtrl = xDialogModel->getByName( aCtrlName );
+ for(const auto& rCtrlName : xDialogModel->getElementNames()) {
+ Any aCtrl = xDialogModel->getByName( rCtrlName );
implHandleControlResourceProperties( aCtrl, aDlgName,
- aCtrlName, xStringResourceManager,
+ rCtrlName, xStringResourceManager,
xDummyStringResolver, REMOVE_IDS_FROM_RESOURCE );
}
}
@@ -975,7 +907,7 @@ void LocalizationMgr::resetResourceForDialog( const Reference< container::XNameC
return;
// Dialog as control
- OUString aDummyName;
+ std::u16string_view aDummyName;
Any aDialogCtrl;
aDialogCtrl <<= xDialogModel;
Reference< XStringResourceResolver > xDummyStringResolver;
@@ -983,15 +915,10 @@ void LocalizationMgr::resetResourceForDialog( const Reference< container::XNameC
aDummyName, xStringResourceManager, xDummyStringResolver, RESET_IDS );
// Handle all controls
- Sequence< OUString > aNames = xDialogModel->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 nCtrls = aNames.getLength();
- for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
- {
- OUString aCtrlName( pNames[i] );
- Any aCtrl = xDialogModel->getByName( aCtrlName );
+ for(const auto& rCtrlName : xDialogModel->getElementNames()){
+ Any aCtrl = xDialogModel->getByName( rCtrlName );
implHandleControlResourceProperties( aCtrl, aDummyName,
- aCtrlName, xStringResourceManager, xDummyStringResolver, RESET_IDS );
+ rCtrlName, xStringResourceManager, xDummyStringResolver, RESET_IDS );
}
}
@@ -1002,7 +929,7 @@ void LocalizationMgr::setResourceIDsForDialog( const Reference< container::XName
return;
// Dialog as control
- OUString aDummyName;
+ std::u16string_view aDummyName;
Any aDialogCtrl;
aDialogCtrl <<= xDialogModel;
Reference< XStringResourceResolver > xDummyStringResolver;
@@ -1010,15 +937,10 @@ void LocalizationMgr::setResourceIDsForDialog( const Reference< container::XName
aDummyName, xStringResourceManager, xDummyStringResolver, SET_IDS );
// Handle all controls
- Sequence< OUString > aNames = xDialogModel->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 nCtrls = aNames.getLength();
- for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
- {
- OUString aCtrlName( pNames[i] );
- Any aCtrl = xDialogModel->getByName( aCtrlName );
+ for(const auto& rCtrlName : xDialogModel->getElementNames()) {
+ Any aCtrl = xDialogModel->getByName( rCtrlName );
implHandleControlResourceProperties( aCtrl, aDummyName,
- aCtrlName, xStringResourceManager, xDummyStringResolver, SET_IDS );
+ rCtrlName, xStringResourceManager, xDummyStringResolver, SET_IDS );
}
}
@@ -1064,15 +986,10 @@ void LocalizationMgr::copyResourceForDroppedDialog( const Reference< container::
std::u16string_view(), xStringResourceManager, xSourceStringResolver, MOVE_RESOURCES );
// Handle all controls
- Sequence< OUString > aNames = xDialogModel->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 nCtrls = aNames.getLength();
- for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
- {
- OUString aCtrlName( pNames[i] );
- Any aCtrl = xDialogModel->getByName( aCtrlName );
+ for(const auto& rCtrlName : xDialogModel->getElementNames()) {
+ Any aCtrl = xDialogModel->getByName( rCtrlName );
implHandleControlResourceProperties( aCtrl, aDialogName,
- aCtrlName, xStringResourceManager, xSourceStringResolver, MOVE_RESOURCES );
+ rCtrlName, xStringResourceManager, xSourceStringResolver, MOVE_RESOURCES );
}
}
@@ -1084,7 +1001,7 @@ void LocalizationMgr::copyResourceForDialog(
if( !xDialogModel.is() || !xSourceStringResolver.is() || !xTargetStringResourceManager.is() )
return;
- OUString aDummyName;
+ std::u16string_view aDummyName;
Any aDialogCtrl;
aDialogCtrl <<= xDialogModel;
implHandleControlResourceProperties
@@ -1092,13 +1009,8 @@ void LocalizationMgr::copyResourceForDialog(
xSourceStringResolver, COPY_RESOURCES );
// Handle all controls
- Sequence< OUString > aNames = xDialogModel->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 nCtrls = aNames.getLength();
- for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
- {
- OUString aCtrlName( pNames[i] );
- Any aCtrl = xDialogModel->getByName( aCtrlName );
+ for(const auto& rCtrlName : xDialogModel->getElementNames()) {
+ Any aCtrl = xDialogModel->getByName( rCtrlName );
implHandleControlResourceProperties( aCtrl, aDummyName, aDummyName,
xTargetStringResourceManager, xSourceStringResolver, COPY_RESOURCES );
}
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index 511abf83591e..6b4afb79f772 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -31,7 +31,7 @@
#include <basic/sbmeth.hxx>
#include <basic/sbmod.hxx>
#include <com/sun/star/script/XLibraryContainer2.hpp>
-
+#include <sal/log.hxx>
#include <sfx2/app.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/frame.hxx>
@@ -122,7 +122,8 @@ MacroChooser::~MacroChooser()
void MacroChooser::StoreMacroDescription()
{
- m_xBasicBox->get_selected(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_selected(m_xBasicBoxIter.get()))
+ return;
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
OUString aMethodName;
if (m_xMacroBox->get_selected(m_xMacroBoxIter.get()))
@@ -141,6 +142,9 @@ void MacroChooser::StoreMacroDescription()
void MacroChooser::RestoreMacroDescription()
{
+ // The following call is a workaround to ensure the last used macro is scrolled to in kf5
+ m_xDialog->resize_to_request();
+
EntryDescriptor aDesc;
if (Shell* pShell = GetShell())
{
@@ -291,7 +295,11 @@ void MacroChooser::DeleteMacro()
SbMethod* MacroChooser::CreateMacro()
{
SbMethod* pMethod = nullptr;
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return nullptr;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
OSL_ENSURE( aDocument.isAlive(), "MacroChooser::CreateMacro: no document!" );
@@ -470,8 +478,9 @@ IMPL_LINK_NOARG(MacroChooser, MacroSelectHdl, weld::TreeView&, void)
IMPL_LINK_NOARG(MacroChooser, BasicSelectHdl, weld::TreeView&, void)
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
- SbModule* pModule = m_xBasicBox->FindModule(m_xBasicBoxIter.get());
+ SbModule* pModule = nullptr;
+ if (m_xBasicBox->get_cursor(m_xBasicBoxIter.get()))
+ pModule = m_xBasicBox->FindModule(m_xBasicBoxIter.get());
m_xMacroBox->clear();
if (pModule)
{
@@ -610,7 +619,11 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
}
else if (&rButton == m_xEditButton.get() || &rButton == m_xDelButton.get() || &rButton == m_xNewButton.get())
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
DBG_ASSERT( aDocument.isAlive(), "MacroChooser::ButtonHdl: no document, or document is dead!" );
@@ -693,7 +706,11 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
}
else if (&rButton == m_xAssignButton.get())
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
DBG_ASSERT( aDocument.isAlive(), "MacroChooser::ButtonHdl: no document, or document is dead!" );
@@ -714,20 +731,28 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
if (m_xDocumentFrame.is())
aInternalSet.Put(SfxUnoFrameItem(SID_FILLFRAME, m_xDocumentFrame));
- SfxRequest aRequest(SID_CONFIG, SfxCallMode::SYNCHRON, Args, aInternalSet);
+ SfxRequest aRequest(SID_CONFIGACCEL, SfxCallMode::SYNCHRON, Args, aInternalSet);
aRequest.AppendItem( aItem );
SfxGetpApp()->ExecuteSlot( aRequest );
}
else if (&rButton == m_xNewLibButton.get())
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
createLibImpl(m_xDialog.get(), aDocument, nullptr, m_xBasicBox.get());
}
else if (&rButton == m_xNewModButton.get())
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
const OUString& aLibName( aDesc.GetLibName() );
@@ -738,7 +763,7 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
StoreMacroDescription();
m_xBasicBox->get_selected(m_xBasicBoxIter.get());
- auto xDlg(std::make_shared<OrganizeDialog>(m_xDialog.get(), 0));
+ auto xDlg(std::make_shared<OrganizeDialog>(m_xDialog.get(), nullptr, 0));
weld::DialogController::runAsync(xDlg, [this](sal_Int32 nRet) {
if (nRet == RET_OK) // not only closed
{
@@ -766,7 +791,7 @@ IMPL_LINK(MacroChooser, ContextMenuHdl, const CommandEvent&, rCEvt, bool)
xDropMenu->set_active("alphabetically", m_xMacroBox->get_sort_order());
xDropMenu->set_active("properorder", !m_xMacroBox->get_sort_order());
- OString sCommand(xPopup->popup_at_rect(m_xMacroBox.get(), tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1))));
+ OUString sCommand(xPopup->popup_at_rect(m_xMacroBox.get(), tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1))));
if (sCommand == "alphabetically")
{
m_xMacroBox->make_sorted();
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index cd6587dc800d..49b8927f11c5 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -38,13 +38,13 @@
#include <svl/stritem.hxx>
#include <tools/debug.hxx>
#include <tools/urlobj.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
#include <com/sun/star/io/Pipe.hpp>
#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
-#include <com/sun/star/ui/dialogs/FolderPicker.hpp>
+#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/script/DocumentScriptLibraryContainer.hpp>
#include <com/sun/star/script/DocumentDialogLibraryContainer.hpp>
@@ -63,9 +63,9 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
#include <cppuhelper/implbase.hxx>
+#include <o3tl/string_view.hxx>
#include <cassert>
-#include <string_view>
namespace basctl
{
@@ -92,9 +92,9 @@ public:
{
if ( m_xHandler.is() )
{
- script::ModuleSizeExceededRequest aModSizeException;
- if ( rRequest->getRequest() >>= aModSizeException )
- m_xHandler->handle( rRequest );
+ script::ModuleSizeExceededRequest aModSizeException;
+ if ( rRequest->getRequest() >>= aModSizeException )
+ m_xHandler->handle( rRequest );
}
}
};
@@ -103,12 +103,12 @@ public:
namespace
{
- int FindEntry(const weld::TreeView& rBox, const OUString& rName)
+ int FindEntry(const weld::TreeView& rBox, std::u16string_view rName)
{
int nCount = rBox.n_children();
for (int i = 0; i < nCount; ++i)
{
- if (rName.equalsIgnoreAsciiCase(rBox.get_text(i, 0)))
+ if (o3tl::equalsIgnoreAsciiCase(rName, rBox.get_text(i, 0)))
return i;
}
return -1;
@@ -153,12 +153,24 @@ NewObjectDialog::NewObjectDialog(weld::Window * pParent, ObjectMode eMode, bool
}
// GotoLineDialog
-GotoLineDialog::GotoLineDialog(weld::Window* pParent )
+GotoLineDialog::GotoLineDialog(weld::Window* pParent, sal_uInt32 nCurLine, sal_uInt32 nLineCount)
: GenericDialogController(pParent, "modules/BasicIDE/ui/gotolinedialog.ui", "GotoLineDialog")
- , m_xEdit(m_xBuilder->weld_entry("entry"))
+ , m_xSpinButton(m_xBuilder->weld_spin_button("spin"))
+ , m_xLineCount(m_xBuilder->weld_label("line_count"))
, m_xOKButton(m_xBuilder->weld_button("ok"))
+ , m_nCurLine(nCurLine)
+ , m_nLineCount(nLineCount)
{
- m_xEdit->grab_focus();
+ // Adjust line count label
+ OUString sLabel = m_xLineCount->get_label();
+ m_xLineCount->set_label(sLabel.replaceFirst("$1", OUString::number(m_nLineCount)));
+
+ // Initialize the spin button
+ m_xSpinButton->set_text(OUString::number(m_nCurLine));
+ m_xSpinButton->set_range(1, m_nLineCount);
+ m_xSpinButton->grab_focus();
+ m_xSpinButton->select_region(0, -1);
+
m_xOKButton->connect_clicked(LINK(this, GotoLineDialog, OkButtonHandler));
}
@@ -168,15 +180,22 @@ GotoLineDialog::~GotoLineDialog()
sal_Int32 GotoLineDialog::GetLineNumber() const
{
- return m_xEdit->get_text().toInt32();
+ return m_xSpinButton->get_text().toInt32();
}
IMPL_LINK_NOARG(GotoLineDialog, OkButtonHandler, weld::Button&, void)
{
- if (GetLineNumber())
+ // The number must be in the range between 1 and the number of lines in the module
+ sal_Int32 nNumber = GetLineNumber();
+ if (nNumber && nNumber >= 1 && nNumber <= static_cast<sal_Int32>(m_nLineCount))
+ {
m_xDialog->response(RET_OK);
+ }
else
- m_xEdit->select_region(0, -1);
+ {
+ m_xSpinButton->set_text(OUString::number(m_nCurLine));
+ m_xSpinButton->select_region(0, -1);
+ }
}
// ExportDialog
@@ -346,7 +365,7 @@ LibPage::~LibPage()
const sal_Int32 nCount = m_xBasicsBox->get_count();
for (sal_Int32 i = 0; i < nCount; ++i)
{
- DocumentEntry* pEntry = reinterpret_cast<DocumentEntry*>(m_xBasicsBox->get_id(i).toInt64());
+ DocumentEntry* pEntry = weld::fromId<DocumentEntry*>(m_xBasicsBox->get_id(i));
delete pEntry;
}
}
@@ -461,10 +480,10 @@ IMPL_LINK( LibPage, ButtonHdl, weld::Button&, rButton, void )
{
Shell* pShell = GetShell();
if (pShell)
- pShell->GetViewFrame()->GetWindow().EnterWait();
+ pShell->GetViewFrame().GetWindow().EnterWait();
xModLibContainer->loadLibrary( aLibName );
if (pShell)
- pShell->GetViewFrame()->GetWindow().LeaveWait();
+ pShell->GetViewFrame().GetWindow().LeaveWait();
}
// load dialog library (if not loaded)
@@ -473,10 +492,10 @@ IMPL_LINK( LibPage, ButtonHdl, weld::Button&, rButton, void )
{
Shell* pShell = GetShell();
if (pShell)
- pShell->GetViewFrame()->GetWindow().EnterWait();
+ pShell->GetViewFrame().GetWindow().EnterWait();
xDlgLibContainer->loadLibrary( aLibName );
if (pShell)
- pShell->GetViewFrame()->GetWindow().LeaveWait();
+ pShell->GetViewFrame().GetWindow().LeaveWait();
}
// check, if library is password protected
@@ -549,6 +568,7 @@ void LibPage::InsertLib()
Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
// file open dialog
sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, m_pDialog->getDialog());
+ aDlg.SetContext(sfx2::FileDialogHelper::BasicInsertLib);
const Reference <XFilePicker3>& xFP = aDlg.GetFilePicker();
xFP->setTitle(IDEResId(RID_STR_APPENDLIBS));
@@ -568,16 +588,6 @@ void LibPage::InsertLib()
";*.sti;*.otp" // presentation template
";*.sxm;*.odf" ); // formula
- // set display directory and filter
- OUString aPath(GetExtraData()->GetAddLibPath());
- if ( !aPath.isEmpty() )
- xFP->setDisplayDirectory( aPath );
- else
- {
- // macro path from configuration management
- xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
- }
-
OUString aLastFilter(GetExtraData()->GetAddLibFilter());
if ( !aLastFilter.isEmpty() )
xFP->setCurrentFilter( aLastFilter );
@@ -630,29 +640,33 @@ void LibPage::InsertLib()
std::shared_ptr<LibDialog> xLibDlg;
Sequence< OUString > aLibNames = GetMergedLibraryNames( xModLibContImport, xDlgLibContImport );
- sal_Int32 nLibCount = aLibNames.getLength();
- const OUString* pLibNames = aLibNames.getConstArray();
- for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+ if (aLibNames.hasElements())
{
// library import dialog
- if (!xLibDlg)
- {
- xLibDlg = std::make_shared<LibDialog>(m_pDialog->getDialog());
- xLibDlg->SetStorageName( aURLObj.getName() );
- }
+ xLibDlg = std::make_shared<LibDialog>(m_pDialog->getDialog());
+ xLibDlg->SetStorageName(aURLObj.getName());
+ weld::TreeView& rView = xLibDlg->GetLibBox();
+ rView.make_unsorted();
+ rView.freeze();
- // libbox entries
- OUString aLibName( pLibNames[ i ] );
- if ( !( ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) && xModLibContImport->isLibraryLink( aLibName ) ) ||
- ( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aLibName ) && xDlgLibContImport->isLibraryLink( aLibName ) ) ) )
+ for (auto& aLibName : aLibNames)
{
- weld::TreeView& rView = xLibDlg->GetLibBox();
- rView.append();
- const int nRow = rView.n_children() - 1;
- rView.set_toggle(nRow, TRISTATE_TRUE);
- rView.set_text(nRow, aLibName, 0);
- rView.set_cursor(rView.find_text(aLibName));
+ // libbox entries
+ if ( !( ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) && xModLibContImport->isLibraryLink( aLibName ) ) ||
+ ( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aLibName ) && xDlgLibContImport->isLibraryLink( aLibName ) ) ) )
+ {
+ rView.append();
+ const int nRow = rView.n_children() - 1;
+ rView.set_toggle(nRow, TRISTATE_TRUE);
+ rView.set_text(nRow, aLibName, 0);
+ }
}
+
+ rView.thaw();
+ rView.make_sorted();
+
+ if (rView.n_children())
+ rView.set_cursor(0);
}
if (!xLibDlg)
@@ -811,12 +825,8 @@ void LibPage::InsertLib()
xModLibContImport->loadLibrary( aLibName );
// copy all modules
- Sequence< OUString > aModNames = xModLibImport->getElementNames();
- sal_Int32 nModCount = aModNames.getLength();
- const OUString* pModNames = aModNames.getConstArray();
- for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
+ for (auto& aModName : xModLibImport->getElementNames())
{
- OUString aModName( pModNames[ i ] );
Any aElement_ = xModLibImport->getByName( aModName );
xModLib->insertByName( aModName, aElement_ );
}
@@ -879,12 +889,8 @@ void LibPage::InsertLib()
xDlgLibContImport->loadLibrary( aLibName );
// copy all dialogs
- Sequence< OUString > aDlgNames = xDlgLibImport->getElementNames();
- sal_Int32 nDlgCount = aDlgNames.getLength();
- const OUString* pDlgNames = aDlgNames.getConstArray();
- for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
+ for (auto& aDlgName : xDlgLibImport->getElementNames())
{
- OUString aDlgName( pDlgNames[ i ] );
Any aElement_ = xDlgLibImport->getByName( aDlgName );
xDlgLib->insertByName( aDlgName, aElement_ );
}
@@ -1005,6 +1011,7 @@ void LibPage::ExportAsPackage( const OUString& aLibName )
{
// file open dialog
sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, FileDialogFlags::NONE, m_pDialog->getDialog());
+ aDlg.SetContext(sfx2::FileDialogHelper::BasicExportPackage);
const Reference <XFilePicker3>& xFP = aDlg.GetFilePicker();
Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
@@ -1017,17 +1024,6 @@ void LibPage::ExportAsPackage( const OUString& aLibName )
OUString aTitle(IDEResId(RID_STR_PACKAGE_BUNDLE));
xFP->appendFilter( aTitle, "*.oxt" ); // library files
- // set display directory and filter
- OUString aPath = GetExtraData()->GetAddLibPath();
- if ( !aPath.isEmpty() )
- {
- xFP->setDisplayDirectory( aPath );
- }
- else
- {
- // macro path from configuration management
- xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
- }
xFP->setCurrentFilter( aTitle );
if ( xFP->execute() != RET_OK )
@@ -1117,7 +1113,7 @@ void LibPage::ExportAsBasic( const OUString& aLibName )
{
// Folder picker
Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
- Reference< XFolderPicker2 > xFolderPicker = FolderPicker::create(xContext);
+ Reference< XFolderPicker2 > xFolderPicker = sfx2::createFolderPicker(xContext, m_pDialog->getDialog());
Reference< task::XInteractionHandler2 > xHandler( task::InteractionHandler::createWithParent(xContext, nullptr) );
xFolderPicker->setTitle(IDEResId(RID_STR_EXPORTBASIC));
@@ -1197,13 +1193,13 @@ void LibPage::FillListBox()
void LibPage::InsertListBoxEntry( const ScriptDocument& rDocument, LibraryLocation eLocation )
{
OUString aEntryText(rDocument.getTitle(eLocation));
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(new DocumentEntry(rDocument, eLocation))));
+ OUString sId(weld::toId(new DocumentEntry(rDocument, eLocation)));
m_xBasicsBox->append(sId, aEntryText);
}
void LibPage::SetCurLib()
{
- DocumentEntry* pEntry = reinterpret_cast<DocumentEntry*>(m_xBasicsBox->get_active_id().toInt64());
+ DocumentEntry* pEntry = weld::fromId<DocumentEntry*>(m_xBasicsBox->get_active_id());
if (!pEntry)
return;
@@ -1220,25 +1216,20 @@ void LibPage::SetCurLib()
m_xLibBox->clear();
// get a sorted list of library names
- Sequence< OUString > aLibNames = aDocument.getLibraryNames();
- sal_Int32 nLibCount = aLibNames.getLength();
- const OUString* pLibNames = aLibNames.getConstArray();
-
int nEntry = 0;
- for (int i = 0 ; i < nLibCount; ++i)
+ for (auto& aLibName : aDocument.getLibraryNames())
{
- OUString aLibName(pLibNames[i]);
if (eLocation == aDocument.getLibraryLocation(aLibName))
ImpInsertLibEntry(aLibName, nEntry++);
}
- int nEntry_ = FindEntry(*m_xLibBox, "Standard");
+ int nEntry_ = FindEntry(*m_xLibBox, u"Standard");
if (nEntry_ == -1 && m_xLibBox->n_children())
nEntry_ = 0;
m_xLibBox->set_cursor(nEntry_);
}
-void LibPage::ImpInsertLibEntry( const OUString& rLibName, sal_uLong nPos )
+void LibPage::ImpInsertLibEntry( const OUString& rLibName, int nPos )
{
// check, if library is password protected
bool bProtected = false;
@@ -1332,6 +1323,22 @@ void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
if ( !rDocument.createModule( aLibName, aModName, true, sModuleCode ) )
throw Exception("could not create module " + aModName, nullptr);
+ // tdf#151741 - store all libraries to the file system, otherwise they
+ // cannot be renamed/moved since the SfxLibraryContainer::renameLibrary
+ // moves the folders/files on the file system
+ Reference<script::XLibraryContainer2> xModLibContainer(
+ rDocument.getLibraryContainer(E_SCRIPTS), UNO_QUERY);
+ Reference<script::XLibraryContainer2> xDlgLibContainer(
+ rDocument.getLibraryContainer(E_DIALOGS), UNO_QUERY);
+ Reference<script::XPersistentLibraryContainer> xModPersLibContainer(xModLibContainer,
+ UNO_QUERY);
+ if (xModPersLibContainer.is())
+ xModPersLibContainer->storeLibraries();
+ Reference<script::XPersistentLibraryContainer> xDlgPersLibContainer(xDlgLibContainer,
+ UNO_QUERY);
+ if (xDlgPersLibContainer.is())
+ xDlgPersLibContainer->storeLibraries();
+
SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, TYPE_MODULE );
if (SfxDispatcher* pDispatcher = GetDispatcher())
pDispatcher->ExecuteList(SID_BASICIDE_SBXINSERTED,
@@ -1350,8 +1357,8 @@ void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
BrowseMode nMode = pBasicBox->GetMode();
bool bDlgMode = ( nMode & BrowseMode::Dialogs ) && !( nMode & BrowseMode::Modules );
- const auto sId = bDlgMode ? std::u16string_view(u"" RID_BMP_DLGLIB) : std::u16string_view(u"" RID_BMP_MODLIB);
- pBasicBox->AddEntry(aLibName, OUString(sId), xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_LIBRARY));
+ const auto sId = bDlgMode ? RID_BMP_DLGLIB : RID_BMP_MODLIB;
+ pBasicBox->AddEntry(aLibName, sId, xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_LIBRARY));
pBasicBox->AddEntry(aModName, RID_BMP_MODULE, xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_MODULE));
pBasicBox->set_cursor(*xRootEntry);
pBasicBox->select(*xRootEntry);
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
index 9f5daa34d644..dcdac9fbd645 100644
--- a/basctl/source/basicide/moduldlg.cxx
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -31,6 +31,7 @@
#include <basic/basmgr.hxx>
#include <com/sun/star/script/XLibraryContainerPassword.hpp>
#include <com/sun/star/script/XLibraryContainer2.hpp>
+#include <com/sun/star/frame/XController.hpp>
#include <comphelper/processfactory.hxx>
#include <sfx2/app.hxx>
#include <sfx2/dispatch.hxx>
@@ -42,7 +43,7 @@
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
#include <tools/debug.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <xmlscript/xmldlg_imexp.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
@@ -182,8 +183,23 @@ void Shell::CopyDialogResources(
io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.isDocument() ? rDestDoc.getDocument() : Reference< frame::XModel >() );
}
+void OrganizeDialog::SetCurrentEntry(const css::uno::Reference<css::frame::XFrame>& xDocFrame)
+{
+ if (!xDocFrame)
+ return;
+ Reference<css::frame::XController> xController(xDocFrame->getController());
+ if (!xController)
+ return;
+ Reference<css::frame::XModel> xModel(xController->getModel());
+ if (!xModel)
+ return;
+ EntryDescriptor aDesc(ScriptDocument(xModel), LIBRARY_LOCATION_DOCUMENT, OUString(), OUString(), OUString(), OBJ_TYPE_DOCUMENT);
+ m_xModulePage->SetCurrentEntry(aDesc);
+ m_xDialogPage->SetCurrentEntry(aDesc);
+}
+
// OrganizeDialog
-OrganizeDialog::OrganizeDialog(weld::Window* pParent, sal_Int16 tabId )
+OrganizeDialog::OrganizeDialog(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 tabId)
: GenericDialogController(pParent, "modules/BasicIDE/ui/organizedialog.ui", "OrganizeDialog")
, m_xTabCtrl(m_xBuilder->weld_notebook("tabcontrol"))
, m_xModulePage(new ObjectPage(m_xTabCtrl->get_page("modules"), "ModulePage", BrowseMode::Modules, this))
@@ -192,7 +208,9 @@ OrganizeDialog::OrganizeDialog(weld::Window* pParent, sal_Int16 tabId )
{
m_xTabCtrl->connect_enter_page(LINK(this, OrganizeDialog, ActivatePageHdl));
- OString sPage;
+ SetCurrentEntry(xDocFrame);
+
+ OUString sPage;
if (tabId == 0)
sPage = "modules";
else if (tabId == 1)
@@ -206,7 +224,7 @@ OrganizeDialog::OrganizeDialog(weld::Window* pParent, sal_Int16 tabId )
pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
}
-IMPL_LINK(OrganizeDialog, ActivatePageHdl, const OString&, rPage, void)
+IMPL_LINK(OrganizeDialog, ActivatePageHdl, const OUString&, rPage, void)
{
if (rPage == "modules")
m_xModulePage->ActivatePage();
@@ -220,7 +238,7 @@ OrganizeDialog::~OrganizeDialog()
{
}
-OrganizePage::OrganizePage(weld::Container* pParent, const OUString& rUIFile, const OString &rName, OrganizeDialog* pDialog)
+OrganizePage::OrganizePage(weld::Container* pParent, const OUString& rUIFile, const OUString &rName, OrganizeDialog* pDialog)
: m_pDialog(pDialog)
, m_xBuilder(Application::CreateBuilder(pParent, rUIFile))
, m_xContainer(m_xBuilder->weld_container(rName))
@@ -246,6 +264,10 @@ private:
if (!pSource)
return DND_ACTION_NONE;
+ // tdf#145722 only return a DND_ACTION_MOVE possibility if that
+ // is requested as an option
+ const bool bCheckForMove = rEvt.mnAction & DND_ACTION_MOVE;
+
sal_Int8 nMode = DND_ACTION_NONE;
std::unique_ptr<weld::TreeIter> xEntry(pSource->make_iterator());
@@ -255,28 +277,31 @@ private:
if (nDepth >= 2)
{
nMode = DND_ACTION_COPY;
- EntryDescriptor aDesc = m_rTreeView.GetEntryDescriptor(xEntry.get());
- const ScriptDocument& aDocument( aDesc.GetDocument() );
- const OUString& aLibName( 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( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
- ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) )
+ if (bCheckForMove)
{
- // Only allow copy for localized libraries
- bool bAllowMove = true;
- if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
+ EntryDescriptor aDesc = m_rTreeView.GetEntryDescriptor(xEntry.get());
+ const ScriptDocument& aDocument( aDesc.GetDocument() );
+ const OUString& aLibName( 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( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) )
{
- // Get StringResourceManager
- Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, aLibName, true ) );
- Reference< XStringResourceManager > xSourceMgr =
- LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
- if( xSourceMgr.is() )
- bAllowMove = ( xSourceMgr->getLocales().getLength() == 0 );
+ // Only allow copy for localized libraries
+ bool bAllowMove = true;
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
+ {
+ // Get StringResourceManager
+ Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, aLibName, true ) );
+ Reference< XStringResourceManager > xSourceMgr =
+ LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
+ if( xSourceMgr.is() )
+ bAllowMove = ( xSourceMgr->getLocales().getLength() == 0 );
+ }
+ if( bAllowMove )
+ nMode |= DND_ACTION_MOVE;
}
- if( bAllowMove )
- nMode |= DND_ACTION_MOVE;
}
}
}
@@ -369,7 +394,7 @@ private:
return DND_ACTION_NONE;
}
- void NotifyCopyingMoving(weld::TreeIter& rTarget, bool bMove)
+ void NotifyCopyingMoving(const weld::TreeIter& rTarget, bool bMove)
{
sal_uInt16 nDepth = m_rTreeView.get_iter_depth(rTarget);
std::unique_ptr<weld::TreeIter> xNewParent(m_rTreeView.make_iterator(&rTarget));
@@ -390,7 +415,7 @@ private:
// get source shell, library name and module/dialog name
std::unique_ptr<weld::TreeIter> xSelected(m_rTreeView.make_iterator());
if (!m_rTreeView.get_selected(xSelected.get()))
- xSelected.reset();
+ return;
EntryDescriptor aSourceDesc = m_rTreeView.GetEntryDescriptor(xSelected.get());
const ScriptDocument& rSourceDoc( aSourceDesc.GetDocument() );
const OUString& aSourceLibName( aSourceDesc.GetLibName() );
@@ -496,6 +521,13 @@ private:
OUString sText(m_rTreeView.get_text(*xSelected));
OUString sId(m_rTreeView.get_id(*xSelected));
+ /// if copying then clone the userdata
+ if (Entry* pEntry = bMove ? nullptr : weld::fromId<Entry*>(sId))
+ {
+ assert(pEntry->GetType() != OBJ_TYPE_DOCUMENT);
+ std::unique_ptr<Entry> xNewUserData(std::make_unique<Entry>(*pEntry));
+ sId = weld::toId(xNewUserData.release());
+ }
std::unique_ptr<weld::TreeIter> xRet(m_rTreeView.make_iterator());
m_rTreeView.get_widget().insert(xNewParent.get(), nNewChildPos, &sText, &sId, nullptr, nullptr, false, xRet.get());
if (eType == OBJ_TYPE_MODULE)
@@ -530,8 +562,8 @@ public:
};
// ObjectPage
-ObjectPage::ObjectPage(weld::Container* pParent, const OString &rName, BrowseMode nMode, OrganizeDialog* pDialog)
- : OrganizePage(pParent, "modules/BasicIDE/ui/" + OStringToOUString(rName, RTL_TEXTENCODING_UTF8).toAsciiLowerCase() + ".ui",
+ObjectPage::ObjectPage(weld::Container* pParent, const OUString &rName, BrowseMode nMode, OrganizeDialog* pDialog)
+ : OrganizePage(pParent, "modules/BasicIDE/ui/" + rName.toAsciiLowerCase() + ".ui",
rName, pDialog)
, m_xBasicBox(new SbTreeListBox(m_xBuilder->weld_tree_view("library"), pDialog->getDialog()))
, m_xEditButton(m_xBuilder->weld_button("edit"))
@@ -562,6 +594,9 @@ ObjectPage::ObjectPage(weld::Container* pParent, const OString &rName, BrowseMod
}
m_xDropTarget.reset(new SbTreeListBoxDropTarget(*m_xBasicBox));
+ // tdf#145722 explicitly claim COPY and MOVE are options
+ rtl::Reference<TransferDataContainer> xHelper(new TransferDataContainer);
+ m_xBasicBox->get_widget().enable_drag_source(xHelper, DND_ACTION_COPYMOVE);
m_xBasicBox->connect_editing(LINK(this, ObjectPage, EditingEntryHdl),
LINK(this, ObjectPage, EditedEntryHdl));
@@ -685,7 +720,7 @@ IMPL_LINK(ObjectPage, ButtonHdl, weld::Button&, rButton, void)
std::unique_ptr<weld::TreeIter> xParentEntry(m_xBasicBox->make_iterator(xCurEntry.get()));
if (m_xBasicBox->iter_parent(*xParentEntry))
{
- DocumentEntry* pDocumentEntry = reinterpret_cast<DocumentEntry*>(m_xBasicBox->get_id(*xParentEntry).toInt64());
+ DocumentEntry* pDocumentEntry = weld::fromId<DocumentEntry*>(m_xBasicBox->get_id(*xParentEntry));
if (pDocumentEntry)
aDocument = pDocumentEntry->GetDocument();
}
@@ -843,6 +878,8 @@ void ObjectPage::DeleteCurrent()
if (!m_xBasicBox->get_cursor(xCurEntry.get()))
xCurEntry.reset();
DBG_ASSERT( xCurEntry, "No current entry!" );
+ if (!xCurEntry)
+ return;
EntryDescriptor aDesc( m_xBasicBox->GetEntryDescriptor( xCurEntry.get() ) );
const ScriptDocument& aDocument( aDesc.GetDocument() );
DBG_ASSERT( aDocument.isAlive(), "ObjectPage::DeleteCurrent: no document!" );
diff --git a/basctl/source/basicide/moduldlg.hxx b/basctl/source/basicide/moduldlg.hxx
index b7fb13d8901e..c6ff166c5bb7 100644
--- a/basctl/source/basicide/moduldlg.hxx
+++ b/basctl/source/basicide/moduldlg.hxx
@@ -24,7 +24,6 @@
#include <string_view>
#include <bastype2.hxx>
-#include <tools/solar.h>
#include <vcl/weld.hxx>
#include <com/sun/star/task/XInteractionHandler.hpp>
@@ -60,11 +59,15 @@ public:
class GotoLineDialog : public weld::GenericDialogController
{
- std::unique_ptr<weld::Entry> m_xEdit;
+ std::unique_ptr<weld::SpinButton> m_xSpinButton;
+ std::unique_ptr<weld::Label> m_xLineCount;
std::unique_ptr<weld::Button> m_xOKButton;
+ sal_uInt32 m_nCurLine;
+ sal_uInt32 m_nLineCount;
+
DECL_LINK(OkButtonHandler, weld::Button&, void);
public:
- explicit GotoLineDialog(weld::Window* pParent);
+ explicit GotoLineDialog(weld::Window* pParent, sal_uInt32 nCurLine, sal_uInt32 nLineCount);
virtual ~GotoLineDialog() override;
sal_Int32 GetLineNumber() const;
};
@@ -116,7 +119,7 @@ protected:
std::unique_ptr<weld::Builder> m_xBuilder;
std::unique_ptr<weld::Container> m_xContainer;
- OrganizePage(weld::Container* pParent, const OUString& rUIFile, const OString &rName, OrganizeDialog* pDialog);
+ OrganizePage(weld::Container* pParent, const OUString& rUIFile, const OUString &rName, OrganizeDialog* pDialog);
virtual ~OrganizePage();
public:
@@ -148,9 +151,11 @@ class ObjectPage final : public OrganizePage
void EndTabDialog();
public:
- ObjectPage(weld::Container* pParent, const OString& rName, BrowseMode nMode, OrganizeDialog* pDialog);
+ ObjectPage(weld::Container* pParent, const OUString& rName, BrowseMode nMode, OrganizeDialog* pDialog);
virtual ~ObjectPage() override;
+ void SetCurrentEntry(const EntryDescriptor& rDesc) { m_xBasicBox->SetCurrentEntry(rDesc); }
+
virtual void ActivatePage() override;
};
@@ -189,7 +194,7 @@ class LibPage final : public OrganizePage
void FillListBox();
void InsertListBoxEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
void SetCurLib();
- void ImpInsertLibEntry( const OUString& rLibName, sal_uLong nPos );
+ void ImpInsertLibEntry( const OUString& rLibName, int nPos );
public:
explicit LibPage(weld::Container* pParent, OrganizeDialog* pDialog);
@@ -205,10 +210,12 @@ private:
std::unique_ptr<ObjectPage> m_xDialogPage;
std::unique_ptr<LibPage> m_xLibPage;
- DECL_LINK(ActivatePageHdl, const OString&, void);
+ DECL_LINK(ActivatePageHdl, const OUString&, void);
+
+ void SetCurrentEntry(const css::uno::Reference<css::frame::XFrame>& xDocFrame);
public:
- OrganizeDialog(weld::Window* pParent, sal_Int16 tabId);
+ OrganizeDialog(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 tabId);
virtual ~OrganizeDialog() override;
};
diff --git a/basctl/source/basicide/sbxitem.cxx b/basctl/source/basicide/sbxitem.cxx
index db012ec6c4fa..39c86b1d0893 100644
--- a/basctl/source/basicide/sbxitem.cxx
+++ b/basctl/source/basicide/sbxitem.cxx
@@ -19,37 +19,38 @@
#include <sbxitem.hxx>
#include <sal/log.hxx>
+#include <utility>
namespace basctl
{
SfxPoolItem* SbxItem::CreateDefault() { SAL_WARN( "basctl.basicide", "No SbxItem factory available"); return nullptr; }
SbxItem::SbxItem (
sal_uInt16 nWhichItem,
- ScriptDocument const& rDocument,
- OUString const& aLibName,
- OUString const& aName,
+ ScriptDocument aDocument,
+ OUString aLibName,
+ OUString aName,
ItemType eType
) :
SfxPoolItem(nWhichItem),
- m_aDocument(rDocument),
- m_aLibName(aLibName),
- m_aName(aName),
+ m_aDocument(std::move(aDocument)),
+ m_aLibName(std::move(aLibName)),
+ m_aName(std::move(aName)),
m_eType(eType)
{ }
SbxItem::SbxItem (
sal_uInt16 nWhichItem,
- ScriptDocument const& rDocument,
- OUString const& aLibName,
- OUString const& aName,
- OUString const& aMethodName,
+ ScriptDocument aDocument,
+ OUString aLibName,
+ OUString aName,
+ OUString aMethodName,
ItemType eType
) :
SfxPoolItem(nWhichItem),
- m_aDocument(rDocument),
- m_aLibName(aLibName),
- m_aName(aName),
- m_aMethodName(aMethodName),
+ m_aDocument(std::move(aDocument)),
+ m_aLibName(std::move(aLibName)),
+ m_aName(std::move(aName)),
+ m_aMethodName(std::move(aMethodName)),
m_eType(eType)
{ }
diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx
index 61c2747d5eb3..c435d7a57da7 100644
--- a/basctl/source/basicide/scriptdocument.cxx
+++ b/basctl/source/basicide/scriptdocument.cxx
@@ -51,7 +51,8 @@
#include <i18nlangtag/languagetag.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <config_folders.h>
#include <tools/debug.hxx>
#include <comphelper/documentinfo.hxx>
@@ -509,25 +510,24 @@ namespace basctl
bool ScriptDocument::Impl::removeModuleOrDialog( LibraryContainerType _eType, const OUString& _rLibName, const OUString& _rModuleName )
{
OSL_ENSURE( isValid(), "ScriptDocument::Impl::removeModuleOrDialog: invalid!" );
- if ( isValid() )
+ if ( !isValid() )
+ return false;
+ try
{
- try
- {
- Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, true ) );
- if ( xLib.is() )
- {
- xLib->removeByName( _rModuleName );
- Reference< XVBAModuleInfo > xVBAModuleInfo(xLib, UNO_QUERY);
- if(xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo(_rModuleName))
- xVBAModuleInfo->removeModuleInfo(_rModuleName);
- return true;
- }
- }
- catch( const Exception& )
+ Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, true ) );
+ if ( xLib.is() )
{
- DBG_UNHANDLED_EXCEPTION("basctl.basicide");
+ xLib->removeByName( _rModuleName );
+ Reference< XVBAModuleInfo > xVBAModuleInfo(xLib, UNO_QUERY);
+ if(xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo(_rModuleName))
+ xVBAModuleInfo->removeModuleInfo(_rModuleName);
+ return true;
}
}
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("basctl.basicide");
+ }
return false;
}
@@ -928,10 +928,9 @@ namespace basctl
}
else if ( aScheme.equalsIgnoreAsciiCase("vnd.sun.star.pkg") )
{
- OUString aAuthority = xUriRef->getAuthority();
- if ( aAuthority.matchIgnoreAsciiCase("vnd.sun.star.expand:") )
+ OUString aDecodedURL = xUriRef->getAuthority();
+ if (aDecodedURL.startsWithIgnoreAsciiCase("vnd.sun.star.expand:", &aDecodedURL))
{
- OUString aDecodedURL( aAuthority.copy( sizeof ( "vnd.sun.star.expand:" ) - 1 ) );
aDecodedURL = ::rtl::Uri::decode( aDecodedURL, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
Reference< XMacroExpander > xMacroExpander = theMacroExpander::get(xContext);
aFileURL = xMacroExpander->expandMacros( aDecodedURL );
@@ -946,9 +945,9 @@ namespace basctl
OSL_VERIFY( aFileItem.getFileStatus( aFileStatus ) == ::osl::FileBase::E_None );
OUString aCanonicalFileURL( aFileStatus.getFileURL() );
- if( aCanonicalFileURL.indexOf( "share/basic" ) >= 0 ||
- aCanonicalFileURL.indexOf( "share/uno_packages" ) >= 0 ||
- aCanonicalFileURL.indexOf( "share/extensions" ) >= 0 )
+ if( aCanonicalFileURL.indexOf( LIBO_SHARE_FOLDER "/basic" ) >= 0 ||
+ aCanonicalFileURL.indexOf( LIBO_SHARE_FOLDER "/uno_packages" ) >= 0 ||
+ aCanonicalFileURL.indexOf( LIBO_SHARE_FOLDER "/extensions" ) >= 0 )
bIsShared = true;
}
}
@@ -1213,7 +1212,8 @@ namespace basctl
auto const sort = comphelper::string::NaturalStringSorter(
comphelper::getProcessComponentContext(),
Application::GetSettings().GetUILanguageTag().getLocale());
- std::sort(aModuleNames.begin(), aModuleNames.end(),
+ auto [begin, end] = asNonConstRange(aModuleNames);
+ std::sort(begin, end,
[&sort](const OUString& rLHS, const OUString& rRHS) {
return sort.compare(rLHS, rRHS) < 0;
});
@@ -1227,7 +1227,7 @@ namespace basctl
OUString aBaseName = _eType == E_SCRIPTS ? OUString("Module") : OUString("Dialog");
- Sequence< OUString > aUsedNames( getObjectNames( _eType, _rLibName ) );
+ const Sequence< OUString > aUsedNames( getObjectNames( _eType, _rLibName ) );
std::set< OUString > aUsedNamesCheck( aUsedNames.begin(), aUsedNames.end() );
bool bValid = false;
diff --git a/basctl/source/basicide/textwindowpeer.cxx b/basctl/source/basicide/textwindowpeer.cxx
index fc458453778b..421468a27918 100644
--- a/basctl/source/basicide/textwindowpeer.cxx
+++ b/basctl/source/basicide/textwindowpeer.cxx
@@ -62,7 +62,7 @@ TextWindowPeer::CreateAccessibleContext() {
}
-css::uno::Reference<css::awt::XWindowPeer> basctl::createTextWindowPeer(
+css::uno::Reference<css::awt::XVclWindowPeer> basctl::createTextWindowPeer(
TextView & view)
{
return new TextWindowPeer(view);
diff --git a/basctl/source/basicide/textwindowpeer.hxx b/basctl/source/basicide/textwindowpeer.hxx
index 077ad32cd79f..e29c4a412dcb 100644
--- a/basctl/source/basicide/textwindowpeer.hxx
+++ b/basctl/source/basicide/textwindowpeer.hxx
@@ -25,13 +25,13 @@
namespace com::sun::star::awt
{
-class XWindowPeer;
+class XVclWindowPeer;
}
class TextView;
namespace basctl
{
-css::uno::Reference<css::awt::XWindowPeer> createTextWindowPeer(TextView& view);
+css::uno::Reference<css::awt::XVclWindowPeer> createTextWindowPeer(TextView& view);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/uiobject.cxx b/basctl/source/basicide/uiobject.cxx
index 80807d3a40a6..b875b1eceda7 100644
--- a/basctl/source/basicide/uiobject.cxx
+++ b/basctl/source/basicide/uiobject.cxx
@@ -28,8 +28,7 @@ StringMap EditorWindowUIObject::get_state()
OUStringBuffer aRes;
for (i = 0, nParas = pEditEngine->GetParagraphCount(); i < nParas; ++i)
{
- aRes.append(pEditEngine->GetText(i));
- aRes.append("\n");
+ aRes.append(pEditEngine->GetText(i) + "\n");
}
aMap["Text"] = aRes.makeStringAndClear();
diff --git a/basctl/source/basicide/unomodel.cxx b/basctl/source/basicide/unomodel.cxx
index 4a9ee759f060..64938be7754b 100644
--- a/basctl/source/basicide/unomodel.cxx
+++ b/basctl/source/basicide/unomodel.cxx
@@ -19,6 +19,7 @@
#include "basdoc.hxx"
+#include <basidesh.hxx>
#include <iderdll.hxx>
#include <com/sun/star/io/IOException.hpp>
#include <comphelper/sequence.hxx>
@@ -29,11 +30,45 @@
#include "unomodel.hxx"
+
+namespace {
+
+// Implements XEnumeration to hold a single selected portion of text
+// This will actually only hold a single string value
+class SelectionEnumeration : public ::cppu::WeakImplHelper<css::container::XEnumeration>
+{
+private:
+ OUString m_sText;
+ bool m_bHasElements;
+
+public:
+ explicit SelectionEnumeration(OUString& sSelectedText)
+ : m_sText(sSelectedText)
+ , m_bHasElements(true) {}
+
+ virtual sal_Bool SAL_CALL hasMoreElements() override
+ {
+ return m_bHasElements;
+ }
+
+ virtual css::uno::Any SAL_CALL nextElement() override
+ {
+ if (m_bHasElements)
+ {
+ m_bHasElements = false;
+ return css::uno::Any(m_sText);
+ }
+
+ throw css::container::NoSuchElementException();
+ }
+};
+
+} // End of unnamed namespace
+
namespace basctl
{
using namespace ::cppu;
-using namespace ::std;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
@@ -115,6 +150,21 @@ void SIDEModel::notImplemented()
throw io::IOException("Can't store IDE model" );
}
+// XModel
+css::uno::Reference< css::uno::XInterface > SAL_CALL SIDEModel::getCurrentSelection()
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<container::XEnumeration> xEnum;
+ Shell* pShell = GetShell();
+
+ if (pShell)
+ {
+ OUString sText = GetShell()->GetSelectionText(false);
+ xEnum = new SelectionEnumeration(sText);
+ }
+ return xEnum;
+}
+
} // namespace basctl
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
@@ -123,7 +173,7 @@ com_sun_star_comp_basic_BasicID_get_implementation(
{
SolarMutexGuard aGuard;
basctl::EnsureIde();
- SfxObjectShell* pShell = new basctl::DocShell();
+ rtl::Reference<SfxObjectShell> pShell = new basctl::DocShell();
auto pModel = pShell->GetModel();
pModel->acquire();
return pModel.get();
diff --git a/basctl/source/basicide/unomodel.hxx b/basctl/source/basicide/unomodel.hxx
index b47873005699..9b0289032660 100644
--- a/basctl/source/basicide/unomodel.hxx
+++ b/basctl/source/basicide/unomodel.hxx
@@ -53,6 +53,9 @@ public:
const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override;
virtual void SAL_CALL storeToURL( const OUString& sURL,
const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override;
+
+ // XModel
+ virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getCurrentSelection() override;
};
} // namespace basctl
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index 34467260c140..b8f3901eb34b 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -32,6 +32,7 @@
#include <com/sun/star/awt/Toolkit.hpp>
#include <com/sun/star/awt/UnoControlDialog.hpp>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
#include <com/sun/star/resource/StringResource.hpp>
#include <com/sun/star/util/XCloneable.hpp>
#include <com/sun/star/util/NumberFormatsSupplier.hpp>
@@ -43,7 +44,6 @@
#include <svx/svdpagv.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/print.hxx>
-#include <vcl/scrbar.hxx>
#include <vcl/svapp.hxx>
#include <xmlscript/xml_helper.hxx>
#include <xmlscript/xmldlg_imexp.hxx>
@@ -58,8 +58,8 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::io;
-constexpr OUStringLiteral aResourceResolverPropName = u"ResourceResolver";
-constexpr OUStringLiteral aDecorationPropName = u"Decoration";
+constexpr OUString aResourceResolverPropName = u"ResourceResolver"_ustr;
+constexpr OUString aDecorationPropName = u"Decoration"_ustr;
// DlgEdHint
@@ -182,14 +182,20 @@ DlgEditor::DlgEditor (
,pVScroll(nullptr)
,pDlgEdModel(new DlgEdModel())
,pDlgEdPage(new DlgEdPage(*pDlgEdModel))
- ,m_ClipboardDataFlavors(1)
- ,m_ClipboardDataFlavorsResource(2)
+ // set clipboard data flavors
+ ,m_ClipboardDataFlavors{ { /* MimeType */ "application/vnd.sun.xml.dialog",
+ /* HumanPresentableName */ "Dialog 6.0",
+ /* DataType */ cppu::UnoType<Sequence< sal_Int8 >>::get() } }
+ ,m_ClipboardDataFlavorsResource{ m_ClipboardDataFlavors[0],
+ { /* MimeType */ "application/vnd.sun.xml.dialogwithresource",
+ /* HumanPresentableName */ "Dialog 8.0",
+ /* DataType */ cppu::UnoType<Sequence< sal_Int8 >>::get() } }
,pObjFac(new DlgEdFactory(xModel))
,rWindow(rWindow_)
,pFunc(new DlgEdFuncSelect(*this))
,rLayout(rLayout_)
,eMode( DlgEditor::SELECT )
- ,eActObj( OBJ_DLG_PUSHBUTTON )
+ ,eActObj( SdrObjKind::BasicDialogPushButton )
,bFirstDraw(false)
,bCreateOK(true)
,bDialogModelChanged(false)
@@ -197,7 +203,6 @@ DlgEditor::DlgEditor (
,mnPaintGuard(0)
,m_xDocument( xModel )
{
- pDlgEdModel->GetItemPool().FreezeIdRanges();
pDlgEdView.reset(new DlgEdView(*pDlgEdModel, *rWindow_.GetOutDev(), *this));
pDlgEdModel->SetScaleUnit( MapUnit::Map100thMM );
@@ -207,22 +212,12 @@ DlgEditor::DlgEditor (
pDlgEdModel->InsertPage(pDlgEdPage);
- // set clipboard data flavors
- m_ClipboardDataFlavors[0].MimeType = "application/vnd.sun.xml.dialog" ;
- m_ClipboardDataFlavors[0].HumanPresentableName = "Dialog 6.0" ;
- m_ClipboardDataFlavors[0].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get();
-
- m_ClipboardDataFlavorsResource[0] = m_ClipboardDataFlavors[0];
- m_ClipboardDataFlavorsResource[1].MimeType = "application/vnd.sun.xml.dialogwithresource" ;
- m_ClipboardDataFlavorsResource[1].HumanPresentableName = "Dialog 8.0" ;
- m_ClipboardDataFlavorsResource[1].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get();
-
aMarkIdle.SetInvokeHandler( LINK( this, DlgEditor, MarkTimeout ) );
rWindow.SetMapMode( MapMode( MapUnit::Map100thMM ) );
pDlgEdPage->SetSize( rWindow.PixelToLogic( Size(DLGED_PAGE_WIDTH_MIN, DLGED_PAGE_HEIGHT_MIN) ) );
- pDlgEdView->ShowSdrPage(pDlgEdView->GetModel()->GetPage(0));
+ pDlgEdView->ShowSdrPage(pDlgEdView->GetModel().GetPage(0));
pDlgEdView->SetLayerVisible( "HiddenLayer", false );
pDlgEdView->SetMoveSnapOnlyTopLeft(true);
pDlgEdView->SetWorkArea( tools::Rectangle( Point( 0, 0 ), pDlgEdPage->GetSize() ) );
@@ -241,7 +236,6 @@ DlgEditor::DlgEditor (
SetDialog(xDialogModel);
}
-
DlgEditor::~DlgEditor()
{
aMarkIdle.Stop();
@@ -249,7 +243,6 @@ DlgEditor::~DlgEditor()
::comphelper::disposeComponent( m_xControlContainer );
}
-
Reference< awt::XControlContainer > const & DlgEditor::GetWindowControlContainer()
{
if (!m_xControlContainer.is())
@@ -257,8 +250,7 @@ Reference< awt::XControlContainer > const & DlgEditor::GetWindowControlContainer
return m_xControlContainer;
}
-
-void DlgEditor::SetScrollBars( ScrollBar* pHS, ScrollBar* pVS )
+void DlgEditor::SetScrollBars(ScrollAdaptor* pHS, ScrollAdaptor* pVS)
{
pHScroll = pHS;
pVScroll = pVS;
@@ -266,7 +258,6 @@ void DlgEditor::SetScrollBars( ScrollBar* pHS, ScrollBar* pVS )
InitScrollBars();
}
-
void DlgEditor::InitScrollBars()
{
DBG_ASSERT( pHScroll, "DlgEditor::InitScrollBars: no horizontal scroll bar!" );
@@ -351,8 +342,8 @@ void DlgEditor::SetDialog( const uno::Reference< container::XNameContainer >& xU
pDlgEdForm = new DlgEdForm(*pDlgEdModel, *this);
uno::Reference< awt::XControlModel > xDlgMod( m_xUnoControlDialogModel , uno::UNO_QUERY );
pDlgEdForm->SetUnoControlModel(xDlgMod);
- static_cast<DlgEdPage*>(pDlgEdModel->GetPage(0))->SetDlgEdForm( pDlgEdForm );
- pDlgEdModel->GetPage(0)->InsertObject( pDlgEdForm );
+ static_cast<DlgEdPage*>(pDlgEdModel->GetPage(0))->SetDlgEdForm( pDlgEdForm.get() );
+ pDlgEdModel->GetPage(0)->InsertObject( pDlgEdForm.get() );
AdjustPageSize();
pDlgEdForm->SetRectFromProps();
pDlgEdForm->UpdateTabIndices(); // for backward compatibility
@@ -362,17 +353,10 @@ void DlgEditor::SetDialog( const uno::Reference< container::XNameContainer >& xU
if ( m_xUnoControlDialogModel.is() )
{
// get sequence of control names
- Sequence< OUString > aNames = m_xUnoControlDialogModel->getElementNames();
- const 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 )
+ for (auto& aName : m_xUnoControlDialogModel->getElementNames())
{
- // get name
- OUString aName( pNames[i] );
-
// get tab index
sal_Int16 nTabIndex = -1;
Any aCtrl = m_xUnoControlDialogModel->getByName( aName );
@@ -391,11 +375,11 @@ void DlgEditor::SetDialog( const uno::Reference< container::XNameContainer >& xU
Any aCtrl = m_xUnoControlDialogModel->getByName( indexToName.second );
Reference< css::awt::XControlModel > xCtrlModel;
aCtrl >>= xCtrlModel;
- DlgEdObj* pCtrlObj = new DlgEdObj(*pDlgEdModel);
+ rtl::Reference<DlgEdObj> pCtrlObj = new DlgEdObj(*pDlgEdModel);
pCtrlObj->SetUnoControlModel( xCtrlModel );
- pCtrlObj->SetDlgEdForm( pDlgEdForm );
- pDlgEdForm->AddChild( pCtrlObj );
- pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj );
+ pCtrlObj->SetDlgEdForm( pDlgEdForm.get() );
+ pDlgEdForm->AddChild( pCtrlObj.get() );
+ pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj.get() );
pCtrlObj->SetRectFromProps();
pCtrlObj->UpdateStep();
pCtrlObj->StartListening();
@@ -409,7 +393,7 @@ void DlgEditor::SetDialog( const uno::Reference< container::XNameContainer >& xU
void DlgEditor::ResetDialog ()
{
- DlgEdForm* pOldDlgEdForm = pDlgEdForm;
+ DlgEdForm* pOldDlgEdForm = pDlgEdForm.get();
DlgEdPage* pPage = static_cast<DlgEdPage*>(pDlgEdModel->GetPage(0));
SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
bool bWasMarked = pDlgEdView->IsObjMarked( pOldDlgEdForm );
@@ -421,7 +405,7 @@ void DlgEditor::ResetDialog ()
pPage->SetDlgEdForm( nullptr );
SetDialog( m_xUnoControlDialogModel );
if( bWasMarked )
- pDlgEdView->MarkObj( pDlgEdForm, pPgView );
+ pDlgEdView->MarkObj( pDlgEdForm.get(), pPgView );
}
@@ -435,7 +419,7 @@ Reference< util::XNumberFormatsSupplier > const & DlgEditor::GetNumberFormatsSup
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
if ( !m_xSupplier.is() )
{
- m_xSupplier = xSupplier;
+ m_xSupplier = std::move(xSupplier);
}
}
return m_xSupplier;
@@ -524,16 +508,13 @@ void DlgEditor::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle
pDlgEdForm->StartListening();
// set position and size of controls
- if (const size_t nObjCount = pDlgEdPage->GetObjCount())
+ for (const rtl::Reference<SdrObject>& pObj : *pDlgEdPage)
{
- for (size_t i = 0 ; i < nObjCount ; ++i)
+ if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get()))
{
- if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pDlgEdPage->GetObj(i)))
+ if (!dynamic_cast<DlgEdForm*>(pDlgEdObj))
{
- if (!dynamic_cast<DlgEdForm*>(pDlgEdObj))
- {
- pDlgEdObj->SetRectFromProps();
- }
+ pDlgEdObj->SetRectFromProps();
}
}
}
@@ -545,27 +526,20 @@ void DlgEditor::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle
SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
const vcl::Region aPaintRectRegion(aPaintRect);
- // #i74769#
- SdrPaintWindow* pTargetPaintWindow = nullptr;
-
// mark repaint start
if (pPgView)
{
- pTargetPaintWindow = pPgView->GetView().BeginDrawLayers(&rRenderContext, aPaintRectRegion);
- OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
- }
+ // #i74769#
+ SdrPaintWindow* pTargetPaintWindow(pPgView->GetView().BeginDrawLayers(&rRenderContext, aPaintRectRegion));
+ assert(pTargetPaintWindow && "BeginDrawLayers: Got no SdrPaintWindow (!)");
- // draw background self using wallpaper
- // #i79128# ...and use correct OutDev for that
- if (pTargetPaintWindow)
- {
+ // draw background self using wallpaper
+ // #i79128# ...and use correct OutDev for that
+ Color maBackColor = rRenderContext.GetSettings().GetStyleSettings().GetLightColor();
OutputDevice& rTargetOutDev = pTargetPaintWindow->GetTargetOutputDevice();
- rTargetOutDev.DrawWallpaper(aPaintRect, Wallpaper(COL_WHITE));
- }
+ rTargetOutDev.DrawWallpaper(aPaintRect, Wallpaper(maBackColor));
- // do paint (unbuffered) and mark repaint end
- if (pPgView)
- {
+ // do paint (unbuffered) and mark repaint end
// paint of control layer is done in EndDrawLayers anyway...
pPgView->GetView().EndDrawLayers(*pTargetPaintWindow, true);
}
@@ -612,12 +586,12 @@ void DlgEditor::SetInsertObj(SdrObjKind eObj)
void DlgEditor::CreateDefaultObject()
{
// create object by factory
- SdrObject* pObj = SdrObjFactory::MakeNewObject(
+ rtl::Reference<SdrObject> pObj = SdrObjFactory::MakeNewObject(
*pDlgEdModel,
pDlgEdView->GetCurrentObjInventor(),
pDlgEdView->GetCurrentObjIdentifier());
- DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj);
+ DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get());
if (!pDlgEdObj)
return;
@@ -630,6 +604,8 @@ void DlgEditor::CreateDefaultObject()
// set default property values
pDlgEdObj->SetDefaults();
+ // set the form to which the new object belongs
+ pDlgEdObj->SetDlgEdForm(pDlgEdForm.get());
// insert object into drawing page
SdrPageView* pPageView = pDlgEdView->GetSdrPageView();
@@ -678,13 +654,9 @@ void DlgEditor::Copy()
if ( xClipDialogModel.is() )
{
- Sequence< OUString > aNames = xClipDialogModel->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_uInt32 nCtrls = aNames.getLength();
-
- for ( sal_uInt32 n = 0; n < nCtrls; n++ )
+ for (auto& rName : xClipDialogModel->getElementNames())
{
- xClipDialogModel->removeByName( pNames[n] );
+ xClipDialogModel->removeByName(rName);
}
}
@@ -763,10 +735,8 @@ void DlgEditor::Copy()
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();
@@ -792,18 +762,18 @@ void DlgEditor::Copy()
memcpy( pCombinedData + 4, DialogModelBytes.getConstArray(), nDialogDataLen );
memcpy( pCombinedData + nResOffset, aResData.getConstArray(), nResDataLen );
- aSeqData[1] <<= aCombinedData;
+ Sequence< Any > aSeqData
+ {
+ aNoResourceDialogModelBytesAny,
+ Any(aCombinedData)
+ };
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 );
+ pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavors , { Any(DialogModelBytes) } );
}
SolarMutexReleaser aReleaser;
xClipboard->setContents( pTrans , pTrans );
@@ -867,27 +837,31 @@ void DlgEditor::Paste()
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++ )
+ if (nTotalLen > 4)
{
- nResOffset += nFactor * sal_uInt8( pCombinedData[i] );
- nFactor *= 256;
- }
+ // Reading offset
+ sal_Int32 nResOffset = 0;
+ sal_Int32 nFactor = 1;
+ for (sal_Int16 i = 0; i < 4; i++)
+ {
+ nResOffset += nFactor * sal_uInt8(aCombinedData[i]);
+ nFactor *= 256;
+ }
+
+ if (nResOffset > nTotalLen || nResOffset < 0)
+ nResOffset = nTotalLen;
- sal_Int32 nResDataLen = nTotalLen - nResOffset;
- sal_Int32 nDialogDataLen = nTotalLen - nResDataLen - 4;
+ sal_Int32 nResDataLen = nTotalLen - nResOffset;
+ sal_Int32 nDialogDataLen = nTotalLen - nResDataLen - 4;
- DialogModelBytes.realloc( nDialogDataLen );
- memcpy( DialogModelBytes.getArray(), pCombinedData + 4, nDialogDataLen );
+ DialogModelBytes.realloc(nDialogDataLen);
+ memcpy(DialogModelBytes.getArray(), aCombinedData.getConstArray() + 4, nDialogDataLen);
- aResData.realloc( nResDataLen );
- memcpy( aResData.getArray(), pCombinedData + nResOffset, nResDataLen );
+ aResData.realloc(nResDataLen);
+ memcpy(aResData.getArray(), aCombinedData.getConstArray() + nResOffset, nResDataLen);
+ }
}
else
{
@@ -906,18 +880,16 @@ void DlgEditor::Paste()
return;
Sequence< OUString > aNames = xClipDialogModel->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_uInt32 nCtrls = aNames.getLength();
Reference< resource::XStringResourcePersistence > xStringResourcePersistence;
- if( nCtrls > 0 && bSourceIsLocalized )
+ if (aNames.hasElements() && bSourceIsLocalized)
{
xStringResourcePersistence = css::resource::StringResource::create( getProcessComponentContext() );
xStringResourcePersistence->importBinary( aResData );
}
- for( sal_uInt32 n = 0; n < nCtrls; n++ )
+ for (auto& rName : aNames)
{
- Any aA = xClipDialogModel->getByName( pNames[n] );
+ Any aA = xClipDialogModel->getByName(rName);
Reference< css::awt::XControlModel > xCM;
aA >>= xCM;
@@ -925,9 +897,9 @@ void DlgEditor::Paste()
Reference< util::XCloneable > xClone( xCM, uno::UNO_QUERY );
Reference< awt::XControlModel > xCtrlModel( xClone->createClone(), uno::UNO_QUERY );
- DlgEdObj* pCtrlObj = new DlgEdObj(*pDlgEdModel);
- pCtrlObj->SetDlgEdForm(pDlgEdForm); // set parent form
- pDlgEdForm->AddChild(pCtrlObj); // add child to parent form
+ rtl::Reference<DlgEdObj> pCtrlObj = new DlgEdObj(*pDlgEdModel);
+ pCtrlObj->SetDlgEdForm(pDlgEdForm.get()); // set parent form
+ pDlgEdForm->AddChild(pCtrlObj.get()); // add child to parent form
pCtrlObj->SetUnoControlModel( xCtrlModel ); // set control model
// set new name
@@ -961,7 +933,7 @@ void DlgEditor::Paste()
m_xUnoControlDialogModel->insertByName( aOUniqueName , aCtrlModel );
// insert object into drawing page
- pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj );
+ pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj.get() );
pCtrlObj->SetRectFromProps();
pCtrlObj->UpdateStep();
pDlgEdForm->UpdateTabOrderAndGroups();
@@ -969,7 +941,7 @@ void DlgEditor::Paste()
// mark object
SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
- pDlgEdView->MarkObj( pCtrlObj, pPgView, false, true);
+ pDlgEdView->MarkObj( pCtrlObj.get(), pPgView, false, true);
}
// center marked objects in dialog editor form
diff --git a/basctl/source/dlged/dlgedclip.cxx b/basctl/source/dlged/dlgedclip.cxx
index 931f10afe507..264e42c835b4 100644
--- a/basctl/source/dlged/dlgedclip.cxx
+++ b/basctl/source/dlged/dlgedclip.cxx
@@ -90,7 +90,7 @@ sal_Bool SAL_CALL DlgEdTransferableImpl::isDataFlavorSupported( const DataFlavor
{
const SolarMutexGuard aGuard;
- for ( auto const & i : std::as_const(m_SeqFlavors) )
+ for (auto const& i : m_SeqFlavors)
if ( compareDataFlavors( i, rFlavor ) )
return true;
return false;
diff --git a/basctl/source/dlged/dlgedfac.cxx b/basctl/source/dlged/dlgedfac.cxx
index 98c0f260b0f9..65e29654914d 100644
--- a/basctl/source/dlged/dlgedfac.cxx
+++ b/basctl/source/dlged/dlgedfac.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/awt/ScrollBarOrientation.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <comphelper/processfactory.hxx>
+#include <utility>
namespace basctl
{
@@ -32,7 +33,7 @@ namespace basctl
using namespace ::com::sun::star;
-DlgEdFactory::DlgEdFactory( const css::uno::Reference< css::frame::XModel >& xModel ) : mxModel( xModel )
+DlgEdFactory::DlgEdFactory( css::uno::Reference< css::frame::XModel > xModel ) : mxModel(std::move( xModel ))
{
SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
}
@@ -44,56 +45,53 @@ DlgEdFactory::~DlgEdFactory() COVERITY_NOEXCEPT_FALSE
}
-IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
+IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, rtl::Reference<SdrObject> )
{
static const uno::Reference<lang::XMultiServiceFactory> xDialogSFact = [] {
uno::Reference<lang::XMultiServiceFactory> xFact;
uno::Reference< uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
uno::Reference< container::XNameContainer > xC( xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.awt.UnoControlDialogModel", xContext ), uno::UNO_QUERY );
- if( xC.is() )
- {
- uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY );
- xFact = xModFact;
- }
+ if (xC.is())
+ xFact.set(xC, uno::UNO_QUERY);
return xFact;
}();
- SdrObject* pNewObj = nullptr;
+ rtl::Reference<SdrObject> pNewObj;
if( (aParams.nInventor == SdrInventor::BasicDialog) &&
- (aParams.nObjIdentifier >= OBJ_DLG_PUSHBUTTON) &&
- (aParams.nObjIdentifier <= OBJ_DLG_FORMHSCROLL) )
+ (aParams.nObjIdentifier >= SdrObjKind::BasicDialogPushButton) &&
+ (aParams.nObjIdentifier <= SdrObjKind::BasicDialogFormHorizontalScroll) )
{
switch( aParams.nObjIdentifier )
{
- case OBJ_DLG_PUSHBUTTON:
+ case SdrObjKind::BasicDialogPushButton:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlButtonModel", xDialogSFact );
break;
- case OBJ_DLG_RADIOBUTTON:
+ case SdrObjKind::BasicDialogRadioButton:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlRadioButtonModel", xDialogSFact );
break;
- case OBJ_DLG_FORMRADIO:
+ case SdrObjKind::BasicDialogFormRadio:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.RadioButton", xDialogSFact );
- static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
+ static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel );
break;
- case OBJ_DLG_CHECKBOX:
+ case SdrObjKind::BasicDialogCheckbox:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlCheckBoxModel", xDialogSFact );
break;
- case OBJ_DLG_FORMCHECK:
+ case SdrObjKind::BasicDialogFormCheck:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.CheckBox", xDialogSFact );
- static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
+ static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel );
break;
- case OBJ_DLG_LISTBOX:
+ case SdrObjKind::BasicDialogListbox:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact );
break;
- case OBJ_DLG_FORMLIST:
+ case SdrObjKind::BasicDialogFormList:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ListBox", xDialogSFact );
- static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
+ static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel );
break;
- case OBJ_DLG_FORMCOMBO:
- case OBJ_DLG_COMBOBOX:
+ case SdrObjKind::BasicDialogFormCombo:
+ case SdrObjKind::BasicDialogCombobox:
{
- DlgEdObj* pNew = nullptr;
- if ( aParams.nObjIdentifier == OBJ_DLG_COMBOBOX )
+ rtl::Reference<DlgEdObj> pNew;
+ if ( aParams.nObjIdentifier == SdrObjKind::BasicDialogCombobox )
pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlComboBoxModel", xDialogSFact );
else
{
@@ -114,33 +112,33 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
}
}
break;
- case OBJ_DLG_GROUPBOX:
+ case SdrObjKind::BasicDialogGroupBox:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlGroupBoxModel", xDialogSFact );
break;
- case OBJ_DLG_EDIT:
+ case SdrObjKind::BasicDialogEdit:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlEditModel", xDialogSFact );
break;
- case OBJ_DLG_FIXEDTEXT:
+ case SdrObjKind::BasicDialogFixedText:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedTextModel", xDialogSFact );
break;
- case OBJ_DLG_IMAGECONTROL:
+ case SdrObjKind::BasicDialogImageControl:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlImageControlModel", xDialogSFact );
break;
- case OBJ_DLG_PROGRESSBAR:
+ case SdrObjKind::BasicDialogProgressbar:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlProgressBarModel", xDialogSFact );
break;
- case OBJ_DLG_HSCROLLBAR:
+ case SdrObjKind::BasicDialogHorizontalScrollbar:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact );
break;
- case OBJ_DLG_FORMHSCROLL:
+ case SdrObjKind::BasicDialogFormHorizontalScroll:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ScrollBar", xDialogSFact );
- static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
+ static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel );
break;
- case OBJ_DLG_FORMVSCROLL:
- case OBJ_DLG_VSCROLLBAR:
+ case SdrObjKind::BasicDialogFormVerticalScroll:
+ case SdrObjKind::BasicDialogVerticalScrollbar:
{
- DlgEdObj* pNew = nullptr;
- if ( aParams.nObjIdentifier == OBJ_DLG_VSCROLLBAR )
+ rtl::Reference<DlgEdObj> pNew;
+ if ( aParams.nObjIdentifier == SdrObjKind::BasicDialogVerticalScrollbar )
pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact );
else
{
@@ -161,12 +159,12 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
{
}
} break;
- case OBJ_DLG_HFIXEDLINE:
+ case SdrObjKind::BasicDialogHorizontalFixedLine:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
break;
- case OBJ_DLG_VFIXEDLINE:
+ case SdrObjKind::BasicDialogVerticalFixedLine:
{
- DlgEdObj* pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
+ rtl::Reference<DlgEdObj> pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
pNewObj = pNew;
// set vertical orientation
try
@@ -181,41 +179,41 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* )
{
}
} break;
- case OBJ_DLG_DATEFIELD:
+ case SdrObjKind::BasicDialogDateField:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlDateFieldModel", xDialogSFact );
break;
- case OBJ_DLG_TIMEFIELD:
+ case SdrObjKind::BasicDialogTimeField:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlTimeFieldModel", xDialogSFact );
break;
- case OBJ_DLG_NUMERICFIELD:
+ case SdrObjKind::BasicDialogNumericField:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlNumericFieldModel", xDialogSFact );
break;
- case OBJ_DLG_CURRENCYFIELD:
+ case SdrObjKind::BasicDialogCurencyField:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlCurrencyFieldModel", xDialogSFact );
break;
- case OBJ_DLG_FORMATTEDFIELD:
+ case SdrObjKind::BasicDialogFormattedField:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFormattedFieldModel", xDialogSFact );
break;
- case OBJ_DLG_PATTERNFIELD:
+ case SdrObjKind::BasicDialogPatternField:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlPatternFieldModel", xDialogSFact );
break;
- case OBJ_DLG_FILECONTROL:
+ case SdrObjKind::BasicDialogFileControl:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFileControlModel", xDialogSFact );
break;
- case OBJ_DLG_SPINBUTTON:
+ case SdrObjKind::BasicDialogSpinButton:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlSpinButtonModel", xDialogSFact );
break;
- case OBJ_DLG_FORMSPIN:
+ case SdrObjKind::BasicDialogFormSpin:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.SpinButton", xDialogSFact );
- static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel );
+ static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel );
break;
- case OBJ_DLG_TREECONTROL:
+ case SdrObjKind::BasicDialogTreeControl:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.tree.TreeControlModel", xDialogSFact );
break;
- case OBJ_DLG_GRIDCONTROL:
+ case SdrObjKind::BasicDialogGridControl:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.grid.UnoControlGridModel", xDialogSFact );
break;
- case OBJ_DLG_HYPERLINKCONTROL:
+ case SdrObjKind::BasicDialogHyperlinkControl:
pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedHyperlinkModel", xDialogSFact );
break;
default:
diff --git a/basctl/source/dlged/dlgedfunc.cxx b/basctl/source/dlged/dlgedfunc.cxx
index 593f0370f635..7f1a0388eeaa 100644
--- a/basctl/source/dlged/dlgedfunc.cxx
+++ b/basctl/source/dlged/dlgedfunc.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <vcl/scrbar.hxx>
+#include <svtools/scrolladaptor.hxx>
#include <svx/svdview.hxx>
#include <dlgedfunc.hxx>
#include <dlged.hxx>
@@ -41,16 +41,16 @@ void DlgEdFunc::ForceScroll( const Point& rPos )
vcl::Window& rWindow = rParent.GetWindow();
- static Point aDefPoint;
+ static const Point aDefPoint;
tools::Rectangle aOutRect( aDefPoint, rWindow.GetOutputSizePixel() );
aOutRect = rWindow.PixelToLogic( aOutRect );
- ScrollBar* pHScroll = rParent.GetHScroll();
- ScrollBar* pVScroll = rParent.GetVScroll();
+ ScrollAdaptor* pHScroll = rParent.GetHScroll();
+ ScrollAdaptor* pVScroll = rParent.GetVScroll();
tools::Long nDeltaX = pHScroll->GetLineSize();
tools::Long nDeltaY = pVScroll->GetLineSize();
- if( !aOutRect.IsInside( rPos ) )
+ if( !aOutRect.Contains( rPos ) )
{
if( rPos.X() < aOutRect.Left() )
nDeltaX = -nDeltaX;
@@ -77,7 +77,7 @@ void DlgEdFunc::ForceScroll( const Point& rPos )
}
DlgEdFunc::DlgEdFunc (DlgEditor& rParent_) :
- rParent(rParent_)
+ rParent(rParent_), aScrollTimer("basctl DlgEdFunc aScrollTimer")
{
aScrollTimer.SetInvokeHandler( LINK( this, DlgEdFunc, ScrollTimeout ) );
aScrollTimer.SetTimeout( SELENG_AUTOREPEAT_INTERVAL );
@@ -233,7 +233,7 @@ bool DlgEdFunc::KeyInput( const KeyEvent& rKEvt )
tools::Rectangle aMarkRect( rView.GetMarkedObjRect() );
aMarkRect.Move( nX, nY );
- if ( !rWorkArea.IsInside( aMarkRect ) )
+ if ( !rWorkArea.Contains( aMarkRect ) )
{
if ( aMarkRect.Left() < rWorkArea.Left() )
nX += rWorkArea.Left() - aMarkRect.Left();
@@ -294,7 +294,7 @@ bool DlgEdFunc::KeyInput( const KeyEvent& rKEvt )
else
{
// scroll page
- ScrollBar* pScrollBar = ( nX != 0 ) ? rParent.GetHScroll() : rParent.GetVScroll();
+ ScrollAdaptor* pScrollBar = ( nX != 0 ) ? rParent.GetHScroll() : rParent.GetVScroll();
if ( pScrollBar )
{
tools::Long nRangeMin = pScrollBar->GetRangeMin();
diff --git a/basctl/source/dlged/dlgedmod.cxx b/basctl/source/dlged/dlgedmod.cxx
index 3bc5453ad66f..017e4b16c78f 100644
--- a/basctl/source/dlged/dlgedmod.cxx
+++ b/basctl/source/dlged/dlgedmod.cxx
@@ -22,10 +22,7 @@
namespace basctl
{
-DlgEdModel::DlgEdModel()
- : SdrModel()
-{
-}
+DlgEdModel::DlgEdModel() {}
DlgEdModel::~DlgEdModel() {}
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
index 6353ddf9ecd6..505c570b7f05 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -42,6 +42,7 @@
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <com/sun/star/script/XScriptEventsSupplier.hpp>
#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
#include <cppuhelper/exc_hlp.hxx>
#include <o3tl/functional.hxx>
#include <svx/svdpagv.hxx>
@@ -70,7 +71,6 @@ DlgEditor& DlgEdObj::GetDialogEditor ()
DlgEdObj::DlgEdObj(SdrModel& rSdrModel)
: SdrUnoObj(rSdrModel, OUString())
,bIsListening(false)
- ,pDlgEdForm( nullptr )
{
}
@@ -118,7 +118,6 @@ DlgEdObj::DlgEdObj(
const css::uno::Reference< css::lang::XMultiServiceFactory >& rxSFac)
: SdrUnoObj(rSdrModel, rModelName, rxSFac)
,bIsListening(false)
- ,pDlgEdForm( nullptr )
{
}
@@ -581,16 +580,12 @@ void DlgEdObj::TabIndexChange( const beans::PropertyChangeEvent& evt )
{
// get sequence of control names
Sequence< OUString > aNames = xNameAcc->getElementNames();
- const 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 )
+ for (auto& aName : aNames)
{
- // get control name
- OUString aName( pNames[i] );
-
// get tab index
sal_Int16 nTabIndex = -1;
Any aCtrl = xNameAcc->getByName( aName );
@@ -810,112 +805,112 @@ SdrObjKind DlgEdObj::GetObjIdentifier() const
{
if ( supportsService( "com.sun.star.awt.UnoControlDialogModel" ))
{
- return OBJ_DLG_DIALOG;
+ return SdrObjKind::BasicDialogDialog;
}
else if ( supportsService( "com.sun.star.awt.UnoControlButtonModel" ))
{
- return OBJ_DLG_PUSHBUTTON;
+ return SdrObjKind::BasicDialogPushButton;
}
else if ( supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ))
{
- return OBJ_DLG_RADIOBUTTON;
+ return SdrObjKind::BasicDialogRadioButton;
}
else if ( supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" ))
{
- return OBJ_DLG_CHECKBOX;
+ return SdrObjKind::BasicDialogCheckbox;
}
else if ( supportsService( "com.sun.star.awt.UnoControlListBoxModel" ))
{
- return OBJ_DLG_LISTBOX;
+ return SdrObjKind::BasicDialogListbox;
}
else if ( supportsService( "com.sun.star.awt.UnoControlComboBoxModel" ))
{
- return OBJ_DLG_COMBOBOX;
+ return SdrObjKind::BasicDialogCombobox;
}
else if ( supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" ))
{
- return OBJ_DLG_GROUPBOX;
+ return SdrObjKind::BasicDialogGroupBox;
}
else if ( supportsService( "com.sun.star.awt.UnoControlEditModel" ))
{
- return OBJ_DLG_EDIT;
+ return SdrObjKind::BasicDialogEdit;
}
else if ( supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ))
{
- return OBJ_DLG_FIXEDTEXT;
+ return SdrObjKind::BasicDialogFixedText;
}
else if ( supportsService( "com.sun.star.awt.UnoControlImageControlModel" ))
{
- return OBJ_DLG_IMAGECONTROL;
+ return SdrObjKind::BasicDialogImageControl;
}
else if ( supportsService( "com.sun.star.awt.UnoControlProgressBarModel" ))
{
- return OBJ_DLG_PROGRESSBAR;
+ return SdrObjKind::BasicDialogProgressbar;
}
else if ( supportsService( "com.sun.star.awt.UnoControlScrollBarModel" ))
{
- return OBJ_DLG_HSCROLLBAR;
+ return SdrObjKind::BasicDialogHorizontalScrollbar;
}
else if ( supportsService( "com.sun.star.awt.UnoControlFixedLineModel" ))
{
- return OBJ_DLG_HFIXEDLINE;
+ return SdrObjKind::BasicDialogHorizontalFixedLine;
}
else if ( supportsService( "com.sun.star.awt.UnoControlDateFieldModel" ))
{
- return OBJ_DLG_DATEFIELD;
+ return SdrObjKind::BasicDialogDateField;
}
else if ( supportsService( "com.sun.star.awt.UnoControlTimeFieldModel" ))
{
- return OBJ_DLG_TIMEFIELD;
+ return SdrObjKind::BasicDialogTimeField;
}
else if ( supportsService( "com.sun.star.awt.UnoControlNumericFieldModel" ))
{
- return OBJ_DLG_NUMERICFIELD;
+ return SdrObjKind::BasicDialogNumericField;
}
else if ( supportsService( "com.sun.star.awt.UnoControlCurrencyFieldModel" ))
{
- return OBJ_DLG_CURRENCYFIELD;
+ return SdrObjKind::BasicDialogCurencyField;
}
else if ( supportsService( "com.sun.star.awt.UnoControlFormattedFieldModel" ))
{
- return OBJ_DLG_FORMATTEDFIELD;
+ return SdrObjKind::BasicDialogFormattedField;
}
else if ( supportsService( "com.sun.star.awt.UnoControlPatternFieldModel" ))
{
- return OBJ_DLG_PATTERNFIELD;
+ return SdrObjKind::BasicDialogPatternField;
}
else if ( supportsService( "com.sun.star.awt.UnoControlFileControlModel" ))
{
- return OBJ_DLG_FILECONTROL;
+ return SdrObjKind::BasicDialogFileControl;
}
else if ( supportsService( "com.sun.star.awt.tree.TreeControlModel" ))
{
- return OBJ_DLG_TREECONTROL;
+ return SdrObjKind::BasicDialogTreeControl;
}
else if ( supportsService( "com.sun.star.awt.grid.UnoControlGridModel" ))
{
- return OBJ_DLG_GRIDCONTROL;
+ return SdrObjKind::BasicDialogGridControl;
}
else if ( supportsService( "com.sun.star.awt.UnoControlFixedHyperlinkModel" ))
{
- return OBJ_DLG_HYPERLINKCONTROL;
+ return SdrObjKind::BasicDialogHyperlinkControl;
}
else
{
- return OBJ_DLG_CONTROL;
+ return SdrObjKind::BasicDialogControl;
}
}
-DlgEdObj* DlgEdObj::CloneSdrObject(SdrModel& rTargetModel) const
+rtl::Reference<SdrObject> DlgEdObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new DlgEdObj(rTargetModel, *this);
}
-SdrObjectUniquePtr DlgEdObj::getFullDragClone() const
+rtl::Reference<SdrObject> DlgEdObj::getFullDragClone() const
{
// no need to really add the clone for dragging, it's a temporary
// object
- return SdrObjectUniquePtr(new SdrUnoObj(getSdrModelFromSdrObject(), *this));
+ return rtl::Reference<SdrObject>(new SdrUnoObj(getSdrModelFromSdrObject(), *this));
}
void DlgEdObj::NbcMove( const Size& rSize )
@@ -961,7 +956,7 @@ bool DlgEdObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
// implementation. For historical reasons, the SdrPage (which is the DlgEdPage) was
// already set. For now, get it from the SdrDragStat and use it to access and set
// the local pDlgEdForm
- if(nullptr == pDlgEdForm && nullptr != rStat.GetPageView())
+ if(!pDlgEdForm && nullptr != rStat.GetPageView())
{
const DlgEdPage* pDlgEdPage(dynamic_cast<const DlgEdPage*>(rStat.GetPageView()->GetPage()));
@@ -1289,7 +1284,7 @@ void DlgEdForm::AddChild( DlgEdObj* pDlgEdObj )
void DlgEdForm::RemoveChild( DlgEdObj* pDlgEdObj )
{
- pChildren.erase( std::remove( pChildren.begin() , pChildren.end() , pDlgEdObj ) );
+ std::erase(pChildren, pDlgEdObj);
}
void DlgEdForm::PositionAndSizeChange( const beans::PropertyChangeEvent& evt )
@@ -1407,10 +1402,9 @@ void DlgEdForm::UpdateStep()
if ( pSdrPage )
{
- const size_t nObjCount = pSdrPage->GetObjCount();
- for ( size_t i = 0 ; i < nObjCount ; i++ )
+ for (const rtl::Reference<SdrObject>& pObj : *pSdrPage)
{
- DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pSdrPage->GetObj(i));
+ DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get());
if (pDlgEdObj && !dynamic_cast<DlgEdForm*>(pDlgEdObj))
pDlgEdObj->UpdateStep();
}
@@ -1429,17 +1423,10 @@ void DlgEdForm::UpdateTabIndices()
if ( xNameAcc.is() )
{
// get sequence of control names
- Sequence< OUString > aNames = xNameAcc->getElementNames();
- const 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 )
+ for (auto& aName : xNameAcc->getElementNames())
{
- // get name
- OUString aName( pNames[i] );
-
// get tab index
sal_Int16 nTabIndex = -1;
Any aCtrl = xNameAcc->getByName( aName );
@@ -1487,11 +1474,8 @@ void DlgEdForm::UpdateTabOrder()
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();
+ for (auto& xTabController : xCont->getTabControllers())
+ xTabController->activateTabOrder();
}
}
@@ -1513,8 +1497,9 @@ void DlgEdForm::UpdateGroups()
std::vector<DlgEdObj*> aChildList = GetChildren();
sal_uInt32 nSize = aChildList.size();
Sequence< Reference< awt::XControl > > aSeqControls( nSize );
+ auto* pSeqControlsData = aSeqControls.getArray();
for ( sal_uInt32 i = 0; i < nSize; ++i )
- aSeqControls.getArray()[i] = aChildList[i]->GetControl();
+ pSeqControlsData[i] = aChildList[i]->GetControl();
sal_Int32 nGroupCount = xTabModel->getGroupCount();
for ( sal_Int32 nGroup = 0; nGroup < nGroupCount; ++nGroup )
@@ -1523,26 +1508,23 @@ void DlgEdForm::UpdateGroups()
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 );
+ auto* pSeqPeersData = aSeqPeers.getArray();
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 )
+ for (auto& xCtrl : aSeqControls)
{
- const Reference< awt::XControl > xCtrl( pControls[nControl] );
if ( xCtrl.is() )
{
Reference< awt::XControlModel > xCtrlModel( xCtrl->getModel() );
- if ( xCtrlModel.get() == pModels[nModel].get() )
+ if (xCtrlModel.get() == aSeqModels[nModel].get())
{
// get the control peer and insert into the list of peers
- aSeqPeers.getArray()[ nModel ].set( xCtrl->getPeer(), UNO_QUERY );
+ pSeqPeersData[nModel].set(xCtrl->getPeer(), UNO_QUERY);
break;
}
}
@@ -1675,18 +1657,21 @@ void DlgEdObj::MakeDataAware( const Reference< frame::XModel >& xModel )
if ( !xFac.is() )
return;
- css::table::CellAddress aApiAddress;
-
- //tdf#90361 CellValueBinding and CellRangeListSource are unusable
+ //tdf#90361 and tdf#104011 CellValueBinding and CellRangeListSource are unusable
//without being initialized, so use createInstanceWithArguments with a
- //dummy BoundCell instead of createInstance. This at least results in
+ //dummy BoundCell and CellRange instead of createInstance. This at least results in
//the dialog editor not falling.
- css::beans::NamedValue aValue;
- aValue.Name = "BoundCell";
- aValue.Value <<= aApiAddress;
+ css::beans::NamedValue aCellValue;
+ aCellValue.Name = "BoundCell";
+ css::table::CellAddress aCellAddress;
+ aCellValue.Value <<= aCellAddress;
+
+ css::beans::NamedValue aCellRange;
+ aCellRange.Name = "CellRange";
+ css::table::CellRangeAddress aRangeAddress;
+ aCellRange.Value <<= aRangeAddress;
- Sequence< Any > aArgs( 1 );
- aArgs[ 0 ] <<= aValue;
+ Sequence< Any > aArgs{ Any(aCellValue), Any(aCellRange) };
if ( xBindable.is() )
{
diff --git a/basctl/source/dlged/dlgedview.cxx b/basctl/source/dlged/dlgedview.cxx
index 0878596d8f41..81271d38f8bd 100644
--- a/basctl/source/dlged/dlgedview.cxx
+++ b/basctl/source/dlged/dlgedview.cxx
@@ -21,8 +21,8 @@
#include <dlged.hxx>
#include <dlgedpage.hxx>
+#include <svtools/scrolladaptor.hxx>
#include <vcl/canvastools.hxx>
-#include <vcl/scrbar.hxx>
#include <dlgedobj.hxx>
@@ -63,7 +63,7 @@ void DlgEdView::MakeVisible( const tools::Rectangle& rRect, vcl::Window& rWin )
tools::Rectangle aVisRect( RectTmp );
// check, if rectangle is inside visible area
- if ( aVisRect.IsInside( rRect ) )
+ if ( aVisRect.Contains( rRect ) )
return;
// calculate scroll distance; the rectangle must be inside the visible area
diff --git a/basctl/source/dlged/managelang.cxx b/basctl/source/dlged/managelang.cxx
index d36c23803e7a..ba6ca0a01442 100644
--- a/basctl/source/dlged/managelang.cxx
+++ b/basctl/source/dlged/managelang.cxx
@@ -31,6 +31,7 @@
#include <sfx2/sfxsids.hrc>
#include <svtools/langtab.hxx>
#include <svx/langbox.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
#include <vcl/settings.hxx>
@@ -39,7 +40,6 @@
namespace basctl
{
-using namespace ::com::sun::star::i18n;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::resource;
using namespace ::com::sun::star::uno;
@@ -52,9 +52,9 @@ bool localesAreEqual( const Locale& rLocaleLeft, const Locale& rLocaleRight )
return bRet;
}
-ManageLanguageDialog::ManageLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> const & xLMgr)
+ManageLanguageDialog::ManageLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> xLMgr)
: GenericDialogController(pParent, "modules/BasicIDE/ui/managelanguages.ui", "ManageLanguagesDialog")
- , m_xLocalizationMgr(xLMgr)
+ , m_xLocalizationMgr(std::move(xLMgr))
, m_sDefLangStr(IDEResId(RID_STR_DEF_LANG))
, m_sCreateLangStr(IDEResId(RID_STR_CREATE_LANG))
, m_xLanguageLB(m_xBuilder->weld_tree_view("treeview"))
@@ -100,20 +100,17 @@ void ManageLanguageDialog::FillLanguageBox()
if ( m_xLocalizationMgr->isLibraryLocalized() )
{
Locale aDefaultLocale = m_xLocalizationMgr->getStringResourceManager()->getDefaultLocale();
- Sequence< Locale > aLocaleSeq = m_xLocalizationMgr->getStringResourceManager()->getLocales();
- const Locale* pLocale = aLocaleSeq.getConstArray();
- sal_Int32 i, nCount = aLocaleSeq.getLength();
- for ( i = 0; i < nCount; ++i )
+ for (auto& rLocale : m_xLocalizationMgr->getStringResourceManager()->getLocales())
{
- bool bIsDefault = localesAreEqual( aDefaultLocale, pLocale[i] );
- LanguageType eLangType = LanguageTag::convertToLanguageType( pLocale[i] );
+ bool bIsDefault = localesAreEqual(aDefaultLocale, rLocale);
+ LanguageType eLangType = LanguageTag::convertToLanguageType(rLocale);
OUString sLanguage = SvtLanguageTable::GetLanguageString( eLangType );
if ( bIsDefault )
{
sLanguage += " " + m_sDefLangStr;
}
- LanguageEntry* pEntry = new LanguageEntry(pLocale[i], bIsDefault);
- m_xLanguageLB->append(OUString::number(reinterpret_cast<sal_Int64>(pEntry)), sLanguage);
+ LanguageEntry* pEntry = new LanguageEntry(rLocale, bIsDefault);
+ m_xLanguageLB->append(weld::toId(pEntry), sLanguage);
}
}
else
@@ -125,7 +122,7 @@ void ManageLanguageDialog::ClearLanguageBox()
const sal_Int32 nCount = m_xLanguageLB->n_children();
for (sal_Int32 i = 0; i < nCount; ++i)
{
- LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xLanguageLB->get_id(i).toInt64());
+ LanguageEntry* pEntry = weld::fromId<LanguageEntry*>(m_xLanguageLB->get_id(i));
delete pEntry;
}
m_xLanguageLB->clear();
@@ -162,12 +159,13 @@ IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl, weld::Button&, void)
int nPos = m_xLanguageLB->get_selected_index();
// remove locales
Sequence< Locale > aLocaleSeq( nCount );
+ auto aLocaleSeqRange = asNonConstRange(aLocaleSeq);
for (int i = 0; i < nCount; ++i)
{
const sal_Int32 nSelPos = aSelection[i];
- LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xLanguageLB->get_id(nSelPos).toInt64());
+ LanguageEntry* pEntry = weld::fromId<LanguageEntry*>(m_xLanguageLB->get_id(nSelPos));
if ( pEntry )
- aLocaleSeq[i] = pEntry->m_aLocale;
+ aLocaleSeqRange[i] = pEntry->m_aLocale;
}
m_xLocalizationMgr->handleRemoveLocales( aLocaleSeq );
// update listbox
@@ -184,7 +182,7 @@ IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl, weld::Button&, void)
IMPL_LINK_NOARG(ManageLanguageDialog, MakeDefHdl, weld::Button&, void)
{
const sal_Int32 nPos = m_xLanguageLB->get_selected_index();
- LanguageEntry* pSelectEntry = reinterpret_cast<LanguageEntry*>(m_xLanguageLB->get_id(nPos).toInt64());
+ LanguageEntry* pSelectEntry = weld::fromId<LanguageEntry*>(m_xLanguageLB->get_id(nPos));
if (pSelectEntry && !pSelectEntry->m_bIsDefault)
{
// set new default entry
@@ -212,9 +210,9 @@ IMPL_LINK_NOARG(ManageLanguageDialog, SelectHdl, weld::TreeView&, void)
// class SetDefaultLanguageDialog -----------------------------------------------
-SetDefaultLanguageDialog::SetDefaultLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> const & xLMgr)
+SetDefaultLanguageDialog::SetDefaultLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> xLMgr)
: GenericDialogController(pParent, "modules/BasicIDE/ui/defaultlanguage.ui", "DefaultLanguageDialog")
- , m_xLocalizationMgr(xLMgr)
+ , m_xLocalizationMgr(std::move(xLMgr))
, m_xLanguageFT(m_xBuilder->weld_label("defaultlabel"))
, m_xLanguageLB(m_xBuilder->weld_tree_view("entries"))
, m_xCheckLangFT(m_xBuilder->weld_label("checkedlabel"))
@@ -255,11 +253,8 @@ void SetDefaultLanguageDialog::FillLanguageBox()
if (m_xLocalizationMgr->isLibraryLocalized())
{
// remove the already localized languages
- Sequence< Locale > aLocaleSeq = m_xLocalizationMgr->getStringResourceManager()->getLocales();
- const Locale* pLocale = aLocaleSeq.getConstArray();
- const sal_Int32 nCountLoc = aLocaleSeq.getLength();
- for ( sal_Int32 i = 0; i < nCountLoc; ++i )
- m_xLanguageCB->remove_id(LanguageTag::convertToLanguageType(pLocale[i]));
+ for (auto& rLocale : m_xLocalizationMgr->getStringResourceManager()->getLocales())
+ m_xLanguageCB->remove_id(LanguageTag::convertToLanguageType(rLocale));
// fill checklistbox if not in default mode
const sal_Int32 nCountLang = m_xLanguageCB->get_count();
diff --git a/basctl/source/dlged/propbrw.cxx b/basctl/source/dlged/propbrw.cxx
index 4a8481249640..04fa2b3d3b86 100644
--- a/basctl/source/dlged/propbrw.cxx
+++ b/basctl/source/dlged/propbrw.cxx
@@ -37,7 +37,7 @@
#include <svx/svditer.hxx>
#include <svx/svdview.hxx>
#include <toolkit/helper/vclunohelper.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/layout.hxx>
#include <vcl/stdtext.hxx>
#include <vcl/weld.hxx>
@@ -82,11 +82,18 @@ const tools::Long WIN_BORDER = 2;
} // namespace
+static Reference<XModel> lclGetModel()
+{
+ if (SfxViewShell* pCurrent = SfxViewShell::Current())
+ return pCurrent->GetCurrentDocument();
+ return Reference<XModel>();
+}
+
PropBrw::PropBrw (DialogWindowLayout& rLayout_):
DockingWindow(&rLayout_),
m_xContentArea(VclPtr<VclVBox>::Create(this)),
m_bInitialStateChange(true),
- m_xContextDocument(SfxViewShell::Current() ? SfxViewShell::Current()->GetCurrentDocument() : Reference<XModel>()),
+ m_xContextDocument(lclGetModel()),
pView(nullptr)
{
Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y);
@@ -137,11 +144,11 @@ void PropBrw::ImplReCreateController()
::cppu::ContextEntry_Init( "ContextDocument", Any( m_xContextDocument ) )
};
Reference< XComponentContext > xInspectorContext(
- ::cppu::createComponentContext( aHandlerContextInfo, SAL_N_ELEMENTS( aHandlerContextInfo ), xOwnContext ) );
+ ::cppu::createComponentContext( aHandlerContextInfo, std::size( aHandlerContextInfo ), xOwnContext ) );
// create a property browser controller
Reference< XMultiComponentFactory > xFactory( xInspectorContext->getServiceManager(), UNO_SET_THROW );
- static constexpr OUStringLiteral s_sControllerServiceName = u"com.sun.star.awt.PropertyBrowserController";
+ static constexpr OUString s_sControllerServiceName = u"com.sun.star.awt.PropertyBrowserController"_ustr;
m_xBrowserController.set( xFactory->createInstanceWithContext( s_sControllerServiceName, xInspectorContext ), UNO_QUERY );
if ( !m_xBrowserController.is() )
{
@@ -241,12 +248,13 @@ Sequence< Reference< XInterface > >
for( size_t i = 0 ; i < nMarkCount ; ++i )
{
SdrObject* pCurrent = _rMarkList.GetMark(i)->GetMarkedSdrObj();
+ assert(pCurrent && "GetMarkedSdrObj will succeed");
- std::unique_ptr<SdrObjListIter> pGroupIterator;
+ std::optional<SdrObjListIter> oGroupIterator;
if (pCurrent->IsGroupObject())
{
- pGroupIterator.reset(new SdrObjListIter(pCurrent->GetSubList()));
- pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : nullptr;
+ oGroupIterator.emplace(pCurrent->GetSubList());
+ pCurrent = oGroupIterator->IsMore() ? oGroupIterator->Next() : nullptr;
}
while (pCurrent)
@@ -259,7 +267,7 @@ Sequence< Reference< XInterface > >
}
// next element
- pCurrent = pGroupIterator && pGroupIterator->IsMore() ? pGroupIterator->Next() : nullptr;
+ pCurrent = oGroupIterator && oGroupIterator->IsMore() ? oGroupIterator->Next() : nullptr;
}
}
@@ -443,7 +451,7 @@ void PropBrw::ImplUpdate( const Reference< XModel >& _rxContextDocument, SdrView
{
if ( pView )
{
- EndListening( *(pView->GetModel()) );
+ EndListening(pView->GetModel());
pView = nullptr;
}
@@ -464,7 +472,7 @@ void PropBrw::ImplUpdate( const Reference< XModel >& _rxContextDocument, SdrView
if ( nMarkCount == 0 )
{
- EndListening( *(pView->GetModel()) );
+ EndListening(pView->GetModel());
pView = nullptr;
implSetNewObject( nullptr );
return;
@@ -492,7 +500,7 @@ void PropBrw::ImplUpdate( const Reference< XModel >& _rxContextDocument, SdrView
else
implSetNewObject( xNewObject );
- StartListening( *(pView->GetModel()) );
+ StartListening(pView->GetModel());
}
catch ( const PropertyVetoException& ) { /* silence */ }
catch ( const Exception& )
diff --git a/basctl/source/inc/BasicColorConfig.hxx b/basctl/source/inc/BasicColorConfig.hxx
new file mode 100644
index 000000000000..a393f5aedb6a
--- /dev/null
+++ b/basctl/source/inc/BasicColorConfig.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <rtl/ustring.hxx>
+#include <strings.hrc>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <comphelper/sequence.hxx>
+#include <unotools/configitem.hxx>
+#include <svtools/colorcfg.hxx>
+#include "colorscheme.hxx"
+#include "iderid.hxx"
+#include <map>
+
+namespace basctl
+{
+// Name used to refer to the application color scheme (the one defined in Application Colors)
+inline constexpr OUString DEFAULT_SCHEME = u"COLORSCHEME_DEFAULT"_ustr;
+
+typedef std::map<OUString, TranslateId> SchemeTranslateIdMap;
+
+class BasicColorConfig : public utl::ConfigItem
+{
+private:
+ // Name of the color scheme that is currently active
+ OUString m_sCurrentColorScheme;
+
+ // Names of all available scheme names
+ css::uno::Sequence<OUString> m_aSchemeNames;
+
+ // Names of default color schemes shipped with LibreOffice
+ css::uno::Sequence<OUString> m_aDefaultSchemes
+ = { "COLORSCHEME_LIBREOFFICE_LIGHT", "COLORSCHEME_LIBREOFFICE_DARK",
+ "COLORSCHEME_BREEZE_LIGHT", "COLORSCHEME_BREEZE_DARK",
+ "COLORSCHEME_SOLARIZED_LIGHT", "COLORSCHEME_SOLARIZED_DARK" };
+
+ // Maps the scheme names to their TranslateId
+ SchemeTranslateIdMap m_aTranslateIdsMap = {
+ { "COLORSCHEME_LIBREOFFICE_LIGHT", RID_STR_COLORSCHEME_LIGHT },
+ { "COLORSCHEME_LIBREOFFICE_DARK", RID_STR_COLORSCHEME_DARK },
+ { "COLORSCHEME_BREEZE_LIGHT", RID_STR_COLORSCHEME_BREEZE_LIGHT },
+ { "COLORSCHEME_BREEZE_DARK", RID_STR_COLORSCHEME_BREEZE_DARK },
+ { "COLORSCHEME_SOLARIZED_LIGHT", RID_STR_COLORSCHEME_SOLARIZED_LIGHT },
+ { "COLORSCHEME_SOLARIZED_DARK", RID_STR_COLORSCHEME_SOLARIZED_DARK },
+ };
+
+ // Used to get colors defined in the Application Colors dialog
+ const svtools::ColorConfig aColorConfig;
+
+ virtual void ImplCommit() override;
+
+public:
+ BasicColorConfig();
+ virtual ~BasicColorConfig() override;
+
+ virtual void Notify(const css::uno::Sequence<OUString>& aPropertyNames) override;
+
+ ColorScheme GetColorScheme(const OUString& rScheme);
+ css::uno::Sequence<OUString> GetColorSchemeNames() { return m_aSchemeNames; }
+
+ // Returns the color scheme defined by the current Application Colors
+ ColorScheme GetAutomaticColorScheme();
+
+ // Returns the name of the currently active color scheme
+ OUString& GetCurrentColorSchemeName();
+
+ // Returns the current color scheme
+ ColorScheme GetCurrentColorScheme() { return GetColorScheme(GetCurrentColorSchemeName()); }
+
+ // Returns true if the scheme is a scheme preinstalled with LO
+ bool IsDefaultScheme(const OUString& rScheme)
+ {
+ return comphelper::findValue(m_aDefaultSchemes, rScheme) != -1;
+ }
+
+ // Returns the TranslateId of the scheme name
+ TranslateId GetSchemeTranslateId(const OUString& rScheme);
+};
+
+} // namespace basctl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/ColorSchemeDialog.hxx b/basctl/source/inc/ColorSchemeDialog.hxx
new file mode 100644
index 000000000000..617121206e9c
--- /dev/null
+++ b/basctl/source/inc/ColorSchemeDialog.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <utility>
+#include <vcl/weld.hxx>
+
+namespace basctl
+{
+class ModulWindowLayout;
+class BasicColorConfig;
+
+class ColorSchemeDialog : public weld::GenericDialogController
+{
+private:
+ VclPtr<ModulWindowLayout> m_pModulWinLayout;
+ OUString m_sSelectedSchemeId;
+
+ std::unique_ptr<weld::TreeView> m_xSchemeList;
+ std::unique_ptr<weld::RadioButton> m_xUseAppCollors;
+ std::unique_ptr<weld::RadioButton> m_xUseScheme;
+ std::unique_ptr<weld::Button> m_xOk;
+ std::shared_ptr<BasicColorConfig> m_pColorConfig;
+
+ void Init();
+
+ DECL_LINK(BtnOkHdl, weld::Button&, void);
+ DECL_LINK(OptionHdl, weld::Toggleable&, void);
+ DECL_LINK(SelectHdl, weld::TreeView&, void);
+
+public:
+ ColorSchemeDialog(weld::Window* pParent, VclPtr<ModulWindowLayout> pModulWinLayout);
+ virtual ~ColorSchemeDialog() override;
+
+ const OUString& GetColorSchemeId() { return m_sSelectedSchemeId; }
+};
+
+} // namespace basctl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/LineStatusControl.hxx b/basctl/source/inc/LineStatusControl.hxx
new file mode 100644
index 000000000000..268738f821d3
--- /dev/null
+++ b/basctl/source/inc/LineStatusControl.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <sfx2/stbitem.hxx>
+
+namespace basctl
+{
+class LineStatusControl final : public SfxStatusBarControl
+{
+public:
+ SFX_DECL_STATUSBAR_CONTROL();
+
+ LineStatusControl(sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb);
+ virtual ~LineStatusControl() override;
+
+ virtual void StateChangedAtStatusBarControl(sal_uInt16 nSID, SfxItemState eState,
+ const SfxPoolItem* pState) override;
+};
+
+} // namespace basctl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/accessibledialogcontrolshape.hxx b/basctl/source/inc/accessibledialogcontrolshape.hxx
index 2fbf73aa4e83..3af6e3da90ee 100644
--- a/basctl/source/inc/accessibledialogcontrolshape.hxx
+++ b/basctl/source/inc/accessibledialogcontrolshape.hxx
@@ -22,15 +22,11 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <comphelper/accessiblecomponenthelper.hxx>
-#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implbase.hxx>
#include <vcl/vclptr.hxx>
namespace vcl { class Window; }
-namespace utl {
- class AccessibleStateSetHelper;
-}
-
namespace basctl
{
@@ -39,13 +35,11 @@ class DialogWindow;
-typedef ::cppu::ImplHelper3<
- css::accessibility::XAccessible,
- css::lang::XServiceInfo,
- css::beans::XPropertyChangeListener > AccessibleDialogControlShape_BASE;
-
-class AccessibleDialogControlShape final : public comphelper::OAccessibleExtendedComponentHelper,
- public AccessibleDialogControlShape_BASE
+class AccessibleDialogControlShape final : public cppu::ImplInheritanceHelper<
+ comphelper::OAccessibleExtendedComponentHelper,
+ css::accessibility::XAccessible,
+ css::lang::XServiceInfo,
+ css::beans::XPropertyChangeListener>
{
friend class AccessibleDialogWindow;
@@ -71,7 +65,7 @@ private:
OUString GetModelStringProperty( OUString const & pPropertyName );
- void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet );
+ void FillAccessibleStateSet( sal_Int64& rStateSet );
// OCommonAccessibleComponent
virtual css::awt::Rectangle implGetBounds() override;
@@ -83,12 +77,6 @@ public:
AccessibleDialogControlShape (DialogWindow*, DlgEdObj*);
virtual ~AccessibleDialogControlShape() override;
- // XInterface
- DECLARE_XINTERFACE()
-
- // XTypeProvider
- DECLARE_XTYPEPROVIDER()
-
// XEventListener
virtual void SAL_CALL disposing( const css::lang::EventObject& rSource ) override;
@@ -104,15 +92,15 @@ public:
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
// XAccessibleContext
- virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
- virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
+ virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override;
+ virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override;
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
- virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override;
+ virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override;
virtual sal_Int16 SAL_CALL getAccessibleRole( ) override;
virtual OUString SAL_CALL getAccessibleDescription( ) override;
virtual OUString SAL_CALL getAccessibleName( ) override;
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
- virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override;
+ virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override;
virtual css::lang::Locale SAL_CALL getLocale( ) override;
// XAccessibleComponent
diff --git a/basctl/source/inc/accessibledialogwindow.hxx b/basctl/source/inc/accessibledialogwindow.hxx
index 2c3a065247ac..0332b98a4175 100644
--- a/basctl/source/inc/accessibledialogwindow.hxx
+++ b/basctl/source/inc/accessibledialogwindow.hxx
@@ -22,7 +22,7 @@
#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <comphelper/accessiblecomponenthelper.hxx>
-#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implbase.hxx>
#include <svl/lstner.hxx>
#include <tools/link.hxx>
#include <vcl/vclptr.hxx>
@@ -30,10 +30,6 @@
class VclSimpleEvent;
class VclWindowEvent;
-namespace utl {
- class AccessibleStateSetHelper;
-}
-
namespace basctl
{
@@ -41,16 +37,14 @@ class DialogWindow;
class DlgEditor;
class DlgEdModel;
class DlgEdObj;
+class AccessibleDialogControlShape;
-
-typedef ::cppu::ImplHelper3 <
- css::accessibility::XAccessible,
- css::accessibility::XAccessibleSelection,
- css::lang::XServiceInfo > AccessibleDialogWindow_BASE;
-
-class AccessibleDialogWindow final : public comphelper::OAccessibleExtendedComponentHelper,
- public AccessibleDialogWindow_BASE,
+class AccessibleDialogWindow final : public cppu::ImplInheritanceHelper<
+ comphelper::OAccessibleExtendedComponentHelper,
+ css::accessibility::XAccessible,
+ css::accessibility::XAccessibleSelection,
+ css::lang::XServiceInfo>,
public SfxListener
{
private:
@@ -58,8 +52,8 @@ private:
class ChildDescriptor
{
public:
- DlgEdObj* pDlgEdObj;
- css::uno::Reference< css::accessibility::XAccessible > rxAccessible;
+ DlgEdObj* pDlgEdObj;
+ rtl::Reference< AccessibleDialogControlShape > mxAccessible;
ChildDescriptor( DlgEdObj* _pDlgEdObj );
@@ -88,7 +82,7 @@ private:
DECL_LINK( WindowEventListener, VclWindowEvent&, void );
void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
- void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet );
+ void FillAccessibleStateSet( sal_Int64& rStateSet );
// OCommonAccessibleComponent
virtual css::awt::Rectangle implGetBounds( ) override;
@@ -103,12 +97,6 @@ public:
// SfxListener
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
- // XInterface
- DECLARE_XINTERFACE()
-
- // XTypeProvider
- DECLARE_XTYPEPROVIDER()
-
// XServiceInfo
virtual OUString SAL_CALL getImplementationName() override;
virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override;
@@ -118,15 +106,15 @@ public:
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
// XAccessibleContext
- virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
- virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
+ virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override;
+ virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override;
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
- virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override;
+ virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override;
virtual sal_Int16 SAL_CALL getAccessibleRole( ) override;
virtual OUString SAL_CALL getAccessibleDescription( ) override;
virtual OUString SAL_CALL getAccessibleName( ) override;
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
- virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override;
+ virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override;
virtual css::lang::Locale SAL_CALL getLocale( ) override;
// XAccessibleComponent
@@ -141,13 +129,13 @@ public:
virtual OUString SAL_CALL getToolTipText( ) override;
// XAccessibleSelection
- virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) override;
- virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) override;
+ virtual void SAL_CALL selectAccessibleChild( sal_Int64 nChildIndex ) override;
+ virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int64 nChildIndex ) override;
virtual void SAL_CALL clearAccessibleSelection() override;
virtual void SAL_CALL selectAllAccessibleChildren( ) override;
- virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) override;
- virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) override;
- virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nChildIndex ) override;
+ virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount( ) override;
+ virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override;
+ virtual void SAL_CALL deselectAccessibleChild( sal_Int64 nChildIndex ) override;
};
} // namespace basctl
diff --git a/basctl/source/inc/baside3.hxx b/basctl/source/inc/baside3.hxx
index 15f157565fb2..14fc68f07951 100644
--- a/basctl/source/inc/baside3.hxx
+++ b/basctl/source/inc/baside3.hxx
@@ -43,7 +43,7 @@ class DlgEdView;
class DialogWindowLayout;
class ObjectCatalog;
-bool implImportDialog(weld::Window* pWin, const OUString& rCurPath, const ScriptDocument& rDocument, const OUString& rLibName);
+bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const OUString& rLibName);
class DialogWindow: public BaseWindow
{
@@ -51,7 +51,6 @@ private:
DialogWindowLayout& m_rLayout;
std::unique_ptr<DlgEditor> m_pEditor;
std::unique_ptr<SfxUndoManager> m_pUndoMgr; // never nullptr
- OUString m_sCurPath;
sal_uInt16 m_nControlSlotId;
protected:
@@ -68,7 +67,7 @@ protected:
static void NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> );
virtual void DoInit() override;
- virtual void DoScroll( ScrollBar* pCurScrollBar ) override;
+ virtual void DoScroll( Scrollable* pCurScrollBar ) override;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
void InitSettings();
@@ -108,7 +107,7 @@ public:
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
- virtual char const* GetHid () const override;
+ virtual OUString GetHid () const override;
virtual ItemType GetType () const override;
};
diff --git a/basctl/source/inc/basidesh.hxx b/basctl/source/inc/basidesh.hxx
index f3127186ce93..afaa47c88ff4 100644
--- a/basctl/source/inc/basidesh.hxx
+++ b/basctl/source/inc/basidesh.hxx
@@ -26,7 +26,7 @@
#include <sfx2/viewsh.hxx>
#include <svx/ifaceids.hxx>
#include <svl/srchitem.hxx>
-#include <vcl/scrbar.hxx>
+#include <svtools/scrolladaptor.hxx>
#include <map>
#include <memory>
#include <string_view>
@@ -40,6 +40,12 @@ class StarBASIC;
namespace basctl
{
+
+// Used to control zoom level
+constexpr sal_uInt16 MIN_ZOOM_LEVEL = 50;
+constexpr sal_uInt16 DEFAULT_ZOOM_LEVEL = 100;
+constexpr sal_uInt16 MAX_ZOOM_LEVEL = 400;
+
class Layout;
class ModulWindow;
class ModulWindowLayout;
@@ -48,6 +54,7 @@ class DialogWindowLayout;
class TabBar;
class BaseWindow;
class LocalizationMgr;
+class BasicColorConfig;
class Shell :
public SfxViewShell,
@@ -59,7 +66,7 @@ public:
private:
friend class JavaDebuggingListenerImpl;
friend class LocalizationMgr;
- friend bool implImportDialog(weld::Window* pWin, const OUString& rCurPath, const ScriptDocument& rDocument, const OUString& rLibName); // defined in baside3.cxx
+ friend bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const OUString& rLibName); // defined in baside3.cxx
WindowTable aWindowTable;
sal_uInt16 nCurKey;
@@ -68,12 +75,16 @@ private:
OUString m_aCurLibName;
std::shared_ptr<LocalizationMgr> m_pCurLocalizationMgr;
- VclPtr<ScrollBar> aHScrollBar;
- VclPtr<ScrollBar> aVScrollBar;
- VclPtr<ScrollBarBox> aScrollBarBox;
+ // Current value of the zoom slider
+ sal_uInt16 m_nCurrentZoomSliderValue;
+ VclPtr<ScrollAdaptor> aHScrollBar;
+ VclPtr<ScrollAdaptor> aVScrollBar;
VclPtr<TabBar> pTabBar; // basctl::TabBar
bool bCreatingWindow;
+ // Basic editor color configuration
+ std::shared_ptr<BasicColorConfig> m_aColorConfig;
+
// layout windows
VclPtr<ModulWindowLayout> pModulLayout;
VclPtr<DialogWindowLayout> pDialogLayout;
@@ -93,13 +104,13 @@ private:
void Init();
void InitTabBar();
void InitScrollBars();
+ void InitZoomLevel();
void CheckWindows();
void RemoveWindows( const ScriptDocument& rDocument, std::u16string_view rLibName );
void UpdateWindows();
static void InvalidateBasicIDESlots();
void StoreAllWindowData( bool bPersistent = true );
void SetMDITitle();
- void EnableScrollbars( bool bEnable );
void SetCurLib( const ScriptDocument& rDocument, const OUString& aLibName, bool bUpdateWindows = true , bool bCheck = true );
void SetCurLibForLocalization( const ScriptDocument& rDocument, const OUString& aLibName );
@@ -149,7 +160,7 @@ private:
static void InitInterface_Impl();
public:
- Shell( SfxViewFrame *pFrame, SfxViewShell *pOldSh );
+ Shell(SfxViewFrame& rFrame, SfxViewShell *pOldSh);
virtual ~Shell() override;
BaseWindow* GetCurWindow() const { return pCurWin; }
@@ -164,12 +175,17 @@ public:
SfxUndoManager* GetUndoManager() override;
+ void SetGlobalEditorZoomLevel(sal_uInt16 nNewZoomLevel);
+ sal_uInt16 GetCurrentZoomSliderValue() { return m_nCurrentZoomSliderValue; }
+ static sal_uInt16 GetMinZoom() { return MIN_ZOOM_LEVEL; }
+ static sal_uInt16 GetMaxZoom() { return MAX_ZOOM_LEVEL; }
+
virtual css::uno::Reference< css::view::XRenderable > GetRenderable() override;
// virtual sal_uInt16 Print( SfxProgress &rProgress, sal_Bool bIsAPI, PrintDialog *pPrintDialog = 0 );
virtual SfxPrinter* GetPrinter( bool bCreate = false ) override;
virtual sal_uInt16 SetPrinter( SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL ) override;
- virtual OUString GetSelectionText( bool bCompleteWords = false ) override;
+ virtual OUString GetSelectionText( bool bCompleteWords = false, bool bOnlyASample = false ) override;
virtual bool HasSelection( bool bText = true ) const override;
void GetState( SfxItemSet& );
@@ -208,6 +224,8 @@ public:
void UpdateObjectCatalog () { aObjectCatalog->UpdateEntries(); }
void RemoveWindow (BaseWindow* pWindow, bool bDestroy, bool bAllowChangeCurWindow = true);
+
+ const std::shared_ptr<BasicColorConfig>& GetColorConfig() const { return m_aColorConfig; }
};
} // namespace basctl
diff --git a/basctl/source/inc/basobj.hxx b/basctl/source/inc/basobj.hxx
index 46d0f9392896..70c603d4548a 100644
--- a/basctl/source/inc/basobj.hxx
+++ b/basctl/source/inc/basobj.hxx
@@ -32,8 +32,7 @@ namespace weld { class Widget; class Window; }
namespace basctl
{
- void Organize(weld::Window* pParent, sal_Int16 tabId);
-
+ void Organize(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 tabId);
// help methods for the general use:
SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName );
@@ -45,7 +44,7 @@ namespace basctl
void BasicStopped( bool* pbAppWindowDisabled = nullptr, bool* pbDispatcherLocked = nullptr, sal_uInt16* pnWaitCount = nullptr,
SfxUInt16Item** ppSWActionCount = nullptr, SfxUInt16Item** ppSWLockViewCount = nullptr );
- bool IsValidSbxName( const OUString& rName );
+ bool IsValidSbxName( std::u16string_view rName );
BasicManager* FindBasicManager( StarBASIC const * pLib );
diff --git a/basctl/source/inc/bastype2.hxx b/basctl/source/inc/bastype2.hxx
index 3eb4de6beec9..22321b309757 100644
--- a/basctl/source/inc/bastype2.hxx
+++ b/basctl/source/inc/bastype2.hxx
@@ -45,7 +45,6 @@ namespace o3tl {
namespace basctl
{
-using namespace ::com::sun::star::uno;
enum EntryType
{
@@ -90,7 +89,7 @@ private:
public:
DocumentEntry (
- ScriptDocument const& rDocument,
+ ScriptDocument aDocument,
LibraryLocation eLocation,
EntryType eType = OBJ_TYPE_DOCUMENT
);
@@ -109,7 +108,7 @@ public:
LibEntry (
ScriptDocument const& rDocument,
LibraryLocation eLocation,
- OUString const& rLibName
+ OUString aLibName
);
virtual ~LibEntry () override;
@@ -129,20 +128,20 @@ class EntryDescriptor
public:
EntryDescriptor ();
EntryDescriptor (
- ScriptDocument const& rDocument,
+ ScriptDocument aDocument,
LibraryLocation eLocation,
- OUString const& rLibName,
- OUString const& rLibSubName,
- OUString const& rName,
+ OUString aLibName,
+ OUString aLibSubName,
+ OUString aName,
EntryType eType
);
EntryDescriptor (
- ScriptDocument const& rDocument,
+ ScriptDocument aDocument,
LibraryLocation eLocation,
- OUString const& rLibName,
- OUString const& rLibSubName,
- OUString const& rName,
- OUString const& rMethodName,
+ OUString aLibName,
+ OUString aLibSubName,
+ OUString aName,
+ OUString aMethodName,
EntryType eType
);
@@ -222,7 +221,7 @@ public:
EntryDescriptor GetEntryDescriptor(const weld::TreeIter* pEntry);
static ItemType ConvertType (EntryType eType);
- bool IsValidEntry(weld::TreeIter& rEntry);
+ bool IsValidEntry(const weld::TreeIter& rEntry);
void AddEntry(const OUString& rText, const OUString& rImage,
const weld::TreeIter* pParent, bool bChildrenOnDemand,
std::unique_ptr<Entry>&& rUserData,
diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx
index e6e306a73b5a..513fbce3a41c 100644
--- a/basctl/source/inc/bastypes.hxx
+++ b/basctl/source/inc/bastypes.hxx
@@ -21,6 +21,7 @@
#include "scriptdocument.hxx"
#include "sbxitem.hxx"
+#include <svtools/scrolladaptor.hxx>
#include <svtools/tabbar.hxx>
#include <basic/sbdef.hxx>
#include <vcl/dockwin.hxx>
@@ -49,11 +50,11 @@ class Layout;
class ModulWindow;
class DialogWindow;
-#define LINE_SEP_CR 0x0D
-#define LINE_SEP 0x0A
+constexpr auto LINE_SEP_CR = 0x0D;
+constexpr auto LINE_SEP = 0x0A;
// Implementation: baside2b.cxx
-sal_Int32 searchEOL( const OUString& rStr, sal_Int32 fromIndex );
+sal_Int32 searchEOL( std::u16string_view rStr, sal_Int32 fromIndex );
// Meaning of bToBeKilled:
// While being in a reschedule-loop, I may not destroy the window.
@@ -81,7 +82,7 @@ struct BasicStatus
class DockingWindow : public ResizableDockingWindow
{
public:
- DockingWindow(vcl::Window* pParent, const OUString& rUIXMLDescription, const OString& rID);
+ DockingWindow(vcl::Window* pParent, const OUString& rUIXMLDescription, const OUString& rID);
DockingWindow(Layout* pParent);
virtual ~DockingWindow() override;
virtual void dispose() override;
@@ -155,10 +156,11 @@ class EntryDescriptor;
class BaseWindow : public vcl::Window
{
private:
- VclPtr<ScrollBar> pShellHScrollBar;
- VclPtr<ScrollBar> pShellVScrollBar;
+ VclPtr<ScrollAdaptor> pShellHScrollBar;
+ VclPtr<ScrollAdaptor> pShellVScrollBar;
- DECL_LINK( ScrollHdl, ScrollBar*, void );
+ DECL_LINK( VertScrollHdl, weld::Scrollbar&, void );
+ DECL_LINK( HorzScrollHdl, weld::Scrollbar&, void );
int nStatus;
ScriptDocument m_aDocument;
@@ -169,10 +171,10 @@ private:
friend class DialogWindow;
protected:
- virtual void DoScroll( ScrollBar* pCurScrollBar );
+ virtual void DoScroll(Scrollable* pCurScrollBar);
public:
- BaseWindow( vcl::Window* pParent, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName );
+ BaseWindow( vcl::Window* pParent, ScriptDocument aDocument, OUString aLibName, OUString aName );
virtual ~BaseWindow() override;
virtual void dispose() override;
@@ -180,10 +182,11 @@ public:
virtual void DoInit();
virtual void Activating () = 0;
virtual void Deactivating () = 0;
- void GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll );
+ void GrabScrollBars(ScrollAdaptor* pHScroll, ScrollAdaptor* pVScroll);
- ScrollBar* GetHScrollBar() const { return pShellHScrollBar; }
- ScrollBar* GetVScrollBar() const { return pShellVScrollBar; }
+ ScrollAdaptor* GetHScrollBar() const { return pShellHScrollBar.get(); }
+ ScrollAdaptor* GetVScrollBar() const { return pShellVScrollBar.get(); }
+ void ShowShellScrollBars(bool bVisible = true);
virtual void ExecuteCommand (SfxRequest&);
virtual void ExecuteGlobal (SfxRequest&);
@@ -208,6 +211,7 @@ public:
virtual void SetReadOnly (bool bReadOnly);
virtual bool IsReadOnly();
+ void ShowReadOnlyInfoBar();
int GetStatus() const { return nStatus; }
void SetStatus(int n) { nStatus = n; }
@@ -233,7 +237,7 @@ public:
void SetName( const OUString& aName ) { m_aName = aName; }
virtual void OnNewDocument ();
- virtual char const* GetHid () const = 0;
+ virtual OUString GetHid () const = 0;
virtual ItemType GetType () const = 0;
void InsertLibInfo () const;
bool Is (ScriptDocument const&, std::u16string_view, std::u16string_view, ItemType, bool bFindSuspended);
@@ -260,7 +264,7 @@ private:
OUString m_aLibName;
public:
- Key (ScriptDocument const&, OUString const& rLibName);
+ Key (ScriptDocument , OUString aLibName);
public:
bool operator == (Key const&) const;
struct Hash
@@ -278,7 +282,7 @@ public:
ItemType m_eCurrentType;
public:
- Item (OUString const& rCurrentName, ItemType eCurrentType);
+ Item (OUString aCurrentName, ItemType eCurrentType);
const OUString& GetCurrentName() const { return m_aCurrentName; }
ItemType GetCurrentType() const { return m_eCurrentType; }
};
diff --git a/basctl/source/inc/colorscheme.hxx b/basctl/source/inc/colorscheme.hxx
new file mode 100644
index 000000000000..96567f79f7ff
--- /dev/null
+++ b/basctl/source/inc/colorscheme.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <tools/color.hxx>
+
+namespace basctl
+{
+// Defines a single color scheme
+typedef struct
+{
+ OUString m_sSchemeName;
+ bool m_bIsDefault;
+ Color m_aGenericFontColor;
+ Color m_aIdentifierColor;
+ Color m_aNumberColor;
+ Color m_aStringColor;
+ Color m_aCommentColor;
+ Color m_aErrorColor;
+ Color m_aOperatorColor;
+ Color m_aKeywordColor;
+ Color m_aBackgroundColor;
+ Color m_aLineHighlightColor;
+} ColorScheme;
+
+} // namespace basctl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/dlged.hxx b/basctl/source/inc/dlged.hxx
index 82d3a14f605d..c50faf51b36c 100644
--- a/basctl/source/inc/dlged.hxx
+++ b/basctl/source/inc/dlged.hxx
@@ -36,7 +36,7 @@
#include <memory>
-class ScrollBar;
+class ScrollAdaptor;
class Printer;
class KeyEvent;
class MouseEvent;
@@ -48,9 +48,8 @@ namespace basctl
class DialogWindowLayout;
-#define DLGED_PAGE_WIDTH_MIN 1280
-#define DLGED_PAGE_HEIGHT_MIN 1024
-
+constexpr auto DLGED_PAGE_WIDTH_MIN = 1280;
+constexpr auto DLGED_PAGE_HEIGHT_MIN = 1024;
// DlgEdHint
@@ -108,12 +107,12 @@ private:
static void Print( Printer* pPrinter, const OUString& rTitle );
private:
- VclPtr<ScrollBar> pHScroll;
- VclPtr<ScrollBar> pVScroll;
+ VclPtr<ScrollAdaptor> pHScroll;
+ VclPtr<ScrollAdaptor> pVScroll;
std::unique_ptr<DlgEdModel> pDlgEdModel; // never nullptr
DlgEdPage* pDlgEdPage; // never nullptr
std::unique_ptr<DlgEdView> pDlgEdView; // never nullptr
- DlgEdForm* pDlgEdForm; // never nullptr
+ rtl::Reference<DlgEdForm> pDlgEdForm; // never nullptr
css::uno::Reference< css::container::XNameContainer > m_xUnoControlDialogModel;
css::uno::Reference< css::awt::XControlContainer > m_xControlContainer;
css::uno::Sequence< css::datatransfer::DataFlavor > m_ClipboardDataFlavors;
@@ -150,10 +149,10 @@ public:
css::uno::Reference< css::awt::XControlContainer > const &
GetWindowControlContainer();
- void SetScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll );
+ void SetScrollBars(ScrollAdaptor* pHScroll, ScrollAdaptor* pVScroll);
void InitScrollBars();
- ScrollBar* GetHScroll() const { return pHScroll; }
- ScrollBar* GetVScroll() const { return pVScroll; }
+ ScrollAdaptor* GetHScroll() const { return pHScroll; }
+ ScrollAdaptor* GetVScroll() const { return pVScroll; }
void DoScroll();
void UpdateScrollBars();
diff --git a/basctl/source/inc/dlgeddef.hxx b/basctl/source/inc/dlgeddef.hxx
index 0cb0a6dc8573..c10ef16cd8d3 100644
--- a/basctl/source/inc/dlgeddef.hxx
+++ b/basctl/source/inc/dlgeddef.hxx
@@ -19,27 +19,27 @@
#pragma once
-#include <svx/svdobjkind.hxx>
+#include <rtl/ustring.hxx>
namespace basctl
{
// control properties
#define DLGED_PROP_BACKGROUNDCOLOR "BackgroundColor"
-#define DLGED_PROP_DROPDOWN "Dropdown"
-#define DLGED_PROP_FORMATSSUPPLIER "FormatsSupplier"
-#define DLGED_PROP_HEIGHT "Height"
-#define DLGED_PROP_LABEL "Label"
-#define DLGED_PROP_NAME "Name"
-#define DLGED_PROP_ORIENTATION "Orientation"
-#define DLGED_PROP_POSITIONX "PositionX"
-#define DLGED_PROP_POSITIONY "PositionY"
-#define DLGED_PROP_STEP "Step"
-#define DLGED_PROP_TABINDEX "TabIndex"
+inline constexpr OUString DLGED_PROP_DROPDOWN = u"Dropdown"_ustr;
+inline constexpr OUString DLGED_PROP_FORMATSSUPPLIER = u"FormatsSupplier"_ustr;
+inline constexpr OUString DLGED_PROP_HEIGHT = u"Height"_ustr;
+inline constexpr OUString DLGED_PROP_LABEL = u"Label"_ustr;
+inline constexpr OUString DLGED_PROP_NAME = u"Name"_ustr;
+inline constexpr OUString DLGED_PROP_ORIENTATION = u"Orientation"_ustr;
+inline constexpr OUString DLGED_PROP_POSITIONX = u"PositionX"_ustr;
+inline constexpr OUString DLGED_PROP_POSITIONY = u"PositionY"_ustr;
+inline constexpr OUString DLGED_PROP_STEP = u"Step"_ustr;
+inline constexpr OUString DLGED_PROP_TABINDEX = u"TabIndex"_ustr;
#define DLGED_PROP_TEXTCOLOR "TextColor"
#define DLGED_PROP_TEXTLINECOLOR "TextLineColor"
-#define DLGED_PROP_WIDTH "Width"
-#define DLGED_PROP_DECORATION "Decoration"
+inline constexpr OUString DLGED_PROP_WIDTH = u"Width"_ustr;
+inline constexpr OUString DLGED_PROP_DECORATION = u"Decoration"_ustr;
} // namespace basctl
diff --git a/basctl/source/inc/dlgedfac.hxx b/basctl/source/inc/dlgedfac.hxx
index f780bc22bb95..5e583ada1729 100644
--- a/basctl/source/inc/dlgedfac.hxx
+++ b/basctl/source/inc/dlgedfac.hxx
@@ -32,10 +32,10 @@ class DlgEdFactory
const css::uno::Reference<css::frame::XModel> mxModel;
public:
- DlgEdFactory(const css::uno::Reference<css::frame::XModel>& xModel);
+ DlgEdFactory(css::uno::Reference<css::frame::XModel> xModel);
~DlgEdFactory() COVERITY_NOEXCEPT_FALSE;
- DECL_LINK(MakeObject, SdrObjCreatorParams, SdrObject*);
+ DECL_LINK(MakeObject, SdrObjCreatorParams, rtl::Reference<SdrObject>);
};
} // namespace basctl
diff --git a/basctl/source/inc/dlgedobj.hxx b/basctl/source/inc/dlgedobj.hxx
index d5e29cf48caf..a8c249adec16 100644
--- a/basctl/source/inc/dlgedobj.hxx
+++ b/basctl/source/inc/dlgedobj.hxx
@@ -50,7 +50,7 @@ class DlgEdObj: public SdrUnoObj
private:
bool bIsListening;
- DlgEdForm* pDlgEdForm;
+ rtl::Reference<DlgEdForm> pDlgEdForm;
css::uno::Reference< css::beans::XPropertyChangeListener> m_xPropertyChangeListener;
css::uno::Reference< css::container::XContainerListener> m_xContainerListener;
@@ -94,15 +94,15 @@ protected:
public:
void SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; }
- DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; }
+ DlgEdForm* GetDlgEdForm() const { return pDlgEdForm.get(); }
virtual SdrInventor GetObjInventor() const override;
virtual SdrObjKind GetObjIdentifier() const override;
- virtual DlgEdObj* CloneSdrObject(SdrModel& rTargetModel) const override; // not working yet
+ virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override; // not working yet
// FullDrag support
- virtual SdrObjectUniquePtr getFullDragClone() const override;
+ virtual rtl::Reference<SdrObject> getFullDragClone() const override;
bool supportsService( OUString const & serviceName ) const;
OUString GetDefaultName() const;
diff --git a/basctl/source/inc/docsignature.hxx b/basctl/source/inc/docsignature.hxx
index 94e7db2224dd..1681807d390e 100644
--- a/basctl/source/inc/docsignature.hxx
+++ b/basctl/source/inc/docsignature.hxx
@@ -20,7 +20,6 @@
#include <sfx2/signaturestate.hxx>
#include <vcl/weld.hxx>
-#include <memory>
class SfxObjectShell;
@@ -40,7 +39,6 @@ namespace basctl
which does not support being signed, the DocumentSignature instance is invalid afterwards.
*/
explicit DocumentSignature (ScriptDocument const&);
- ~DocumentSignature();
/** determines whether the instance is valid
diff --git a/basctl/source/inc/iderid.hxx b/basctl/source/inc/iderid.hxx
index 254d481ad614..83cbc3d0c4aa 100644
--- a/basctl/source/inc/iderid.hxx
+++ b/basctl/source/inc/iderid.hxx
@@ -20,11 +20,11 @@
#pragma once
#include <rtl/ustring.hxx>
-#include <string_view>
+#include <unotools/resmgr.hxx>
namespace basctl
{
-OUString IDEResId(std::string_view aId);
+OUString IDEResId(TranslateId aId);
} // namespace basctl
diff --git a/basctl/source/inc/localizationmgr.hxx b/basctl/source/inc/localizationmgr.hxx
index 847ef0f75729..3e2ff0fc58a8 100644
--- a/basctl/source/inc/localizationmgr.hxx
+++ b/basctl/source/inc/localizationmgr.hxx
@@ -72,7 +72,7 @@ class LocalizationMgr
void implEnableDisableResourceForAllLibraryDialogs( HandleResourceMode eMode );
public:
- LocalizationMgr(Shell*, ScriptDocument const&, OUString const& aLibName,
+ LocalizationMgr(Shell*, ScriptDocument , OUString aLibName,
const css::uno::Reference < css::resource::XStringResourceManager >& xStringResourceManager );
const css::uno::Reference< css::resource::XStringResourceManager >& getStringResourceManager() const
diff --git a/basctl/source/inc/managelang.hxx b/basctl/source/inc/managelang.hxx
index 722ec60c46ac..58dd4189057a 100644
--- a/basctl/source/inc/managelang.hxx
+++ b/basctl/source/inc/managelang.hxx
@@ -19,6 +19,7 @@
#pragma once
+#include <utility>
#include <vcl/weld.hxx>
class SvxLanguageBox;
@@ -33,9 +34,9 @@ struct LanguageEntry
css::lang::Locale m_aLocale;
bool m_bIsDefault;
- LanguageEntry( const css::lang::Locale& _rLocale,
+ LanguageEntry( css::lang::Locale _aLocale,
bool _bIsDefault ) :
- m_aLocale( _rLocale ),
+ m_aLocale(std::move( _aLocale )),
m_bIsDefault( _bIsDefault ) {}
};
@@ -65,7 +66,7 @@ private:
DECL_LINK(SelectHdl, weld::TreeView&, void);
public:
- ManageLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> const & _pLMgr);
+ ManageLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> _pLMgr);
virtual ~ManageLanguageDialog() override;
};
@@ -86,7 +87,7 @@ private:
std::unique_ptr<SvxLanguageBox> m_xLanguageCB;
public:
- SetDefaultLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> const & xLMgr);
+ SetDefaultLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> xLMgr);
virtual ~SetDefaultLanguageDialog() override;
css::uno::Sequence< css::lang::Locale > GetLocales() const;
diff --git a/basctl/source/inc/sbxitem.hxx b/basctl/source/inc/sbxitem.hxx
index e5f8d65d900f..941ffd3e0ee9 100644
--- a/basctl/source/inc/sbxitem.hxx
+++ b/basctl/source/inc/sbxitem.hxx
@@ -44,8 +44,8 @@ class SbxItem : public SfxPoolItem
public:
static SfxPoolItem* CreateDefault();
- SbxItem(sal_uInt16 nWhich, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, ItemType);
- SbxItem(sal_uInt16 nWhich, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, const OUString& aMethodName, ItemType eType);
+ SbxItem(sal_uInt16 nWhich, ScriptDocument aDocument, OUString aLibName, OUString aName, ItemType);
+ SbxItem(sal_uInt16 nWhich, ScriptDocument aDocument, OUString aLibName, OUString aName, OUString aMethodName, ItemType eType);
virtual SbxItem* Clone(SfxItemPool *pPool = nullptr) const override;
virtual bool operator==(const SfxPoolItem&) const override;