diff options
Diffstat (limited to 'basctl/source')
69 files changed, 2261 insertions, 1096 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 e52d08bfe458..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() ); } } @@ -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; } @@ -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 e295e44ff1ed..d25e143d62fa 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 { @@ -222,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); @@ -261,7 +262,7 @@ void LibBox::InsertEntries(const ScriptDocument& rDocument, LibraryLocation eLoc 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); } } } @@ -320,7 +321,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()); @@ -340,7 +341,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(); @@ -440,7 +441,7 @@ void LanguageBox::FillBox() sLanguage += " " + msDefaultLanguageStr; } LanguageEntry* pEntry = new LanguageEntry(pLocale[i], bIsDefault); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry))); + OUString sId(weld::toId(pEntry)); m_xWidget->append(sId, sLanguage); if (bIsCurrent) @@ -467,7 +468,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(); @@ -475,7 +476,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 83a3f1781630..ffd22b9063c7 100644 --- a/basctl/source/basicide/basdoc.cxx +++ b/basctl/source/basicide/basdoc.cxx @@ -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 79e381399703..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::getFromUnoTunnel<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 52769276bacb..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> @@ -56,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> @@ -68,6 +71,7 @@ #include <cassert> #include <osl/diagnose.h> #include <officecfg/Office/Common.hxx> +#include <BasicColorConfig.hxx> namespace basctl { @@ -94,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 @@ -182,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; @@ -193,13 +197,16 @@ void lcl_ConvertTabsToSpaces( OUString& rLine ) } // 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(); } @@ -254,9 +261,6 @@ void ModulWindow::GetFocus() void ModulWindow::DoInit() { - if (GetVScrollBar()) - GetVScrollBar()->Hide(); - GetHScrollBar()->Show(); GetEditorWindow().InitScrollBars(); } @@ -284,7 +288,7 @@ void ModulWindow::CheckCompileBasic() bool bDone = false; - GetShell()->GetViewFrame()->GetWindow().EnterWait(); + GetShell()->GetViewFrame().GetWindow().EnterWait(); AssertValidEditEngine(); GetEditorWindow().SetSourceInBasic(); @@ -304,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; @@ -444,7 +448,7 @@ void ModulWindow::LoadBasic() GetEditorWindow().PaintImmediately(); GetEditorWindow().ForceSyntaxTimeout(); GetEditorWindow().DestroyProgress(); - ErrCode nError = aMedium.GetError(); + ErrCodeMsg nError = aMedium.GetErrorIgnoreWarning(); if ( nError ) ErrorHandler::HandleError( nError ); } @@ -459,17 +463,12 @@ void ModulWindow::LoadBasic() void ModulWindow::SaveBasicSource() { - Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); - sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD, + sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, FileDialogFlags::NONE, this->GetFrameWeld()); aDlg.SetContext(sfx2::FileDialogHelper::BasicExportSource); const Reference<XFilePicker3>& xFP = aDlg.GetFilePicker(); - Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY); - xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false); - Any aValue; - aValue <<= true; - xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue); + xFP.queryThrow<XFilePickerControlAccess>()->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, Any(true)); xFP->appendFilter( "BASIC", "*.bas" ); xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All ); @@ -491,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 ); } @@ -615,7 +614,7 @@ void ModulWindow::ManageBreakPoints() void ModulWindow::BasicErrorHdl( StarBASIC const * pBasic ) { - GetShell()->GetViewFrame()->ToTop(); + GetShell()->GetViewFrame().ToTop(); // Return value: BOOL // FALSE: cancel @@ -1029,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); } } @@ -1058,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; } } @@ -1133,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 ); } @@ -1164,7 +1181,7 @@ void ModulWindow::GetState( SfxItemSet &rSet ) } } -void ModulWindow::DoScroll( ScrollBar* pCurScrollBar ) +void ModulWindow::DoScroll( Scrollable* pCurScrollBar ) { if ( ( pCurScrollBar == GetHScrollBar() ) && GetEditView() ) { @@ -1381,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; @@ -1405,7 +1417,7 @@ void ModulWindow::OnNewDocument () m_aXEditorWindow->SetLineNumberDisplay(bLineNumbers); } -OString ModulWindow::GetHid () const +OUString ModulWindow::GetHid () const { return HID_BASICIDE_MODULWINDOW; } @@ -1437,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() { @@ -1480,6 +1522,7 @@ void ModulWindowLayout::Activating (BaseWindow& rChild) rObjectCatalog.UpdateEntries(); Layout::Activating(rChild); aSyntaxColors.SetActiveEditor(&pChild->GetEditorWindow()); + aSyntaxColors.SetActiveColorSchemeId(m_sColorSchemeId); } void ModulWindowLayout::Deactivating () @@ -1516,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)); @@ -1523,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 () @@ -1539,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 + const TokenType vTokenTypes[] = { - TokenType eTokenType; - svtools::ColorConfigEntry eEntry; - } - const vIds[] = - { - { 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_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_aBackgroundColor = aDocColor; - if (!bFirst && pEditor) - { - pEditor->SetBackground(Wallpaper(m_aBackgroundColor)); - pEditor->Invalidate(); - } + pEditor->ChangeFontColor(aFontColor); + pEditor->SetBackground(Wallpaper(aDocColor)); + pEditor->SetLineHighlightColor(aColorScheme.m_aLineHighlightColor); + pEditor->Invalidate(); } - Color aFontColor = aConfig.GetColorValue(svtools::FONTCOLOR).nColor; - if (bFirst || aFontColor != m_aFontColor) + for (const auto& aToken: vTokenTypes) { - m_aFontColor = aFontColor; - if (!bFirst && pEditor) - pEditor->ChangeFontColor(m_aFontColor); - } - - bool bChanged = false; - for (unsigned i = 0; i != SAL_N_ELEMENTS(vIds); ++i) - { - 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 8d07cd81ddc1..cd0485c46b4b 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -24,6 +24,7 @@ #include <layout.hxx> #include "breakpoint.hxx" #include "linenumberwindow.hxx" +#include <colorscheme.hxx> #include <basic/sbmod.hxx> #include <basic/sbstar.hxx> @@ -32,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> @@ -94,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(); @@ -123,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*); @@ -138,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(); @@ -152,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; }; @@ -253,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 ); @@ -267,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); }; @@ -283,6 +299,7 @@ private: BasicStatus m_aStatus; SbModuleRef m_xModule; 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 OString 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 9671d149ca2b..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 { @@ -230,7 +236,7 @@ public: } private: - sal_uLong nCurState; + sal_uInt32 nCurState; }; EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) : @@ -243,10 +249,14 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) : 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 ); @@ -258,6 +268,10 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) : 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_); } @@ -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() @@ -1016,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); @@ -1078,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 @@ -1102,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(); @@ -1138,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++) @@ -1165,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() @@ -1184,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; @@ -1226,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()) { @@ -1241,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 @@ -1249,6 +1335,7 @@ void EditorWindow::ImplSetFont() rModulWindow.GetBreakPointWindow().SetFont(aFont); rModulWindow.GetLineNumberWindow().SetFont(aFont); + rModulWindow.Invalidate(); if (pEditEngine) { @@ -1256,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! @@ -1271,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 @@ -1313,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(); @@ -1346,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 )); @@ -1419,7 +1525,7 @@ void BreakPointWindow::ShowMarker(vcl::RenderContext& rRenderContext) Size const aOutSz = GetOutDev()->GetOutputSize(); tools::Long const nLineHeight = GetTextHeight(); - Image aMarker = GetImage(bErrorMarker ? OUString(RID_BMP_ERRORMARKER) : OUString(RID_BMP_STEPMARKER)); + Image aMarker = GetImage(bErrorMarker ? RID_BMP_ERRORMARKER : RID_BMP_STEPMARKER); Size aMarkerSz(aMarker.GetSizePixel()); aMarkerSz = rRenderContext.PixelToLogic(aMarkerSz); @@ -1427,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; @@ -1482,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(); } } @@ -1506,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; @@ -1524,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()); @@ -1588,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) @@ -1668,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; }); @@ -1729,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); @@ -1752,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() ) @@ -1772,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); @@ -1941,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(); @@ -1950,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() @@ -1963,6 +2079,7 @@ void ComplexEditorWindow::dispose() aLineNumberWindow.disposeAndClear(); aEdtWindow.disposeAndClear(); aEWVScrollBar.disposeAndClear(); + aEWHScrollBar.disposeAndClear(); vcl::Window::dispose(); } @@ -1974,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() ); } } @@ -2032,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) { @@ -2069,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(); @@ -2097,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); @@ -2148,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()); @@ -2178,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(); @@ -2216,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()) @@ -2293,7 +2413,7 @@ void implCollapseModifiedObjectEntry(const weld::TreeIter& rParent, weld::TreeVi { 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); @@ -2352,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; @@ -2742,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 6e20187055c9..4a6b1dfbfb5c 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -50,7 +50,7 @@ #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> @@ -70,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, @@ -232,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(); } @@ -315,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 ); @@ -603,18 +601,12 @@ void DialogWindow::UpdateBrowser() void DialogWindow::SaveDialog() { - Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext()); - sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD, + sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, FileDialogFlags::NONE, this->GetFrameWeld()); aDlg.SetContext(sfx2::FileDialogHelper::BasicExportDialog); Reference<XFilePicker3> xFP = aDlg.GetFilePicker(); - Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY); - xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false); - Any aValue; - aValue <<= true; - xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue); - + xFP.queryThrow<XFilePickerControlAccess>()->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, Any(true)); xFP->setDefaultName( GetName() ); OUString aDialogStr(IDEResId(RID_STR_STDDIALOGNAME)); @@ -625,133 +617,109 @@ void DialogWindow::SaveDialog() if( aDlg.Execute() != ERRCODE_NONE ) return; - Sequence< OUString > aPaths = xFP->getSelectedFiles(); - - // 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( aPaths[0] ) ) - xSFI->kill( aPaths[0] ); - xOutput = xSFI->openFileWrite( aPaths[0] ); + 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(""); - 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; } @@ -840,18 +791,12 @@ bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const aDlg.SetContext(sfx2::FileDialogHelper::BasicImportDialog); Reference<XFilePicker3> xFP = aDlg.GetFilePicker(); - Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY); - xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false); - Any aValue; - aValue <<= true; - xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue); - OUString aDialogStr(IDEResId(RID_STR_STDDIALOGNAME)); xFP->appendFilter( aDialogStr, "*.xdl" ); xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All ); xFP->setCurrentFilter( aDialogStr ); - if( aDlg.Execute() != ERRCODE_NONE ) + if( aDlg.Execute() == ERRCODE_NONE ) { Sequence< OUString > aPaths = xFP->getSelectedFiles(); @@ -993,15 +938,13 @@ bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const { // 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; } } @@ -1011,13 +954,11 @@ bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const { Sequence< lang::Locale > aRemainingLocaleSeq( nOnlyInImportLanguageCount - 1 ); auto pRemainingLocaleSeq = aRemainingLocaleSeq.getArray(); - lang::Locale aTmpLocale; int iSeq = 0; - for( int i = 0 ; i < nOnlyInImportLanguageCount ; ++i ) + for( const lang::Locale& rLocale : aOnlyInImportLanguages ) { - aTmpLocale = aOnlyInImportLanguages[i]; - if( !localesAreEqual( aFirstLocale, aTmpLocale ) ) - pRemainingLocaleSeq[iSeq++] = aTmpLocale; + if( !localesAreEqual( aFirstLocale, rLocale ) ) + pRemainingLocaleSeq[iSeq++] = rLocale; } pCurMgr->handleAddLocales( aRemainingLocaleSeq ); } @@ -1236,7 +1177,7 @@ void DialogWindow::InitSettings() SetTextColor( rStyleSettings.GetFieldTextColor() ); SetTextFillColor(); - SetBackground( rStyleSettings.GetFieldColor() ); + SetBackground(rStyleSettings.GetFaceColor()); } css::uno::Reference< css::accessibility::XAccessible > DialogWindow::CreateAccessible() @@ -1244,10 +1185,11 @@ css::uno::Reference< css::accessibility::XAccessible > DialogWindow::CreateAcces return new AccessibleDialogWindow(this); } -OString 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 70991525331a..6fe3b9a562f6 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: @@ -1062,6 +1235,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 +1290,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 +1359,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 +1400,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 +1419,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; @@ -1301,7 +1511,7 @@ BasicDebugFlags Shell::CallBasicBreakHdl( StarBASIC const * pBasic ) { Shell* pShell = GetShell(); for ( sal_uInt16 n = 0; n < nWaitCount; n++ ) - pShell->GetViewFrame()->GetWindow().EnterWait(); + pShell->GetViewFrame().GetWindow().EnterWait(); } } } @@ -1345,27 +1555,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..c478d80fdf81 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,6 +378,44 @@ 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) @@ -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; @@ -665,6 +718,7 @@ void Shell::UpdateWindows() Sequence< OUString > aModNames( doc.getObjectNames( E_SCRIPTS, aLibName ) ); sal_Int32 nModCount = aModNames.getLength(); const OUString* pModNames = aModNames.getConstArray(); + nTotalTabs += nModCount; for ( sal_Int32 j = 0 ; j < nModCount ; j++ ) { @@ -694,6 +748,7 @@ void Shell::UpdateWindows() Sequence< OUString > aDlgNames = doc.getObjectNames( E_DIALOGS, aLibName ); sal_Int32 nDlgCount = aDlgNames.getLength(); const OUString* pDlgNames = aDlgNames.getConstArray(); + nTotalTabs += nDlgCount; for ( sal_Int32 j = 0 ; j < nDlgCount ; j++ ) { @@ -722,7 +777,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(); } @@ -891,12 +951,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 28c1acdb383f..708b1ce035d2 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 = ( @@ -216,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() ); } diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx index 26de81e35cb9..5d5bacf0e88d 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()); @@ -323,9 +320,9 @@ 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 ) @@ -432,7 +429,7 @@ SfxBindings* GetBindingsPtr() SfxViewFrame* pFrame = nullptr; if (Shell* pShell = GetShell()) { - pFrame = pShell->GetViewFrame(); + pFrame = &pShell->GetViewFrame(); } else { @@ -456,9 +453,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 afff27b75dfd..18ca75e01bfe 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); } @@ -243,9 +245,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 ? OUString(RID_BMP_DLGLIB) : OUString(RID_BMP_DLGLIBNOTLOADED); + sId = bLoaded ? RID_BMP_DLGLIB : RID_BMP_DLGLIBNOTLOADED; else - sId = bLoaded ? OUString(RID_BMP_MODLIB) : OUString(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) @@ -577,7 +579,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 +606,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 +656,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); } diff --git a/basctl/source/basicide/bastype3.cxx b/basctl/source/basicide/bastype3.cxx index edf4c5bae04a..d26ae83252f6 100644 --- a/basctl/source/basicide/bastype3.cxx +++ b/basctl/source/basicide/bastype3.cxx @@ -101,7 +101,7 @@ IMPL_LINK(SbTreeListBox, RequestingChildrenHdl, const weld::TreeIter&, rEntry, b // exchange image const bool bDlgMode = (nMode & BrowseMode::Dialogs) && !(nMode & BrowseMode::Modules); - auto const aImage(bDlgMode ? OUString(RID_BMP_DLGLIB) : OUString(RID_BMP_MODLIB)); + 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: @@ -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 e0ad3daceca5..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,7 +314,7 @@ 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) @@ -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/linenumberwindow.cxx b/basctl/source/basicide/linenumberwindow.cxx index 7dcbff0ddd7f..80fff0872f10 100644 --- a/basctl/source/basicide/linenumberwindow.cxx +++ b/basctl/source/basicide/linenumberwindow.cxx @@ -21,8 +21,14 @@ LineNumberWindow::LineNumberWindow(vcl::Window* pParent, ModulWindow* pModulWind , m_pModulWindow(pModulWindow) , m_nCurYOffset(0) { - SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetWindowColor())); + // 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; } @@ -48,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) { @@ -78,10 +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); - rRenderContext.SetTextColor(m_FontColor); + 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 a2e457f71103..5f5ab744f0f0 100644 --- a/basctl/source/basicide/linenumberwindow.hxx +++ b/basctl/source/basicide/linenumberwindow.hxx @@ -23,6 +23,7 @@ private: 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..4d311741b4bb 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; } @@ -432,8 +434,7 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties xStringResourceManager->setStringForLocale( aPureIdStr, aPropStr, rLocale ); } - OUString aPropIdStr = aEsc + aPureIdStr; - pIdStrings[i] = aPropIdStr; + pIdStrings[i] = aEsc + aPureIdStr; } xPropertySet->setPropertyValue( aPropName, Any(aIdStrings) ); } @@ -529,8 +530,7 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties {} } - OUString aPropIdStr = aEsc + aPureIdStr; - pIdStrings[i] = aPropIdStr; + pIdStrings[i] = aEsc + aPureIdStr; } xPropertySet->setPropertyValue( aPropName, Any(aIdStrings) ); } @@ -578,8 +578,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) ); } @@ -924,15 +923,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 +949,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 +964,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 +972,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 +986,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 +994,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 +1043,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 +1058,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 +1066,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 dbeaf396f3f3..6b4afb79f772 100644 --- a/basctl/source/basicide/macrodlg.cxx +++ b/basctl/source/basicide/macrodlg.cxx @@ -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 2515cace9800..cfb9adf03553 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -38,7 +38,7 @@ #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> @@ -63,6 +63,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> #include <cppuhelper/implbase.hxx> +#include <o3tl/string_view.hxx> #include <cassert> @@ -102,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; @@ -152,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)); } @@ -167,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 @@ -345,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; } } @@ -460,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) @@ -472,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 @@ -1184,13 +1204,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; @@ -1219,7 +1239,7 @@ void LibPage::SetCurLib() 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_); @@ -1319,6 +1339,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, @@ -1337,7 +1373,7 @@ void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument, BrowseMode nMode = pBasicBox->GetMode(); bool bDlgMode = ( nMode & BrowseMode::Dialogs ) && !( nMode & BrowseMode::Modules ); - const auto sId = bDlgMode ? OUString(RID_BMP_DLGLIB) : OUString(RID_BMP_MODLIB); + 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); diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index 2e3c8c2530d1..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; } } } @@ -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 7dadebcc9ebb..c6ff166c5bb7 100644 --- a/basctl/source/basicide/moduldlg.hxx +++ b/basctl/source/basicide/moduldlg.hxx @@ -59,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; }; @@ -115,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: @@ -147,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; }; @@ -204,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 e23cfbe7a113..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> @@ -927,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 ); @@ -945,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; } } 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 69ffb81f3579..26d15e908761 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 @@ -203,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 ); @@ -218,7 +217,7 @@ DlgEditor::DlgEditor ( 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() ) ); @@ -237,7 +236,6 @@ DlgEditor::DlgEditor ( SetDialog(xDialogModel); } - DlgEditor::~DlgEditor() { aMarkIdle.Stop(); @@ -245,7 +243,6 @@ DlgEditor::~DlgEditor() ::comphelper::disposeComponent( m_xControlContainer ); } - Reference< awt::XControlContainer > const & DlgEditor::GetWindowControlContainer() { if (!m_xControlContainer.is()) @@ -253,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; @@ -262,7 +258,6 @@ void DlgEditor::SetScrollBars( ScrollBar* pHS, ScrollBar* pVS ) InitScrollBars(); } - void DlgEditor::InitScrollBars() { DBG_ASSERT( pHScroll, "DlgEditor::InitScrollBars: no horizontal scroll bar!" ); @@ -347,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 @@ -387,11 +382,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(); @@ -405,7 +400,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 ); @@ -417,7 +412,7 @@ void DlgEditor::ResetDialog () pPage->SetDlgEdForm( nullptr ); SetDialog( m_xUnoControlDialogModel ); if( bWasMarked ) - pDlgEdView->MarkObj( pDlgEdForm, pPgView ); + pDlgEdView->MarkObj( pDlgEdForm.get(), pPgView ); } @@ -431,7 +426,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; @@ -520,16 +515,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(); } } } @@ -555,8 +547,9 @@ void DlgEditor::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle // #i79128# ...and use correct OutDev for that if (pTargetPaintWindow) { + 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 @@ -608,12 +601,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; @@ -626,6 +619,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(); @@ -789,7 +784,7 @@ void DlgEditor::Copy() Sequence< Any > aSeqData { aNoResourceDialogModelBytesAny, - makeAny(aCombinedData) + Any(aCombinedData) }; pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavorsResource, aSeqData ); @@ -797,7 +792,7 @@ void DlgEditor::Copy() else { // No resource, support only old format - pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavors , { makeAny(DialogModelBytes) } ); + pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavors , { Any(DialogModelBytes) } ); } SolarMutexReleaser aReleaser; xClipboard->setContents( pTrans , pTrans ); @@ -919,9 +914,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 @@ -955,7 +950,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(); @@ -963,7 +958,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 5c7d012344bb..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,21 +45,18 @@ 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 >= SdrObjKind::BasicDialogPushButton) && (aParams.nObjIdentifier <= SdrObjKind::BasicDialogFormHorizontalScroll) ) @@ -73,26 +71,26 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* ) break; 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 SdrObjKind::BasicDialogCheckbox: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlCheckBoxModel", xDialogSFact ); break; 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 SdrObjKind::BasicDialogListbox: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact ); break; 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 SdrObjKind::BasicDialogFormCombo: case SdrObjKind::BasicDialogCombobox: { - DlgEdObj* pNew = nullptr; + rtl::Reference<DlgEdObj> pNew; if ( aParams.nObjIdentifier == SdrObjKind::BasicDialogCombobox ) pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlComboBoxModel", xDialogSFact ); else @@ -134,12 +132,12 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* ) break; 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 SdrObjKind::BasicDialogFormVerticalScroll: case SdrObjKind::BasicDialogVerticalScrollbar: { - DlgEdObj* pNew = nullptr; + rtl::Reference<DlgEdObj> pNew; if ( aParams.nObjIdentifier == SdrObjKind::BasicDialogVerticalScrollbar ) pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact ); else @@ -166,7 +164,7 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* ) break; 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 @@ -207,7 +205,7 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* ) break; 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 SdrObjKind::BasicDialogTreeControl: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.tree.TreeControlModel", xDialogSFact ); diff --git a/basctl/source/dlged/dlgedfunc.cxx b/basctl/source/dlged/dlgedfunc.cxx index c43b22c8e16a..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> @@ -45,8 +45,8 @@ void DlgEdFunc::ForceScroll( const Point& rPos ) 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(); @@ -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/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx index 1d89210b7dd5..5b87393e51bc 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 ) { } @@ -906,16 +905,16 @@ SdrObjKind DlgEdObj::GetObjIdentifier() const } } -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 +960,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 +1288,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 +1406,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(); } @@ -1675,17 +1673,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{ Any(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 d6c67b7e9f7a..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> diff --git a/basctl/source/dlged/managelang.cxx b/basctl/source/dlged/managelang.cxx index c7cd423cccee..1dc44b0f09cf 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")) @@ -113,7 +113,7 @@ void ManageLanguageDialog::FillLanguageBox() sLanguage += " " + m_sDefLangStr; } LanguageEntry* pEntry = new LanguageEntry(pLocale[i], bIsDefault); - m_xLanguageLB->append(OUString::number(reinterpret_cast<sal_Int64>(pEntry)), sLanguage); + m_xLanguageLB->append(weld::toId(pEntry), sLanguage); } } else @@ -125,7 +125,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(); @@ -166,7 +166,7 @@ IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl, weld::Button&, void) 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 ) aLocaleSeqRange[i] = pEntry->m_aLocale; } @@ -185,7 +185,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 @@ -213,9 +213,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")) diff --git a/basctl/source/dlged/propbrw.cxx b/basctl/source/dlged/propbrw.cxx index 4a8481249640..bb45d5f13e8d 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> @@ -137,11 +137,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() ) { @@ -242,11 +242,11 @@ Sequence< Reference< XInterface > > { SdrObject* pCurrent = _rMarkList.GetMark(i)->GetMarkedSdrObj(); - 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 +259,7 @@ Sequence< Reference< XInterface > > } // next element - pCurrent = pGroupIterator && pGroupIterator->IsMore() ? pGroupIterator->Next() : nullptr; + pCurrent = oGroupIterator && oGroupIterator->IsMore() ? oGroupIterator->Next() : nullptr; } } @@ -443,7 +443,7 @@ void PropBrw::ImplUpdate( const Reference< XModel >& _rxContextDocument, SdrView { if ( pView ) { - EndListening( *(pView->GetModel()) ); + EndListening(pView->GetModel()); pView = nullptr; } @@ -464,7 +464,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 +492,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 cc53d0f11f69..14fc68f07951 100644 --- a/basctl/source/inc/baside3.hxx +++ b/basctl/source/inc/baside3.hxx @@ -67,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(); @@ -107,7 +107,7 @@ public: virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; - virtual OString 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 2d494cd8d4ee..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, @@ -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 e2e81a26916c..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 ); diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx index e150635befb7..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 OString 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 ffb726b21bfc..c10ef16cd8d3 100644 --- a/basctl/source/inc/dlgeddef.hxx +++ b/basctl/source/inc/dlgeddef.hxx @@ -26,20 +26,20 @@ namespace basctl // control properties #define DLGED_PROP_BACKGROUNDCOLOR "BackgroundColor" -inline constexpr OUStringLiteral DLGED_PROP_DROPDOWN = u"Dropdown"; -inline constexpr OUStringLiteral DLGED_PROP_FORMATSSUPPLIER = u"FormatsSupplier"; -inline constexpr OUStringLiteral DLGED_PROP_HEIGHT = u"Height"; -inline constexpr OUStringLiteral DLGED_PROP_LABEL = u"Label"; -inline constexpr OUStringLiteral DLGED_PROP_NAME = u"Name"; -inline constexpr OUStringLiteral DLGED_PROP_ORIENTATION = u"Orientation"; -inline constexpr OUStringLiteral DLGED_PROP_POSITIONX = u"PositionX"; -inline constexpr OUStringLiteral DLGED_PROP_POSITIONY = u"PositionY"; -inline constexpr OUStringLiteral DLGED_PROP_STEP = u"Step"; -inline constexpr OUStringLiteral DLGED_PROP_TABINDEX = u"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" -inline constexpr OUStringLiteral DLGED_PROP_WIDTH = u"Width"; -inline constexpr OUStringLiteral DLGED_PROP_DECORATION = u"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 9dd66da678b8..1681807d390e 100644 --- a/basctl/source/inc/docsignature.hxx +++ b/basctl/source/inc/docsignature.hxx @@ -39,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/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; |