diff options
Diffstat (limited to 'basctl')
102 files changed, 3317 insertions, 1851 deletions
diff --git a/basctl/IwyuFilter_basctl.yaml b/basctl/IwyuFilter_basctl.yaml index a4275b943e48..f72d7e7b7ee2 100644 --- a/basctl/IwyuFilter_basctl.yaml +++ b/basctl/IwyuFilter_basctl.yaml @@ -1,6 +1,11 @@ --- assumeFilename: basctl/source/basicide/baside2b.cxx excludelist: + basctl/sdi/basslots.hrc: + # Needed for basctl/sdi/basslots.sdi + - svx/svxids.hrc + - svx/unomid.hxx + - editeng/memberids.h basctl/source/basicide/basidesh.cxx: # Needed for TypedWhichId defines is basslots.hxx - sfx2/dinfdlg.hxx diff --git a/basctl/Library_basctl.mk b/basctl/Library_basctl.mk index f874dfe9cc54..cb41fa9e461c 100644 --- a/basctl/Library_basctl.mk +++ b/basctl/Library_basctl.mk @@ -19,7 +19,7 @@ $(eval $(call gb_Library_Library,basctl)) -$(eval $(call gb_Library_set_componentfile,basctl,basctl/util/basctl)) +$(eval $(call gb_Library_set_componentfile,basctl,basctl/util/basctl,services)) $(eval $(call gb_Library_set_include,basctl,\ -I$(SRCDIR)/basctl/inc \ @@ -40,6 +40,7 @@ $(eval $(call gb_Library_set_precompiled_header,basctl,basctl/inc/pch/precompile $(eval $(call gb_Library_use_sdk_api,basctl)) $(eval $(call gb_Library_use_libraries,basctl,\ + basegfx \ comphelper \ cppu \ cppuhelper \ @@ -62,9 +63,14 @@ $(eval $(call gb_Library_use_libraries,basctl,\ xmlscript \ )) +ifneq ($(ENABLE_WASM_STRIP_ACCESSIBILITY),TRUE) $(eval $(call gb_Library_add_exception_objects,basctl,\ basctl/source/accessibility/accessibledialogcontrolshape \ basctl/source/accessibility/accessibledialogwindow \ +)) +endif + +$(eval $(call gb_Library_add_exception_objects,basctl,\ basctl/source/basicide/basdoc \ basctl/source/basicide/IDEComboBox \ basctl/source/basicide/basicrenderable \ @@ -89,10 +95,13 @@ $(eval $(call gb_Library_add_exception_objects,basctl,\ basctl/source/basicide/iderdll \ basctl/source/basicide/layout \ basctl/source/basicide/linenumberwindow \ + basctl/source/basicide/LineStatusControl \ basctl/source/basicide/localizationmgr \ basctl/source/basicide/macrodlg \ basctl/source/basicide/moduldl2 \ basctl/source/basicide/moduldlg \ + basctl/source/basicide/BasicColorConfig \ + basctl/source/basicide/ColorSchemeDialog \ basctl/source/basicide/ObjectCatalog \ basctl/source/basicide/sbxitem \ basctl/source/basicide/scriptdocument \ diff --git a/basctl/README b/basctl/README deleted file mode 100644 index 44cdd8f6c46b..000000000000 --- a/basctl/README +++ /dev/null @@ -1 +0,0 @@ -Controls and dialogs for Basic. Contains the Basic IDE. diff --git a/basctl/README.md b/basctl/README.md new file mode 100644 index 000000000000..bf550607668f --- /dev/null +++ b/basctl/README.md @@ -0,0 +1,3 @@ +# BASIC IDE Controls and Dialogs + +Controls and dialogs for BASIC. Contains the BASIC IDE. diff --git a/basctl/UIConfig_basicide.mk b/basctl/UIConfig_basicide.mk index 2c23fbfb58af..217ea6c01708 100644 --- a/basctl/UIConfig_basicide.mk +++ b/basctl/UIConfig_basicide.mk @@ -37,6 +37,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/BasicIDE,\ basctl/uiconfig/basicide/ui/basicmacrodialog \ basctl/uiconfig/basicide/ui/breakpointmenus \ basctl/uiconfig/basicide/ui/codecomplete \ + basctl/uiconfig/basicide/ui/colorscheme \ basctl/uiconfig/basicide/ui/combobox \ basctl/uiconfig/basicide/ui/defaultlanguage \ basctl/uiconfig/basicide/ui/deletelangdialog \ diff --git a/basctl/inc/bitmaps.hlst b/basctl/inc/bitmaps.hlst index 11d35b289d58..0dc8e8d2c8c1 100644 --- a/basctl/inc/bitmaps.hlst +++ b/basctl/inc/bitmaps.hlst @@ -9,19 +9,19 @@ #pragma once -#define RID_BMP_BRKENABLED "res/im30838.png" -#define RID_BMP_BRKDISABLED "res/im30839.png" -#define RID_BMP_STEPMARKER "res/im30840.png" -#define RID_BMP_ERRORMARKER "res/im30841.png" -#define RID_BMP_LOCKED "res/lock.png" -#define RID_BMP_INSTALLATION "res/harddisk_16.png" -#define RID_BMP_DOCUMENT "res/im30826.png" -#define RID_BMP_MODLIB "res/im30820.png" -#define RID_BMP_MODLIBNOTLOADED "res/im30827.png" -#define RID_BMP_MODULE "res/im30821.png" -#define RID_BMP_MACRO "res/im30822.png" -#define RID_BMP_DLGLIB "res/dialogfolder_16.png" -#define RID_BMP_DLGLIBNOTLOADED "res/dialogfoldernot_16.png" -#define RID_BMP_DIALOG "res/im30823.png" +inline constexpr OUString RID_BMP_BRKENABLED = u"res/im30838.png"_ustr; +inline constexpr OUString RID_BMP_BRKDISABLED = u"res/im30839.png"_ustr; +inline constexpr OUString RID_BMP_STEPMARKER = u"res/im30840.png"_ustr; +inline constexpr OUString RID_BMP_ERRORMARKER = u"res/im30841.png"_ustr; +inline constexpr OUString RID_BMP_LOCKED = u"res/lock.png"_ustr; +inline constexpr OUString RID_BMP_INSTALLATION = u"res/harddisk_16.png"_ustr; +inline constexpr OUString RID_BMP_DOCUMENT = u"res/im30826.png"_ustr; +inline constexpr OUString RID_BMP_MODLIB = u"res/im30820.png"_ustr; +inline constexpr OUString RID_BMP_MODLIBNOTLOADED = u"res/im30827.png"_ustr; +inline constexpr OUString RID_BMP_MODULE = u"res/im30821.png"_ustr; +inline constexpr OUString RID_BMP_MACRO = u"res/im30822.png"_ustr; +inline constexpr OUString RID_BMP_DLGLIB = u"res/dialogfolder_16.png"_ustr; +inline constexpr OUString RID_BMP_DLGLIBNOTLOADED = u"res/dialogfoldernot_16.png"_ustr; +inline constexpr OUString RID_BMP_DIALOG = u"res/im30823.png"_ustr; /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/basctl/inc/helpids.h b/basctl/inc/helpids.h index 13e59eb7ef88..2d656b96bf48 100644 --- a/basctl/inc/helpids.h +++ b/basctl/inc/helpids.h @@ -18,20 +18,22 @@ */ #pragma once -#define HID_BASICIDE_OBJECTCAT "BASCTL_HID_BASICIDE_OBJECTCAT" +#include <rtl/ustring.hxx> -#define HID_BASICIDE_REMOVEWATCH "BASCTL_HID_BASICIDE_REMOVEWATCH" +inline constexpr OUString HID_BASICIDE_OBJECTCAT = u"BASCTL_HID_BASICIDE_OBJECTCAT"_ustr; -#define HID_BASICIDE_MODULWINDOW "BASCTL_HID_BASICIDE_MODULWINDOW" -#define HID_BASICIDE_DIALOGWINDOW "BASCTL_HID_BASICIDE_DIALOGWINDOW" +inline constexpr OUString HID_BASICIDE_REMOVEWATCH = u"BASCTL_HID_BASICIDE_REMOVEWATCH"_ustr; -#define HID_BASICIDE_EDITORWINDOW "BASCTL_HID_BASICIDE_EDITORWINDOW" -#define HID_BASICIDE_BREAKPOINTWINDOW "BASCTL_HID_BASICIDE_BREAKPOINTWINDOW" -#define HID_BASICIDE_WATCHWINDOW "BASCTL_HID_BASICIDE_WATCHWINDOW" -#define HID_BASICIDE_STACKWINDOW "BASCTL_HID_BASICIDE_STACKWINDOW" -#define HID_BASICIDE_TABBAR "BASCTL_HID_BASICIDE_TABBAR" -#define HID_BASICIDE_WATCHWINDOW_EDIT "BASCTL_HID_BASICIDE_WATCHWINDOW_EDIT" -#define HID_BASICIDE_WATCHWINDOW_LIST "BASCTL_HID_BASICIDE_WATCHWINDOW_LIST" -#define HID_BASICIDE_STACKWINDOW_LIST "BASCTL_HID_BASICIDE_STACKWINDOW_LIST" +inline constexpr OUString HID_BASICIDE_MODULWINDOW = u"BASCTL_HID_BASICIDE_MODULWINDOW"_ustr; +inline constexpr OUString HID_BASICIDE_DIALOGWINDOW = u"BASCTL_HID_BASICIDE_DIALOGWINDOW"_ustr; + +inline constexpr OUString HID_BASICIDE_EDITORWINDOW = u"BASCTL_HID_BASICIDE_EDITORWINDOW"_ustr; +inline constexpr OUString HID_BASICIDE_BREAKPOINTWINDOW = u"BASCTL_HID_BASICIDE_BREAKPOINTWINDOW"_ustr; +inline constexpr OUString HID_BASICIDE_WATCHWINDOW = u"BASCTL_HID_BASICIDE_WATCHWINDOW"_ustr; +inline constexpr OUString HID_BASICIDE_STACKWINDOW = u"BASCTL_HID_BASICIDE_STACKWINDOW"_ustr; +inline constexpr OUString HID_BASICIDE_TABBAR = u"BASCTL_HID_BASICIDE_TABBAR"_ustr; +inline constexpr OUString HID_BASICIDE_WATCHWINDOW_EDIT = u"BASCTL_HID_BASICIDE_WATCHWINDOW_EDIT"_ustr; +inline constexpr OUString HID_BASICIDE_WATCHWINDOW_LIST = u"BASCTL_HID_BASICIDE_WATCHWINDOW_LIST"_ustr; +inline constexpr OUString HID_BASICIDE_STACKWINDOW_LIST = u"BASCTL_HID_BASICIDE_STACKWINDOW_LIST"_ustr; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basctl/inc/pch/precompiled_basctl.hxx b/basctl/inc/pch/precompiled_basctl.hxx index 7d31e61a4d8b..1794f96f90e9 100644 --- a/basctl/inc/pch/precompiled_basctl.hxx +++ b/basctl/inc/pch/precompiled_basctl.hxx @@ -13,18 +13,19 @@ manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). - Generated on 2020-12-15 11:15:22 using: + Generated on 2023-07-19 09:19:46 using: ./bin/update_pch basctl basctl --cutoff=3 --exclude:system --include:module --exclude:local If after updating build fails, use the following command to locate conflicting headers: ./bin/update_pch_bisect ./basctl/inc/pch/precompiled_basctl.hxx "make basctl.build" --find-conflicts */ +#include <sal/config.h> #if PCH_LEVEL >= 1 #include <algorithm> -#include <assert.h> -#include <atomic> +#include <array> #include <cassert> +#include <chrono> #include <climits> #include <cmath> #include <cstddef> @@ -41,11 +42,14 @@ #include <map> #include <math.h> #include <memory> +#include <mutex> #include <new> +#include <numeric> #include <optional> #include <ostream> -#include <set> +#include <span> #include <stddef.h> +#include <stdexcept> #include <string.h> #include <string> #include <string_view> @@ -55,7 +59,6 @@ #include <unordered_set> #include <utility> #include <vector> -#include <boost/functional/hash.hpp> #include <boost/property_tree/ptree_fwd.hpp> #endif // PCH_LEVEL >= 1 #if PCH_LEVEL >= 2 @@ -67,12 +70,15 @@ #include <osl/interlck.h> #include <osl/mutex.h> #include <osl/mutex.hxx> -#include <osl/thread.h> #include <osl/time.h> #include <rtl/alloc.h> +#include <rtl/character.hxx> #include <rtl/instance.hxx> +#include <rtl/locale.h> #include <rtl/math.h> #include <rtl/ref.hxx> +#include <rtl/strbuf.h> +#include <rtl/strbuf.hxx> #include <rtl/string.h> #include <rtl/string.hxx> #include <rtl/stringconcat.hxx> @@ -85,12 +91,13 @@ #include <rtl/ustring.h> #include <rtl/ustring.hxx> #include <rtl/uuid.h> -#include <sal/config.h> +#include <sal/backtrace.hxx> #include <sal/log.hxx> #include <sal/macros.h> #include <sal/saldllapi.h> #include <sal/types.h> #include <sal/typesizes.h> +#include <vcl/BinaryDataContainer.hxx> #include <vcl/EnumContext.hxx> #include <vcl/GraphicAttributes.hxx> #include <vcl/GraphicExternalLink.hxx> @@ -99,45 +106,54 @@ #include <vcl/InterimItemWindow.hxx> #include <vcl/PrinterSupport.hxx> #include <vcl/Scanline.hxx> +#include <vcl/WindowPosSize.hxx> #include <vcl/alpha.hxx> #include <vcl/animate/Animation.hxx> -#include <vcl/animate/AnimationBitmap.hxx> +#include <vcl/animate/AnimationFrame.hxx> #include <vcl/bitmap.hxx> +#include <vcl/bitmap/BitmapTypes.hxx> #include <vcl/bitmapex.hxx> -#include <vcl/builder.hxx> #include <vcl/builderpage.hxx> #include <vcl/cairo.hxx> #include <vcl/checksum.hxx> #include <vcl/commandevent.hxx> #include <vcl/ctrl.hxx> -#include <vcl/devicecoordinate.hxx> #include <vcl/dllapi.h> -#include <vcl/errcode.hxx> +#include <vcl/dockwin.hxx> #include <vcl/event.hxx> -#include <vcl/floatwin.hxx> #include <vcl/fntstyle.hxx> #include <vcl/font.hxx> +#include <vcl/formatter.hxx> #include <vcl/gdimtf.hxx> #include <vcl/gfxlink.hxx> +#include <vcl/gradient.hxx> #include <vcl/graph.hxx> #include <vcl/idle.hxx> -#include <vcl/image.hxx> #include <vcl/jobset.hxx> +#include <vcl/kernarray.hxx> #include <vcl/keycod.hxx> #include <vcl/keycodes.hxx> #include <vcl/mapmod.hxx> #include <vcl/metaactiontypes.hxx> #include <vcl/metric.hxx> -#include <vcl/notebookbar/NotebookBarAddonsMerger.hxx> #include <vcl/outdev.hxx> -#include <vcl/outdevmap.hxx> -#include <vcl/outdevstate.hxx> #include <vcl/prntypes.hxx> #include <vcl/region.hxx> +#include <vcl/rendercontext/AddFontSubstituteFlags.hxx> +#include <vcl/rendercontext/AntialiasingFlags.hxx> +#include <vcl/rendercontext/DrawGridFlags.hxx> +#include <vcl/rendercontext/DrawImageFlags.hxx> +#include <vcl/rendercontext/DrawModeFlags.hxx> +#include <vcl/rendercontext/DrawTextFlags.hxx> +#include <vcl/rendercontext/GetDefaultFontFlags.hxx> +#include <vcl/rendercontext/ImplMapRes.hxx> +#include <vcl/rendercontext/InvertFlags.hxx> +#include <vcl/rendercontext/RasterOp.hxx> +#include <vcl/rendercontext/SalLayoutFlags.hxx> +#include <vcl/rendercontext/State.hxx> +#include <vcl/rendercontext/SystemTextColorFlags.hxx> #include <vcl/salgtype.hxx> #include <vcl/salnativewidgets.hxx> -#include <vcl/scopedbitmapaccess.hxx> -#include <vcl/scrbar.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <vcl/syswin.hxx> @@ -145,6 +161,8 @@ #include <vcl/texteng.hxx> #include <vcl/textview.hxx> #include <vcl/timer.hxx> +#include <vcl/toolboxid.hxx> +#include <vcl/transfer.hxx> #include <vcl/uitest/factory.hxx> #include <vcl/vclenum.hxx> #include <vcl/vclptr.hxx> @@ -155,30 +173,38 @@ #include <vcl/weld.hxx> #include <vcl/window.hxx> #include <vcl/windowstate.hxx> +#include <vcl/wintypes.hxx> #include <vcl/xtextedt.hxx> #endif // PCH_LEVEL >= 2 #if PCH_LEVEL >= 3 #include <basegfx/basegfxdllapi.h> #include <basegfx/color/bcolor.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/matrix/hommatrixtemplate.hxx> #include <basegfx/numeric/ftools.hxx> #include <basegfx/point/b2dpoint.hxx> #include <basegfx/point/b2ipoint.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/range/Range2D.hxx> #include <basegfx/range/b2drange.hxx> #include <basegfx/range/b2drectangle.hxx> #include <basegfx/range/b2irange.hxx> #include <basegfx/range/b2irectangle.hxx> #include <basegfx/range/basicrange.hxx> +#include <basegfx/tuple/Size2D.hxx> +#include <basegfx/tuple/Tuple2D.hxx> +#include <basegfx/tuple/Tuple3D.hxx> #include <basegfx/tuple/b2dtuple.hxx> #include <basegfx/tuple/b2i64tuple.hxx> #include <basegfx/tuple/b2ituple.hxx> #include <basegfx/tuple/b3dtuple.hxx> +#include <basegfx/utils/bgradient.hxx> #include <basegfx/utils/common.hxx> #include <basegfx/vector/b2dsize.hxx> #include <basegfx/vector/b2dvector.hxx> #include <basegfx/vector/b2enums.hxx> +#include <basegfx/vector/b2isize.hxx> #include <basegfx/vector/b2ivector.hxx> #include <basic/basicdllapi.h> #include <basic/basmgr.hxx> @@ -192,13 +218,15 @@ #include <com/sun/star/accessibility/XAccessibleContext2.hpp> #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> #include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp> -#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/awt/DeviceInfo.hpp> +#include <com/sun/star/awt/Gradient2.hpp> #include <com/sun/star/awt/GradientStyle.hpp> #include <com/sun/star/awt/Key.hpp> #include <com/sun/star/awt/KeyGroup.hpp> #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/awt/XUnitConversion.hpp> #include <com/sun/star/awt/XUserInputInterception.hpp> +#include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/beans/Property.hpp> #include <com/sun/star/beans/PropertyState.hpp> #include <com/sun/star/beans/PropertyValue.hpp> @@ -229,6 +257,7 @@ #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/frame/XController2.hpp> #include <com/sun/star/frame/XControllerBorder.hpp> +#include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/frame/XDispatchInformationProvider.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XFrame.hpp> @@ -240,17 +269,28 @@ #include <com/sun/star/frame/XTitle.hpp> #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp> #include <com/sun/star/frame/XToolbarController.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/graphic/XPrimitive2D.hpp> #include <com/sun/star/i18n/Calendar2.hpp> +#include <com/sun/star/i18n/DirectionProperty.hpp> #include <com/sun/star/i18n/ForbiddenCharacters.hpp> +#include <com/sun/star/i18n/KCharacterType.hpp> #include <com/sun/star/i18n/LanguageCountryInfo.hpp> #include <com/sun/star/i18n/LocaleDataItem2.hpp> #include <com/sun/star/i18n/LocaleItem.hpp> #include <com/sun/star/i18n/NativeNumberXmlAttributes.hpp> +#include <com/sun/star/i18n/ParseResult.hpp> #include <com/sun/star/i18n/TransliterationModules.hpp> #include <com/sun/star/i18n/TransliterationModulesExtra.hpp> +#include <com/sun/star/i18n/UnicodeScript.hpp> #include <com/sun/star/i18n/WordType.hpp> +#include <com/sun/star/i18n/XNumberFormatCode.hpp> #include <com/sun/star/i18n/reservedWords.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/io/XSeekable.hpp> +#include <com/sun/star/io/XStream.hpp> +#include <com/sun/star/io/XTruncate.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/EventObject.hpp> #include <com/sun/star/lang/Locale.hpp> @@ -270,9 +310,9 @@ #include <com/sun/star/text/textfield/Type.hpp> #include <com/sun/star/ui/XContextMenuInterception.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> +#include <com/sun/star/ui/dialogs/XFilePicker3.hpp> #include <com/sun/star/uno/Any.h> #include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/uno/Exception.hpp> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/RuntimeException.hpp> @@ -296,12 +336,18 @@ #include <com/sun/star/util/SearchFlags.hpp> #include <com/sun/star/util/SearchOptions2.hpp> #include <com/sun/star/util/Time.hpp> +#include <com/sun/star/util/XAccounting.hpp> #include <com/sun/star/util/XUpdatable.hpp> #include <com/sun/star/view/PrintableState.hpp> -#include <comphelper/accessiblecomponenthelper.hxx> -#include <comphelper/accessiblecontexthelper.hxx> +#include <comphelper/accessibleeventnotifier.hxx> #include <comphelper/broadcasthelper.hxx> +#include <comphelper/compbase.hxx> #include <comphelper/comphelperdllapi.h> +#include <comphelper/diagnose_ex.hxx> +#include <comphelper/errcode.hxx> +#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> +#include <comphelper/multicontainer2.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propagg.hxx> #include <comphelper/proparrhlp.hxx> @@ -311,34 +357,32 @@ #include <comphelper/propstate.hxx> #include <comphelper/sequence.hxx> #include <comphelper/servicehelper.hxx> -#include <comphelper/solarmutex.hxx> #include <comphelper/string.hxx> #include <comphelper/uno3.hxx> -#include <comphelper/weak.hxx> +#include <comphelper/unoimplbase.hxx> #include <cppu/cppudllapi.h> #include <cppu/unotype.hxx> #include <cppuhelper/basemutex.hxx> -#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/compbase.hxx> #include <cppuhelper/compbase_ex.hxx> #include <cppuhelper/cppuhelperdllapi.h> #include <cppuhelper/implbase.hxx> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> -#include <cppuhelper/implbase_ex.hxx> -#include <cppuhelper/implbase_ex_post.hxx> -#include <cppuhelper/implbase_ex_pre.hxx> #include <cppuhelper/interfacecontainer.h> -#include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/propshlp.hxx> -#include <cppuhelper/supportsservice.hxx> +#include <cppuhelper/queryinterface.hxx> #include <cppuhelper/weak.hxx> #include <cppuhelper/weakagg.hxx> #include <cppuhelper/weakref.hxx> +#include <docmodel/color/ComplexColor.hxx> +#include <docmodel/color/Transformation.hxx> +#include <docmodel/dllapi.h> +#include <docmodel/theme/ThemeColorType.hxx> #include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/geometry/viewinformation2d.hxx> #include <drawinglayer/primitive2d/CommonTypes.hxx> #include <drawinglayer/primitive2d/Primitive2DContainer.hxx> #include <drawinglayer/primitive2d/Primitive2DVisitor.hxx> +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <editeng/borderline.hxx> #include <editeng/editdata.hxx> #include <editeng/editengdllapi.h> @@ -348,9 +392,12 @@ #include <editeng/flditem.hxx> #include <editeng/forbiddencharacterstable.hxx> #include <editeng/outliner.hxx> +#include <editeng/outlobj.hxx> +#include <editeng/overflowingtxt.hxx> #include <editeng/paragraphdata.hxx> #include <editeng/svxenum.hxx> #include <editeng/svxfont.hxx> +#include <i18nlangtag/i18nlangtagdllapi.h> #include <i18nlangtag/lang.h> #include <i18nlangtag/languagetag.hxx> #include <i18nutil/i18nutildllapi.h> @@ -360,11 +407,14 @@ #include <o3tl/cow_wrapper.hxx> #include <o3tl/deleter.hxx> #include <o3tl/enumarray.hxx> +#include <o3tl/hash_combine.hxx> #include <o3tl/safeint.hxx> #include <o3tl/sorted_vector.hxx> +#include <o3tl/string_view.hxx> #include <o3tl/strong_int.hxx> #include <o3tl/typed_flags_set.hxx> #include <o3tl/underlyingenumvalue.hxx> +#include <o3tl/unit_conversion.hxx> #include <salhelper/salhelperdllapi.h> #include <salhelper/simplereferenceobject.hxx> #include <sfx2/app.hxx> @@ -374,6 +424,7 @@ #include <sfx2/childwin.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/dllapi.h> +#include <sfx2/filedlghelper.hxx> #include <sfx2/frame.hxx> #include <sfx2/groupid.hxx> #include <sfx2/minfitem.hxx> @@ -387,6 +438,7 @@ #include <sot/sotdllapi.h> #include <svl/SfxBroadcaster.hxx> #include <svl/cenumitm.hxx> +#include <svl/cintitem.hxx> #include <svl/eitem.hxx> #include <svl/hint.hxx> #include <svl/itempool.hxx> @@ -396,6 +448,7 @@ #include <svl/nfkeytab.hxx> #include <svl/ondemand.hxx> #include <svl/poolitem.hxx> +#include <svl/setitem.hxx> #include <svl/srchdefs.hxx> #include <svl/stritem.hxx> #include <svl/style.hxx> @@ -404,14 +457,15 @@ #include <svl/typedwhich.hxx> #include <svl/undo.hxx> #include <svl/visitem.hxx> +#include <svl/whichranges.hxx> #include <svl/whiter.hxx> +#include <svl/zforlist.hxx> #include <svtools/borderline.hxx> #include <svtools/colorcfg.hxx> -#include <svtools/optionsdrawinglayer.hxx> #include <svtools/statusbarcontroller.hxx> #include <svtools/svtdllapi.h> +#include <svtools/toolbarmenu.hxx> #include <svtools/toolboxcontroller.hxx> -#include <svx/DiagramDataInterface.hxx> #include <svx/XPropertyEntry.hxx> #include <svx/ipolypolygoneditorcontroller.hxx> #include <svx/itextprovider.hxx> @@ -425,7 +479,6 @@ #include <svx/sdtaitm.hxx> #include <svx/sdtakitm.hxx> #include <svx/selectioncontroller.hxx> -#include <svx/shapeproperty.hxx> #include <svx/svddef.hxx> #include <svx/svddrag.hxx> #include <svx/svddrgv.hxx> @@ -456,7 +509,6 @@ #include <svx/svxdllapi.h> #include <svx/xdash.hxx> #include <svx/xdef.hxx> -#include <svx/xgrad.hxx> #include <svx/xhatch.hxx> #include <svx/xpoly.hxx> #include <svx/xtable.hxx> @@ -467,7 +519,6 @@ #include <tools/datetime.hxx> #include <tools/debug.hxx> #include <tools/degree.hxx> -#include <tools/diagnose_ex.h> #include <tools/fldunit.hxx> #include <tools/fontenum.hxx> #include <tools/fract.hxx> @@ -481,12 +532,11 @@ #include <tools/poly.hxx> #include <tools/ref.hxx> #include <tools/solar.h> +#include <tools/stream.hxx> #include <tools/time.hxx> #include <tools/toolsdllapi.h> #include <tools/urlobj.hxx> #include <tools/weakbase.h> -#include <tools/weakbase.hxx> -#include <tools/wintypes.hxx> #include <typelib/typeclass.h> #include <typelib/typedescription.h> #include <typelib/uik.h> @@ -496,16 +546,18 @@ #include <uno/lbnames.h> #include <uno/sequence2.h> #include <unotools/calendarwrapper.hxx> +#include <unotools/charclass.hxx> #include <unotools/configitem.hxx> #include <unotools/fontdefs.hxx> #include <unotools/localedatawrapper.hxx> #include <unotools/nativenumberwrapper.hxx> #include <unotools/options.hxx> -#include <unotools/readwritemutexguard.hxx> #include <unotools/resmgr.hxx> #include <unotools/syslocale.hxx> +#include <unotools/tempfile.hxx> #include <unotools/transliterationwrapper.hxx> #include <unotools/unotoolsdllapi.h> +#include <unotools/weakref.hxx> #include <xmlscript/xmldlg_imexp.hxx> #endif // PCH_LEVEL >= 3 #if PCH_LEVEL >= 4 diff --git a/basctl/inc/strings.hrc b/basctl/inc/strings.hrc index a5a0a4660b59..ee83fbb543b0 100644 --- a/basctl/inc/strings.hrc +++ b/basctl/inc/strings.hrc @@ -20,7 +20,7 @@ #ifndef BASCTL_INC_BASIDESH_HRC #define BASCTL_INC_BASIDESH_HRC -#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String) +#define NC_(Context, String) TranslateId(Context, u8##String) #define RID_STR_FILTER_ALLFILES NC_("RID_STR_FILTER_ALLFILES", "<All>") #define RID_STR_NOMODULE NC_("RID_STR_NOMODULE", "< No Module >") @@ -75,9 +75,9 @@ #define RID_STR_USERMACROS NC_("RID_STR_USERMACROS", "My Macros") #define RID_STR_USERDIALOGS NC_("RID_STR_USERDIALOGS", "My Dialogs") #define RID_STR_USERMACROSDIALOGS NC_("RID_STR_USERMACROSDIALOGS", "My Macros & Dialogs") -#define RID_STR_SHAREMACROS NC_("RID_STR_SHAREMACROS", "%PRODUCTNAME Macros") -#define RID_STR_SHAREDIALOGS NC_("RID_STR_SHAREDIALOGS", "%PRODUCTNAME Dialogs") -#define RID_STR_SHAREMACROSDIALOGS NC_("RID_STR_SHAREMACROSDIALOGS", "%PRODUCTNAME Macros & Dialogs") +#define RID_STR_SHAREMACROS NC_("RID_STR_SHAREMACROS", "Application Macros") +#define RID_STR_SHAREDIALOGS NC_("RID_STR_SHAREDIALOGS", "Application Dialogs") +#define RID_STR_SHAREMACROSDIALOGS NC_("RID_STR_SHAREMACROSDIALOGS", "Application Macros & Dialogs") #define RID_STR_REMOVEWATCHTIP NC_("RID_STR_REMOVEWATCHTIP", "Remove Watch") #define RID_STR_QUERYREPLACEMACRO NC_("RID_STR_QUERYREPLACEMACRO", "Do you want to overwrite the XX macro?") #define RID_STR_TRANSLATION_NOTLOCALIZED NC_("RID_STR_TRANSLATION_NOTLOCALIZED", "<Not localized>") @@ -89,7 +89,7 @@ #define RID_STR_DLGIMP_CLASH_RENAME NC_("RID_STR_DLGIMP_CLASH_RENAME", "Rename") #define RID_STR_DLGIMP_CLASH_REPLACE NC_("RID_STR_DLGIMP_CLASH_REPLACE", "Replace") #define RID_STR_DLGIMP_CLASH_TITLE NC_("RID_STR_DLGIMP_CLASH_TITLE", "Dialog Import - Name already used") -#define RID_STR_DLGIMP_CLASH_TEXT NC_("RID_STR_DLGIMP_CLASH_TEXT", "The library already contains a dialog with the name:\n\n$(ARG1)\n\nRename dialog to keep current dialog or replace existing dialog.\n ") +#define RID_STR_DLGIMP_CLASH_TEXT NC_("RID_STR_DLGIMP_CLASH_TEXT", "The library already contains a dialog with the name:\n\n$(ARG1)\n\nChoose “Rename” to give the imported dialog a new automatic name, or “Replace” to overwrite the existing dialog completely.\n ") #define RID_STR_DLGIMP_MISMATCH_ADD NC_("RID_STR_DLGIMP_MISMATCH_ADD", "Add") #define RID_STR_DLGIMP_MISMATCH_OMIT NC_("RID_STR_DLGIMP_MISMATCH_OMIT", "Omit") #define RID_STR_DLGIMP_MISMATCH_TITLE NC_("RID_STR_DLGIMP_MISMATCH_TITLE", "Dialog Import - Language Mismatch") @@ -97,8 +97,6 @@ #define RID_STR_PRINTDLG_PAGES NC_("RID_STR_PRINTDLG_PAGES", "Pages:") #define RID_STR_PRINTDLG_PRINTALLPAGES NC_("RID_STR_PRINTDLG_PRINTALLPAGES", "All ~Pages") #define RID_STR_PRINTDLG_PRINTPAGES NC_("RID_STR_PRINTDLG_PRINTPAGES", "Pa~ges:") -#define RID_STR_PRINTDLG_PRINTEVENPAGES NC_("RID_STR_PRINTDLG_PRINTEVENPAGES", "~Even pages") -#define RID_STR_PRINTDLG_PRINTODDPAGES NC_("RID_STR_PRINTDLG_PRINTODDPAGES", "~Odd pages") #define RID_STR_CHOOSE NC_("RID_STR_CHOOSE", "Choose") #define RID_STR_RUN NC_("RID_STR_RUN", "Run") #define RID_STR_RECORD NC_("RID_STR_RECORD", "~Save") @@ -112,6 +110,19 @@ #define RID_STR_EXPORTPACKAGE NC_("RID_STR_EXPORTPACKAGE", "Export library as extension") #define RID_STR_EXPORTBASIC NC_("RID_STR_EXPORTBASIC", "Export as BASIC library") #define RID_STR_PACKAGE_BUNDLE NC_("RID_STR_PACKAGE_BUNDLE", "Extension") +#define RID_STR_READONLY NC_("RID_STR_READONLY", "Read-only") +#define RID_STR_MODULE_READONLY NC_("RID_STR_READONLY_WARNING", "This module is read-only and cannot be edited.") +#define RID_STR_DIALOG_READONLY NC_("RID_STR_READONLY_WARNING", "This dialog is read-only and cannot be edited.") +#define RID_LINE_STATUS_CONTROL NC_("RID_LINE_STATUS_CONTROL", "Current line and character. Click to open 'Go to Line' dialog.") + +// Color scheme names +#define RID_STR_COLORSCHEME_DEFAULT NC_("RID_STR_COLORSCHEME_DEFAULT", "Default") +#define RID_STR_COLORSCHEME_LIGHT NC_("RID_STR_COLORSCHEME_LIGHT", "%PRODUCTNAME Light") +#define RID_STR_COLORSCHEME_DARK NC_("RID_STR_COLORSCHEME_DARK", "%PRODUCTNAME Dark") +#define RID_STR_COLORSCHEME_BREEZE_LIGHT NC_("RID_STR_COLORSCHEME_BREEZE_LIGHT", "Breeze Light") +#define RID_STR_COLORSCHEME_BREEZE_DARK NC_("RID_STR_COLORSCHEME_BREEZE_DARK", "Breeze Dark") +#define RID_STR_COLORSCHEME_SOLARIZED_DARK NC_("RID_STR_COLORSCHEME_SOLARIZED_DARK", "Solarized Dark") +#define RID_STR_COLORSCHEME_SOLARIZED_LIGHT NC_("RID_STR_COLORSCHEME_SOLARIZED_LIGHT", "Solarized Light") #endif diff --git a/basctl/inc/strings.hxx b/basctl/inc/strings.hxx index fc04eae43dc1..5481d62de326 100644 --- a/basctl/inc/strings.hxx +++ b/basctl/inc/strings.hxx @@ -9,32 +9,34 @@ #pragma once +#include <rtl/ustring.hxx> + // Dialog Controls --------------------------------------------------------------- -#define RID_STR_CLASS_CONTROL "Control" -#define RID_STR_CLASS_DIALOG "Dialog" -#define RID_STR_CLASS_BUTTON "CommandButton" -#define RID_STR_CLASS_RADIOBUTTON "OptionButton" -#define RID_STR_CLASS_CHECKBOX "CheckBox" -#define RID_STR_CLASS_LISTBOX "ListBox" -#define RID_STR_CLASS_COMBOBOX "ComboBox" -#define RID_STR_CLASS_GROUPBOX "FrameControl" -#define RID_STR_CLASS_EDIT "TextField" -#define RID_STR_CLASS_FIXEDTEXT "Label" -#define RID_STR_CLASS_IMAGECONTROL "ImageControl" -#define RID_STR_CLASS_PROGRESSBAR "ProgressBar" -#define RID_STR_CLASS_SCROLLBAR "ScrollBar" -#define RID_STR_CLASS_FIXEDLINE "FixedLine" -#define RID_STR_CLASS_DATEFIELD "DateField" -#define RID_STR_CLASS_TIMEFIELD "TimeField" -#define RID_STR_CLASS_NUMERICFIELD "NumericField" -#define RID_STR_CLASS_CURRENCYFIELD "CurrencyField" -#define RID_STR_CLASS_FORMATTEDFIELD "FormattedField" -#define RID_STR_CLASS_PATTERNFIELD "PatternField" -#define RID_STR_CLASS_FILECONTROL "FileControl" -#define RID_STR_CLASS_TREECONTROL "TreeControl" -#define RID_STR_CLASS_GRIDCONTROL "GridControl" -#define RID_STR_CLASS_SPINCONTROL "SpinButton" -#define RID_STR_CLASS_HYPERLINKCONTROL "HyperlinkControl" +inline constexpr OUString RID_STR_CLASS_CONTROL = u"Control"_ustr; +inline constexpr OUString RID_STR_CLASS_DIALOG = u"Dialog"_ustr; +inline constexpr OUString RID_STR_CLASS_BUTTON = u"CommandButton"_ustr; +inline constexpr OUString RID_STR_CLASS_RADIOBUTTON = u"OptionButton"_ustr; +inline constexpr OUString RID_STR_CLASS_CHECKBOX = u"CheckBox"_ustr; +inline constexpr OUString RID_STR_CLASS_LISTBOX = u"ListBox"_ustr; +inline constexpr OUString RID_STR_CLASS_COMBOBOX = u"ComboBox"_ustr; +inline constexpr OUString RID_STR_CLASS_GROUPBOX = u"FrameControl"_ustr; +inline constexpr OUString RID_STR_CLASS_EDIT = u"TextField"_ustr; +inline constexpr OUString RID_STR_CLASS_FIXEDTEXT = u"Label"_ustr; +inline constexpr OUString RID_STR_CLASS_IMAGECONTROL = u"ImageControl"_ustr; +inline constexpr OUString RID_STR_CLASS_PROGRESSBAR = u"ProgressBar"_ustr; +inline constexpr OUString RID_STR_CLASS_SCROLLBAR = u"ScrollBar"_ustr; +inline constexpr OUString RID_STR_CLASS_FIXEDLINE = u"FixedLine"_ustr; +inline constexpr OUString RID_STR_CLASS_DATEFIELD = u"DateField"_ustr; +inline constexpr OUString RID_STR_CLASS_TIMEFIELD = u"TimeField"_ustr; +inline constexpr OUString RID_STR_CLASS_NUMERICFIELD = u"NumericField"_ustr; +inline constexpr OUString RID_STR_CLASS_CURRENCYFIELD = u"CurrencyField"_ustr; +inline constexpr OUString RID_STR_CLASS_FORMATTEDFIELD = u"FormattedField"_ustr; +inline constexpr OUString RID_STR_CLASS_PATTERNFIELD = u"PatternField"_ustr; +inline constexpr OUString RID_STR_CLASS_FILECONTROL = u"FileControl"_ustr; +inline constexpr OUString RID_STR_CLASS_TREECONTROL = u"TreeControl"_ustr; +inline constexpr OUString RID_STR_CLASS_GRIDCONTROL = u"GridControl"_ustr; +inline constexpr OUString RID_STR_CLASS_SPINCONTROL = u"SpinButton"_ustr; +inline constexpr OUString RID_STR_CLASS_HYPERLINKCONTROL = u"HyperlinkControl"_ustr; /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/basctl/sdi/baside.sdi b/basctl/sdi/baside.sdi index 192b6cdc06c4..34f34a6362e2 100644 --- a/basctl/sdi/baside.sdi +++ b/basctl/sdi/baside.sdi @@ -248,6 +248,18 @@ shell basctl_Shell StateMethod = GetState; ] + SID_BASICIDE_WATCH + [ + ExecMethod = ExecuteGlobal; + StateMethod = GetState; + ] + + SID_BASICIDE_STACK + [ + ExecMethod = ExecuteGlobal; + StateMethod = GetState; + ] + SID_BASICIDE_CREATEMACRO [ ExecMethod = ExecuteGlobal; @@ -331,6 +343,34 @@ shell basctl_Shell StateMethod = GetState; ] + SID_BASICIDE_COLOR_SCHEME_DLG + [ + ExecMethod = ExecuteGlobal; + StateMethod = GetState; + ] + + SID_ATTR_ZOOMSLIDER + [ + ExecMethod = ExecuteGlobal; + StateMethod = GetState; + ] + + SID_ZOOM_IN + [ + ExecMethod = ExecuteGlobal; + StateMethod = GetState; + ] + + SID_ZOOM_OUT + [ + ExecMethod = ExecuteGlobal; + StateMethod = GetState; + ] + + SID_BASICIDE_CURRENT_ZOOM + [ + StateMethod = GetState; + ] // Only, when BasicWindow up @@ -578,6 +618,7 @@ shell basctl_Shell SID_BASICIDE_STAT_POS [ + ExecMethod = ExecuteGlobal; StateMethod = GetState; ] @@ -647,6 +688,12 @@ shell basctl_Shell ExecMethod = ExecuteDialog; StateMethod = GetState; ] + + SID_TOGGLE_COMMENT + [ + StateMethod = GetState; + ExecMethod = ExecuteGlobal; + ] } interface BasicIDEDocument @@ -657,4 +704,3 @@ shell basctl_DocShell { import BasicIDEDocument; } - diff --git a/basctl/source/accessibility/accessibledialogcontrolshape.cxx b/basctl/source/accessibility/accessibledialogcontrolshape.cxx index b48eb53a0d1a..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> @@ -171,7 +172,7 @@ vcl::Window* AccessibleDialogControlShape::GetWindow() const { Reference< awt::XControl > xControl = m_pDlgEdObj->GetControl(); if ( xControl.is() ) - pWindow = VCLUnoHelper::GetWindow( xControl->getPeer() ).get(); + pWindow = VCLUnoHelper::GetWindow( xControl->getPeer() ); } return pWindow; @@ -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() ) @@ -393,29 +388,26 @@ Reference< XAccessibleRelationSet > AccessibleDialogControlShape::getAccessibleR { OExternalLockGuard aGuard( this ); - utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; - Reference< XAccessibleRelationSet > xSet = pRelationSetHelper; - return xSet; + return new utl::AccessibleRelationSetHelper; } -Reference< XAccessibleStateSet > AccessibleDialogControlShape::getAccessibleStateSet( ) +sal_Int64 AccessibleDialogControlShape::getAccessibleStateSet( ) { OExternalLockGuard aGuard( this ); - utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; - Reference< XAccessibleStateSet > xSet = pStateSetHelper; + sal_Int64 nStateSet = 0; if ( !rBHelper.bDisposed && !rBHelper.bInDispose ) { - FillAccessibleStateSet( *pStateSetHelper ); + FillAccessibleStateSet( nStateSet ); } else { - pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); + nStateSet |= AccessibleStateType::DEFUNC; } - return xSet; + return nStateSet; } @@ -506,7 +498,7 @@ Reference< awt::XFont > AccessibleDialogControlShape::getFont( ) aFont = pWindow->GetControlFont(); else aFont = pWindow->GetFont(); - VCLXFont* pVCLXFont = new VCLXFont; + rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont; pVCLXFont->Init( *xDev, aFont ); xFont = pVCLXFont; } diff --git a/basctl/source/accessibility/accessibledialogwindow.cxx b/basctl/source/accessibility/accessibledialogwindow.cxx index eeb43b4f0c8b..e9b4513294fb 100644 --- a/basctl/source/accessibility/accessibledialogwindow.cxx +++ b/basctl/source/accessibility/accessibledialogwindow.cxx @@ -26,13 +26,14 @@ #include <dlgedpage.hxx> #include <dlgedview.hxx> #include <dlgedobj.hxx> +#include <com/sun/star/awt/XVclWindowPeer.hpp> #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#include <comphelper/accessiblecontexthelper.hxx> #include <cppuhelper/supportsservice.hxx> #include <tools/debug.hxx> -#include <unotools/accessiblestatesethelper.hxx> #include <unotools/accessiblerelationsethelper.hxx> #include <toolkit/awt/vclxfont.hxx> #include <toolkit/helper/convert.hxx> @@ -84,11 +85,10 @@ AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow* pDialogWin return; SdrPage& rPage = m_pDialogWindow->GetPage(); - const size_t nCount = rPage.GetObjCount(); - for ( size_t i = 0; i < nCount; ++i ) + for (const rtl::Reference<SdrObject>& pObj : rPage) { - if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i))) + if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get())) { ChildDescriptor aDesc( pDlgEdObj ); if ( IsChildVisible( aDesc ) ) @@ -119,13 +119,8 @@ void AccessibleDialogWindow::UpdateFocused() { for (const ChildDescriptor & i : m_aAccessibleChildren) { - Reference< XAccessible > xChild( i.rxAccessible ); - if ( xChild.is() ) - { - AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() ); - if ( pShape ) - pShape->SetFocused( pShape->IsFocused() ); - } + if ( i.mxAccessible ) + i.mxAccessible->SetFocused( i.mxAccessible->IsFocused() ); } } @@ -136,13 +131,8 @@ void AccessibleDialogWindow::UpdateSelected() for (const ChildDescriptor & i : m_aAccessibleChildren) { - Reference< XAccessible > xChild( i.rxAccessible ); - if ( xChild.is() ) - { - AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() ); - if ( pShape ) - pShape->SetSelected( pShape->IsSelected() ); - } + if ( i.mxAccessible ) + i.mxAccessible->SetSelected( i.mxAccessible->IsSelected() ); } } @@ -151,13 +141,8 @@ void AccessibleDialogWindow::UpdateBounds() { for (const ChildDescriptor & i : m_aAccessibleChildren) { - Reference< XAccessible > xChild( i.rxAccessible ); - if ( xChild.is() ) - { - AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() ); - if ( pShape ) - pShape->SetBounds( pShape->GetBounds() ); - } + if ( i.mxAccessible ) + i.mxAccessible->SetBounds( i.mxAccessible->GetBounds() ); } } @@ -194,7 +179,7 @@ bool AccessibleDialogWindow::IsChildVisible( const ChildDescriptor& rDesc ) // check, if the shape's bounding box intersects with the bounding box of its parent tools::Rectangle aParentRect( Point( 0, 0 ), m_pDialogWindow->GetSizePixel() ); - if ( aParentRect.IsOver( aRect ) ) + if ( aParentRect.Overlaps( aRect ) ) bVisible = true; } } @@ -243,7 +228,7 @@ void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc ) return; // get the accessible of the removed child - Reference< XAccessible > xChild( aIter->rxAccessible ); + rtl::Reference< AccessibleDialogControlShape > xChild( aIter->mxAccessible ); // remove entry from child list m_aAccessibleChildren.erase( aIter ); @@ -252,12 +237,11 @@ void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc ) if ( xChild.is() ) { Any aOldValue, aNewValue; - aOldValue <<= xChild; + aOldValue <<= uno::Reference<XAccessible>(xChild); NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); - Reference< XComponent > xComponent( xChild, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); + if ( xChild ) + xChild->dispose(); } } @@ -282,8 +266,8 @@ void AccessibleDialogWindow::UpdateChildren() if ( m_pDialogWindow ) { SdrPage& rPage = m_pDialogWindow->GetPage(); - for ( size_t i = 0, nCount = rPage.GetObjCount(); i < nCount; ++i ) - if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i))) + for (const rtl::Reference<SdrObject>& pObj : rPage) + if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get())) UpdateChild( ChildDescriptor( pDlgEdObj ) ); } } @@ -379,9 +363,8 @@ void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindo // dispose all children for (const ChildDescriptor & i : m_aAccessibleChildren) { - Reference< XComponent > xComponent( i.rxAccessible, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); + if ( i.mxAccessible ) + i.mxAccessible->dispose(); } m_aAccessibleChildren.clear(); } @@ -395,27 +378,27 @@ void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindo } -void AccessibleDialogWindow::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) +void AccessibleDialogWindow::FillAccessibleStateSet( sal_Int64& rStateSet ) { if ( !m_pDialogWindow ) return; if ( m_pDialogWindow->IsEnabled() ) - rStateSet.AddState( AccessibleStateType::ENABLED ); + rStateSet |= AccessibleStateType::ENABLED; - rStateSet.AddState( AccessibleStateType::FOCUSABLE ); + rStateSet |= AccessibleStateType::FOCUSABLE; if ( m_pDialogWindow->HasFocus() ) - rStateSet.AddState( AccessibleStateType::FOCUSED ); + rStateSet |= AccessibleStateType::FOCUSED; - rStateSet.AddState( AccessibleStateType::VISIBLE ); + rStateSet |= AccessibleStateType::VISIBLE; if ( m_pDialogWindow->IsVisible() ) - rStateSet.AddState( AccessibleStateType::SHOWING ); + rStateSet |= AccessibleStateType::SHOWING; - rStateSet.AddState( AccessibleStateType::OPAQUE ); + rStateSet |= AccessibleStateType::OPAQUE; - rStateSet.AddState( AccessibleStateType::RESIZABLE ); + rStateSet |= AccessibleStateType::RESIZABLE; } @@ -493,18 +476,6 @@ void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint ) } -// XInterface - - -IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogWindow, OAccessibleExtendedComponentHelper, AccessibleDialogWindow_BASE ) - - -// XTypeProvider - - -IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogWindow, OAccessibleExtendedComponentHelper, AccessibleDialogWindow_BASE ) - - // XComponent @@ -525,9 +496,8 @@ void AccessibleDialogWindow::disposing() // dispose all children for (const ChildDescriptor & i : m_aAccessibleChildren) { - Reference< XComponent > xComponent( i.rxAccessible, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); + if ( i.mxAccessible ) + i.mxAccessible->dispose(); } m_aAccessibleChildren.clear(); } @@ -535,7 +505,7 @@ void AccessibleDialogWindow::disposing() // XServiceInfo OUString AccessibleDialogWindow::getImplementationName() { - return "com.sun.star.comp.basctl.AccessibleWindow"; + return u"com.sun.star.comp.basctl.AccessibleWindow"_ustr; } sal_Bool AccessibleDialogWindow::supportsService( const OUString& rServiceName ) @@ -545,7 +515,7 @@ sal_Bool AccessibleDialogWindow::supportsService( const OUString& rServiceName ) Sequence< OUString > AccessibleDialogWindow::getSupportedServiceNames() { - return { "com.sun.star.awt.AccessibleWindow" }; + return { u"com.sun.star.awt.AccessibleWindow"_ustr }; } // XAccessible @@ -555,7 +525,7 @@ Reference< XAccessibleContext > AccessibleDialogWindow::getAccessibleContext( ) } // XAccessibleContext -sal_Int32 AccessibleDialogWindow::getAccessibleChildCount() +sal_Int64 AccessibleDialogWindow::getAccessibleChildCount() { OExternalLockGuard aGuard( this ); @@ -563,14 +533,14 @@ sal_Int32 AccessibleDialogWindow::getAccessibleChildCount() } -Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int32 i ) +Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int64 i ) { OExternalLockGuard aGuard( this ); if ( i < 0 || i >= getAccessibleChildCount() ) throw IndexOutOfBoundsException(); - Reference< XAccessible > xChild = m_aAccessibleChildren[i].rxAccessible; + rtl::Reference< AccessibleDialogControlShape > xChild = m_aAccessibleChildren[i].mxAccessible; if ( !xChild.is() ) { if ( m_pDialogWindow ) @@ -581,7 +551,7 @@ Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int32 i xChild = new AccessibleDialogControlShape( m_pDialogWindow, pDlgEdObj ); // insert into child list - m_aAccessibleChildren[i].rxAccessible = xChild; + m_aAccessibleChildren[i].mxAccessible = xChild; } } } @@ -606,11 +576,11 @@ Reference< XAccessible > AccessibleDialogWindow::getAccessibleParent( ) } -sal_Int32 AccessibleDialogWindow::getAccessibleIndexInParent( ) +sal_Int64 AccessibleDialogWindow::getAccessibleIndexInParent( ) { OExternalLockGuard aGuard( this ); - sal_Int32 nIndexInParent = -1; + sal_Int64 nIndexInParent = -1; if ( m_pDialogWindow ) { vcl::Window* pParent = m_pDialogWindow->GetAccessibleParentWindow(); @@ -668,29 +638,26 @@ Reference< XAccessibleRelationSet > AccessibleDialogWindow::getAccessibleRelatio { OExternalLockGuard aGuard( this ); - utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; - Reference< XAccessibleRelationSet > xSet = pRelationSetHelper; - return xSet; + return new utl::AccessibleRelationSetHelper; } -Reference< XAccessibleStateSet > AccessibleDialogWindow::getAccessibleStateSet( ) +sal_Int64 AccessibleDialogWindow::getAccessibleStateSet( ) { OExternalLockGuard aGuard( this ); - utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; - Reference< XAccessibleStateSet > xSet = pStateSetHelper; + sal_Int64 nStateSet = 0; if ( !rBHelper.bDisposed && !rBHelper.bInDispose ) { - FillAccessibleStateSet( *pStateSetHelper ); + FillAccessibleStateSet( nStateSet ); } else { - pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); + nStateSet |= AccessibleStateType::DEFUNC; } - return xSet; + return nStateSet; } @@ -720,7 +687,7 @@ Reference< XAccessible > AccessibleDialogWindow::getAccessibleAtPoint( const awt { tools::Rectangle aRect = VCLRectangle( xComp->getBounds() ); Point aPos = VCLPoint( rPoint ); - if ( aRect.IsInside( aPos ) ) + if ( aRect.Contains( aPos ) ) { xChild = xAcc; break; @@ -801,7 +768,7 @@ Reference< awt::XFont > AccessibleDialogWindow::getFont( ) aFont = m_pDialogWindow->GetControlFont(); else aFont = m_pDialogWindow->GetFont(); - VCLXFont* pVCLXFont = new VCLXFont; + rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont; pVCLXFont->Init( *xDev, aFont ); xFont = pVCLXFont; } @@ -834,7 +801,7 @@ OUString AccessibleDialogWindow::getToolTipText( ) // XAccessibleSelection -void AccessibleDialogWindow::selectAccessibleChild( sal_Int32 nChildIndex ) +void AccessibleDialogWindow::selectAccessibleChild( sal_Int64 nChildIndex ) { OExternalLockGuard aGuard( this ); @@ -853,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 ); @@ -885,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; @@ -901,7 +868,7 @@ sal_Int32 AccessibleDialogWindow::getSelectedAccessibleChildCount( ) } -Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) +Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) { OExternalLockGuard aGuard( this ); @@ -910,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 ) ) { @@ -923,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 5063eb4f45a9..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 { @@ -59,12 +60,13 @@ using namespace ::com::sun::star::uno; */ SFX_IMPL_TOOLBOX_CONTROL(LibBoxControl, SfxStringItem); -LibBoxControl::LibBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx) +LibBoxControl::LibBoxControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx) : SfxToolBoxControl(nSlotId, nId, rTbx) { } -void LibBoxControl::StateChanged(sal_uInt16, SfxItemState eState, const SfxPoolItem* pState) +void LibBoxControl::StateChangedAtToolBoxControl(sal_uInt16, SfxItemState eState, + const SfxPoolItem* pState) { LibBox* pBox = static_cast<LibBox*>(GetToolBox().GetItemWindow(GetId())); @@ -193,14 +195,20 @@ void LibBox::ReleaseFocus() SfxViewShell* pCurSh = SfxViewShell::Current(); DBG_ASSERT(pCurSh, "Current ViewShell not found!"); - if (pCurSh) - { - vcl::Window* pShellWin = pCurSh->GetWindow(); - if (!pShellWin) - pShellWin = Application::GetDefDialogParent(); + if (!pCurSh) + return; + vcl::Window* pShellWin = pCurSh->GetWindow(); + if (pShellWin) + { pShellWin->GrabFocus(); + return; } + + weld::Window* pWin = Application::GetDefDialogParent(); + if (!pWin) + return; + pWin->grab_focus(); } void LibBox::FillBox() @@ -215,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); @@ -254,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); } } } @@ -313,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()); @@ -333,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(); @@ -359,12 +367,13 @@ void LibBox::ClearBox() */ SFX_IMPL_TOOLBOX_CONTROL(LanguageBoxControl, SfxStringItem); -LanguageBoxControl::LanguageBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx) +LanguageBoxControl::LanguageBoxControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx) : SfxToolBoxControl(nSlotId, nId, rTbx) { } -void LanguageBoxControl::StateChanged(sal_uInt16, SfxItemState eState, const SfxPoolItem* pItem) +void LanguageBoxControl::StateChangedAtToolBoxControl(sal_uInt16, SfxItemState eState, + const SfxPoolItem* pItem) { if (LanguageBox* pBox = static_cast<LanguageBox*>(GetToolBox().GetItemWindow(GetId()))) { @@ -432,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) @@ -459,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(); @@ -467,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 5ad7913ae139..13069ed46621 100644 --- a/basctl/source/basicide/ObjectCatalog.cxx +++ b/basctl/source/basicide/ObjectCatalog.cxx @@ -54,8 +54,7 @@ ObjectCatalog::~ObjectCatalog() { disposeOnce(); } void ObjectCatalog::dispose() { - if (!IsDisposed()) - GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow(this); + GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow(this); m_xTitle.reset(); m_xTree.reset(); DockingWindow::dispose(); @@ -68,7 +67,9 @@ void ObjectCatalog::ToggleFloatingMode() DockingWindow::ToggleFloatingMode(); bool const bFloating = IsFloatingMode(); - m_xTitle->set_visible(!bFloating); + // tdf#152154: m_xTitle will be null during disposing + if (m_xTitle) + m_xTitle->set_visible(!bFloating); } void ObjectCatalog::SetCurrentEntry(BaseWindow* pCurWin) diff --git a/basctl/source/basicide/basdoc.cxx b/basctl/source/basicide/basdoc.cxx index 58c4097284e4..ffd22b9063c7 100644 --- a/basctl/source/basicide/basdoc.cxx +++ b/basctl/source/basicide/basdoc.cxx @@ -62,9 +62,9 @@ DocShell::~DocShell() SfxPrinter* DocShell::GetPrinter( bool bCreate ) { if ( !pPrinter && bCreate ) - pPrinter.disposeAndReset(VclPtr<SfxPrinter>::Create(std::make_unique<SfxItemSet>( - GetPool(), svl::Items<SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN>{} - ))); + pPrinter.disposeAndReset(VclPtr<SfxPrinter>::Create(std::make_unique<SfxItemSetFixed + <SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN>>(GetPool()) + )); return pPrinter.get(); } @@ -82,7 +82,7 @@ void DocShell::FillClass( SvGlobalName*, SotClipboardFormatId*, OUString*, sal_I DBG_ASSERT( !bTemplate, "No template for Basic" ); } -void DocShell::Draw( OutputDevice *, const JobSetup &, sal_uInt16 ) +void DocShell::Draw( OutputDevice *, const JobSetup &, sal_uInt16, bool ) {} } // namespace basctl diff --git a/basctl/source/basicide/basdoc.hxx b/basctl/source/basicide/basdoc.hxx index d5b3aabcf961..bb847a0a9b1a 100644 --- a/basctl/source/basicide/basdoc.hxx +++ b/basctl/source/basicide/basdoc.hxx @@ -34,7 +34,7 @@ class DocShell: public SfxObjectShell protected: virtual void Draw( OutputDevice *, const JobSetup & rSetup, - sal_uInt16 nAspect ) override; + sal_uInt16 nAspect, bool bOutputForScreen ) override; virtual void FillClass( SvGlobalName * pClassName, SotClipboardFormatId * pFormat, OUString * pFullTypeName, diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx index 12bb90610877..648f234cbdb0 100644 --- a/basctl/source/basicide/basicrenderable.cxx +++ b/basctl/source/basicide/basicrenderable.cxx @@ -88,7 +88,7 @@ VclPtr< Printer > Renderable::getPrinter() const if( aValue >>= xRenderDevice ) { - VCLXDevice* pDevice = comphelper::getUnoTunnelImplementation<VCLXDevice>(xRenderDevice); + VCLXDevice* pDevice = dynamic_cast<VCLXDevice*>(xRenderDevice.get()); VclPtr< OutputDevice > pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >(); pPrinter = dynamic_cast<Printer*>(pOut.get()); } diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index bf1c17dc03c1..62bbaa799815 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -25,7 +25,9 @@ #include <iderdll.hxx> #include <iderid.hxx> #include "moduldlg.hxx" +#include <sfx2/dispatch.hxx> #include <docsignature.hxx> +#include <colorscheme.hxx> #include <officecfg/Office/BasicIDE.hxx> #include <helpids.h> @@ -38,13 +40,14 @@ #include <com/sun/star/script/ModuleType.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> -#include <com/sun/star/ui/dialogs/FilePicker.hpp> +#include <com/sun/star/ui/dialogs/XFilePicker3.hpp> #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> #include <comphelper/SetFlagContextHelper.hxx> #include <comphelper/string.hxx> #include <svl/srchdefs.hxx> #include <sfx2/bindings.hxx> #include <sfx2/docfile.hxx> +#include <sfx2/filedlghelper.hxx> #include <sfx2/request.hxx> #include <sfx2/viewfrm.hxx> #include <sot/exchange.hxx> @@ -55,7 +58,8 @@ #include <svl/whiter.hxx> #include <svx/svxids.hrc> #include <tools/debug.hxx> -#include <vcl/waitobj.hxx> +#include <utility> +#include <vcl/locktoplevels.hxx> #include <vcl/errinf.hxx> #include <vcl/event.hxx> #include <vcl/print.hxx> @@ -67,6 +71,7 @@ #include <cassert> #include <osl/diagnose.h> #include <officecfg/Office/Common.hxx> +#include <BasicColorConfig.hxx> namespace basctl { @@ -93,7 +98,7 @@ short const ValidWindow = 0x1234; #if defined(OW) || defined(MTF) char const FilterMask_All[] = "*"; #else -constexpr OUStringLiteral FilterMask_All = u"*.*"; +constexpr OUString FilterMask_All = u"*.*"_ustr; #endif } // end anonymous namespace @@ -181,7 +186,7 @@ void lcl_ConvertTabsToSpaces( OUString& rLine ) OUStringBuffer aBlanker; string::padToLength(aBlanker, ( 4 - ( nPos % 4 ) ), ' '); aResult.remove( nPos, 1 ); - aResult.insert( nPos, aBlanker.makeStringAndClear() ); + aResult.insert( nPos, aBlanker ); nMax = aResult.getLength(); } ++nPos; @@ -192,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(); } @@ -253,9 +261,6 @@ void ModulWindow::GetFocus() void ModulWindow::DoInit() { - if (GetVScrollBar()) - GetVScrollBar()->Hide(); - GetHScrollBar()->Show(); GetEditorWindow().InitScrollBars(); } @@ -283,7 +288,7 @@ void ModulWindow::CheckCompileBasic() bool bDone = false; - GetShell()->GetViewFrame()->GetWindow().EnterWait(); + GetShell()->GetViewFrame().GetWindow().EnterWait(); AssertValidEditEngine(); GetEditorWindow().SetSourceInBasic(); @@ -303,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; @@ -341,9 +346,9 @@ void ModulWindow::BasicExecute() const sal_uInt32 nCurMethodStart = aSel.GetStart().GetPara() + 1; SbMethod* pMethod = nullptr; // first Macro, else blind "Main" (ExtSearch?) - for ( sal_uInt32 nMacro = 0; nMacro < m_xModule->GetMethods()->Count32(); nMacro++ ) + for (sal_uInt32 nMacro = 0; nMacro < m_xModule->GetMethods()->Count(); nMacro++) { - SbMethod* pM = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMacro )); + SbMethod* pM = static_cast<SbMethod*>(m_xModule->GetMethods()->Get(nMacro)); assert(pM && "Method?"); pM->GetLineRange( nStart, nEnd ); if ( nCurMethodStart >= nStart && nCurMethodStart <= nEnd ) @@ -412,22 +417,20 @@ void ModulWindow::BasicStop() void ModulWindow::LoadBasic() { - Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); - Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_SIMPLE); - - if ( !m_sCurPath.isEmpty() ) - xFP->setDisplayDirectory ( m_sCurPath ); + sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, + FileDialogFlags::NONE, this->GetFrameWeld()); + aDlg.SetContext(sfx2::FileDialogHelper::BasicImportSource); + Reference<XFilePicker3> xFP = aDlg.GetFilePicker(); xFP->appendFilter( "BASIC" , "*.bas" ); xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All ); xFP->setCurrentFilter( "BASIC" ); - if( xFP->execute() != RET_OK ) + if( aDlg.Execute() != ERRCODE_NONE ) return; Sequence< OUString > aPaths = xFP->getSelectedFiles(); - m_sCurPath = aPaths[0]; - SfxMedium aMedium( m_sCurPath, StreamMode::READ | StreamMode::SHARE_DENYWRITE | StreamMode::NOCREATE ); + SfxMedium aMedium( aPaths[0], StreamMode::READ | StreamMode::SHARE_DENYWRITE | StreamMode::NOCREATE ); SvStream* pStream = aMedium.GetInStream(); if ( pStream ) { @@ -436,12 +439,16 @@ void ModulWindow::LoadBasic() // nLines*4: ReadText/Formatting/Highlighting/Formatting GetEditorWindow().CreateProgress( IDEResId(RID_STR_GENERATESOURCE), nLines*4 ); GetEditEngine()->SetUpdateMode( false ); + // tdf#139196 - import macros using either default or utf-8 text encoding + pStream->StartReadingUnicodeText(RTL_TEXTENCODING_UTF8); + if (pStream->Tell() == 3) + pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8); GetEditView()->Read( *pStream ); GetEditEngine()->SetUpdateMode( true ); GetEditorWindow().PaintImmediately(); GetEditorWindow().ForceSyntaxTimeout(); GetEditorWindow().DestroyProgress(); - ErrCode nError = aMedium.GetError(); + ErrCodeMsg nError = aMedium.GetErrorIgnoreWarning(); if ( nError ) ErrorHandler::HandleError( nError ); } @@ -456,37 +463,34 @@ void ModulWindow::LoadBasic() void ModulWindow::SaveBasicSource() { - Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); - Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, 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); - - if ( !m_sCurPath.isEmpty() ) - xFP->setDisplayDirectory ( m_sCurPath ); + xFP.queryThrow<XFilePickerControlAccess>()->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, Any(true)); xFP->appendFilter( "BASIC", "*.bas" ); xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All ); xFP->setCurrentFilter( "BASIC" ); - if( xFP->execute() != RET_OK ) + if( aDlg.Execute() != ERRCODE_NONE ) return; Sequence< OUString > aPaths = xFP->getSelectedFiles(); - m_sCurPath = aPaths[0]; - SfxMedium aMedium( m_sCurPath, StreamMode::WRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC ); + SfxMedium aMedium( aPaths[0], StreamMode::WRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC ); SvStream* pStream = aMedium.GetOutStream(); if ( pStream ) { EnterWait(); AssertValidEditEngine(); + // tdf#139196 - export macros using utf-8 including BOM + pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8); + pStream->WriteUChar(0xEF).WriteUChar(0xBB).WriteUChar(0xBF); GetEditEngine()->Write( *pStream ); aMedium.Commit(); LeaveWait(); - ErrCode nError = aMedium.GetError(); + ErrCodeMsg nError = aMedium.GetErrorIgnoreWarning(); if ( nError ) ErrorHandler::HandleError( nError ); } @@ -502,7 +506,7 @@ void ModulWindow::ImportDialog() { const ScriptDocument& rDocument = GetDocument(); OUString aLibName = GetLibName(); - implImportDialog(GetFrameWeld(), m_sCurPath, rDocument, aLibName); + implImportDialog(GetFrameWeld(), rDocument, aLibName); } void ModulWindow::ToggleBreakPoint( sal_uInt16 nLine ) @@ -531,9 +535,10 @@ void ModulWindow::ToggleBreakPoint( sal_uInt16 nLine ) GetBreakPoints().InsertSorted( BreakPoint( nLine ) ); if ( StarBASIC::IsRunning() ) { - for ( sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count32(); nMethod++ ) + for (sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count(); nMethod++) { - SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMethod )); + SbMethod* pMethod + = static_cast<SbMethod*>(m_xModule->GetMethods()->Get(nMethod)); assert(pMethod && "Method not found! (NULL)"); pMethod->SetDebugFlags( pMethod->GetDebugFlags() | BasicDebugFlags::Break ); } @@ -609,7 +614,7 @@ void ModulWindow::ManageBreakPoints() void ModulWindow::BasicErrorHdl( StarBASIC const * pBasic ) { - GetShell()->GetViewFrame()->ToTop(); + GetShell()->GetViewFrame().ToTop(); // Return value: BOOL // FALSE: cancel @@ -679,7 +684,7 @@ BasicDebugFlags ModulWindow::BasicBreakHdl() InvalidateDebuggerSlots(); - while( m_aStatus.bIsRunning ) + while( m_aStatus.bIsRunning && !Application::IsQuit()) Application::Yield(); m_aStatus.bIsInReschedule = false; @@ -1023,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); } } @@ -1052,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; } } @@ -1127,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 ); } @@ -1158,7 +1181,7 @@ void ModulWindow::GetState( SfxItemSet &rSet ) } } -void ModulWindow::DoScroll( ScrollBar* pCurScrollBar ) +void ModulWindow::DoScroll( Scrollable* pCurScrollBar ) { if ( ( pCurScrollBar == GetHScrollBar() ) && GetEditView() ) { @@ -1300,9 +1323,9 @@ void ModulWindow::BasicStarted() { rList.ResetHitCount(); rList.SetBreakPointsInBasic( m_xModule.get() ); - for ( sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count32(); nMethod++ ) + for (sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count(); nMethod++) { - SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMethod )); + SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->GetMethods()->Get(nMethod)); assert(pMethod && "Method not found! (NULL)"); pMethod->SetDebugFlags( pMethod->GetDebugFlags() | BasicDebugFlags::Break ); } @@ -1375,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; @@ -1399,7 +1417,7 @@ void ModulWindow::OnNewDocument () m_aXEditorWindow->SetLineNumberDisplay(bLineNumbers); } -char const* ModulWindow::GetHid () const +OUString ModulWindow::GetHid () const { return HID_BASICIDE_MODULWINDOW; } @@ -1431,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() { @@ -1474,6 +1522,7 @@ void ModulWindowLayout::Activating (BaseWindow& rChild) rObjectCatalog.UpdateEntries(); Layout::Activating(rChild); aSyntaxColors.SetActiveEditor(&pChild->GetEditorWindow()); + aSyntaxColors.SetActiveColorSchemeId(m_sColorSchemeId); } void ModulWindowLayout::Deactivating () @@ -1510,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)); @@ -1517,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 () @@ -1533,62 +1601,88 @@ ModulWindowLayout::SyntaxColors::~SyntaxColors () // virtual void ModulWindowLayout::SyntaxColors::ConfigurationChanged (utl::ConfigurationBroadcaster*, ConfigurationHints) { - NewConfig(false); + // The color scheme only needs to be applied when configuration changed if the "default" color + // scheme (based on Application Colors) is being used + if (m_sActiveSchemeId == DEFAULT_SCHEME) + ApplyColorScheme(DEFAULT_SCHEME, false); } -// when a new configuration has to be set -void ModulWindowLayout::SyntaxColors::NewConfig (bool bFirst) +// Applies an entire new color scheme; when bFirst is true, then the checks to see if the color scheme +// has changed are ignored to make sure the color scheme is applied +void ModulWindowLayout::SyntaxColors::ApplyColorScheme(OUString aSchemeId, bool bFirst) { - static struct - { - TokenType eTokenType; - svtools::ColorConfigEntry eEntry; - } - const vIds[] = + const TokenType vTokenTypes[] = { - { TokenType::Unknown, svtools::FONTCOLOR }, - { TokenType::Identifier, svtools::BASICIDENTIFIER }, - { TokenType::Whitespace, svtools::FONTCOLOR }, - { TokenType::Number, svtools::BASICNUMBER }, - { TokenType::String, svtools::BASICSTRING }, - { TokenType::EOL, svtools::FONTCOLOR }, - { TokenType::Comment, svtools::BASICCOMMENT }, - { TokenType::Error, svtools::BASICERROR }, - { TokenType::Operator, svtools::BASICOPERATOR }, - { TokenType::Keywords, svtools::BASICKEYWORD }, + TokenType::Unknown, + TokenType::Identifier, + TokenType::Whitespace, + TokenType::Number, + TokenType::String, + TokenType::EOL, + TokenType::Comment, + TokenType::Error, + TokenType::Operator, + TokenType::Keywords }; - Color aDocColor = aConfig.GetColorValue(svtools::DOCCOLOR).nColor; - if (bFirst || aDocColor != m_aBackgroundColor) - { - m_aBackgroundColor = aDocColor; - if (!bFirst && pEditor) - { - pEditor->SetBackground(Wallpaper(m_aBackgroundColor)); - pEditor->Invalidate(); - } - } - - Color aFontColor = aConfig.GetColorValue(svtools::FONTCOLOR).nColor; - if (bFirst || aFontColor != m_aFontColor) + m_sActiveSchemeId = aSchemeId; + ColorScheme aColorScheme = GetShell()->GetColorConfig()->GetColorScheme(aSchemeId); + Color aFontColor = aColorScheme.m_aGenericFontColor; + m_aFontColor = aFontColor; + Color aDocColor = aColorScheme.m_aBackgroundColor; + m_aBackgroundColor = aDocColor; + if (!bFirst && pEditor) { - m_aFontColor = aFontColor; - if (!bFirst && pEditor) - pEditor->ChangeFontColor(m_aFontColor); + pEditor->ChangeFontColor(aFontColor); + pEditor->SetBackground(Wallpaper(aDocColor)); + pEditor->SetLineHighlightColor(aColorScheme.m_aLineHighlightColor); + pEditor->Invalidate(); } - bool bChanged = false; - for (unsigned i = 0; i != SAL_N_ELEMENTS(vIds); ++i) + for (const auto& aToken: vTokenTypes) { - Color const aColor = aConfig.GetColorValue(vIds[i].eEntry).nColor; - Color& rMyColor = aColors[vIds[i].eTokenType]; - if (bFirst || aColor != rMyColor) + // Retrieves the new color to be set from the color scheme + Color aNewColor; + switch (aToken) { - rMyColor = aColor; - bChanged = true; + case TokenType::EOL: + case TokenType::Whitespace: + case TokenType::Unknown: + aNewColor = aColorScheme.m_aGenericFontColor; + break; + case TokenType::Identifier: + aNewColor = aColorScheme.m_aIdentifierColor; + break; + case TokenType::Number: + aNewColor = aColorScheme.m_aNumberColor; + break; + case TokenType::String: + aNewColor = aColorScheme.m_aStringColor; + break; + case TokenType::Comment: + aNewColor = aColorScheme.m_aCommentColor; + break; + case TokenType::Error: + aNewColor = aColorScheme.m_aErrorColor; + break; + case TokenType::Operator: + aNewColor = aColorScheme.m_aOperatorColor; + break; + case TokenType::Keywords: + aNewColor = aColorScheme.m_aKeywordColor; + break; + default: + SAL_WARN("basctl.basicide", "Unexpected token type for color scheme"); + aNewColor = aColorScheme.m_aGenericFontColor; } + + Color& rCurrentColor = aColors[aToken]; + rCurrentColor = aNewColor; } - if (bChanged && !bFirst && pEditor) + + // This check is needed because the EditEngine will only exist in the EditorWindow when the + // module is actually opened + if (!bFirst && pEditor) pEditor->UpdateSyntaxHighlighting(); } diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 06045356bccb..cd0485c46b4b 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -20,9 +20,11 @@ #pragma once #include <memory> +#include <mutex> #include <layout.hxx> #include "breakpoint.hxx" #include "linenumberwindow.hxx" +#include <colorscheme.hxx> #include <basic/sbmod.hxx> #include <basic/sbstar.hxx> @@ -31,10 +33,12 @@ #include <vcl/weld.hxx> #include <svtools/colorcfg.hxx> +#include <svtools/scrolladaptor.hxx> #include <o3tl/enumarray.hxx> #include <rtl/ustrbuf.hxx> #include <set> +#include <map> #include <string_view> #include <vcl/textdata.hxx> @@ -73,7 +77,7 @@ private: ModulWindow& rModulWindow; rtl::Reference< ChangesListener > listener_; - osl::Mutex mutex_; + std::mutex mutex_; css::uno::Reference< css::beans::XMultiPropertySet > notifier_; @@ -93,17 +97,23 @@ private: virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; - void ImpDoHighlight( sal_uLong nLineOff ); + void ImpDoHighlight( sal_uInt32 nLineOff ); void ImplSetFont(); + sal_uInt16 nCurrentZoomLevel; bool bHighlighting; bool bDoSyntaxHighlight; bool bDelayHighlight; - virtual css::uno::Reference< css::awt::XWindowPeer > GetComponentInterface(bool bCreate = true) override; + // Used to determine if the highlighted line has changed, which would require redrawing the highlight + sal_uInt32 m_nLastHighlightPara; + + Color m_aLineHighlightColor; + + virtual css::uno::Reference< css::awt::XVclWindowPeer > GetComponentInterface(bool bCreate = true) override; CodeCompleteDataCache aCodeCompleteCache; VclPtr<CodeCompleteWindow> pCodeCompleteWnd; - OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number + OUString GetActualSubName( sal_uInt32 nLine ); // gets the actual subroutine name according to line number void SetupAndShowCodeCompleteWnd(const std::vector< OUString >& aEntryVect, TextSelection aSel ); void HandleAutoCorrect(); void HandleAutoCloseParen(); @@ -122,9 +132,10 @@ private: virtual void LoseFocus() override; virtual void RequestHelp( const HelpEvent& rHEvt ) override; - void DoSyntaxHighlight( sal_uLong nPara ); + void DoSyntaxHighlight( sal_uInt32 nPara ); OUString GetWordAtCursor(); bool ImpCanModify(); + void HighlightCurrentLine(vcl::RenderContext& rRenderContext); public: EditorWindow (vcl::Window* pParent, ModulWindow*); @@ -137,8 +148,8 @@ public: void CreateProgress( const OUString& rText, sal_uInt32 nRange ); void DestroyProgress(); - void ParagraphInsertedDeleted( sal_uLong nNewPara, bool bInserted ); - void DoDelayedSyntaxHighlight( sal_uLong nPara ); + void ParagraphInsertedDeleted( sal_uInt32 nNewPara, bool bInserted ); + void DoDelayedSyntaxHighlight( sal_uInt32 nPara ); void CreateEditEngine(); void SetScrollBarRanges(); @@ -151,8 +162,12 @@ public: void ChangeFontColor( Color aColor ); void UpdateSyntaxHighlighting (); + void SetLineHighlightColor(Color aColor); - bool GetProcedureName(OUString const & rLine, OUString& rProcType, OUString& rProcName) const; + void SetEditorZoomLevel(sal_uInt16 nNewZoomLevel); + sal_uInt16 GetCurrentZoom() { return nCurrentZoomLevel; } + + bool GetProcedureName(std::u16string_view rLine, OUString& rProcType, OUString& rProcName) const; FactoryFunction GetUITestFactory() const override; }; @@ -252,12 +267,13 @@ private: VclPtr<BreakPointWindow> aBrkWindow; VclPtr<LineNumberWindow> aLineNumberWindow; VclPtr<EditorWindow> aEdtWindow; - VclPtr<ScrollBar> aEWVScrollBar; + VclPtr<ScrollAdaptor> aEWVScrollBar; + VclPtr<ScrollAdaptor> aEWHScrollBar; virtual void DataChanged(DataChangedEvent const & rDCEvt) override; virtual void Resize() override; - DECL_LINK( ScrollHdl, ScrollBar*, void ); + DECL_LINK(ScrollHdl, weld::Scrollbar&, void); public: explicit ComplexEditorWindow( ModulWindow* pParent ); @@ -266,7 +282,8 @@ public: BreakPointWindow& GetBrkWindow() { return *aBrkWindow; } LineNumberWindow& GetLineNumberWindow() { return *aLineNumberWindow; } EditorWindow& GetEdtWindow() { return *aEdtWindow; } - ScrollBar& GetEWVScrollBar() { return *aEWVScrollBar; } + ScrollAdaptor& GetEWVScrollBar() { return *aEWVScrollBar; } + ScrollAdaptor& GetEWHScrollBar() { return *aEWHScrollBar; } void SetLineNumberDisplay(bool b); }; @@ -281,8 +298,8 @@ private: VclPtr<ComplexEditorWindow> m_aXEditorWindow; BasicStatus m_aStatus; SbModuleRef m_xModule; - OUString m_sCurPath; OUString m_aModule; + OUString m_sWinColorScheme; void CheckCompileBasic(); void BasicExecute(); @@ -294,10 +311,10 @@ protected: virtual void GetFocus() override; virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override; virtual void DoInit() override; - virtual void DoScroll( ScrollBar* pCurScrollBar ) override; + virtual void DoScroll(Scrollable* pCurScrollBar) override; public: - ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, OUString const & aModule ); + ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, OUString aModule ); virtual ~ModulWindow() override; virtual void dispose() override; @@ -360,7 +377,8 @@ public: EditorWindow& GetEditorWindow() { return m_aXEditorWindow->GetEdtWindow(); } BreakPointWindow& GetBreakPointWindow() { return m_aXEditorWindow->GetBrkWindow(); } LineNumberWindow& GetLineNumberWindow() { return m_aXEditorWindow->GetLineNumberWindow(); } - ScrollBar& GetEditVScrollBar() { return m_aXEditorWindow->GetEWVScrollBar(); } + ScrollAdaptor& GetEditVScrollBar() { return m_aXEditorWindow->GetEWVScrollBar(); } + ScrollAdaptor& GetEditHScrollBar() { return m_aXEditorWindow->GetEWHScrollBar(); } ExtTextEngine* GetEditEngine() { return GetEditorWindow().GetEditEngine(); } TextView* GetEditView() { return GetEditorWindow().GetEditView(); } BreakPointList& GetBreakPoints() { return GetBreakPointWindow().GetBreakPoints(); } @@ -379,11 +397,13 @@ public: virtual void Deactivating () override; virtual void OnNewDocument () override; - virtual char const* GetHid () const override; + virtual OUString GetHid () const override; virtual ItemType GetType () const override; virtual bool HasActiveEditor () const override; void UpdateModule (); + OUString GetEditorColorScheme() { return m_sWinColorScheme; } + void SetEditorColorScheme(const OUString& rColorScheme); }; class ModulWindowLayout: public Layout @@ -401,9 +421,15 @@ public: public: void BasicAddWatch (OUString const&); void BasicRemoveWatch (); + void ShowWatchWindow(bool bVisible); + void ShowStackWindow(bool bVisible); + bool IsWatchWindowVisible() { return aWatchWindow->IsVisible(); } + bool IsStackWindowVisible() { return aStackWindow->IsVisible(); } Color const & GetSyntaxBackgroundColor () const { return aSyntaxColors.GetBackgroundColor(); } Color const & GetFontColor () const { return aSyntaxColors.GetFontColor(); } Color const & GetSyntaxColor (TokenType eType) const { return aSyntaxColors.GetColor(eType); } + OUString GetActiveColorSchemeId() { return m_sColorSchemeId; } + void ApplyColorSchemeToCurrentWindow(const OUString& rSchemeId); protected: // Window: @@ -418,6 +444,8 @@ private: VclPtr<WatchWindow> aWatchWindow; VclPtr<StackWindow> aStackWindow; ObjectCatalog& rObjectCatalog; + // Active color scheme ID + OUString m_sColorSchemeId; // SyntaxColors -- stores Basic syntax highlighting colors class SyntaxColors : public utl::ConfigurationListener @@ -427,25 +455,26 @@ private: virtual ~SyntaxColors () override; public: void SetActiveEditor (EditorWindow* pEditor_) { pEditor = pEditor_; } + void SetActiveColorSchemeId(const OUString& rColorSchemeId) { m_sActiveSchemeId = rColorSchemeId; } public: Color const & GetBackgroundColor () const { return m_aBackgroundColor; }; Color const & GetFontColor () const { return m_aFontColor; } Color const & GetColor(TokenType eType) const { return aColors[eType]; } + void ApplyColorScheme(OUString aSchemeId, bool bFirst); private: virtual void ConfigurationChanged (utl::ConfigurationBroadcaster*, ConfigurationHints) override; - void NewConfig (bool bFirst); private: Color m_aBackgroundColor; Color m_aFontColor; + OUString m_sActiveSchemeId; // the color values (the indexes are TokenType, see comphelper/syntaxhighlight.hxx) o3tl::enumarray<TokenType, Color> aColors; // the configuration svtools::ColorConfig aConfig; // the active editor VclPtr<EditorWindow> pEditor; - } aSyntaxColors; }; diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 3bb09f3bb140..e5fd31d22a21 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -40,11 +40,15 @@ #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> #include <svl/urihelper.hxx> @@ -65,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 { @@ -174,13 +181,13 @@ void lcl_SeparateNameAndIndex( const OUString& rVName, OUString& rVar, OUString& { sal_uInt16 nLastChar = rVar.getLength()-1; if ( cSuffixes.find(rVar[ nLastChar ] ) != std::u16string_view::npos ) - rVar = rVar.replaceAt( nLastChar, 1, "" ); + rVar = rVar.replaceAt( nLastChar, 1, u"" ); } if ( !rIndex.isEmpty() ) { sal_uInt16 nLastChar = rIndex.getLength()-1; if ( cSuffixes.find(rIndex[ nLastChar ] ) != std::u16string_view::npos ) - rIndex = rIndex.replaceAt( nLastChar, 1, "" ); + rIndex = rIndex.replaceAt( nLastChar, 1, u"" ); } } @@ -201,7 +208,7 @@ private: virtual void SAL_CALL disposing(lang::EventObject const &) override { - osl::MutexGuard g(editor_.mutex_); + std::unique_lock g(editor_.mutex_); editor_.notifier_.clear(); } @@ -229,7 +236,7 @@ public: } private: - sal_uLong nCurState; + sal_uInt32 nCurState; }; EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) : @@ -238,13 +245,18 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) : nCurTextWidth(0), m_nSetSourceInBasicId(nullptr), aHighlighter(HighlighterLanguage::Basic), + aSyntaxIdle( "basctl EditorWindow aSyntaxIdle" ), bHighlighting(false), bDoSyntaxHighlight(true), bDelayHighlight(true), + m_nLastHighlightPara(0), pCodeCompleteWnd(VclPtr<CodeCompleteWindow>::Create(this)) { set_id("EditorWindow"); - SetBackground(Wallpaper(rModulWindow.GetLayout().GetSyntaxBackgroundColor())); + const Wallpaper aBackground(rModulWindow.GetLayout().GetSyntaxBackgroundColor()); + SetBackground(aBackground); + GetWindow(GetWindowType::Border)->SetBackground(aBackground); + SetLineHighlightColor(GetShell()->GetColorConfig()->GetCurrentColorScheme().m_aLineHighlightColor); SetPointer( PointerStyle::Text ); SetHelpId( HID_BASICIDE_EDITORWINDOW ); @@ -253,11 +265,15 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) : officecfg::Office::Common::Font::SourceViewFont::get(), UNO_QUERY_THROW); { - osl::MutexGuard g(mutex_); + std::unique_lock g(mutex_); notifier_ = n; } + + // The zoom level applied to the editor window is the zoom slider value in the shell + nCurrentZoomLevel = GetShell()->GetCurrentZoomSliderValue(); + const Sequence<OUString> aPropertyNames{"FontHeight", "FontName"}; - n->addPropertiesChangeListener(aPropertyNames, listener_.get()); + n->addPropertiesChangeListener(aPropertyNames, listener_); } @@ -276,11 +292,11 @@ void EditorWindow::dispose() Reference< beans::XMultiPropertySet > n; { - osl::MutexGuard g(mutex_); + std::unique_lock g(mutex_); n = notifier_; } if (n.is()) { - n->removePropertiesChangeListener(listener_.get()); + n->removePropertiesChangeListener(listener_); } aSyntaxIdle.Stop(); @@ -371,7 +387,7 @@ void EditorWindow::RequestHelp( const HelpEvent& rHEvt ) { sal_uInt16 nLastChar = aWord.getLength() - 1; if ( cSuffixes.find(aWord[ nLastChar ] ) != std::u16string_view::npos ) - aWord = aWord.replaceAt( nLastChar, 1, "" ); + aWord = aWord.replaceAt( nLastChar, 1, u"" ); SbxBase* pSBX = StarBASIC::FindSBXInCurrentScope( aWord ); if (SbxVariable const* pVar = IsSbxVariable(pSBX)) { @@ -400,8 +416,7 @@ void EditorWindow::RequestHelp( const HelpEvent& rHEvt ) Point aTopLeft = GetEditView()->GetWindowPos(aHelpRect.TopLeft()); aTopLeft = GetEditView()->GetWindow()->OutputToScreenPixel(aTopLeft); - aHelpRect.setX(aTopLeft.X()); - aHelpRect.setY(aTopLeft.Y()); + aHelpRect.SetPos(aTopLeft); } } } @@ -466,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()) @@ -488,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 ) { @@ -533,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; } @@ -598,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 ); @@ -675,11 +719,11 @@ void EditorWindow::HandleAutoCorrect() { //autocorrect procedures SbxArray* pArr = rModulWindow.GetSbModule()->GetMethods().get(); - for( sal_uInt32 i=0; i < pArr->Count32(); ++i ) + for (sal_uInt32 i = 0; i < pArr->Count(); ++i) { - if( pArr->Get32(i)->GetName().equalsIgnoreAsciiCase( sStr ) ) + if (pArr->Get(i)->GetName().equalsIgnoreAsciiCase(sStr)) { - sStr = pArr->Get32(i)->GetName(); //if found, get the correct case + sStr = pArr->Get(i)->GetName(); //if found, get the correct case pEditEngine->ReplaceText( sTextSelection, sStr ); pEditView->SetSelection( aSel ); return; @@ -688,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(); @@ -713,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 ); } @@ -791,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; } } @@ -809,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); @@ -822,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; @@ -935,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 @@ -969,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() @@ -999,7 +1067,6 @@ void EditorWindow::CreateEditEngine() ImplSetFont(); aSyntaxIdle.SetInvokeHandler( LINK( this, EditorWindow, SyntaxTimerHdl ) ); - aSyntaxIdle.SetDebugName( "basctl EditorWindow aSyntaxIdle" ); bool bWasDoSyntaxHighlight = bDoSyntaxHighlight; bDoSyntaxHighlight = false; // too slow for large texts... @@ -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,14 +1202,32 @@ 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->Count32(); i++ ) + for (sal_uInt32 i = 0; i < pMethods->Count(); i++) { - SbMethod* pMeth = dynamic_cast<SbMethod*>( pMethods->Get32( i ) ); + SbMethod* pMeth = dynamic_cast<SbMethod*>(pMethods->Get(i)); if( pMeth ) { sal_uInt16 l1,l2; @@ -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,29 +1303,39 @@ 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()) { vcl::Font aTmpFont(OutputDevice::GetDefaultFont(DefaultFontType::FIXED, Application::GetSettings().GetUILanguageTag().getLanguageType(), - GetDefaultFontFlags::NONE, this)); + 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(*this, aFont); // FIXME RenderContext + SetPointFont(*GetOutDev(), aFont); // FIXME RenderContext aFont = GetFont(); 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(); @@ -1329,7 +1435,7 @@ void EditorWindow::ParagraphInsertedDeleted( sal_uLong nPara, bool bInserted ) rModulWindow.GetBreakPoints().AdjustBreakPoints( static_cast<sal_uInt16>(nPara)+1, bInserted ); tools::Long nLineHeight = GetTextHeight(); - Size aSz = rModulWindow.GetBreakPointWindow().GetOutputSize(); + Size aSz = rModulWindow.GetBreakPointWindow().GetOutDev()->GetOutputSize(); tools::Rectangle aInvRect( Point( 0, 0 ), aSz ); tools::Long nY = nPara*nLineHeight - rModulWindow.GetBreakPointWindow().GetCurYOffset(); aInvRect.SetTop( nY ); @@ -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 )); @@ -1416,10 +1522,10 @@ void BreakPointWindow::ShowMarker(vcl::RenderContext& rRenderContext) if (nMarkerPos == NoMarker) return; - Size const aOutSz = GetOutputSize(); + Size const aOutSz = GetOutDev()->GetOutputSize(); tools::Long const nLineHeight = GetTextHeight(); - Image aMarker = GetImage(OUString(bErrorMarker ? std::u16string_view(u"" RID_BMP_ERRORMARKER) : std::u16string_view(u"" RID_BMP_STEPMARKER))); + Image aMarker = GetImage(bErrorMarker ? RID_BMP_ERRORMARKER : RID_BMP_STEPMARKER); Size aMarkerSz(aMarker.GetSizePixel()); aMarkerSz = rRenderContext.PixelToLogic(aMarkerSz); @@ -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) @@ -1639,14 +1745,9 @@ WatchWindow::WatchWindow(Layout* pParent) m_xTreeListBox->connect_changed( LINK( this, WatchWindow, TreeListHdl ) ); m_xTreeListBox->connect_expanding(LINK(this, WatchWindow, RequestingChildrenHdl)); - std::vector<int> aWidths; - std::vector<bool> aEditables; - aWidths.push_back(220); // VarTabWidth - aEditables.push_back(false); - aWidths.push_back(100); // ValueTabWidth - aEditables.push_back(true); - aWidths.push_back(1250); // TypeTabWidth - aEditables.push_back(false); + // VarTabWidth, ValueTabWidth, TypeTabWidth + std::vector<int> aWidths { 220, 100, 1250 }; + std::vector<bool> aEditables { false, true, false }; m_xTreeListBox->set_column_fixed_widths(aWidths); m_xTreeListBox->set_column_editables(aEditables); @@ -1673,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; }); @@ -1683,8 +1784,7 @@ void WatchWindow::dispose() m_xRemoveWatchButton.reset(); m_xTitleArea.reset(); m_xTreeListBox.reset(); - if (!IsDisposed()) - GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); + GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); DockingWindow::dispose(); } @@ -1703,7 +1803,7 @@ void WatchWindow::Resize() if ( aBoxSz.Height() < 4 ) aBoxSz.setHeight( 0 ); - m_xVclContentArea->SetPosSizePixel(Point(DWBORDER, DWBORDER), aBoxSz); + m_xBox->SetPosSizePixel(Point(DWBORDER, DWBORDER), aBoxSz); Invalidate(); } @@ -1735,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); @@ -1758,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() ) @@ -1778,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); @@ -1840,8 +1940,7 @@ StackWindow::~StackWindow() void StackWindow::dispose() { - if (!IsDisposed()) - GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); + GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); m_xTitle.reset(); m_xTreeListBox.reset(); DockingWindow::dispose(); @@ -1862,7 +1961,7 @@ void StackWindow::Resize() if ( aBoxSz.Height() < 4 ) aBoxSz.setHeight( 0 ); - m_xVclContentArea->SetPosSizePixel(Point(DWBORDER, DWBORDER), aBoxSz); + m_xBox->SetPosSizePixel(Point(DWBORDER, DWBORDER), aBoxSz); Invalidate(); } @@ -1884,16 +1983,16 @@ void StackWindow::UpdateCalls() OUStringBuffer aEntry( OUString::number(nScope )); if ( aEntry.getLength() < 2 ) aEntry.insert(0, " "); - aEntry.append(": ").append(pMethod->GetName()); + aEntry.append(": " + pMethod->GetName()); SbxArray* pParams = pMethod->GetParameters(); SbxInfo* pInfo = pMethod->GetInfo(); if ( pParams ) { aEntry.append("("); // 0 is the sub's name... - for ( sal_uInt32 nParam = 1; nParam < pParams->Count32(); nParam++ ) + for (sal_uInt32 nParam = 1; nParam < pParams->Count(); nParam++) { - SbxVariable* pVar = pParams->Get32( nParam ); + SbxVariable* pVar = pParams->Get(nParam); assert(pVar && "Parameter?!"); if ( !pVar->GetName().isEmpty() ) { @@ -1918,7 +2017,7 @@ void StackWindow::UpdateCalls() { aEntry.append(pVar->GetOUString()); } - if ( nParam < ( pParams->Count32() - 1 ) ) + if (nParam < (pParams->Count() - 1)) { aEntry.append(", "); } @@ -1948,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(); @@ -1957,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() @@ -1970,6 +2079,7 @@ void ComplexEditorWindow::dispose() aLineNumberWindow.disposeAndClear(); aEdtWindow.disposeAndClear(); aEWVScrollBar.disposeAndClear(); + aEWHScrollBar.disposeAndClear(); vcl::Window::dispose(); } @@ -1981,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() ); } } @@ -2039,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) { @@ -2058,11 +2171,10 @@ EditorWindow::GetComponentInterface(bool bCreate) static sal_uInt32 getCorrectedPropCount(SbxArray* p) { - sal_uInt32 nPropCount = p->Count32(); - if (nPropCount >= 3 - && p->Get32(nPropCount - 1)->GetName().equalsIgnoreAsciiCase("Dbg_Methods") - && p->Get32(nPropCount - 2)->GetName().equalsIgnoreAsciiCase("Dbg_Properties") - && p->Get32(nPropCount - 3)->GetName().equalsIgnoreAsciiCase("Dbg_SupportedInterfaces")) + sal_uInt32 nPropCount = p->Count(); + if (nPropCount >= 3 && p->Get(nPropCount - 1)->GetName().equalsIgnoreAsciiCase("Dbg_Methods") + && p->Get(nPropCount - 2)->GetName().equalsIgnoreAsciiCase("Dbg_Properties") + && p->Get(nPropCount - 3)->GetName().equalsIgnoreAsciiCase("Dbg_SupportedInterfaces")) { nPropCount -= 3; } @@ -2077,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(); @@ -2099,13 +2211,13 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo for( sal_uInt32 i = 0 ; i < nPropCount ; ++i ) { - SbxVariable* pVar = pProps->Get32( i ); + SbxVariable* pVar = pProps->Get(i); pItem->maMemberList.push_back(pVar->GetName()); 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); @@ -2125,7 +2237,7 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo int nParentLevel = bArrayIsRootArray ? pItem->nDimLevel : 0; int nThisLevel = nParentLevel + 1; sal_Int32 nMin, nMax; - if (pArray->GetDim32(nThisLevel, nMin, nMax)) + if (pArray->GetDim(nThisLevel, nMin, nMax)) { for (sal_Int32 i = nMin; i <= nMax; i++) { @@ -2142,10 +2254,10 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo for (j = 0; j < nParentLevel; j++) { sal_Int32 n = pChildItem->vIndices[j] = pItem->vIndices[j]; - aIndexStr.append(OUString::number(n)).append(","); + aIndexStr.append( OUString::number(n) + "," ); } pChildItem->vIndices[nParentLevel] = i; - aIndexStr.append(OUString::number(i)).append(")"); + aIndexStr.append( OUString::number(i) + ")" ); OUString aDisplayName; WatchItem* pArrayRootItem = pChildItem->GetRootItem(); @@ -2156,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()); @@ -2186,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(); @@ -2212,7 +2324,7 @@ SbxBase* WatchWindow::ImplGetSBXForEntry(const weld::TreeIter& rEntry, bool& rbA { rbArrayElement = true; if( pParentItem->nDimLevel + 1 == pParentItem->nDimCount ) - pSBX = pArray->Get32(pItem->vIndices.empty() ? nullptr : &*pItem->vIndices.begin()); + pSBX = pArray->Get(pItem->vIndices.empty() ? nullptr : &*pItem->vIndices.begin()); } } else @@ -2224,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()) @@ -2291,7 +2403,7 @@ IMPL_LINK(WatchWindow, EditedEntryHdl, const IterString&, rIterString, bool) namespace { -void implCollapseModifiedObjectEntry(weld::TreeIter& rParent, weld::TreeView& rTree) +void implCollapseModifiedObjectEntry(const weld::TreeIter& rParent, weld::TreeView& rTree) { rTree.collapse_row(rParent); @@ -2301,7 +2413,7 @@ void implCollapseModifiedObjectEntry(weld::TreeIter& rParent, weld::TreeView& rT { implCollapseModifiedObjectEntry(*xDeleteEntry, rTree); - WatchItem* pItem = reinterpret_cast<WatchItem*>(rTree.get_id(*xDeleteEntry).toInt64()); + WatchItem* pItem = weld::fromId<WatchItem*>(rTree.get_id(*xDeleteEntry)); delete pItem; rTree.remove(*xDeleteEntry); rTree.copy_iterator(rParent, *xDeleteEntry); @@ -2325,7 +2437,7 @@ OUString implCreateTypeStringForDimArray( WatchItem* pItem, SbxDataType eType ) for( int i = nDimLevel ; i < nDims ; i++ ) { sal_Int32 nMin, nMax; - pArray->GetDim32( sal::static_int_cast<sal_Int32>( i+1 ), nMin, nMax ); + pArray->GetDim(sal::static_int_cast<sal_Int32>(i + 1), nMin, nMax); aRetStr += OUString::number(nMin) + " to " + OUString::number(nMax); if( i < nDims - 1 ) aRetStr += ", "; @@ -2360,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; @@ -2381,7 +2493,7 @@ void WatchWindow::UpdateWatches(bool bBasicStopped) eEnableChildren = TRISTATE_TRUE; } - if (SbxVariable const* pVar = IsSbxVariable(pSBX)) + if (SbxVariable* pVar = dynamic_cast<SbxVariable*>(pSBX)) { // extra treatment of arrays SbxDataType eType = pVar->GetType(); @@ -2397,8 +2509,8 @@ void WatchWindow::UpdateWatches(bool bBasicStopped) { // Compare Array dimensions to see if array has changed // Can be a copy, so comparing pointers does not work - sal_Int32 nOldDims = pOldArray->GetDims32(); - sal_Int32 nNewDims = pNewArray->GetDims32(); + sal_Int32 nOldDims = pOldArray->GetDims(); + sal_Int32 nNewDims = pNewArray->GetDims(); if( nOldDims != nNewDims ) { bArrayChanged = true; @@ -2410,8 +2522,8 @@ void WatchWindow::UpdateWatches(bool bBasicStopped) sal_Int32 nOldMin, nOldMax; sal_Int32 nNewMin, nNewMax; - pOldArray->GetDim32( i+1, nOldMin, nOldMax ); - pNewArray->GetDim32( i+1, nNewMin, nNewMax ); + pOldArray->GetDim(i + 1, nOldMin, nOldMax); + pNewArray->GetDim(i + 1, nNewMin, nNewMax); if( nOldMin != nNewMin || nOldMax != nNewMax ) { bArrayChanged = true; @@ -2432,7 +2544,7 @@ void WatchWindow::UpdateWatches(bool bBasicStopped) eEnableChildren = TRISTATE_TRUE; pItem->mpArray = pNewArray; - sal_Int32 nDims = pNewArray->GetDims32(); + sal_Int32 nDims = pNewArray->GetDims(); pItem->nDimLevel = 0; pItem->nDimCount = nDims; } @@ -2460,7 +2572,7 @@ void WatchWindow::UpdateWatches(bool bBasicStopped) bCollapse = pItem->maMemberList.size() != nPropCount; for( sal_uInt32 i = 0 ; !bCollapse && i < nPropCount ; i++ ) { - SbxVariable* pVar_ = pProps->Get32( i ); + SbxVariable* pVar_ = pProps->Get(i); if( pItem->maMemberList[i] != pVar_->GetName() ) bCollapse = true; } @@ -2494,7 +2606,11 @@ void WatchWindow::UpdateWatches(bool bBasicStopped) { aWatchStr += aStrStr; } + // tdf#57308 - avoid a second call to retrieve the data + const SbxFlagBits nFlags = pVar->GetFlags(); + pVar->SetFlag(SbxFlagBits::NoBroadcast); aWatchStr += pVar->GetOUString(); + pVar->SetFlags(nFlags); if( bString ) { aWatchStr += aStrStr; @@ -2595,7 +2711,7 @@ void CodeCompleteWindow::SetMatchingEntries() for (sal_Int32 i = 0, nEntryCount = m_xListBox->n_children(); i< nEntryCount; ++i) { OUString sEntry = m_xListBox->get_text(i); - if (sEntry.startsWithIgnoreAsciiCase(aFuncBuffer.toString())) + if (sEntry.startsWithIgnoreAsciiCase(aFuncBuffer)) { m_xListBox->select(i); break; @@ -2661,8 +2777,8 @@ bool CodeCompleteWindow::HandleKeyInput( const KeyEvent& rKeyEvt ) for (sal_Int32 i = nInd; i != nEntryCount; ++i) { OUString sEntry = m_xListBox->get_text(i); - if( sEntry.startsWithIgnoreAsciiCase( aFuncBuffer.toString() ) - && (aFuncBuffer.toString() != sTypedText) && (i != nInd) ) + if( sEntry.startsWithIgnoreAsciiCase( aFuncBuffer ) + && (std::u16string_view(aFuncBuffer) != sTypedText) && (i != nInd) ) { m_xListBox->select(i); bFound = true; @@ -2692,7 +2808,7 @@ bool CodeCompleteWindow::HandleKeyInput( const KeyEvent& rKeyEvt ) OUString aTabInsertedStr( GetParentEditView()->GetSelected() ); GetParentEditView()->SetSelection( aSel ); - if( !aTabInsertedStr.isEmpty() && aTabInsertedStr != aFuncBuffer.toString() ) + if( !aTabInsertedStr.isEmpty() && aTabInsertedStr != std::u16string_view(aFuncBuffer) ) { aFuncBuffer = aTabInsertedStr; } @@ -2746,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 69fc19b74329..4a6b1dfbfb5c 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -39,17 +39,18 @@ #include <com/sun/star/ucb/SimpleFileAccess.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> -#include <com/sun/star/ui/dialogs/FilePicker.hpp> +#include <com/sun/star/ui/dialogs/XFilePicker3.hpp> #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> #include <comphelper/processfactory.hxx> #include <sfx2/dispatch.hxx> +#include <sfx2/filedlghelper.hxx> #include <sfx2/request.hxx> #include <sfx2/viewfrm.hxx> #include <svl/visitem.hxx> #include <svl/whiter.hxx> #include <svx/svdundo.hxx> #include <svx/svxids.hrc> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <tools/urlobj.hxx> #include <vcl/commandevent.hxx> #include <vcl/weld.hxx> @@ -69,9 +70,9 @@ using namespace ::com::sun::star::resource; using namespace ::com::sun::star::ui::dialogs; #ifdef _WIN32 -OUStringLiteral const FilterMask_All = u"*.*"; +constexpr OUString FilterMask_All = u"*.*"_ustr; #else -constexpr OUStringLiteral FilterMask_All = u"*"; +constexpr OUString FilterMask_All = u"*"_ustr; #endif DialogWindow::DialogWindow(DialogWindowLayout* pParent, ScriptDocument const& rDocument, @@ -231,12 +232,10 @@ void DialogWindow::NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> ) void DialogWindow::DoInit() { - GetHScrollBar()->Show(); - GetVScrollBar()->Show(); m_pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() ); } -void DialogWindow::DoScroll( ScrollBar* ) +void DialogWindow::DoScroll( Scrollable* ) { m_pEditor->DoScroll(); } @@ -314,7 +313,7 @@ void DialogWindow::GetState( SfxItemSet& rSet ) case SID_SHOW_PROPERTYBROWSER: { Shell* pShell = GetShell(); - SfxViewFrame* pViewFrame = pShell ? pShell->GetViewFrame() : nullptr; + SfxViewFrame* pViewFrame = pShell ? &pShell->GetViewFrame() : nullptr; if ( pViewFrame && !pViewFrame->HasChildWindow( SID_SHOW_PROPERTYBROWSER ) && !m_pEditor->GetView().AreObjectsMarked() ) rSet.DisableItem( nWh ); @@ -391,7 +390,7 @@ void DialogWindow::GetState( SfxItemSet& rSet ) void DialogWindow::ExecuteCommand( SfxRequest& rReq ) { const sal_uInt16 nSlotId(rReq.GetSlot()); - SdrObjKind nInsertObj(OBJ_NONE); + SdrObjKind nInsertObj(SdrObjKind::NONE); switch ( nSlotId ) { @@ -424,100 +423,100 @@ void DialogWindow::ExecuteCommand( SfxRequest& rReq ) break; case SID_INSERT_FORM_RADIO: - nInsertObj = OBJ_DLG_FORMRADIO; + nInsertObj = SdrObjKind::BasicDialogFormRadio; break; case SID_INSERT_FORM_CHECK: - nInsertObj = OBJ_DLG_FORMCHECK; + nInsertObj = SdrObjKind::BasicDialogFormCheck; break; case SID_INSERT_FORM_LIST: - nInsertObj = OBJ_DLG_FORMLIST; + nInsertObj = SdrObjKind::BasicDialogFormList; break; case SID_INSERT_FORM_COMBO: - nInsertObj = OBJ_DLG_FORMCOMBO; + nInsertObj = SdrObjKind::BasicDialogFormCombo; break; case SID_INSERT_FORM_SPIN: - nInsertObj = OBJ_DLG_FORMSPIN; + nInsertObj = SdrObjKind::BasicDialogFormSpin; break; case SID_INSERT_FORM_VSCROLL: - nInsertObj = OBJ_DLG_FORMVSCROLL; + nInsertObj = SdrObjKind::BasicDialogFormVerticalScroll; break; case SID_INSERT_FORM_HSCROLL: - nInsertObj = OBJ_DLG_FORMHSCROLL; + nInsertObj = SdrObjKind::BasicDialogFormHorizontalScroll; break; case SID_INSERT_PUSHBUTTON: - nInsertObj = OBJ_DLG_PUSHBUTTON; + nInsertObj = SdrObjKind::BasicDialogPushButton; break; case SID_INSERT_RADIOBUTTON: - nInsertObj = OBJ_DLG_RADIOBUTTON; + nInsertObj = SdrObjKind::BasicDialogRadioButton; break; case SID_INSERT_CHECKBOX: - nInsertObj = OBJ_DLG_CHECKBOX; + nInsertObj = SdrObjKind::BasicDialogCheckbox; break; case SID_INSERT_LISTBOX: - nInsertObj = OBJ_DLG_LISTBOX; + nInsertObj = SdrObjKind::BasicDialogListbox; break; case SID_INSERT_COMBOBOX: - nInsertObj = OBJ_DLG_COMBOBOX; + nInsertObj = SdrObjKind::BasicDialogCombobox; break; case SID_INSERT_GROUPBOX: - nInsertObj = OBJ_DLG_GROUPBOX; + nInsertObj = SdrObjKind::BasicDialogGroupBox; break; case SID_INSERT_EDIT: - nInsertObj = OBJ_DLG_EDIT; + nInsertObj = SdrObjKind::BasicDialogEdit; break; case SID_INSERT_FIXEDTEXT: - nInsertObj = OBJ_DLG_FIXEDTEXT; + nInsertObj = SdrObjKind::BasicDialogFixedText; break; case SID_INSERT_IMAGECONTROL: - nInsertObj = OBJ_DLG_IMAGECONTROL; + nInsertObj = SdrObjKind::BasicDialogImageControl; break; case SID_INSERT_PROGRESSBAR: - nInsertObj = OBJ_DLG_PROGRESSBAR; + nInsertObj = SdrObjKind::BasicDialogProgressbar; break; case SID_INSERT_HSCROLLBAR: - nInsertObj = OBJ_DLG_HSCROLLBAR; + nInsertObj = SdrObjKind::BasicDialogHorizontalScrollbar; break; case SID_INSERT_VSCROLLBAR: - nInsertObj = OBJ_DLG_VSCROLLBAR; + nInsertObj = SdrObjKind::BasicDialogVerticalScrollbar; break; case SID_INSERT_HFIXEDLINE: - nInsertObj = OBJ_DLG_HFIXEDLINE; + nInsertObj = SdrObjKind::BasicDialogHorizontalFixedLine; break; case SID_INSERT_VFIXEDLINE: - nInsertObj = OBJ_DLG_VFIXEDLINE; + nInsertObj = SdrObjKind::BasicDialogVerticalFixedLine; break; case SID_INSERT_DATEFIELD: - nInsertObj = OBJ_DLG_DATEFIELD; + nInsertObj = SdrObjKind::BasicDialogDateField; break; case SID_INSERT_TIMEFIELD: - nInsertObj = OBJ_DLG_TIMEFIELD; + nInsertObj = SdrObjKind::BasicDialogTimeField; break; case SID_INSERT_NUMERICFIELD: - nInsertObj = OBJ_DLG_NUMERICFIELD; + nInsertObj = SdrObjKind::BasicDialogNumericField; break; case SID_INSERT_CURRENCYFIELD: - nInsertObj = OBJ_DLG_CURRENCYFIELD; + nInsertObj = SdrObjKind::BasicDialogCurencyField; break; case SID_INSERT_FORMATTEDFIELD: - nInsertObj = OBJ_DLG_FORMATTEDFIELD; + nInsertObj = SdrObjKind::BasicDialogFormattedField; break; case SID_INSERT_PATTERNFIELD: - nInsertObj = OBJ_DLG_PATTERNFIELD; + nInsertObj = SdrObjKind::BasicDialogPatternField; break; case SID_INSERT_FILECONTROL: - nInsertObj = OBJ_DLG_FILECONTROL; + nInsertObj = SdrObjKind::BasicDialogFileControl; break; case SID_INSERT_SPINBUTTON: - nInsertObj = OBJ_DLG_SPINBUTTON; + nInsertObj = SdrObjKind::BasicDialogSpinButton; break; case SID_INSERT_GRIDCONTROL: - nInsertObj = OBJ_DLG_GRIDCONTROL; + nInsertObj = SdrObjKind::BasicDialogGridControl; break; case SID_INSERT_HYPERLINKCONTROL: - nInsertObj = OBJ_DLG_HYPERLINKCONTROL; + nInsertObj = SdrObjKind::BasicDialogHyperlinkControl; break; case SID_INSERT_TREECONTROL: - nInsertObj = OBJ_DLG_TREECONTROL; + nInsertObj = SdrObjKind::BasicDialogTreeControl; break; case SID_INSERT_SELECT: m_nControlSlotId = nSlotId; @@ -555,7 +554,7 @@ void DialogWindow::ExecuteCommand( SfxRequest& rReq ) break; } - if ( nInsertObj ) + if ( nInsertObj != SdrObjKind::NONE ) { m_nControlSlotId = nSlotId; GetEditor().SetMode( DlgEditor::INSERT ); @@ -602,18 +601,12 @@ void DialogWindow::UpdateBrowser() void DialogWindow::SaveDialog() { - Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() ); - Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD); - - Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY); - xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false); - Any aValue; - aValue <<= true; - xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue); - - if ( !m_sCurPath.isEmpty() ) - xFP->setDisplayDirectory ( m_sCurPath ); + sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, + FileDialogFlags::NONE, this->GetFrameWeld()); + aDlg.SetContext(sfx2::FileDialogHelper::BasicExportDialog); + Reference<XFilePicker3> xFP = aDlg.GetFilePicker(); + xFP.queryThrow<XFilePickerControlAccess>()->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, Any(true)); xFP->setDefaultName( GetName() ); OUString aDialogStr(IDEResId(RID_STR_STDDIALOGNAME)); @@ -621,137 +614,112 @@ void DialogWindow::SaveDialog() xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All ); xFP->setCurrentFilter( aDialogStr ); - if( xFP->execute() != RET_OK ) + if( aDlg.Execute() != ERRCODE_NONE ) return; - Sequence< OUString > aPaths = xFP->getSelectedFiles(); - m_sCurPath = aPaths[0]; - - // export dialog model to xml - Reference< container::XNameContainer > xDialogModel = GetDialog(); - Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() ); - Reference< XInputStream > xInput( xISP->createInputStream() ); + OUString aSelectedFileURL = xFP->getSelectedFiles()[0]; + Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext()); Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) ); Reference< XOutputStream > xOutput; try { - if( xSFI->exists( m_sCurPath ) ) - xSFI->kill( m_sCurPath ); - xOutput = xSFI->openFileWrite( m_sCurPath ); + if( xSFI->exists(aSelectedFileURL) ) + xSFI->kill(aSelectedFileURL); + xOutput = xSFI->openFileWrite(aSelectedFileURL); } catch(const Exception& ) {} - if( xOutput.is() ) + if (!xOutput) { - Sequence< sal_Int8 > bytes; - sal_Int32 nRead = xInput->readBytes( bytes, xInput->available() ); - for (;;) - { - if( nRead ) - xOutput->writeBytes( bytes ); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTWRITE))); + xBox->run(); + return; + } - nRead = xInput->readBytes( bytes, 1024 ); - if (! nRead) - break; - } + // export dialog model to xml + auto xInput(xmlscript::exportDialogModel(GetDialog(), xContext, GetDocument().getDocumentOrNull())->createInputStream()); - // With resource? - Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY ); - Reference< resource::XStringResourceResolver > xStringResourceResolver; - if( xDialogModelPropSet.is() ) - { - try - { - Any aResourceResolver = xDialogModelPropSet->getPropertyValue( "ResourceResolver" ); - aResourceResolver >>= xStringResourceResolver; - } - catch(const beans::UnknownPropertyException& ) - {} - } + for (Sequence<sal_Int8> bytes; xInput->readBytes(bytes, xInput->available());) + xOutput->writeBytes(bytes); - bool bResource = false; - if( xStringResourceResolver.is() ) + // With resource? + Reference< resource::XStringResourceResolver > xStringResourceResolver; + if (auto xDialogModelPropSet = GetDialog().query<beans::XPropertySet>()) + { + try { - Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales(); - if( aLocaleSeq.hasElements() ) - bResource = true; + Any aResourceResolver = xDialogModelPropSet->getPropertyValue( "ResourceResolver" ); + aResourceResolver >>= xStringResourceResolver; } + catch(const beans::UnknownPropertyException& ) + {} + } - if( bResource ) + Sequence<lang::Locale> aLocaleSeq; + if (xStringResourceResolver) + aLocaleSeq = xStringResourceResolver->getLocales(); + if (aLocaleSeq.hasElements()) + { + INetURLObject aURLObj(aSelectedFileURL); + aURLObj.removeExtension(); + OUString aDialogName( aURLObj.getName() ); + aURLObj.removeSegment(); + OUString aURL( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + OUString aComment = "# " + aDialogName + " strings" ; + Reference< task::XInteractionHandler > xDummyHandler; + + // Remove old properties files in case of overwriting Dialog files + if( xSFI->isFolder( aURL ) ) { - INetURLObject aURLObj( m_sCurPath ); - aURLObj.removeExtension(); - OUString aDialogName( aURLObj.getName() ); - aURLObj.removeSegment(); - OUString aURL( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); - OUString aComment = "# " + aDialogName + " strings" ; - Reference< task::XInteractionHandler > xDummyHandler; + Sequence< OUString > aContentSeq = xSFI->getFolderContents( aURL, false ); - // Remove old properties files in case of overwriting Dialog files - if( xSFI->isFolder( aURL ) ) + OUString aDialogName_ = aDialogName + "_" ; + for( const OUString& rCompleteName : aContentSeq ) { - Sequence< OUString > aContentSeq = xSFI->getFolderContents( aURL, false ); - - OUString aDialogName_ = aDialogName + "_" ; - sal_Int32 nCount = aContentSeq.getLength(); - const OUString* pFiles = aContentSeq.getConstArray(); - for( int i = 0 ; i < nCount ; i++ ) + OUString aPureName; + OUString aExtension; + sal_Int32 iDot = rCompleteName.lastIndexOf( '.' ); + if( iDot != -1 ) { - OUString aCompleteName = pFiles[i]; - OUString aPureName; - OUString aExtension; - sal_Int32 iDot = aCompleteName.lastIndexOf( '.' ); - sal_Int32 iSlash = aCompleteName.lastIndexOf( '/' ); - if( iDot != -1 ) - { - sal_Int32 iCopyFrom = (iSlash != -1) ? iSlash + 1 : 0; - aPureName = aCompleteName.copy( iCopyFrom, iDot-iCopyFrom ); - aExtension = aCompleteName.copy( iDot + 1 ); - } + sal_Int32 iSlash = rCompleteName.lastIndexOf( '/' ); + sal_Int32 iCopyFrom = (iSlash != -1) ? iSlash + 1 : 0; + aPureName = rCompleteName.copy( iCopyFrom, iDot-iCopyFrom ); + aExtension = rCompleteName.copy( iDot + 1 ); + } - if( aExtension == "properties" || aExtension == "default" ) + if( aExtension == "properties" || aExtension == "default" ) + { + if( aPureName.startsWith( aDialogName_ ) ) { - if( aPureName.startsWith( aDialogName_ ) ) + try { - try - { - xSFI->kill( aCompleteName ); - } - catch(const uno::Exception& ) - {} + xSFI->kill( rCompleteName ); } + catch(const uno::Exception& ) + {} } } } + } - Reference< XStringResourceWithLocation > xStringResourceWithLocation = - StringResourceWithLocation::create( xContext, aURL, false/*bReadOnly*/, - xStringResourceResolver->getDefaultLocale(), aDialogName, aComment, xDummyHandler ); + Reference< XStringResourceWithLocation > xStringResourceWithLocation = + StringResourceWithLocation::create( xContext, aURL, false/*bReadOnly*/, + xStringResourceResolver->getDefaultLocale(), aDialogName, aComment, xDummyHandler ); - // Add locales - Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales(); - const lang::Locale* pLocales = aLocaleSeq.getConstArray(); - sal_Int32 nLocaleCount = aLocaleSeq.getLength(); - for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ ) - { - const lang::Locale& rLocale = pLocales[ iLocale ]; - xStringResourceWithLocation->newLocale( rLocale ); - } + // Add locales + for( const lang::Locale& rLocale : aLocaleSeq ) + { + xStringResourceWithLocation->newLocale( rLocale ); + } - LocalizationMgr::copyResourceForDialog( xDialogModel, - xStringResourceResolver, xStringResourceWithLocation ); + LocalizationMgr::copyResourceForDialog( GetDialog(), + xStringResourceResolver, xStringResourceWithLocation ); - xStringResourceWithLocation->store(); - } - } - else - { - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTWRITE))); - xBox->run(); + xStringResourceWithLocation->store(); } } @@ -760,32 +728,15 @@ static std::vector< lang::Locale > implGetLanguagesOnlyContainedInFirstSeq { std::vector< lang::Locale > avRet; - const lang::Locale* pFirst = aFirstSeq.getConstArray(); - const lang::Locale* pSecond = aSecondSeq.getConstArray(); - sal_Int32 nFirstCount = aFirstSeq.getLength(); - sal_Int32 nSecondCount = aSecondSeq.getLength(); - - for( sal_Int32 iFirst = 0 ; iFirst < nFirstCount ; iFirst++ ) - { - const lang::Locale& rFirstLocale = pFirst[ iFirst ]; - - bool bAlsoContainedInSecondSeq = false; - for( sal_Int32 iSecond = 0 ; iSecond < nSecondCount ; iSecond++ ) - { - const lang::Locale& rSecondLocale = pSecond[ iSecond ]; - - bool bMatch = localesAreEqual( rFirstLocale, rSecondLocale ); - if( bMatch ) - { - bAlsoContainedInSecondSeq = true; - break; - } - } - - if( !bAlsoContainedInSecondSeq ) - avRet.push_back( rFirstLocale ); - } - + std::copy_if(aFirstSeq.begin(), aFirstSeq.end(), + std::back_inserter(avRet), + [&aSecondSeq](const lang::Locale& rFirstLocale) { + return std::none_of( + aSecondSeq.begin(), aSecondSeq.end(), + [&rFirstLocale](const lang::Locale& rSecondLocale) { + return localesAreEqual(rFirstLocale, rSecondLocale); + }); + }); return avRet; } @@ -830,35 +781,27 @@ public: } -bool implImportDialog(weld::Window* pWin, const OUString& rCurPath, const ScriptDocument& rDocument, const OUString& aLibName) +bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const OUString& aLibName) { bool bDone = false; - Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() ); - Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_SIMPLE); - - Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY); - xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false); - Any aValue; - aValue <<= true; - xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue); - - OUString aCurPath( rCurPath ); - if ( !aCurPath.isEmpty() ) - xFP->setDisplayDirectory ( aCurPath ); + Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext()); + sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, + FileDialogFlags::NONE, pWin); + aDlg.SetContext(sfx2::FileDialogHelper::BasicImportDialog); + Reference<XFilePicker3> xFP = aDlg.GetFilePicker(); OUString aDialogStr(IDEResId(RID_STR_STDDIALOGNAME)); xFP->appendFilter( aDialogStr, "*.xdl" ); xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All ); xFP->setCurrentFilter( aDialogStr ); - if( xFP->execute() == RET_OK ) + if( aDlg.Execute() == ERRCODE_NONE ) { Sequence< OUString > aPaths = xFP->getSelectedFiles(); - aCurPath = aPaths[0]; OUString aBasePath; - OUString aOUCurPath( aCurPath ); + OUString aOUCurPath( aPaths[0] ); sal_Int32 iSlash = aOUCurPath.lastIndexOf( '/' ); if( iSlash != -1 ) aBasePath = aOUCurPath.copy( 0, iSlash + 1 ); @@ -873,8 +816,8 @@ bool implImportDialog(weld::Window* pWin, const OUString& rCurPath, const Script Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) ); Reference< XInputStream > xInput; - if( xSFI->exists( aCurPath ) ) - xInput = xSFI->openFileRead( aCurPath ); + if( xSFI->exists( aOUCurPath ) ) + xInput = xSFI->openFileRead( aOUCurPath ); ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() ); @@ -995,15 +938,13 @@ bool implImportDialog(weld::Window* pWin, const OUString& rCurPath, const Script { // Check if import default belongs to only import languages and use it then lang::Locale aImportDefaultLocale = xImportStringResource->getDefaultLocale(); - lang::Locale aTmpLocale; - for( int i = 0 ; i < nOnlyInImportLanguageCount ; ++i ) + + if (std::any_of(aOnlyInImportLanguages.begin(), aOnlyInImportLanguages.end(), + [&aImportDefaultLocale](const lang::Locale& aTmpLocale) { + return localesAreEqual(aImportDefaultLocale, aTmpLocale); + })) { - aTmpLocale = aOnlyInImportLanguages[i]; - if( localesAreEqual( aImportDefaultLocale, aTmpLocale ) ) - { - aFirstLocale = aImportDefaultLocale; - break; - } + aFirstLocale = aImportDefaultLocale; } } @@ -1012,13 +953,12 @@ bool implImportDialog(weld::Window* pWin, const OUString& rCurPath, const Script if( nOnlyInImportLanguageCount > 1 ) { Sequence< lang::Locale > aRemainingLocaleSeq( nOnlyInImportLanguageCount - 1 ); - lang::Locale aTmpLocale; + auto pRemainingLocaleSeq = aRemainingLocaleSeq.getArray(); int iSeq = 0; - for( int i = 0 ; i < nOnlyInImportLanguageCount ; ++i ) + for( const lang::Locale& rLocale : aOnlyInImportLanguages ) { - aTmpLocale = aOnlyInImportLanguages[i]; - if( !localesAreEqual( aFirstLocale, aTmpLocale ) ) - aRemainingLocaleSeq[iSeq++] = aTmpLocale; + if( !localesAreEqual( aFirstLocale, rLocale ) ) + pRemainingLocaleSeq[iSeq++] = rLocale; } pCurMgr->handleAddLocales( aRemainingLocaleSeq ); } @@ -1106,7 +1046,7 @@ void DialogWindow::ImportDialog() { const ScriptDocument& rDocument = GetDocument(); OUString aLibName = GetLibName(); - implImportDialog(GetFrameWeld(), m_sCurPath, rDocument, aLibName); + implImportDialog(GetFrameWeld(), rDocument, aLibName); } DlgEdModel& DialogWindow::GetModel() const @@ -1232,12 +1172,12 @@ void DialogWindow::InitSettings() // FIXME RenderContext const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); vcl::Font aFont = rStyleSettings.GetFieldFont(); - SetPointFont(*this, aFont); + SetPointFont(*GetOutDev(), aFont); SetTextColor( rStyleSettings.GetFieldTextColor() ); SetTextFillColor(); - SetBackground( rStyleSettings.GetFieldColor() ); + SetBackground(rStyleSettings.GetFaceColor()); } css::uno::Reference< css::accessibility::XAccessible > DialogWindow::CreateAccessible() @@ -1245,10 +1185,11 @@ css::uno::Reference< css::accessibility::XAccessible > DialogWindow::CreateAcces return new AccessibleDialogWindow(this); } -char const* DialogWindow::GetHid () const +OUString DialogWindow::GetHid () const { return HID_BASICIDE_DIALOGWINDOW; } + ItemType DialogWindow::GetType () const { return TYPE_DIALOG; diff --git a/basctl/source/basicide/basidectrlr.cxx b/basctl/source/basicide/basidectrlr.cxx index 88e67bc3bbc0..849bff30cbe7 100644 --- a/basctl/source/basicide/basidectrlr.cxx +++ b/basctl/source/basicide/basidectrlr.cxx @@ -61,12 +61,12 @@ Any SAL_CALL Controller::queryInterface( const Type & rType ) return aReturn; } -void SAL_CALL Controller::acquire() throw() +void SAL_CALL Controller::acquire() noexcept { SfxBaseController::acquire(); } -void SAL_CALL Controller::release() throw() +void SAL_CALL Controller::release() noexcept { SfxBaseController::release(); } diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 8942d87f4ae0..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; @@ -1295,13 +1505,13 @@ BasicDebugFlags Shell::CallBasicBreakHdl( StarBASIC const * pBasic ) if ( StarBASIC::IsRunning() ) // if cancelled... { if ( bAppWindowDisabled ) - Application::GetDefDialogParent()->Enable(false); + Application::GetDefDialogParent()->set_sensitive(false); if ( nWaitCount ) { Shell* pShell = GetShell(); for ( sal_uInt16 n = 0; n < nWaitCount; n++ ) - pShell->GetViewFrame()->GetWindow().EnterWait(); + pShell->GetViewFrame().GetWindow().EnterWait(); } } } @@ -1345,27 +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 a42722ca9816..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()->GetWindow().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 b302c8b9493c..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 = ( @@ -100,21 +101,15 @@ Sequence< OUString > GetMergedLibraryNames( const Reference< script::XLibraryCon std::vector<OUString> aLibList; if ( xModLibContainer.is() ) { - Sequence< OUString > aModLibNames = xModLibContainer->getElementNames(); - sal_Int32 nModLibCount = aModLibNames.getLength(); - const OUString* pModLibNames = aModLibNames.getConstArray(); - for ( sal_Int32 i = 0 ; i < nModLibCount ; i++ ) - aLibList.push_back( pModLibNames[ i ] ); + const Sequence< OUString > aModLibNames = xModLibContainer->getElementNames(); + aLibList.insert( aLibList.end(), aModLibNames.begin(), aModLibNames.end() ); } // create a list of dialog library names if ( xDlgLibContainer.is() ) { - Sequence< OUString > aDlgLibNames = xDlgLibContainer->getElementNames(); - sal_Int32 nDlgLibCount = aDlgLibNames.getLength(); - const OUString* pDlgLibNames = aDlgLibNames.getConstArray(); - for ( sal_Int32 i = 0 ; i < nDlgLibCount ; i++ ) - aLibList.push_back( pDlgLibNames[ i ] ); + const Sequence< OUString > aDlgLibNames = xDlgLibContainer->getElementNames(); + aLibList.insert( aLibList.end(), aDlgLibNames.begin(), aDlgLibNames.end() ); } // sort list @@ -166,27 +161,28 @@ bool RenameModule ( if ( !rDocument.renameModule( rLibName, rOldName, rNewName ) ) return false; - if (Shell* pShell = GetShell()) - { - if (VclPtr<ModulWindow> pWin = pShell->FindBasWin(rDocument, rLibName, rNewName, false, true)) - { - // set new name in window - pWin->SetName( rNewName ); + Shell* pShell = GetShell(); + if (!pShell) + return true; + VclPtr<ModulWindow> pWin = pShell->FindBasWin(rDocument, rLibName, rNewName, false, true); + if (!pWin) + return true; - // set new module in module window - pWin->SetSbModule( pWin->GetBasic()->FindModule( rNewName ) ); + // set new name in window + pWin->SetName( rNewName ); - // update tabwriter - sal_uInt16 nId = pShell->GetWindowId( pWin ); - SAL_WARN_IF( nId == 0 , "basctl.basicide", "No entry in Tabbar!"); - if ( nId ) - { - TabBar& rTabBar = pShell->GetTabBar(); - rTabBar.SetPageText(nId, rNewName); - rTabBar.Sort(); - rTabBar.MakeVisible(rTabBar.GetCurPageId()); - } - } + // set new module in module window + pWin->SetSbModule( pWin->GetBasic()->FindModule( rNewName ) ); + + // update tabwriter + sal_uInt16 nId = pShell->GetWindowId( pWin ); + SAL_WARN_IF( nId == 0 , "basctl.basicide", "No entry in Tabbar!"); + if ( nId ) + { + TabBar& rTabBar = pShell->GetTabBar(); + rTabBar.SetPageText(nId, rNewName); + rTabBar.Sort(); + rTabBar.MakeVisible(rTabBar.GetCurPageId()); } return true; } @@ -221,9 +217,9 @@ namespace // in case this is a document-local macro, try to protect the document's Undo Manager from // flawed scripts - std::unique_ptr< ::framework::DocumentUndoGuard > pUndoGuard; + std::optional< ::framework::DocumentUndoGuard > pUndoGuard; if ( pData->aDocument.isDocument() ) - pUndoGuard.reset( new ::framework::DocumentUndoGuard( pData->aDocument.getDocument() ) ); + pUndoGuard.emplace( pData->aDocument.getDocument() ); RunMethod( pData->xMethod.get() ); } @@ -379,11 +375,11 @@ Sequence< OUString > GetMethodNames( const ScriptDocument& rDocument, const OUSt pMod = xModule.get(); } - sal_uInt32 nCount = pMod->GetMethods()->Count32(); + sal_uInt32 nCount = pMod->GetMethods()->Count(); sal_uInt32 nRealCount = nCount; for ( sal_uInt32 i = 0; i < nCount; i++ ) { - SbMethod* pMethod = static_cast<SbMethod*>(pMod->GetMethods()->Get32( i )); + SbMethod* pMethod = static_cast<SbMethod*>(pMod->GetMethods()->Get(i)); if( pMethod->IsHidden() ) --nRealCount; } @@ -392,7 +388,7 @@ Sequence< OUString > GetMethodNames( const ScriptDocument& rDocument, const OUSt sal_uInt32 iTarget = 0; for ( sal_uInt32 i = 0 ; i < nCount; ++i ) { - SbMethod* pMethod = static_cast<SbMethod*>(pMod->GetMethods()->Get32( i )); + SbMethod* pMethod = static_cast<SbMethod*>(pMod->GetMethods()->Get(i)); if( pMethod->IsHidden() ) continue; SAL_WARN_IF( !pMethod, "basctl.basicide","Method not found! (NULL)" ); diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx index f71bbb206378..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; @@ -74,7 +73,7 @@ SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName ) OUString aMacroName( rMacroName ); if ( aMacroName.isEmpty() ) { - if ( !pModule->GetMethods()->Count32() ) + if (!pModule->GetMethods()->Count()) aMacroName = "Main" ; else { @@ -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()); @@ -180,24 +177,24 @@ bool RenameDialog ( if ( !rDocument.renameDialog( rLibName, rOldName, rNewName, xExistingDialog ) ) return false; - if (pWin && pShell) - { - // set new name in window - pWin->SetName( rNewName ); + if (!pWin || !pShell) + return true; - // update property browser - pWin->UpdateBrowser(); + // set new name in window + pWin->SetName( rNewName ); - // update tabwriter - sal_uInt16 nId = pShell->GetWindowId( pWin ); - DBG_ASSERT( nId, "No entry in Tabbar!" ); - if ( nId ) - { - TabBar& rTabBar = pShell->GetTabBar(); - rTabBar.SetPageText( nId, rNewName ); - rTabBar.Sort(); - rTabBar.MakeVisible( rTabBar.GetCurPageId() ); - } + // update property browser + pWin->UpdateBrowser(); + + // update tabwriter + sal_uInt16 nId = pShell->GetWindowId( pWin ); + DBG_ASSERT( nId, "No entry in Tabbar!" ); + if ( nId ) + { + TabBar& rTabBar = pShell->GetTabBar(); + rTabBar.SetPageText( nId, rNewName ); + rTabBar.Sort(); + rTabBar.MakeVisible( rTabBar.GetCurPageId() ); } return true; } @@ -323,19 +320,19 @@ void BasicStopped( if (Shell* pShell = GetShell()) { sal_uInt16 nWait = 0; - while ( pShell->GetViewFrame()->GetWindow().IsWait() ) + while ( pShell->GetViewFrame().GetWindow().IsWait() ) { - pShell->GetViewFrame()->GetWindow().LeaveWait(); + pShell->GetViewFrame().GetWindow().LeaveWait(); nWait++; } if ( pnWaitCount ) *pnWaitCount = nWait; } - vcl::Window* pDefParent = Application::GetDefDialogParent(); - if ( pDefParent && !pDefParent->IsEnabled() ) + weld::Window* pDefParent = Application::GetDefDialogParent(); + if (pDefParent && !pDefParent->get_sensitive()) { - pDefParent->Enable(); + pDefParent->set_sensitive(true); if ( pbAppWindowDisabled ) *pbAppWindowDisabled = true; } @@ -432,7 +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 eed521ce3fd6..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 ? std::u16string_view(u"" RID_BMP_DLGLIB) : std::u16string_view(u"" RID_BMP_DLGLIBNOTLOADED); + sId = bLoaded ? RID_BMP_DLGLIB : RID_BMP_DLGLIBNOTLOADED; else - sId = bLoaded ? OUStringLiteral(u"" RID_BMP_MODLIB) : OUStringLiteral(u"" RID_BMP_MODLIBNOTLOADED); + sId = bLoaded ? RID_BMP_MODLIB : RID_BMP_MODLIBNOTLOADED; std::unique_ptr<weld::TreeIter> xLibRootEntry(m_xControl->make_iterator(&rIter)); bool bLibRootEntry = FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xLibRootEntry); if (bLibRootEntry) @@ -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 5e409a267423..d26ae83252f6 100644 --- a/basctl/source/basicide/bastype3.cxx +++ b/basctl/source/basicide/bastype3.cxx @@ -101,8 +101,8 @@ IMPL_LINK(SbTreeListBox, RequestingChildrenHdl, const weld::TreeIter&, rEntry, b // exchange image const bool bDlgMode = (nMode & BrowseMode::Dialogs) && !(nMode & BrowseMode::Modules); - auto const aImage(bDlgMode ? std::u16string_view(u"" RID_BMP_DLGLIB) : std::u16string_view(u"" RID_BMP_MODLIB)); - SetEntryBitmaps(rEntry, OUString(aImage)); + auto const aImage(bDlgMode ? RID_BMP_DLGLIB : RID_BMP_MODLIB); + SetEntryBitmaps(rEntry, aImage); } else { @@ -156,7 +156,7 @@ SbxVariable* SbTreeListBox::FindVariable(const weld::TreeIter* pEntry) do { sal_uInt16 nDepth = m_xControl->get_iter_depth(*xIter); - Entry* pBE = reinterpret_cast<Entry*>(m_xControl->get_id(*xIter).toInt64()); + Entry* pBE = weld::fromId<Entry*>(m_xControl->get_id(*xIter)); switch (nDepth) { case 4: @@ -257,7 +257,7 @@ EntryDescriptor SbTreeListBox::GetEntryDescriptor(const weld::TreeIter* pEntry) do { sal_uInt16 nDepth = m_xControl->get_iter_depth(*xIter); - Entry* pBE = reinterpret_cast<Entry*>(m_xControl->get_id(*xIter).toInt64()); + Entry* pBE = weld::fromId<Entry*>(m_xControl->get_id(*xIter)); switch (nDepth) { case 4: @@ -355,7 +355,7 @@ ItemType SbTreeListBox::ConvertType (EntryType eType) } } -bool SbTreeListBox::IsValidEntry(weld::TreeIter& rEntry) +bool SbTreeListBox::IsValidEntry(const weld::TreeIter& rEntry) { bool bIsValid = false; @@ -421,7 +421,7 @@ bool SbTreeListBox::FindRootEntry( const ScriptDocument& rDocument, LibraryLocat bool bValidIter = m_xControl->get_iter_first(rIter); while (bValidIter) { - DocumentEntry* pBDEntry = reinterpret_cast<DocumentEntry*>(m_xControl->get_id(rIter).toInt64()); + DocumentEntry* pBDEntry = weld::fromId<DocumentEntry*>(m_xControl->get_id(rIter)); if (pBDEntry && pBDEntry->GetDocument() == rDocument && pBDEntry->GetLocation() == eLocation) return true; bValidIter = m_xControl->iter_next_sibling(rIter); diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index 0a4f2efc62cf..e436bc9f7e0a 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -35,34 +35,40 @@ #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/layout.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <tools/stream.hxx> -#include <boost/functional/hash.hpp> +#include <o3tl/hash_combine.hxx> 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 ) ) - ,m_aDocument( rDocument ) - ,m_aLibName( aLibName ) - ,m_aName( aName ) + ,pShellHScrollBar( nullptr) + ,pShellVScrollBar( nullptr) + ,nStatus( 0) + ,m_aDocument(std::move( aDocument )) + ,m_aLibName(std::move( aLibName )) + ,m_aName(std::move( aName )) { - pShellHScrollBar = nullptr; - pShellVScrollBar = nullptr; - nStatus = 0; } BaseWindow::~BaseWindow() @@ -72,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(); @@ -145,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() { @@ -160,7 +202,6 @@ bool BaseWindow::AllowUndo() return true; } - void BaseWindow::UpdateData() { } @@ -191,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() { } @@ -258,23 +312,21 @@ bool BaseWindow::HasActiveEditor () const // style bits for DockingWindow WinBits const DockingWindow::StyleBits = WB_BORDER | WB_3DLOOK | WB_CLIPCHILDREN | - WB_MOVEABLE | WB_SIZEABLE | WB_ROLLABLE | WB_DOCKABLE; + WB_MOVEABLE | WB_SIZEABLE | WB_DOCKABLE; -DockingWindow::DockingWindow(vcl::Window* pParent, const OUString& rUIXMLDescription, const OString& rID) : - ::DockingWindow(pParent, "DockingWindow", "sfx/ui/dockingwindow.ui"), - pLayout(nullptr), - nShowCount(0) +DockingWindow::DockingWindow(vcl::Window* pParent, const OUString& rUIXMLDescription, const OUString& rID) + : ResizableDockingWindow(pParent) + , m_xBuilder(Application::CreateInterimBuilder(m_xBox.get(), rUIXMLDescription, true)) + , pLayout(nullptr) + , nShowCount(0) { - m_xVclContentArea = VclPtr<VclVBox>::Create(this); - m_xVclContentArea->Show(); - m_xBuilder.reset(Application::CreateInterimBuilder(m_xVclContentArea, rUIXMLDescription, true)); m_xContainer = m_xBuilder->weld_container(rID); } -DockingWindow::DockingWindow (Layout* pParent) : - ::DockingWindow(pParent, StyleBits), - pLayout(pParent), - nShowCount(0) +DockingWindow::DockingWindow (Layout* pParent) + : ResizableDockingWindow(pParent, StyleBits) + , pLayout(pParent) + , nShowCount(0) { } DockingWindow::~DockingWindow() @@ -286,9 +338,8 @@ void DockingWindow::dispose() { m_xContainer.reset(); m_xBuilder.reset(); - m_xVclContentArea.disposeAndClear(); pLayout.clear(); - ::DockingWindow::dispose(); + ResizableDockingWindow::dispose(); } // Sets the position and the size of the docking window. This property is saved @@ -327,12 +378,12 @@ void DockingWindow::Show (bool bShow) // = true if (bShow) { if (++nShowCount == 1) - ::DockingWindow::Show(); + ResizableDockingWindow::Show(); } else { if (--nShowCount == 0) - ::DockingWindow::Hide(); + ResizableDockingWindow::Hide(); } } @@ -345,7 +396,7 @@ void DockingWindow::Hide () bool DockingWindow::Docking( const Point& rPos, tools::Rectangle& rRect ) { - if (aDockingRect.IsInside(rPos)) + if (aDockingRect.Contains(rPos)) { rRect.SetSize(aDockingRect.GetSize()); return false; // dock @@ -361,7 +412,7 @@ bool DockingWindow::Docking( const Point& rPos, tools::Rectangle& rRect ) void DockingWindow::EndDocking( const tools::Rectangle& rRect, bool bFloatMode ) { if ( bFloatMode ) - ::DockingWindow::EndDocking( rRect, bFloatMode ); + ResizableDockingWindow::EndDocking( rRect, bFloatMode ); else { SetFloatingMode(false); @@ -587,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 { @@ -603,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 ); } } } @@ -671,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 @@ -683,16 +730,16 @@ bool LibInfo::Key::operator == (Key const& rKey) const size_t LibInfo::Key::Hash::operator () (Key const& rKey) const { std::size_t seed = 0; - boost::hash_combine(seed, rKey.m_aDocument.hashCode()); - boost::hash_combine(seed, rKey.m_aLibName.hashCode()); + o3tl::hash_combine(seed, rKey.m_aDocument.hashCode()); + o3tl::hash_combine(seed, rKey.m_aLibName.hashCode()); return seed; } 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 74d5be8542ca..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,20 +121,18 @@ 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()); } } -IMPL_LINK(BreakPointDialog, CheckBoxHdl, weld::ToggleButton&, rButton, void) +IMPL_LINK(BreakPointDialog, CheckBoxHdl, weld::Toggleable&, rButton, void) { BreakPoint* pBrk = GetSelectedBreakPoint(); if (pBrk) diff --git a/basctl/source/basicide/brkdlg.hxx b/basctl/source/basicide/brkdlg.hxx index d3674c371a55..89406d2c0c67 100644 --- a/basctl/source/basicide/brkdlg.hxx +++ b/basctl/source/basicide/brkdlg.hxx @@ -37,7 +37,7 @@ class BreakPointDialog final : public weld::GenericDialogController std::unique_ptr<weld::SpinButton> m_xNumericField; void CheckButtons(); - DECL_LINK(CheckBoxHdl, weld::ToggleButton&, void); + DECL_LINK(CheckBoxHdl, weld::Toggleable&, void); DECL_LINK(EditModifyHdl, weld::ComboBox&, void); DECL_LINK(FieldModifyHdl, weld::SpinButton&, void); DECL_LINK(ButtonHdl, weld::Button&, void); diff --git a/basctl/source/basicide/doceventnotifier.cxx b/basctl/source/basicide/doceventnotifier.cxx index 83d2ea04dff3..254c719bb5cc 100644 --- a/basctl/source/basicide/doceventnotifier.cxx +++ b/basctl/source/basicide/doceventnotifier.cxx @@ -24,13 +24,10 @@ #include <vcl/svapp.hxx> -#include <tools/diagnose_ex.h> - +#include <comphelper/compbase.hxx> +#include <comphelper/diagnose_ex.hxx> #include <comphelper/processfactory.hxx> -#include <cppuhelper/compbase.hxx> -#include <cppuhelper/basemutex.hxx> - namespace basctl { @@ -47,7 +44,7 @@ namespace basctl // DocumentEventNotifier::Impl - typedef ::cppu::WeakComponentImplHelper< XDocumentEventListener + typedef ::comphelper::WeakComponentImplHelper< XDocumentEventListener > DocumentEventNotifier_Impl_Base; namespace { @@ -62,8 +59,7 @@ namespace basctl /** impl class for DocumentEventNotifier */ - class DocumentEventNotifier::Impl :public ::cppu::BaseMutex - ,public DocumentEventNotifier_Impl_Base + class DocumentEventNotifier::Impl : public DocumentEventNotifier_Impl_Base { public: // noncopyable @@ -79,18 +75,18 @@ namespace basctl // XEventListener virtual void SAL_CALL disposing( const css::lang::EventObject& Event ) override; - // ComponentHelper - virtual void SAL_CALL disposing() override; + // WeakComponentImplHelper + virtual void disposing(std::unique_lock<std::mutex>&) override; private: /// determines whether the instance is already disposed - bool impl_isDisposed_nothrow() const { return m_pListener == nullptr; } + bool impl_isDisposed_nothrow(std::unique_lock<std::mutex>& /*rGuard*/) const { return m_pListener == nullptr; } /// disposes the instance - void impl_dispose_nothrow(); + void impl_dispose_nothrow(std::unique_lock<std::mutex>& rGuard); /// registers or revokes the instance as listener at the global event broadcaster - void impl_listenerAction_nothrow( ListenerAction _eAction ); + void impl_listenerAction_nothrow( std::unique_lock<std::mutex>& rGuard, ListenerAction _eAction ); private: DocumentEventListener* m_pListener; @@ -98,18 +94,19 @@ namespace basctl }; DocumentEventNotifier::Impl::Impl (DocumentEventListener& rListener, Reference<XModel> const& rxDocument) : - DocumentEventNotifier_Impl_Base(m_aMutex), m_pListener(&rListener), m_xModel(rxDocument) { + std::unique_lock aGuard(m_aMutex); osl_atomic_increment( &m_refCount ); - impl_listenerAction_nothrow( RegisterListener ); + impl_listenerAction_nothrow( aGuard, RegisterListener ); osl_atomic_decrement( &m_refCount ); } DocumentEventNotifier::Impl::~Impl () { - if ( !impl_isDisposed_nothrow() ) + std::unique_lock aGuard(m_aMutex); + if ( !impl_isDisposed_nothrow(aGuard) ) { acquire(); dispose(); @@ -118,10 +115,10 @@ namespace basctl void SAL_CALL DocumentEventNotifier::Impl::documentEventOccured( const DocumentEvent& _rEvent ) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); - OSL_PRECOND( !impl_isDisposed_nothrow(), "DocumentEventNotifier::Impl::notifyEvent: disposed, but still getting events?" ); - if ( impl_isDisposed_nothrow() ) + OSL_PRECOND( !impl_isDisposed_nothrow(aGuard), "DocumentEventNotifier::Impl::notifyEvent: disposed, but still getting events?" ); + if ( impl_isDisposed_nothrow(aGuard) ) return; Reference< XModel > xDocument( _rEvent.Source, UNO_QUERY ); @@ -151,20 +148,26 @@ namespace basctl if ( !_rEvent.EventName.equalsAscii( aEvent.pEventName ) ) continue; + // Listener implementations require that we hold the mutex, but to avoid lock ordering issues, + // we need to take the solar mutex before we take our own mutex. + aGuard.unlock(); + + // Listener implements require that we hold the solar mutex. + SolarMutexGuard aSolarGuard; + + // Take the lock again, so we can check our local fields. + aGuard.lock(); + if ( impl_isDisposed_nothrow(aGuard) ) + // somebody took the chance to dispose us -> bail out + return; + DocumentEventListener* pListener = m_pListener; ScriptDocument aDocument( xDocument ); - { - // the listener implementations usually require the SolarMutex, so lock it here. - // But ensure the proper order of locking the solar and the own mutex - aGuard.clear(); - SolarMutexGuard aSolarGuard; - ::osl::MutexGuard aGuard2( m_aMutex ); + // We cannot call the listener while holding our mutex because the listener + // call might trigger an event which call back into us. + aGuard.unlock(); - if ( impl_isDisposed_nothrow() ) - // somebody took the chance to dispose us -> bail out - return; + (pListener->*aEvent.listenerMethod)( aDocument ); - (m_pListener->*aEvent.listenerMethod)( aDocument ); - } break; } } @@ -172,25 +175,25 @@ namespace basctl void SAL_CALL DocumentEventNotifier::Impl::disposing( const css::lang::EventObject& /*Event*/ ) { SolarMutexGuard aSolarGuard; - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); - if ( !impl_isDisposed_nothrow() ) - impl_dispose_nothrow(); + if ( !impl_isDisposed_nothrow(aGuard) ) + impl_dispose_nothrow(aGuard); } - void SAL_CALL DocumentEventNotifier::Impl::disposing() + void DocumentEventNotifier::Impl::disposing(std::unique_lock<std::mutex>& rGuard) { - impl_listenerAction_nothrow( RemoveListener ); - impl_dispose_nothrow(); + impl_listenerAction_nothrow( rGuard, RemoveListener ); + impl_dispose_nothrow(rGuard); } - void DocumentEventNotifier::Impl::impl_dispose_nothrow() + void DocumentEventNotifier::Impl::impl_dispose_nothrow(std::unique_lock<std::mutex>& /*rGuard*/) { m_pListener = nullptr; m_xModel.clear(); } - void DocumentEventNotifier::Impl::impl_listenerAction_nothrow( ListenerAction _eAction ) + void DocumentEventNotifier::Impl::impl_listenerAction_nothrow( std::unique_lock<std::mutex>& rGuard, ListenerAction _eAction ) { try { @@ -206,7 +209,10 @@ namespace basctl void ( SAL_CALL XDocumentEventBroadcaster::*listenerAction )( const Reference< XDocumentEventListener >& ) = ( _eAction == RegisterListener ) ? &XDocumentEventBroadcaster::addDocumentEventListener : &XDocumentEventBroadcaster::removeDocumentEventListener; + + rGuard.unlock(); (xBroadcaster.get()->*listenerAction)( this ); + rGuard.lock(); } catch( const Exception& ) { diff --git a/basctl/source/basicide/docsignature.cxx b/basctl/source/basicide/docsignature.cxx index 701c9d478f1a..08d7a1ab9c13 100644 --- a/basctl/source/basicide/docsignature.cxx +++ b/basctl/source/basicide/docsignature.cxx @@ -51,10 +51,6 @@ namespace basctl m_pShell = pShell; } - DocumentSignature::~DocumentSignature() - { - } - bool DocumentSignature::supportsSignatures() const { return ( m_pShell != nullptr ); diff --git a/basctl/source/basicide/documentenumeration.cxx b/basctl/source/basicide/documentenumeration.cxx index e3acf9d4587a..d71e02139e02 100644 --- a/basctl/source/basicide/documentenumeration.cxx +++ b/basctl/source/basicide/documentenumeration.cxx @@ -27,7 +27,7 @@ #include <com/sun/star/frame/XModel2.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace basctl::docs { @@ -48,22 +48,10 @@ namespace basctl::docs { namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag; - // DocumentEnumeration_Data - struct DocumentEnumeration_Data - { - Reference< css::uno::XComponentContext > aContext; - const IDocumentDescriptorFilter* pFilter; - - DocumentEnumeration_Data( Reference< css::uno::XComponentContext > const & _rContext, const IDocumentDescriptorFilter* _pFilter ) - :aContext( _rContext ) - ,pFilter( _pFilter ) - { - } - }; - // DocumentEnumeration DocumentEnumeration::DocumentEnumeration( Reference< css::uno::XComponentContext > const & _rContext, const IDocumentDescriptorFilter* _pFilter ) - :m_pData( new DocumentEnumeration_Data( _rContext, _pFilter ) ) + : m_xContext( _rContext ) + , m_pFilter( _pFilter ) { } @@ -152,11 +140,11 @@ namespace basctl::docs { try { - const Reference< XDesktop2 > xDesktop = Desktop::create( m_pData->aContext ); + const Reference< XDesktop2 > xDesktop = Desktop::create( m_xContext ); const Reference< XFrames > xFrames( xDesktop->getFrames(), UNO_SET_THROW ); const Sequence< Reference< XFrame > > aFrames( xFrames->queryFrames( FrameSearchFlag::ALL ) ); - lcl_getDocuments_nothrow( aFrames, _out_rDocuments, m_pData->pFilter ); + lcl_getDocuments_nothrow( aFrames, _out_rDocuments, m_pFilter ); } catch( const Exception& ) { diff --git a/basctl/source/basicide/documentenumeration.hxx b/basctl/source/basicide/documentenumeration.hxx index 084a4aa0cf09..dfd4d2e8172f 100644 --- a/basctl/source/basicide/documentenumeration.hxx +++ b/basctl/source/basicide/documentenumeration.hxx @@ -51,7 +51,6 @@ namespace basctl::docs { }; - struct DocumentEnumeration_Data; /** is a helper class for enumerating documents in OOo If you need a list of all open documents in OOo, this is little bit of @@ -81,7 +80,8 @@ namespace basctl::docs { ) const; private: - std::unique_ptr< DocumentEnumeration_Data > m_pData; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + const IDocumentDescriptorFilter* m_pFilter; }; diff --git a/basctl/source/basicide/iderdll.cxx b/basctl/source/basicide/iderdll.cxx index cdcfdf24c1a8..022045050e9a 100644 --- a/basctl/source/basicide/iderdll.cxx +++ b/basctl/source/basicide/iderdll.cxx @@ -105,9 +105,9 @@ ExtraData* GetExtraData() return nullptr; } -OUString IDEResId(const char *pId) +OUString IDEResId(TranslateId aId) { - return Translate::get(pId, SfxApplication::GetModule(SfxToolsModule::Basic)->GetResLocale()); + return Translate::get(aId, SfxApplication::GetModule(SfxToolsModule::Basic)->GetResLocale()); } namespace diff --git a/basctl/source/basicide/layout.cxx b/basctl/source/basicide/layout.cxx index 8ec80e8e20a4..e6b6676ed6c6 100644 --- a/basctl/source/basicide/layout.cxx +++ b/basctl/source/basicide/layout.cxx @@ -420,8 +420,8 @@ void Layout::SplittedSide::InitSplitter (Splitter& rSplitter) rSplitter.SetSplitHdl(LINK(this, SplittedSide, SplitHdl)); // color Color aColor = rLayout.GetSettings().GetStyleSettings().GetShadowColor(); - rSplitter.SetLineColor(aColor); - rSplitter.SetFillColor(aColor); + rSplitter.GetOutDev()->SetLineColor(aColor); + rSplitter.GetOutDev()->SetFillColor(aColor); } diff --git a/basctl/source/basicide/linenumberwindow.cxx b/basctl/source/basicide/linenumberwindow.cxx index be9fe3752045..80fff0872f10 100644 --- a/basctl/source/basicide/linenumberwindow.cxx +++ b/basctl/source/basicide/linenumberwindow.cxx @@ -21,7 +21,14 @@ LineNumberWindow::LineNumberWindow(vcl::Window* pParent, ModulWindow* pModulWind , m_pModulWindow(pModulWindow) , m_nCurYOffset(0) { - SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor())); + // tdf#153853 The line number window does not need to be affected by RTL + EnableRTL(false); + + const Wallpaper aBackground(GetSettings().GetStyleSettings().GetWindowColor()); + SetBackground(aBackground); + GetWindow(GetWindowType::Border)->SetBackground(aBackground); + m_FontColor = GetSettings().GetStyleSettings().GetWindowTextColor(); + m_HighlightColor = GetSettings().GetStyleSettings().GetFaceColor(); m_nBaseWidth = GetTextWidth("8"); m_nWidth = m_nBaseWidth * 3 + m_nBaseWidth / 2; } @@ -47,9 +54,8 @@ void LineNumberWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Re if (!txtView) return; - GetParent()->Resize(); - int windowHeight = rRenderContext.GetOutputSize().Height(); + int windowWidth = rRenderContext.GetOutputSize().Width(); int nLineHeight = rRenderContext.GetTextHeight(); if (!nLineHeight) { @@ -77,9 +83,41 @@ void LineNumberWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Re m_nWidth += m_nBaseWidth; } + vcl::Font aNormalFont = rRenderContext.GetFont(); + vcl::Font aBoldFont(aNormalFont); + aBoldFont.SetWeight(FontWeight::WEIGHT_BOLD); + + sal_uInt32 nParaEnd = txtView->GetSelection().GetEnd().GetPara() + 1; sal_Int64 y = (nStartLine - 1) * static_cast<sal_Int64>(nLineHeight); + for (sal_uInt32 n = nStartLine; n <= nEndLine; ++n, y += nLineHeight) - rRenderContext.DrawText(Point(0, y - m_nCurYOffset), OUString::number(n)); + { + // Font weight for the selected lines is bold + if (n == nParaEnd) + { + tools::Rectangle aRect(Point(0, y - m_nCurYOffset), + Point(windowWidth, y - m_nCurYOffset + nLineHeight)); + rRenderContext.SetFillColor(m_HighlightColor); + rRenderContext.DrawRect(aRect); + rRenderContext.SetFont(aBoldFont); + } + else + { + rRenderContext.SetFont(aNormalFont); + } + + rRenderContext.SetTextColor(m_FontColor); + const OUString aLineNumber = OUString::number(n); + // tdf#153798 - align line numbers to the right + rRenderContext.DrawText( + Point(m_nWidth - GetTextWidth(aLineNumber) - m_nBaseWidth / 2, y - m_nCurYOffset), + aLineNumber); + } + // Restore the original font + rRenderContext.SetFont(aNormalFont); + + // Resize the parent after calculating the new width and height values + GetParent()->Resize(); } void LineNumberWindow::DataChanged(DataChangedEvent const& rDCEvt) diff --git a/basctl/source/basicide/linenumberwindow.hxx b/basctl/source/basicide/linenumberwindow.hxx index 14305116ef10..5f5ab744f0f0 100644 --- a/basctl/source/basicide/linenumberwindow.hxx +++ b/basctl/source/basicide/linenumberwindow.hxx @@ -22,6 +22,8 @@ private: int m_nWidth; tools::Long m_nCurYOffset; int m_nBaseWidth; + Color m_FontColor; + Color m_HighlightColor; virtual void DataChanged(DataChangedEvent const& rDCEvt) override; protected: diff --git a/basctl/source/basicide/localizationmgr.cxx b/basctl/source/basicide/localizationmgr.cxx index 6dd07a021d32..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 24cb210ea7e3..6b4afb79f772 100644 --- a/basctl/source/basicide/macrodlg.cxx +++ b/basctl/source/basicide/macrodlg.cxx @@ -31,7 +31,7 @@ #include <basic/sbmeth.hxx> #include <basic/sbmod.hxx> #include <com/sun/star/script/XLibraryContainer2.hpp> - +#include <sal/log.hxx> #include <sfx2/app.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/frame.hxx> @@ -122,7 +122,8 @@ MacroChooser::~MacroChooser() void MacroChooser::StoreMacroDescription() { - m_xBasicBox->get_selected(m_xBasicBoxIter.get()); + if (!m_xBasicBox->get_selected(m_xBasicBoxIter.get())) + return; EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get()); OUString aMethodName; if (m_xMacroBox->get_selected(m_xMacroBoxIter.get())) @@ -141,6 +142,9 @@ void MacroChooser::StoreMacroDescription() void MacroChooser::RestoreMacroDescription() { + // The following call is a workaround to ensure the last used macro is scrolled to in kf5 + m_xDialog->resize_to_request(); + EntryDescriptor aDesc; if (Shell* pShell = GetShell()) { @@ -291,7 +295,11 @@ void MacroChooser::DeleteMacro() SbMethod* MacroChooser::CreateMacro() { SbMethod* pMethod = nullptr; - m_xBasicBox->get_cursor(m_xBasicBoxIter.get()); + if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter)) + { + SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback"); + return nullptr; + } EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get()); const ScriptDocument& aDocument( aDesc.GetDocument() ); OSL_ENSURE( aDocument.isAlive(), "MacroChooser::CreateMacro: no document!" ); @@ -470,8 +478,9 @@ IMPL_LINK_NOARG(MacroChooser, MacroSelectHdl, weld::TreeView&, void) IMPL_LINK_NOARG(MacroChooser, BasicSelectHdl, weld::TreeView&, void) { - m_xBasicBox->get_cursor(m_xBasicBoxIter.get()); - SbModule* pModule = m_xBasicBox->FindModule(m_xBasicBoxIter.get()); + SbModule* pModule = nullptr; + if (m_xBasicBox->get_cursor(m_xBasicBoxIter.get())) + pModule = m_xBasicBox->FindModule(m_xBasicBoxIter.get()); m_xMacroBox->clear(); if (pModule) { @@ -479,10 +488,10 @@ IMPL_LINK_NOARG(MacroChooser, BasicSelectHdl, weld::TreeView&, void) m_xMacroBox->freeze(); - sal_uInt32 nMacroCount = pModule->GetMethods()->Count32(); + sal_uInt32 nMacroCount = pModule->GetMethods()->Count(); for ( sal_uInt32 iMeth = 0; iMeth < nMacroCount; iMeth++ ) { - SbMethod* pMethod = static_cast<SbMethod*>(pModule->GetMethods()->Get32( iMeth )); + SbMethod* pMethod = static_cast<SbMethod*>(pModule->GetMethods()->Get(iMeth)); assert(pMethod && "Method not found!"); if (pMethod->IsHidden()) continue; @@ -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 e04558a42e7f..cfb9adf03553 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -38,13 +38,13 @@ #include <svl/stritem.hxx> #include <tools/debug.hxx> #include <tools/urlobj.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <com/sun/star/io/Pipe.hpp> #include <com/sun/star/ui/dialogs/XFilePicker3.hpp> -#include <com/sun/star/ui/dialogs/FolderPicker.hpp> +#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/script/DocumentScriptLibraryContainer.hpp> #include <com/sun/star/script/DocumentDialogLibraryContainer.hpp> @@ -63,9 +63,9 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> #include <cppuhelper/implbase.hxx> +#include <o3tl/string_view.hxx> #include <cassert> -#include <string_view> namespace basctl { @@ -92,9 +92,9 @@ public: { if ( m_xHandler.is() ) { - script::ModuleSizeExceededRequest aModSizeException; - if ( rRequest->getRequest() >>= aModSizeException ) - m_xHandler->handle( rRequest ); + script::ModuleSizeExceededRequest aModSizeException; + if ( rRequest->getRequest() >>= aModSizeException ) + m_xHandler->handle( rRequest ); } } }; @@ -103,12 +103,12 @@ public: namespace { - int FindEntry(const weld::TreeView& rBox, const OUString& rName) + int FindEntry(const weld::TreeView& rBox, std::u16string_view rName) { int nCount = rBox.n_children(); for (int i = 0; i < nCount; ++i) { - if (rName.equalsIgnoreAsciiCase(rBox.get_text(i, 0))) + if (o3tl::equalsIgnoreAsciiCase(rName, rBox.get_text(i, 0))) return i; } return -1; @@ -153,12 +153,24 @@ NewObjectDialog::NewObjectDialog(weld::Window * pParent, ObjectMode eMode, bool } // GotoLineDialog -GotoLineDialog::GotoLineDialog(weld::Window* pParent ) +GotoLineDialog::GotoLineDialog(weld::Window* pParent, sal_uInt32 nCurLine, sal_uInt32 nLineCount) : GenericDialogController(pParent, "modules/BasicIDE/ui/gotolinedialog.ui", "GotoLineDialog") - , m_xEdit(m_xBuilder->weld_entry("entry")) + , m_xSpinButton(m_xBuilder->weld_spin_button("spin")) + , m_xLineCount(m_xBuilder->weld_label("line_count")) , m_xOKButton(m_xBuilder->weld_button("ok")) + , m_nCurLine(nCurLine) + , m_nLineCount(nLineCount) { - m_xEdit->grab_focus(); + // Adjust line count label + OUString sLabel = m_xLineCount->get_label(); + m_xLineCount->set_label(sLabel.replaceFirst("$1", OUString::number(m_nLineCount))); + + // Initialize the spin button + m_xSpinButton->set_text(OUString::number(m_nCurLine)); + m_xSpinButton->set_range(1, m_nLineCount); + m_xSpinButton->grab_focus(); + m_xSpinButton->select_region(0, -1); + m_xOKButton->connect_clicked(LINK(this, GotoLineDialog, OkButtonHandler)); } @@ -168,15 +180,22 @@ GotoLineDialog::~GotoLineDialog() sal_Int32 GotoLineDialog::GetLineNumber() const { - return m_xEdit->get_text().toInt32(); + return m_xSpinButton->get_text().toInt32(); } IMPL_LINK_NOARG(GotoLineDialog, OkButtonHandler, weld::Button&, void) { - if (GetLineNumber()) + // The number must be in the range between 1 and the number of lines in the module + sal_Int32 nNumber = GetLineNumber(); + if (nNumber && nNumber >= 1 && nNumber <= static_cast<sal_Int32>(m_nLineCount)) + { m_xDialog->response(RET_OK); + } else - m_xEdit->select_region(0, -1); + { + m_xSpinButton->set_text(OUString::number(m_nCurLine)); + m_xSpinButton->select_region(0, -1); + } } // ExportDialog @@ -346,7 +365,7 @@ LibPage::~LibPage() const sal_Int32 nCount = m_xBasicsBox->get_count(); for (sal_Int32 i = 0; i < nCount; ++i) { - DocumentEntry* pEntry = reinterpret_cast<DocumentEntry*>(m_xBasicsBox->get_id(i).toInt64()); + DocumentEntry* pEntry = weld::fromId<DocumentEntry*>(m_xBasicsBox->get_id(i)); delete pEntry; } } @@ -461,10 +480,10 @@ IMPL_LINK( LibPage, ButtonHdl, weld::Button&, rButton, void ) { Shell* pShell = GetShell(); if (pShell) - pShell->GetViewFrame()->GetWindow().EnterWait(); + pShell->GetViewFrame().GetWindow().EnterWait(); xModLibContainer->loadLibrary( aLibName ); if (pShell) - pShell->GetViewFrame()->GetWindow().LeaveWait(); + pShell->GetViewFrame().GetWindow().LeaveWait(); } // load dialog library (if not loaded) @@ -473,10 +492,10 @@ IMPL_LINK( LibPage, ButtonHdl, weld::Button&, rButton, void ) { Shell* pShell = GetShell(); if (pShell) - pShell->GetViewFrame()->GetWindow().EnterWait(); + pShell->GetViewFrame().GetWindow().EnterWait(); xDlgLibContainer->loadLibrary( aLibName ); if (pShell) - pShell->GetViewFrame()->GetWindow().LeaveWait(); + pShell->GetViewFrame().GetWindow().LeaveWait(); } // check, if library is password protected @@ -549,6 +568,7 @@ void LibPage::InsertLib() Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); // file open dialog sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, m_pDialog->getDialog()); + aDlg.SetContext(sfx2::FileDialogHelper::BasicInsertLib); const Reference <XFilePicker3>& xFP = aDlg.GetFilePicker(); xFP->setTitle(IDEResId(RID_STR_APPENDLIBS)); @@ -568,16 +588,6 @@ void LibPage::InsertLib() ";*.sti;*.otp" // presentation template ";*.sxm;*.odf" ); // formula - // set display directory and filter - OUString aPath(GetExtraData()->GetAddLibPath()); - if ( !aPath.isEmpty() ) - xFP->setDisplayDirectory( aPath ); - else - { - // macro path from configuration management - xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() ); - } - OUString aLastFilter(GetExtraData()->GetAddLibFilter()); if ( !aLastFilter.isEmpty() ) xFP->setCurrentFilter( aLastFilter ); @@ -631,28 +641,35 @@ void LibPage::InsertLib() Sequence< OUString > aLibNames = GetMergedLibraryNames( xModLibContImport, xDlgLibContImport ); sal_Int32 nLibCount = aLibNames.getLength(); - const OUString* pLibNames = aLibNames.getConstArray(); - for ( sal_Int32 i = 0 ; i < nLibCount ; i++ ) + if (nLibCount) { // library import dialog - if (!xLibDlg) + xLibDlg = std::make_shared<LibDialog>(m_pDialog->getDialog()); + xLibDlg->SetStorageName(aURLObj.getName()); + weld::TreeView& rView = xLibDlg->GetLibBox(); + rView.make_unsorted(); + rView.freeze(); + + const OUString* pLibNames = aLibNames.getConstArray(); + for (sal_Int32 i = 0 ; i < nLibCount; ++i) { - xLibDlg = std::make_shared<LibDialog>(m_pDialog->getDialog()); - xLibDlg->SetStorageName( aURLObj.getName() ); + // libbox entries + OUString aLibName( pLibNames[ i ] ); + if ( !( ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) && xModLibContImport->isLibraryLink( aLibName ) ) || + ( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aLibName ) && xDlgLibContImport->isLibraryLink( aLibName ) ) ) ) + { + rView.append(); + const int nRow = rView.n_children() - 1; + rView.set_toggle(nRow, TRISTATE_TRUE); + rView.set_text(nRow, aLibName, 0); + } } - // libbox entries - OUString aLibName( pLibNames[ i ] ); - if ( !( ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) && xModLibContImport->isLibraryLink( aLibName ) ) || - ( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aLibName ) && xDlgLibContImport->isLibraryLink( aLibName ) ) ) ) - { - weld::TreeView& rView = xLibDlg->GetLibBox(); - rView.append(); - const int nRow = rView.n_children() - 1; - rView.set_toggle(nRow, TRISTATE_TRUE); - rView.set_text(nRow, aLibName, 0); - rView.set_cursor(rView.find_text(aLibName)); - } + rView.thaw(); + rView.make_sorted(); + + if (rView.n_children()) + rView.set_cursor(0); } if (!xLibDlg) @@ -1005,6 +1022,7 @@ void LibPage::ExportAsPackage( const OUString& aLibName ) { // file open dialog sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, FileDialogFlags::NONE, m_pDialog->getDialog()); + aDlg.SetContext(sfx2::FileDialogHelper::BasicExportPackage); const Reference <XFilePicker3>& xFP = aDlg.GetFilePicker(); Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); @@ -1017,17 +1035,6 @@ void LibPage::ExportAsPackage( const OUString& aLibName ) OUString aTitle(IDEResId(RID_STR_PACKAGE_BUNDLE)); xFP->appendFilter( aTitle, "*.oxt" ); // library files - // set display directory and filter - OUString aPath = GetExtraData()->GetAddLibPath(); - if ( !aPath.isEmpty() ) - { - xFP->setDisplayDirectory( aPath ); - } - else - { - // macro path from configuration management - xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() ); - } xFP->setCurrentFilter( aTitle ); if ( xFP->execute() != RET_OK ) @@ -1038,7 +1045,7 @@ void LibPage::ExportAsPackage( const OUString& aLibName ) Sequence< OUString > aFiles = xFP->getSelectedFiles(); INetURLObject aURL( aFiles[0] ); if( aURL.getExtension().isEmpty() ) - aURL.setExtension( "oxt" ); + aURL.setExtension( u"oxt" ); OUString aPackageURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); @@ -1071,7 +1078,7 @@ void LibPage::ExportAsPackage( const OUString& aLibName ) OUString(), NameClash::OVERWRITE ); INetURLObject aMetaInfInetObj( aTmpPath ); - aMetaInfInetObj.insertName( "META-INF", + aMetaInfInetObj.insertName( u"META-INF", true, INetURLObject::LAST_SEGMENT, INetURLObject::EncodeMechanism::All ); OUString aMetaInfFolder = aMetaInfInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ); if( xSFA->exists( aMetaInfFolder ) ) @@ -1095,7 +1102,7 @@ void LibPage::ExportAsPackage( const OUString& aLibName ) xPipe, Sequence< Sequence<beans::PropertyValue> >( manifest.data(), manifest.size() ) ); - aMetaInfInetObj.insertName( "manifest.xml", + aMetaInfInetObj.insertName( u"manifest.xml", true, INetURLObject::LAST_SEGMENT, INetURLObject::EncodeMechanism::All ); // write buffered pipe data to content: @@ -1117,7 +1124,7 @@ void LibPage::ExportAsBasic( const OUString& aLibName ) { // Folder picker Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); - Reference< XFolderPicker2 > xFolderPicker = FolderPicker::create(xContext); + Reference< XFolderPicker2 > xFolderPicker = sfx2::createFolderPicker(xContext, m_pDialog->getDialog()); Reference< task::XInteractionHandler2 > xHandler( task::InteractionHandler::createWithParent(xContext, nullptr) ); xFolderPicker->setTitle(IDEResId(RID_STR_EXPORTBASIC)); @@ -1197,13 +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; @@ -1232,13 +1239,13 @@ 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_); } -void LibPage::ImpInsertLibEntry( const OUString& rLibName, sal_uLong nPos ) +void LibPage::ImpInsertLibEntry( const OUString& rLibName, int nPos ) { // check, if library is password protected bool bProtected = false; @@ -1332,6 +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, @@ -1350,8 +1373,8 @@ void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument, BrowseMode nMode = pBasicBox->GetMode(); bool bDlgMode = ( nMode & BrowseMode::Dialogs ) && !( nMode & BrowseMode::Modules ); - const auto sId = bDlgMode ? std::u16string_view(u"" RID_BMP_DLGLIB) : std::u16string_view(u"" RID_BMP_MODLIB); - pBasicBox->AddEntry(aLibName, OUString(sId), xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_LIBRARY)); + const auto sId = bDlgMode ? RID_BMP_DLGLIB : RID_BMP_MODLIB; + pBasicBox->AddEntry(aLibName, sId, xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_LIBRARY)); pBasicBox->AddEntry(aModName, RID_BMP_MODULE, xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_MODULE)); pBasicBox->set_cursor(*xRootEntry); pBasicBox->select(*xRootEntry); diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index 9f5daa34d644..dcdac9fbd645 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -31,6 +31,7 @@ #include <basic/basmgr.hxx> #include <com/sun/star/script/XLibraryContainerPassword.hpp> #include <com/sun/star/script/XLibraryContainer2.hpp> +#include <com/sun/star/frame/XController.hpp> #include <comphelper/processfactory.hxx> #include <sfx2/app.hxx> #include <sfx2/dispatch.hxx> @@ -42,7 +43,7 @@ #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <xmlscript/xmldlg_imexp.hxx> #include <com/sun/star/uno/XComponentContext.hpp> @@ -182,8 +183,23 @@ void Shell::CopyDialogResources( io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.isDocument() ? rDestDoc.getDocument() : Reference< frame::XModel >() ); } +void OrganizeDialog::SetCurrentEntry(const css::uno::Reference<css::frame::XFrame>& xDocFrame) +{ + if (!xDocFrame) + return; + Reference<css::frame::XController> xController(xDocFrame->getController()); + if (!xController) + return; + Reference<css::frame::XModel> xModel(xController->getModel()); + if (!xModel) + return; + EntryDescriptor aDesc(ScriptDocument(xModel), LIBRARY_LOCATION_DOCUMENT, OUString(), OUString(), OUString(), OBJ_TYPE_DOCUMENT); + m_xModulePage->SetCurrentEntry(aDesc); + m_xDialogPage->SetCurrentEntry(aDesc); +} + // OrganizeDialog -OrganizeDialog::OrganizeDialog(weld::Window* pParent, sal_Int16 tabId ) +OrganizeDialog::OrganizeDialog(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 tabId) : GenericDialogController(pParent, "modules/BasicIDE/ui/organizedialog.ui", "OrganizeDialog") , m_xTabCtrl(m_xBuilder->weld_notebook("tabcontrol")) , m_xModulePage(new ObjectPage(m_xTabCtrl->get_page("modules"), "ModulePage", BrowseMode::Modules, this)) @@ -192,7 +208,9 @@ OrganizeDialog::OrganizeDialog(weld::Window* pParent, sal_Int16 tabId ) { m_xTabCtrl->connect_enter_page(LINK(this, OrganizeDialog, ActivatePageHdl)); - OString sPage; + SetCurrentEntry(xDocFrame); + + OUString sPage; if (tabId == 0) sPage = "modules"; else if (tabId == 1) @@ -206,7 +224,7 @@ OrganizeDialog::OrganizeDialog(weld::Window* pParent, sal_Int16 tabId ) pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES ); } -IMPL_LINK(OrganizeDialog, ActivatePageHdl, const OString&, rPage, void) +IMPL_LINK(OrganizeDialog, ActivatePageHdl, const OUString&, rPage, void) { if (rPage == "modules") m_xModulePage->ActivatePage(); @@ -220,7 +238,7 @@ OrganizeDialog::~OrganizeDialog() { } -OrganizePage::OrganizePage(weld::Container* pParent, const OUString& rUIFile, const OString &rName, OrganizeDialog* pDialog) +OrganizePage::OrganizePage(weld::Container* pParent, const OUString& rUIFile, const OUString &rName, OrganizeDialog* pDialog) : m_pDialog(pDialog) , m_xBuilder(Application::CreateBuilder(pParent, rUIFile)) , m_xContainer(m_xBuilder->weld_container(rName)) @@ -246,6 +264,10 @@ private: if (!pSource) return DND_ACTION_NONE; + // tdf#145722 only return a DND_ACTION_MOVE possibility if that + // is requested as an option + const bool bCheckForMove = rEvt.mnAction & DND_ACTION_MOVE; + sal_Int8 nMode = DND_ACTION_NONE; std::unique_ptr<weld::TreeIter> xEntry(pSource->make_iterator()); @@ -255,28 +277,31 @@ private: if (nDepth >= 2) { nMode = DND_ACTION_COPY; - EntryDescriptor aDesc = m_rTreeView.GetEntryDescriptor(xEntry.get()); - const ScriptDocument& aDocument( aDesc.GetDocument() ); - const OUString& aLibName( aDesc.GetLibName() ); - // allow MOVE mode only for libraries, which are not readonly - Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); - Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); - if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) || - ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) ) + if (bCheckForMove) { - // Only allow copy for localized libraries - bool bAllowMove = true; - if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) ) + EntryDescriptor aDesc = m_rTreeView.GetEntryDescriptor(xEntry.get()); + const ScriptDocument& aDocument( aDesc.GetDocument() ); + const OUString& aLibName( aDesc.GetLibName() ); + // allow MOVE mode only for libraries, which are not readonly + Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); + Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); + if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) || + ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) ) { - // Get StringResourceManager - Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, aLibName, true ) ); - Reference< XStringResourceManager > xSourceMgr = - LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib ); - if( xSourceMgr.is() ) - bAllowMove = ( xSourceMgr->getLocales().getLength() == 0 ); + // Only allow copy for localized libraries + bool bAllowMove = true; + if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) ) + { + // Get StringResourceManager + Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, aLibName, true ) ); + Reference< XStringResourceManager > xSourceMgr = + LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib ); + if( xSourceMgr.is() ) + bAllowMove = ( xSourceMgr->getLocales().getLength() == 0 ); + } + if( bAllowMove ) + nMode |= DND_ACTION_MOVE; } - if( bAllowMove ) - nMode |= DND_ACTION_MOVE; } } } @@ -369,7 +394,7 @@ private: return DND_ACTION_NONE; } - void NotifyCopyingMoving(weld::TreeIter& rTarget, bool bMove) + void NotifyCopyingMoving(const weld::TreeIter& rTarget, bool bMove) { sal_uInt16 nDepth = m_rTreeView.get_iter_depth(rTarget); std::unique_ptr<weld::TreeIter> xNewParent(m_rTreeView.make_iterator(&rTarget)); @@ -390,7 +415,7 @@ private: // get source shell, library name and module/dialog name std::unique_ptr<weld::TreeIter> xSelected(m_rTreeView.make_iterator()); if (!m_rTreeView.get_selected(xSelected.get())) - xSelected.reset(); + return; EntryDescriptor aSourceDesc = m_rTreeView.GetEntryDescriptor(xSelected.get()); const ScriptDocument& rSourceDoc( aSourceDesc.GetDocument() ); const OUString& aSourceLibName( aSourceDesc.GetLibName() ); @@ -496,6 +521,13 @@ private: OUString sText(m_rTreeView.get_text(*xSelected)); OUString sId(m_rTreeView.get_id(*xSelected)); + /// if copying then clone the userdata + if (Entry* pEntry = bMove ? nullptr : weld::fromId<Entry*>(sId)) + { + assert(pEntry->GetType() != OBJ_TYPE_DOCUMENT); + std::unique_ptr<Entry> xNewUserData(std::make_unique<Entry>(*pEntry)); + sId = weld::toId(xNewUserData.release()); + } std::unique_ptr<weld::TreeIter> xRet(m_rTreeView.make_iterator()); m_rTreeView.get_widget().insert(xNewParent.get(), nNewChildPos, &sText, &sId, nullptr, nullptr, false, xRet.get()); if (eType == OBJ_TYPE_MODULE) @@ -530,8 +562,8 @@ public: }; // ObjectPage -ObjectPage::ObjectPage(weld::Container* pParent, const OString &rName, BrowseMode nMode, OrganizeDialog* pDialog) - : OrganizePage(pParent, "modules/BasicIDE/ui/" + OStringToOUString(rName, RTL_TEXTENCODING_UTF8).toAsciiLowerCase() + ".ui", +ObjectPage::ObjectPage(weld::Container* pParent, const OUString &rName, BrowseMode nMode, OrganizeDialog* pDialog) + : OrganizePage(pParent, "modules/BasicIDE/ui/" + rName.toAsciiLowerCase() + ".ui", rName, pDialog) , m_xBasicBox(new SbTreeListBox(m_xBuilder->weld_tree_view("library"), pDialog->getDialog())) , m_xEditButton(m_xBuilder->weld_button("edit")) @@ -562,6 +594,9 @@ ObjectPage::ObjectPage(weld::Container* pParent, const OString &rName, BrowseMod } m_xDropTarget.reset(new SbTreeListBoxDropTarget(*m_xBasicBox)); + // tdf#145722 explicitly claim COPY and MOVE are options + rtl::Reference<TransferDataContainer> xHelper(new TransferDataContainer); + m_xBasicBox->get_widget().enable_drag_source(xHelper, DND_ACTION_COPYMOVE); m_xBasicBox->connect_editing(LINK(this, ObjectPage, EditingEntryHdl), LINK(this, ObjectPage, EditedEntryHdl)); @@ -685,7 +720,7 @@ IMPL_LINK(ObjectPage, ButtonHdl, weld::Button&, rButton, void) std::unique_ptr<weld::TreeIter> xParentEntry(m_xBasicBox->make_iterator(xCurEntry.get())); if (m_xBasicBox->iter_parent(*xParentEntry)) { - DocumentEntry* pDocumentEntry = reinterpret_cast<DocumentEntry*>(m_xBasicBox->get_id(*xParentEntry).toInt64()); + DocumentEntry* pDocumentEntry = weld::fromId<DocumentEntry*>(m_xBasicBox->get_id(*xParentEntry)); if (pDocumentEntry) aDocument = pDocumentEntry->GetDocument(); } @@ -843,6 +878,8 @@ void ObjectPage::DeleteCurrent() if (!m_xBasicBox->get_cursor(xCurEntry.get())) xCurEntry.reset(); DBG_ASSERT( xCurEntry, "No current entry!" ); + if (!xCurEntry) + return; EntryDescriptor aDesc( m_xBasicBox->GetEntryDescriptor( xCurEntry.get() ) ); const ScriptDocument& aDocument( aDesc.GetDocument() ); DBG_ASSERT( aDocument.isAlive(), "ObjectPage::DeleteCurrent: no document!" ); diff --git a/basctl/source/basicide/moduldlg.hxx b/basctl/source/basicide/moduldlg.hxx index b7fb13d8901e..c6ff166c5bb7 100644 --- a/basctl/source/basicide/moduldlg.hxx +++ b/basctl/source/basicide/moduldlg.hxx @@ -24,7 +24,6 @@ #include <string_view> #include <bastype2.hxx> -#include <tools/solar.h> #include <vcl/weld.hxx> #include <com/sun/star/task/XInteractionHandler.hpp> @@ -60,11 +59,15 @@ public: class GotoLineDialog : public weld::GenericDialogController { - std::unique_ptr<weld::Entry> m_xEdit; + std::unique_ptr<weld::SpinButton> m_xSpinButton; + std::unique_ptr<weld::Label> m_xLineCount; std::unique_ptr<weld::Button> m_xOKButton; + sal_uInt32 m_nCurLine; + sal_uInt32 m_nLineCount; + DECL_LINK(OkButtonHandler, weld::Button&, void); public: - explicit GotoLineDialog(weld::Window* pParent); + explicit GotoLineDialog(weld::Window* pParent, sal_uInt32 nCurLine, sal_uInt32 nLineCount); virtual ~GotoLineDialog() override; sal_Int32 GetLineNumber() const; }; @@ -116,7 +119,7 @@ protected: std::unique_ptr<weld::Builder> m_xBuilder; std::unique_ptr<weld::Container> m_xContainer; - OrganizePage(weld::Container* pParent, const OUString& rUIFile, const OString &rName, OrganizeDialog* pDialog); + OrganizePage(weld::Container* pParent, const OUString& rUIFile, const OUString &rName, OrganizeDialog* pDialog); virtual ~OrganizePage(); public: @@ -148,9 +151,11 @@ class ObjectPage final : public OrganizePage void EndTabDialog(); public: - ObjectPage(weld::Container* pParent, const OString& rName, BrowseMode nMode, OrganizeDialog* pDialog); + ObjectPage(weld::Container* pParent, const OUString& rName, BrowseMode nMode, OrganizeDialog* pDialog); virtual ~ObjectPage() override; + void SetCurrentEntry(const EntryDescriptor& rDesc) { m_xBasicBox->SetCurrentEntry(rDesc); } + virtual void ActivatePage() override; }; @@ -189,7 +194,7 @@ class LibPage final : public OrganizePage void FillListBox(); void InsertListBoxEntry( const ScriptDocument& rDocument, LibraryLocation eLocation ); void SetCurLib(); - void ImpInsertLibEntry( const OUString& rLibName, sal_uLong nPos ); + void ImpInsertLibEntry( const OUString& rLibName, int nPos ); public: explicit LibPage(weld::Container* pParent, OrganizeDialog* pDialog); @@ -205,10 +210,12 @@ private: std::unique_ptr<ObjectPage> m_xDialogPage; std::unique_ptr<LibPage> m_xLibPage; - DECL_LINK(ActivatePageHdl, const OString&, void); + DECL_LINK(ActivatePageHdl, const OUString&, void); + + void SetCurrentEntry(const css::uno::Reference<css::frame::XFrame>& xDocFrame); public: - OrganizeDialog(weld::Window* pParent, sal_Int16 tabId); + OrganizeDialog(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 tabId); virtual ~OrganizeDialog() override; }; diff --git a/basctl/source/basicide/sbxitem.cxx b/basctl/source/basicide/sbxitem.cxx index db012ec6c4fa..39c86b1d0893 100644 --- a/basctl/source/basicide/sbxitem.cxx +++ b/basctl/source/basicide/sbxitem.cxx @@ -19,37 +19,38 @@ #include <sbxitem.hxx> #include <sal/log.hxx> +#include <utility> namespace basctl { SfxPoolItem* SbxItem::CreateDefault() { SAL_WARN( "basctl.basicide", "No SbxItem factory available"); return nullptr; } SbxItem::SbxItem ( sal_uInt16 nWhichItem, - ScriptDocument const& rDocument, - OUString const& aLibName, - OUString const& aName, + ScriptDocument aDocument, + OUString aLibName, + OUString aName, ItemType eType ) : SfxPoolItem(nWhichItem), - m_aDocument(rDocument), - m_aLibName(aLibName), - m_aName(aName), + m_aDocument(std::move(aDocument)), + m_aLibName(std::move(aLibName)), + m_aName(std::move(aName)), m_eType(eType) { } SbxItem::SbxItem ( sal_uInt16 nWhichItem, - ScriptDocument const& rDocument, - OUString const& aLibName, - OUString const& aName, - OUString const& aMethodName, + ScriptDocument aDocument, + OUString aLibName, + OUString aName, + OUString aMethodName, ItemType eType ) : SfxPoolItem(nWhichItem), - m_aDocument(rDocument), - m_aLibName(aLibName), - m_aName(aName), - m_aMethodName(aMethodName), + m_aDocument(std::move(aDocument)), + m_aLibName(std::move(aLibName)), + m_aName(std::move(aName)), + m_aMethodName(std::move(aMethodName)), m_eType(eType) { } diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx index 61c2747d5eb3..c435d7a57da7 100644 --- a/basctl/source/basicide/scriptdocument.cxx +++ b/basctl/source/basicide/scriptdocument.cxx @@ -51,7 +51,8 @@ #include <i18nlangtag/languagetag.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <config_folders.h> #include <tools/debug.hxx> #include <comphelper/documentinfo.hxx> @@ -509,25 +510,24 @@ namespace basctl bool ScriptDocument::Impl::removeModuleOrDialog( LibraryContainerType _eType, const OUString& _rLibName, const OUString& _rModuleName ) { OSL_ENSURE( isValid(), "ScriptDocument::Impl::removeModuleOrDialog: invalid!" ); - if ( isValid() ) + if ( !isValid() ) + return false; + try { - try - { - Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, true ) ); - if ( xLib.is() ) - { - xLib->removeByName( _rModuleName ); - Reference< XVBAModuleInfo > xVBAModuleInfo(xLib, UNO_QUERY); - if(xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo(_rModuleName)) - xVBAModuleInfo->removeModuleInfo(_rModuleName); - return true; - } - } - catch( const Exception& ) + Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, true ) ); + if ( xLib.is() ) { - DBG_UNHANDLED_EXCEPTION("basctl.basicide"); + xLib->removeByName( _rModuleName ); + Reference< XVBAModuleInfo > xVBAModuleInfo(xLib, UNO_QUERY); + if(xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo(_rModuleName)) + xVBAModuleInfo->removeModuleInfo(_rModuleName); + return true; } } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("basctl.basicide"); + } return false; } @@ -928,10 +928,9 @@ namespace basctl } else if ( aScheme.equalsIgnoreAsciiCase("vnd.sun.star.pkg") ) { - OUString aAuthority = xUriRef->getAuthority(); - if ( aAuthority.matchIgnoreAsciiCase("vnd.sun.star.expand:") ) + OUString aDecodedURL = xUriRef->getAuthority(); + if (aDecodedURL.startsWithIgnoreAsciiCase("vnd.sun.star.expand:", &aDecodedURL)) { - OUString aDecodedURL( aAuthority.copy( sizeof ( "vnd.sun.star.expand:" ) - 1 ) ); aDecodedURL = ::rtl::Uri::decode( aDecodedURL, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); Reference< XMacroExpander > xMacroExpander = theMacroExpander::get(xContext); aFileURL = xMacroExpander->expandMacros( aDecodedURL ); @@ -946,9 +945,9 @@ namespace basctl OSL_VERIFY( aFileItem.getFileStatus( aFileStatus ) == ::osl::FileBase::E_None ); OUString aCanonicalFileURL( aFileStatus.getFileURL() ); - if( aCanonicalFileURL.indexOf( "share/basic" ) >= 0 || - aCanonicalFileURL.indexOf( "share/uno_packages" ) >= 0 || - aCanonicalFileURL.indexOf( "share/extensions" ) >= 0 ) + if( aCanonicalFileURL.indexOf( LIBO_SHARE_FOLDER "/basic" ) >= 0 || + aCanonicalFileURL.indexOf( LIBO_SHARE_FOLDER "/uno_packages" ) >= 0 || + aCanonicalFileURL.indexOf( LIBO_SHARE_FOLDER "/extensions" ) >= 0 ) bIsShared = true; } } @@ -1213,7 +1212,8 @@ namespace basctl auto const sort = comphelper::string::NaturalStringSorter( comphelper::getProcessComponentContext(), Application::GetSettings().GetUILanguageTag().getLocale()); - std::sort(aModuleNames.begin(), aModuleNames.end(), + auto [begin, end] = asNonConstRange(aModuleNames); + std::sort(begin, end, [&sort](const OUString& rLHS, const OUString& rRHS) { return sort.compare(rLHS, rRHS) < 0; }); @@ -1227,7 +1227,7 @@ namespace basctl OUString aBaseName = _eType == E_SCRIPTS ? OUString("Module") : OUString("Dialog"); - Sequence< OUString > aUsedNames( getObjectNames( _eType, _rLibName ) ); + const Sequence< OUString > aUsedNames( getObjectNames( _eType, _rLibName ) ); std::set< OUString > aUsedNamesCheck( aUsedNames.begin(), aUsedNames.end() ); bool bValid = false; diff --git a/basctl/source/basicide/textwindowpeer.cxx b/basctl/source/basicide/textwindowpeer.cxx index 8375f353f8a3..421468a27918 100644 --- a/basctl/source/basicide/textwindowpeer.cxx +++ b/basctl/source/basicide/textwindowpeer.cxx @@ -27,6 +27,7 @@ #include <toolkit/awt/vclxwindow.hxx> #include <vcl/texteng.hxx> #include <vcl/textview.hxx> +#include <vcl/window.hxx> #include "textwindowpeer.hxx" namespace { @@ -61,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 f22634935fcc..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; @@ -59,13 +94,13 @@ uno::Any SAL_CALL SIDEModel::queryInterface( const uno::Type& rType ) return aRet; } -void SAL_CALL SIDEModel::acquire() throw() +void SAL_CALL SIDEModel::acquire() noexcept { SolarMutexGuard aGuard; OWeakObject::acquire(); } -void SAL_CALL SIDEModel::release() throw() +void SAL_CALL SIDEModel::release() noexcept { SolarMutexGuard aGuard; OWeakObject::release(); @@ -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 23b458fd8220..9b0289032660 100644 --- a/basctl/source/basicide/unomodel.hxx +++ b/basctl/source/basicide/unomodel.hxx @@ -35,8 +35,8 @@ public: //XInterface virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; - virtual void SAL_CALL acquire( ) throw() override; - virtual void SAL_CALL release( ) throw() override; + virtual void SAL_CALL acquire( ) noexcept override; + virtual void SAL_CALL release( ) noexcept override; //XTypeProvider virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; @@ -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 f99dab40d4c3..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,10 +44,10 @@ #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> +#include <osl/diagnose.h> namespace basctl { @@ -57,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 @@ -181,14 +182,20 @@ DlgEditor::DlgEditor ( ,pVScroll(nullptr) ,pDlgEdModel(new DlgEdModel()) ,pDlgEdPage(new DlgEdPage(*pDlgEdModel)) - ,m_ClipboardDataFlavors(1) - ,m_ClipboardDataFlavorsResource(2) + // set clipboard data flavors + ,m_ClipboardDataFlavors{ { /* MimeType */ "application/vnd.sun.xml.dialog", + /* HumanPresentableName */ "Dialog 6.0", + /* DataType */ cppu::UnoType<Sequence< sal_Int8 >>::get() } } + ,m_ClipboardDataFlavorsResource{ m_ClipboardDataFlavors[0], + { /* MimeType */ "application/vnd.sun.xml.dialogwithresource", + /* HumanPresentableName */ "Dialog 8.0", + /* DataType */ cppu::UnoType<Sequence< sal_Int8 >>::get() } } ,pObjFac(new DlgEdFactory(xModel)) ,rWindow(rWindow_) ,pFunc(new DlgEdFuncSelect(*this)) ,rLayout(rLayout_) ,eMode( DlgEditor::SELECT ) - ,eActObj( OBJ_DLG_PUSHBUTTON ) + ,eActObj( SdrObjKind::BasicDialogPushButton ) ,bFirstDraw(false) ,bCreateOK(true) ,bDialogModelChanged(false) @@ -196,8 +203,7 @@ DlgEditor::DlgEditor ( ,mnPaintGuard(0) ,m_xDocument( xModel ) { - pDlgEdModel->GetItemPool().FreezeIdRanges(); - pDlgEdView.reset(new DlgEdView(*pDlgEdModel, rWindow_, *this)); + pDlgEdView.reset(new DlgEdView(*pDlgEdModel, *rWindow_.GetOutDev(), *this)); pDlgEdModel->SetScaleUnit( MapUnit::Map100thMM ); SdrLayerAdmin& rAdmin = pDlgEdModel->GetLayerAdmin(); @@ -206,22 +212,12 @@ DlgEditor::DlgEditor ( pDlgEdModel->InsertPage(pDlgEdPage); - // set clipboard data flavors - m_ClipboardDataFlavors[0].MimeType = "application/vnd.sun.xml.dialog" ; - m_ClipboardDataFlavors[0].HumanPresentableName = "Dialog 6.0" ; - m_ClipboardDataFlavors[0].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - - m_ClipboardDataFlavorsResource[0] = m_ClipboardDataFlavors[0]; - m_ClipboardDataFlavorsResource[1].MimeType = "application/vnd.sun.xml.dialogwithresource" ; - m_ClipboardDataFlavorsResource[1].HumanPresentableName = "Dialog 8.0" ; - m_ClipboardDataFlavorsResource[1].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - aMarkIdle.SetInvokeHandler( LINK( this, DlgEditor, MarkTimeout ) ); rWindow.SetMapMode( MapMode( MapUnit::Map100thMM ) ); pDlgEdPage->SetSize( rWindow.PixelToLogic( Size(DLGED_PAGE_WIDTH_MIN, DLGED_PAGE_HEIGHT_MIN) ) ); - pDlgEdView->ShowSdrPage(pDlgEdView->GetModel()->GetPage(0)); + pDlgEdView->ShowSdrPage(pDlgEdView->GetModel().GetPage(0)); pDlgEdView->SetLayerVisible( "HiddenLayer", false ); pDlgEdView->SetMoveSnapOnlyTopLeft(true); pDlgEdView->SetWorkArea( tools::Rectangle( Point( 0, 0 ), pDlgEdPage->GetSize() ) ); @@ -240,7 +236,6 @@ DlgEditor::DlgEditor ( SetDialog(xDialogModel); } - DlgEditor::~DlgEditor() { aMarkIdle.Stop(); @@ -248,7 +243,6 @@ DlgEditor::~DlgEditor() ::comphelper::disposeComponent( m_xControlContainer ); } - Reference< awt::XControlContainer > const & DlgEditor::GetWindowControlContainer() { if (!m_xControlContainer.is()) @@ -256,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; @@ -265,7 +258,6 @@ void DlgEditor::SetScrollBars( ScrollBar* pHS, ScrollBar* pVS ) InitScrollBars(); } - void DlgEditor::InitScrollBars() { DBG_ASSERT( pHScroll, "DlgEditor::InitScrollBars: no horizontal scroll bar!" ); @@ -273,13 +265,13 @@ void DlgEditor::InitScrollBars() if ( !pHScroll || !pVScroll ) return; - Size aOutSize = rWindow.GetOutputSize(); + Size aOutSize = rWindow.GetOutDev()->GetOutputSize(); Size aPgSize = pDlgEdPage->GetSize(); pHScroll->SetRange( Range( 0, aPgSize.Width() )); pVScroll->SetRange( Range( 0, aPgSize.Height() )); - pHScroll->SetVisibleSize( static_cast<sal_uLong>(aOutSize.Width()) ); - pVScroll->SetVisibleSize( static_cast<sal_uLong>(aOutSize.Height()) ); + pHScroll->SetVisibleSize( aOutSize.Width() ); + pVScroll->SetVisibleSize( aOutSize.Height() ); pHScroll->SetLineSize( aOutSize.Width() / 10 ); pVScroll->SetLineSize( aOutSize.Height() / 10 ); @@ -350,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 @@ -390,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(); @@ -408,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 ); @@ -420,7 +412,7 @@ void DlgEditor::ResetDialog () pPage->SetDlgEdForm( nullptr ); SetDialog( m_xUnoControlDialogModel ); if( bWasMarked ) - pDlgEdView->MarkObj( pDlgEdForm, pPgView ); + pDlgEdView->MarkObj( pDlgEdForm.get(), pPgView ); } @@ -434,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; @@ -523,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(); } } } @@ -558,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 @@ -611,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; @@ -629,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(); @@ -748,7 +740,7 @@ void DlgEditor::Copy() {} } - DlgEdTransferableImpl* pTrans = nullptr; + rtl::Reference<DlgEdTransferableImpl> pTrans; if( xStringResourcePersistence.is() ) { // With resource, support old and new format @@ -762,10 +754,8 @@ void DlgEditor::Copy() xStream2->closeInput(); // Old format contains dialog with replaced ids - Sequence< Any > aSeqData(2); Any aNoResourceDialogModelBytesAny; aNoResourceDialogModelBytesAny <<= NoResourceDialogModelBytes; - aSeqData[0] = aNoResourceDialogModelBytesAny; // New format contains dialog and resource Sequence< sal_Int8 > aResData = xStringResourcePersistence->exportBinary(); @@ -791,18 +781,18 @@ void DlgEditor::Copy() memcpy( pCombinedData + 4, DialogModelBytes.getConstArray(), nDialogDataLen ); memcpy( pCombinedData + nResOffset, aResData.getConstArray(), nResDataLen ); - aSeqData[1] <<= aCombinedData; + Sequence< Any > aSeqData + { + aNoResourceDialogModelBytesAny, + Any(aCombinedData) + }; pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavorsResource, aSeqData ); } else { // No resource, support only old format - Sequence< Any > aSeqData(1); - Any aDialogModelBytesAny; - aDialogModelBytesAny <<= DialogModelBytes; - aSeqData[0] = aDialogModelBytesAny; - pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavors , aSeqData ); + pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavors , { Any(DialogModelBytes) } ); } SolarMutexReleaser aReleaser; xClipboard->setContents( pTrans , pTrans ); @@ -924,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 @@ -960,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(); @@ -968,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 38c8dc0d1a9c..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,59 +45,53 @@ DlgEdFactory::~DlgEdFactory() COVERITY_NOEXCEPT_FALSE } -IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* ) +IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, rtl::Reference<SdrObject> ) { - static bool bNeedsInit = true; - static uno::Reference< lang::XMultiServiceFactory > xDialogSFact; - - if( bNeedsInit ) - { + 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 ); - xDialogSFact = xModFact; - } - bNeedsInit = false; - } + if (xC.is()) + xFact.set(xC, uno::UNO_QUERY); + return xFact; + }(); - SdrObject* pNewObj = nullptr; + rtl::Reference<SdrObject> pNewObj; if( (aParams.nInventor == SdrInventor::BasicDialog) && - (aParams.nObjIdentifier >= OBJ_DLG_PUSHBUTTON) && - (aParams.nObjIdentifier <= OBJ_DLG_FORMHSCROLL) ) + (aParams.nObjIdentifier >= SdrObjKind::BasicDialogPushButton) && + (aParams.nObjIdentifier <= SdrObjKind::BasicDialogFormHorizontalScroll) ) { switch( aParams.nObjIdentifier ) { - case OBJ_DLG_PUSHBUTTON: + case SdrObjKind::BasicDialogPushButton: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlButtonModel", xDialogSFact ); break; - case OBJ_DLG_RADIOBUTTON: + case SdrObjKind::BasicDialogRadioButton: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlRadioButtonModel", xDialogSFact ); break; - case OBJ_DLG_FORMRADIO: + case SdrObjKind::BasicDialogFormRadio: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.RadioButton", xDialogSFact ); - static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel ); + static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel ); break; - case OBJ_DLG_CHECKBOX: + case SdrObjKind::BasicDialogCheckbox: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlCheckBoxModel", xDialogSFact ); break; - case OBJ_DLG_FORMCHECK: + case SdrObjKind::BasicDialogFormCheck: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.CheckBox", xDialogSFact ); - static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel ); + static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel ); break; - case OBJ_DLG_LISTBOX: + case SdrObjKind::BasicDialogListbox: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact ); break; - case OBJ_DLG_FORMLIST: + case SdrObjKind::BasicDialogFormList: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ListBox", xDialogSFact ); - static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel ); + static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel ); break; - case OBJ_DLG_FORMCOMBO: - case OBJ_DLG_COMBOBOX: + case SdrObjKind::BasicDialogFormCombo: + case SdrObjKind::BasicDialogCombobox: { - DlgEdObj* pNew = nullptr; - if ( aParams.nObjIdentifier == OBJ_DLG_COMBOBOX ) + rtl::Reference<DlgEdObj> pNew; + if ( aParams.nObjIdentifier == SdrObjKind::BasicDialogCombobox ) pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlComboBoxModel", xDialogSFact ); else { @@ -117,33 +112,33 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* ) } } break; - case OBJ_DLG_GROUPBOX: + case SdrObjKind::BasicDialogGroupBox: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlGroupBoxModel", xDialogSFact ); break; - case OBJ_DLG_EDIT: + case SdrObjKind::BasicDialogEdit: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlEditModel", xDialogSFact ); break; - case OBJ_DLG_FIXEDTEXT: + case SdrObjKind::BasicDialogFixedText: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedTextModel", xDialogSFact ); break; - case OBJ_DLG_IMAGECONTROL: + case SdrObjKind::BasicDialogImageControl: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlImageControlModel", xDialogSFact ); break; - case OBJ_DLG_PROGRESSBAR: + case SdrObjKind::BasicDialogProgressbar: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlProgressBarModel", xDialogSFact ); break; - case OBJ_DLG_HSCROLLBAR: + case SdrObjKind::BasicDialogHorizontalScrollbar: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact ); break; - case OBJ_DLG_FORMHSCROLL: + case SdrObjKind::BasicDialogFormHorizontalScroll: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.ScrollBar", xDialogSFact ); - static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel ); + static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel ); break; - case OBJ_DLG_FORMVSCROLL: - case OBJ_DLG_VSCROLLBAR: + case SdrObjKind::BasicDialogFormVerticalScroll: + case SdrObjKind::BasicDialogVerticalScrollbar: { - DlgEdObj* pNew = nullptr; - if ( aParams.nObjIdentifier == OBJ_DLG_VSCROLLBAR ) + rtl::Reference<DlgEdObj> pNew; + if ( aParams.nObjIdentifier == SdrObjKind::BasicDialogVerticalScrollbar ) pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact ); else { @@ -164,12 +159,12 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* ) { } } break; - case OBJ_DLG_HFIXEDLINE: + case SdrObjKind::BasicDialogHorizontalFixedLine: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact ); break; - case OBJ_DLG_VFIXEDLINE: + case SdrObjKind::BasicDialogVerticalFixedLine: { - DlgEdObj* pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact ); + rtl::Reference<DlgEdObj> pNew = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact ); pNewObj = pNew; // set vertical orientation try @@ -184,41 +179,41 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* ) { } } break; - case OBJ_DLG_DATEFIELD: + case SdrObjKind::BasicDialogDateField: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlDateFieldModel", xDialogSFact ); break; - case OBJ_DLG_TIMEFIELD: + case SdrObjKind::BasicDialogTimeField: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlTimeFieldModel", xDialogSFact ); break; - case OBJ_DLG_NUMERICFIELD: + case SdrObjKind::BasicDialogNumericField: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlNumericFieldModel", xDialogSFact ); break; - case OBJ_DLG_CURRENCYFIELD: + case SdrObjKind::BasicDialogCurencyField: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlCurrencyFieldModel", xDialogSFact ); break; - case OBJ_DLG_FORMATTEDFIELD: + case SdrObjKind::BasicDialogFormattedField: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFormattedFieldModel", xDialogSFact ); break; - case OBJ_DLG_PATTERNFIELD: + case SdrObjKind::BasicDialogPatternField: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlPatternFieldModel", xDialogSFact ); break; - case OBJ_DLG_FILECONTROL: + case SdrObjKind::BasicDialogFileControl: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFileControlModel", xDialogSFact ); break; - case OBJ_DLG_SPINBUTTON: + case SdrObjKind::BasicDialogSpinButton: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlSpinButtonModel", xDialogSFact ); break; - case OBJ_DLG_FORMSPIN: + case SdrObjKind::BasicDialogFormSpin: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.form.component.SpinButton", xDialogSFact ); - static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel ); + static_cast< DlgEdObj* >( pNewObj.get() )->MakeDataAware( mxModel ); break; - case OBJ_DLG_TREECONTROL: + case SdrObjKind::BasicDialogTreeControl: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.tree.TreeControlModel", xDialogSFact ); break; - case OBJ_DLG_GRIDCONTROL: + case SdrObjKind::BasicDialogGridControl: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.grid.UnoControlGridModel", xDialogSFact ); break; - case OBJ_DLG_HYPERLINKCONTROL: + case SdrObjKind::BasicDialogHyperlinkControl: pNewObj = new DlgEdObj(aParams.rSdrModel, "com.sun.star.awt.UnoControlFixedHyperlinkModel", xDialogSFact ); break; default: diff --git a/basctl/source/dlged/dlgedfunc.cxx b/basctl/source/dlged/dlgedfunc.cxx index b16cf695a26a..7f1a0388eeaa 100644 --- a/basctl/source/dlged/dlgedfunc.cxx +++ b/basctl/source/dlged/dlgedfunc.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <vcl/scrbar.hxx> +#include <svtools/scrolladaptor.hxx> #include <svx/svdview.hxx> #include <dlgedfunc.hxx> #include <dlged.hxx> @@ -41,16 +41,16 @@ void DlgEdFunc::ForceScroll( const Point& rPos ) vcl::Window& rWindow = rParent.GetWindow(); - static Point aDefPoint; + static const Point aDefPoint; tools::Rectangle aOutRect( aDefPoint, rWindow.GetOutputSizePixel() ); aOutRect = rWindow.PixelToLogic( aOutRect ); - ScrollBar* pHScroll = rParent.GetHScroll(); - ScrollBar* pVScroll = rParent.GetVScroll(); + ScrollAdaptor* pHScroll = rParent.GetHScroll(); + ScrollAdaptor* pVScroll = rParent.GetVScroll(); tools::Long nDeltaX = pHScroll->GetLineSize(); tools::Long nDeltaY = pVScroll->GetLineSize(); - if( !aOutRect.IsInside( rPos ) ) + if( !aOutRect.Contains( rPos ) ) { if( rPos.X() < aOutRect.Left() ) nDeltaX = -nDeltaX; @@ -77,7 +77,7 @@ void DlgEdFunc::ForceScroll( const Point& rPos ) } DlgEdFunc::DlgEdFunc (DlgEditor& rParent_) : - rParent(rParent_) + rParent(rParent_), aScrollTimer("basctl DlgEdFunc aScrollTimer") { aScrollTimer.SetInvokeHandler( LINK( this, DlgEdFunc, ScrollTimeout ) ); aScrollTimer.SetTimeout( SELENG_AUTOREPEAT_INTERVAL ); @@ -233,7 +233,7 @@ bool DlgEdFunc::KeyInput( const KeyEvent& rKEvt ) tools::Rectangle aMarkRect( rView.GetMarkedObjRect() ); aMarkRect.Move( nX, nY ); - if ( !rWorkArea.IsInside( aMarkRect ) ) + if ( !rWorkArea.Contains( aMarkRect ) ) { if ( aMarkRect.Left() < rWorkArea.Left() ) nX += rWorkArea.Left() - aMarkRect.Left(); @@ -294,7 +294,7 @@ bool DlgEdFunc::KeyInput( const KeyEvent& rKEvt ) else { // scroll page - ScrollBar* pScrollBar = ( nX != 0 ) ? rParent.GetHScroll() : rParent.GetVScroll(); + ScrollAdaptor* pScrollBar = ( nX != 0 ) ? rParent.GetHScroll() : rParent.GetVScroll(); if ( pScrollBar ) { tools::Long nRangeMin = pScrollBar->GetRangeMin(); @@ -342,7 +342,7 @@ void DlgEdFuncInsert::MouseButtonDown( const MouseEvent& rMEvt ) SdrView& rView = rParent.GetView(); vcl::Window& rWindow = rParent.GetWindow(); - rView.SetActualWin(&rWindow); + rView.SetActualWin(rWindow.GetOutDev()); Point aPos = rWindow.PixelToLogic( rMEvt.GetPosPixel() ); sal_uInt16 nHitLog = static_cast<sal_uInt16>(rWindow.PixelToLogic(Size(3, 0)).Width()); @@ -378,7 +378,7 @@ bool DlgEdFuncInsert::MouseButtonUp( const MouseEvent& rMEvt ) SdrView& rView = rParent.GetView(); vcl::Window& rWindow = rParent.GetWindow(); - rView.SetActualWin(&rWindow); + rView.SetActualWin(rWindow.GetOutDev()); rWindow.ReleaseMouse(); @@ -408,7 +408,7 @@ void DlgEdFuncInsert::MouseMove( const MouseEvent& rMEvt ) { SdrView& rView = rParent.GetView(); vcl::Window& rWindow = rParent.GetWindow(); - rView.SetActualWin(&rWindow); + rView.SetActualWin(rWindow.GetOutDev()); Point aPos = rWindow.PixelToLogic(rMEvt.GetPosPixel()); sal_uInt16 nHitLog = static_cast<sal_uInt16>(rWindow.PixelToLogic(Size(3, 0)).Width()); @@ -419,7 +419,7 @@ void DlgEdFuncInsert::MouseMove( const MouseEvent& rMEvt ) rView.MovAction(aPos); } - rWindow.SetPointer( rView.GetPreferredPointer( aPos, &rWindow, nHitLog ) ); + rWindow.SetPointer( rView.GetPreferredPointer( aPos, rWindow.GetOutDev(), nHitLog ) ); } DlgEdFuncSelect::DlgEdFuncSelect (DlgEditor& rParent_) : @@ -436,7 +436,7 @@ void DlgEdFuncSelect::MouseButtonDown( const MouseEvent& rMEvt ) // get view from parent SdrView& rView = rParent.GetView(); vcl::Window& rWindow = rParent.GetWindow(); - rView.SetActualWin(&rWindow); + rView.SetActualWin(rWindow.GetOutDev()); sal_uInt16 nDrgLog = static_cast<sal_uInt16>(rWindow.PixelToLogic(Size(3, 0)).Width()); sal_uInt16 nHitLog = static_cast<sal_uInt16>(rWindow.PixelToLogic(Size(3, 0)).Width()); @@ -497,7 +497,7 @@ bool DlgEdFuncSelect::MouseButtonUp( const MouseEvent& rMEvt ) // get view from parent SdrView& rView = rParent.GetView(); vcl::Window& rWindow = rParent.GetWindow(); - rView.SetActualWin(&rWindow); + rView.SetActualWin(rWindow.GetOutDev()); Point aPnt = rWindow.PixelToLogic(rMEvt.GetPosPixel()); sal_uInt16 nHitLog = static_cast<sal_uInt16>(rWindow.PixelToLogic(Size(3, 0)).Width()); @@ -516,7 +516,7 @@ bool DlgEdFuncSelect::MouseButtonUp( const MouseEvent& rMEvt ) } } - rWindow.SetPointer( rView.GetPreferredPointer( aPnt, &rWindow, nHitLog ) ); + rWindow.SetPointer( rView.GetPreferredPointer( aPnt, rWindow.GetOutDev(), nHitLog ) ); rWindow.ReleaseMouse(); return true; @@ -526,7 +526,7 @@ void DlgEdFuncSelect::MouseMove( const MouseEvent& rMEvt ) { SdrView& rView = rParent.GetView(); vcl::Window& rWindow = rParent.GetWindow(); - rView.SetActualWin(&rWindow); + rView.SetActualWin(rWindow.GetOutDev()); Point aPnt = rWindow.PixelToLogic(rMEvt.GetPosPixel()); sal_uInt16 nHitLog = static_cast<sal_uInt16>(rWindow.PixelToLogic(Size(3, 0)).Width()); @@ -540,7 +540,7 @@ void DlgEdFuncSelect::MouseMove( const MouseEvent& rMEvt ) rView.MovAction(aPnt_); } - rWindow.SetPointer( rView.GetPreferredPointer( aPnt, &rWindow, nHitLog ) ); + rWindow.SetPointer( rView.GetPreferredPointer( aPnt, rWindow.GetOutDev(), nHitLog ) ); } } // namespace basctl diff --git a/basctl/source/dlged/dlgedmod.cxx b/basctl/source/dlged/dlgedmod.cxx index 291b5b9136f5..017e4b16c78f 100644 --- a/basctl/source/dlged/dlgedmod.cxx +++ b/basctl/source/dlged/dlgedmod.cxx @@ -22,14 +22,14 @@ namespace basctl { -DlgEdModel::DlgEdModel() - : SdrModel() -{ -} +DlgEdModel::DlgEdModel() {} DlgEdModel::~DlgEdModel() {} -SdrPage* DlgEdModel::AllocPage(bool bMasterPage) { return new DlgEdPage(*this, bMasterPage); } +rtl::Reference<SdrPage> DlgEdModel::AllocPage(bool bMasterPage) +{ + return new DlgEdPage(*this, bMasterPage); +} } // namespace basctl diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx index 056006c4305e..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,17 +71,53 @@ DlgEditor& DlgEdObj::GetDialogEditor () DlgEdObj::DlgEdObj(SdrModel& rSdrModel) : SdrUnoObj(rSdrModel, OUString()) ,bIsListening(false) - ,pDlgEdForm( nullptr ) { } +DlgEdObj::DlgEdObj(SdrModel& rSdrModel, DlgEdObj const & rSource) +: SdrUnoObj(rSdrModel, rSource) + ,bIsListening(false) +{ + // set parent form + pDlgEdForm = rSource.pDlgEdForm; + + // add child to parent form + pDlgEdForm->AddChild( this ); + + Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY ); + if ( xPSet.is() ) + { + // set new name + OUString aOUniqueName( GetUniqueName() ); + Any aUniqueName; + aUniqueName <<= aOUniqueName; + xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName ); + + Reference< container::XNameContainer > xCont( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY ); + if ( xCont.is() ) + { + // set tabindex + Sequence< OUString > aNames = xCont->getElementNames(); + xPSet->setPropertyValue( DLGED_PROP_TABINDEX, Any(static_cast<sal_Int16>(aNames.getLength())) ); + + // insert control model in dialog model + Reference< awt::XControlModel > xCtrl( xPSet , UNO_QUERY ); + xCont->insertByName( aOUniqueName, Any(xCtrl) ); + + pDlgEdForm->UpdateTabOrderAndGroups(); + } + } + + // start listening + StartListening(); +} + DlgEdObj::DlgEdObj( SdrModel& rSdrModel, const OUString& rModelName, const css::uno::Reference< css::lang::XMultiServiceFactory >& rxSFac) : SdrUnoObj(rSdrModel, rModelName, rxSFac) ,bIsListening(false) - ,pDlgEdForm( nullptr ) { } @@ -114,7 +151,7 @@ uno::Reference< awt::XControl > DlgEdObj::GetControl() const if (DlgEdForm const* pForm = GetDlgEdForm()) { DlgEditor const& rEditor = pForm->GetDlgEditor(); - xControl = GetUnoControl(rEditor.GetView(), rEditor.GetWindow()); + xControl = GetUnoControl(rEditor.GetView(), *rEditor.GetWindow().GetOutDev()); } return xControl; } @@ -772,158 +809,112 @@ SdrObjKind DlgEdObj::GetObjIdentifier() const { if ( supportsService( "com.sun.star.awt.UnoControlDialogModel" )) { - return OBJ_DLG_DIALOG; + return SdrObjKind::BasicDialogDialog; } else if ( supportsService( "com.sun.star.awt.UnoControlButtonModel" )) { - return OBJ_DLG_PUSHBUTTON; + return SdrObjKind::BasicDialogPushButton; } else if ( supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" )) { - return OBJ_DLG_RADIOBUTTON; + return SdrObjKind::BasicDialogRadioButton; } else if ( supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" )) { - return OBJ_DLG_CHECKBOX; + return SdrObjKind::BasicDialogCheckbox; } else if ( supportsService( "com.sun.star.awt.UnoControlListBoxModel" )) { - return OBJ_DLG_LISTBOX; + return SdrObjKind::BasicDialogListbox; } else if ( supportsService( "com.sun.star.awt.UnoControlComboBoxModel" )) { - return OBJ_DLG_COMBOBOX; + return SdrObjKind::BasicDialogCombobox; } else if ( supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" )) { - return OBJ_DLG_GROUPBOX; + return SdrObjKind::BasicDialogGroupBox; } else if ( supportsService( "com.sun.star.awt.UnoControlEditModel" )) { - return OBJ_DLG_EDIT; + return SdrObjKind::BasicDialogEdit; } else if ( supportsService( "com.sun.star.awt.UnoControlFixedTextModel" )) { - return OBJ_DLG_FIXEDTEXT; + return SdrObjKind::BasicDialogFixedText; } else if ( supportsService( "com.sun.star.awt.UnoControlImageControlModel" )) { - return OBJ_DLG_IMAGECONTROL; + return SdrObjKind::BasicDialogImageControl; } else if ( supportsService( "com.sun.star.awt.UnoControlProgressBarModel" )) { - return OBJ_DLG_PROGRESSBAR; + return SdrObjKind::BasicDialogProgressbar; } else if ( supportsService( "com.sun.star.awt.UnoControlScrollBarModel" )) { - return OBJ_DLG_HSCROLLBAR; + return SdrObjKind::BasicDialogHorizontalScrollbar; } else if ( supportsService( "com.sun.star.awt.UnoControlFixedLineModel" )) { - return OBJ_DLG_HFIXEDLINE; + return SdrObjKind::BasicDialogHorizontalFixedLine; } else if ( supportsService( "com.sun.star.awt.UnoControlDateFieldModel" )) { - return OBJ_DLG_DATEFIELD; + return SdrObjKind::BasicDialogDateField; } else if ( supportsService( "com.sun.star.awt.UnoControlTimeFieldModel" )) { - return OBJ_DLG_TIMEFIELD; + return SdrObjKind::BasicDialogTimeField; } else if ( supportsService( "com.sun.star.awt.UnoControlNumericFieldModel" )) { - return OBJ_DLG_NUMERICFIELD; + return SdrObjKind::BasicDialogNumericField; } else if ( supportsService( "com.sun.star.awt.UnoControlCurrencyFieldModel" )) { - return OBJ_DLG_CURRENCYFIELD; + return SdrObjKind::BasicDialogCurencyField; } else if ( supportsService( "com.sun.star.awt.UnoControlFormattedFieldModel" )) { - return OBJ_DLG_FORMATTEDFIELD; + return SdrObjKind::BasicDialogFormattedField; } else if ( supportsService( "com.sun.star.awt.UnoControlPatternFieldModel" )) { - return OBJ_DLG_PATTERNFIELD; + return SdrObjKind::BasicDialogPatternField; } else if ( supportsService( "com.sun.star.awt.UnoControlFileControlModel" )) { - return OBJ_DLG_FILECONTROL; + return SdrObjKind::BasicDialogFileControl; } else if ( supportsService( "com.sun.star.awt.tree.TreeControlModel" )) { - return OBJ_DLG_TREECONTROL; + return SdrObjKind::BasicDialogTreeControl; } else if ( supportsService( "com.sun.star.awt.grid.UnoControlGridModel" )) { - return OBJ_DLG_GRIDCONTROL; + return SdrObjKind::BasicDialogGridControl; } else if ( supportsService( "com.sun.star.awt.UnoControlFixedHyperlinkModel" )) { - return OBJ_DLG_HYPERLINKCONTROL; + return SdrObjKind::BasicDialogHyperlinkControl; } else { - return OBJ_DLG_CONTROL; + return SdrObjKind::BasicDialogControl; } } -void DlgEdObj::clonedFrom(const DlgEdObj* _pSource) +rtl::Reference<SdrObject> DlgEdObj::CloneSdrObject(SdrModel& rTargetModel) const { - // set parent form - pDlgEdForm = _pSource->pDlgEdForm; - - // add child to parent form - pDlgEdForm->AddChild( this ); - - Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY ); - if ( xPSet.is() ) - { - // set new name - OUString aOUniqueName( GetUniqueName() ); - Any aUniqueName; - aUniqueName <<= aOUniqueName; - xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName ); - - Reference< container::XNameContainer > xCont( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY ); - if ( xCont.is() ) - { - // set tabindex - Sequence< OUString > aNames = xCont->getElementNames(); - xPSet->setPropertyValue( DLGED_PROP_TABINDEX, Any(static_cast<sal_Int16>(aNames.getLength())) ); - - // insert control model in dialog model - Reference< awt::XControlModel > xCtrl( xPSet , UNO_QUERY ); - xCont->insertByName( aOUniqueName, Any(xCtrl) ); - - pDlgEdForm->UpdateTabOrderAndGroups(); - } - } - - // start listening - StartListening(); + return new DlgEdObj(rTargetModel, *this); } -DlgEdObj* DlgEdObj::CloneSdrObject(SdrModel& rTargetModel) const -{ - DlgEdObj* pDlgEdObj = CloneHelper< DlgEdObj >(rTargetModel); - DBG_ASSERT( pDlgEdObj != nullptr, "DlgEdObj::Clone: invalid clone!" ); - if ( pDlgEdObj ) - pDlgEdObj->clonedFrom( this ); - - return pDlgEdObj; -} - -SdrObjectUniquePtr DlgEdObj::getFullDragClone() const +rtl::Reference<SdrObject> DlgEdObj::getFullDragClone() const { // no need to really add the clone for dragging, it's a temporary // object - SdrObjectUniquePtr pObj( new SdrUnoObj( - getSdrModelFromSdrObject(), - OUString()) ); - *pObj = *static_cast<const SdrUnoObj*>(this); - - return pObj; + return rtl::Reference<SdrObject>(new SdrUnoObj(getSdrModelFromSdrObject(), *this)); } void DlgEdObj::NbcMove( const Size& rSize ) @@ -969,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())); @@ -1297,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 ) @@ -1415,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(); } @@ -1683,18 +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( 1 ); - aArgs[ 0 ] <<= aValue; + Sequence< Any > aArgs{ Any(aCellValue), Any(aCellRange) }; if ( xBindable.is() ) { diff --git a/basctl/source/dlged/dlgedpage.cxx b/basctl/source/dlged/dlgedpage.cxx index d422f757868c..760f88527609 100644 --- a/basctl/source/dlged/dlgedpage.cxx +++ b/basctl/source/dlged/dlgedpage.cxx @@ -38,13 +38,13 @@ DlgEdPage::~DlgEdPage() ClearSdrObjList(); } -SdrPage* DlgEdPage::CloneSdrPage(SdrModel& rTargetModel) const +rtl::Reference<SdrPage> DlgEdPage::CloneSdrPage(SdrModel& rTargetModel) const { DlgEdModel& rDlgEdModel(static_cast< DlgEdModel& >(rTargetModel)); - DlgEdPage* pClonedDlgEdPage( + rtl::Reference<DlgEdPage> pClonedDlgEdPage = new DlgEdPage( rDlgEdModel, - IsMasterPage())); + IsMasterPage()); pClonedDlgEdPage->SdrPage::lateInit(*this); return pClonedDlgEdPage; } diff --git a/basctl/source/dlged/dlgedview.cxx b/basctl/source/dlged/dlgedview.cxx index f9371b10bac3..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> @@ -58,12 +58,12 @@ void DlgEdView::MakeVisible( const tools::Rectangle& rRect, vcl::Window& rWin ) // visible area MapMode aMap( rWin.GetMapMode() ); Point aOrg( aMap.GetOrigin() ); - Size aVisSize( rWin.GetOutputSize() ); + Size aVisSize( rWin.GetOutDev()->GetOutputSize() ); tools::Rectangle RectTmp( Point(-aOrg.X(),-aOrg.Y()), aVisSize ); tools::Rectangle aVisRect( RectTmp ); // check, if rectangle is inside visible area - if ( aVisRect.IsInside( rRect ) ) + if ( aVisRect.Contains( rRect ) ) return; // calculate scroll distance; the rectangle must be inside the visible area diff --git a/basctl/source/dlged/managelang.cxx b/basctl/source/dlged/managelang.cxx index d36c23803e7a..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(); @@ -162,12 +162,13 @@ IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl, weld::Button&, void) int nPos = m_xLanguageLB->get_selected_index(); // remove locales Sequence< Locale > aLocaleSeq( nCount ); + auto aLocaleSeqRange = asNonConstRange(aLocaleSeq); for (int i = 0; i < nCount; ++i) { const sal_Int32 nSelPos = aSelection[i]; - LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xLanguageLB->get_id(nSelPos).toInt64()); + LanguageEntry* pEntry = weld::fromId<LanguageEntry*>(m_xLanguageLB->get_id(nSelPos)); if ( pEntry ) - aLocaleSeq[i] = pEntry->m_aLocale; + aLocaleSeqRange[i] = pEntry->m_aLocale; } m_xLocalizationMgr->handleRemoveLocales( aLocaleSeq ); // update listbox @@ -184,7 +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 @@ -212,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 084395ad2536..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() ) { @@ -228,9 +228,6 @@ bool PropBrw::Close() { ImplDestroyController(); - if( IsRollUp() ) - RollDown(); - return DockingWindow::Close(); } @@ -245,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) @@ -262,7 +259,7 @@ Sequence< Reference< XInterface > > } // next element - pCurrent = pGroupIterator && pGroupIterator->IsMore() ? pGroupIterator->Next() : nullptr; + pCurrent = oGroupIterator && oGroupIterator->IsMore() ? oGroupIterator->Next() : nullptr; } } @@ -446,7 +443,7 @@ void PropBrw::ImplUpdate( const Reference< XModel >& _rxContextDocument, SdrView { if ( pView ) { - EndListening( *(pView->GetModel()) ); + EndListening(pView->GetModel()); pView = nullptr; } @@ -467,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; @@ -495,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/IDEComboBox.hxx b/basctl/source/inc/IDEComboBox.hxx index 76d73cdf8eec..a5e7008a42e9 100644 --- a/basctl/source/inc/IDEComboBox.hxx +++ b/basctl/source/inc/IDEComboBox.hxx @@ -52,7 +52,7 @@ public: * @param nId -- this item's unique id in ToolBox * @param rTbx -- the ToolBox which contains this ComboBox */ - LibBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx); + LibBoxControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx); /*! * Triggered if state was changed @@ -61,8 +61,8 @@ public: * @param eState -- enum value which contains ComboBox state * @param pState -- */ - virtual void StateChanged(sal_uInt16 nSlotID, SfxItemState eState, - const SfxPoolItem* pState) override; + virtual void StateChangedAtToolBoxControl(sal_uInt16 nSlotID, SfxItemState eState, + const SfxPoolItem* pState) override; /*! * Create combobox of Macro and Dialog Library * @@ -140,14 +140,6 @@ protected: /// Called for setting language when user selects a language in ComboBox virtual void Select() override; - /*! - * Handle keystrokes and mouse - * - * @param rNEvt represents mouse event - * @return a bool value: true if was handled, and false if there was nothing handled - */ - //TODO virtual bool PreNotify(NotifyEvent& rNEvt) override; - private: static void ReleaseFocus(); @@ -165,6 +157,12 @@ private: /// Fill up the combobox virtual void FillBox() override; + /*! + * Handle keystrokes + * + * @param rKEvt represents key event + * @return a bool value: true if was handled, and false if there was nothing handled + */ virtual bool HandleKeyInput(const KeyEvent& rKEvt) override; DECL_LINK(FocusInHdl, weld::Widget&, void); @@ -198,7 +196,7 @@ public: * @param nId -- this item's unique id in ToolBox * @param rTbx -- the ToolBox which contains this ComboBox */ - LanguageBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx); + LanguageBoxControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx); /*! * Triggered if state was changed @@ -207,8 +205,8 @@ public: * @param eState -- enum value which contains ComboBox state * @param pState -- */ - virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState) override; + virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState) override; /*! * Create ComboBox of Language * @@ -244,15 +242,13 @@ protected: /// Called for setting language when user selects a language in ComboBox virtual void Select() override; - virtual bool HandleKeyInput(const KeyEvent& rKEvt) override; - /*! - * Handle keystrokes and mouse + * Handle keystrokes * - * @param rNEvt represents mouse event + * @param rKEvt represents key event * @return a bool value: true if was handled, and false if there was nothing handled */ - //TODO virtual bool PreNotify(NotifyEvent& rNEvt) override; + virtual bool HandleKeyInput(const KeyEvent& rKEvt) override; private: /// Delete all languages from ComboBox diff --git a/basctl/source/inc/LineStatusControl.hxx b/basctl/source/inc/LineStatusControl.hxx new file mode 100644 index 000000000000..268738f821d3 --- /dev/null +++ b/basctl/source/inc/LineStatusControl.hxx @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <sfx2/stbitem.hxx> + +namespace basctl +{ +class LineStatusControl final : public SfxStatusBarControl +{ +public: + SFX_DECL_STATUSBAR_CONTROL(); + + LineStatusControl(sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb); + virtual ~LineStatusControl() override; + + virtual void StateChangedAtStatusBarControl(sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState) override; +}; + +} // namespace basctl + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basctl/source/inc/accessibledialogcontrolshape.hxx b/basctl/source/inc/accessibledialogcontrolshape.hxx index 2fbf73aa4e83..3af6e3da90ee 100644 --- a/basctl/source/inc/accessibledialogcontrolshape.hxx +++ b/basctl/source/inc/accessibledialogcontrolshape.hxx @@ -22,15 +22,11 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <comphelper/accessiblecomponenthelper.hxx> -#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase.hxx> #include <vcl/vclptr.hxx> namespace vcl { class Window; } -namespace utl { - class AccessibleStateSetHelper; -} - namespace basctl { @@ -39,13 +35,11 @@ class DialogWindow; -typedef ::cppu::ImplHelper3< - css::accessibility::XAccessible, - css::lang::XServiceInfo, - css::beans::XPropertyChangeListener > AccessibleDialogControlShape_BASE; - -class AccessibleDialogControlShape final : public comphelper::OAccessibleExtendedComponentHelper, - public AccessibleDialogControlShape_BASE +class AccessibleDialogControlShape final : public cppu::ImplInheritanceHelper< + comphelper::OAccessibleExtendedComponentHelper, + css::accessibility::XAccessible, + css::lang::XServiceInfo, + css::beans::XPropertyChangeListener> { friend class AccessibleDialogWindow; @@ -71,7 +65,7 @@ private: OUString GetModelStringProperty( OUString const & pPropertyName ); - void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ); + void FillAccessibleStateSet( sal_Int64& rStateSet ); // OCommonAccessibleComponent virtual css::awt::Rectangle implGetBounds() override; @@ -83,12 +77,6 @@ public: AccessibleDialogControlShape (DialogWindow*, DlgEdObj*); virtual ~AccessibleDialogControlShape() override; - // XInterface - DECLARE_XINTERFACE() - - // XTypeProvider - DECLARE_XTYPEPROVIDER() - // XEventListener virtual void SAL_CALL disposing( const css::lang::EventObject& rSource ) override; @@ -104,15 +92,15 @@ public: virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; // XAccessibleContext - virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override; - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override; + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; - virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override; virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; virtual OUString SAL_CALL getAccessibleDescription( ) override; virtual OUString SAL_CALL getAccessibleName( ) override; virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; - virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; + virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override; virtual css::lang::Locale SAL_CALL getLocale( ) override; // XAccessibleComponent diff --git a/basctl/source/inc/accessibledialogwindow.hxx b/basctl/source/inc/accessibledialogwindow.hxx index 2c3a065247ac..0332b98a4175 100644 --- a/basctl/source/inc/accessibledialogwindow.hxx +++ b/basctl/source/inc/accessibledialogwindow.hxx @@ -22,7 +22,7 @@ #include <com/sun/star/accessibility/XAccessibleSelection.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <comphelper/accessiblecomponenthelper.hxx> -#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase.hxx> #include <svl/lstner.hxx> #include <tools/link.hxx> #include <vcl/vclptr.hxx> @@ -30,10 +30,6 @@ class VclSimpleEvent; class VclWindowEvent; -namespace utl { - class AccessibleStateSetHelper; -} - namespace basctl { @@ -41,16 +37,14 @@ class DialogWindow; class DlgEditor; class DlgEdModel; class DlgEdObj; +class AccessibleDialogControlShape; - -typedef ::cppu::ImplHelper3 < - css::accessibility::XAccessible, - css::accessibility::XAccessibleSelection, - css::lang::XServiceInfo > AccessibleDialogWindow_BASE; - -class AccessibleDialogWindow final : public comphelper::OAccessibleExtendedComponentHelper, - public AccessibleDialogWindow_BASE, +class AccessibleDialogWindow final : public cppu::ImplInheritanceHelper< + comphelper::OAccessibleExtendedComponentHelper, + css::accessibility::XAccessible, + css::accessibility::XAccessibleSelection, + css::lang::XServiceInfo>, public SfxListener { private: @@ -58,8 +52,8 @@ private: class ChildDescriptor { public: - DlgEdObj* pDlgEdObj; - css::uno::Reference< css::accessibility::XAccessible > rxAccessible; + DlgEdObj* pDlgEdObj; + rtl::Reference< AccessibleDialogControlShape > mxAccessible; ChildDescriptor( DlgEdObj* _pDlgEdObj ); @@ -88,7 +82,7 @@ private: DECL_LINK( WindowEventListener, VclWindowEvent&, void ); void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); - void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ); + void FillAccessibleStateSet( sal_Int64& rStateSet ); // OCommonAccessibleComponent virtual css::awt::Rectangle implGetBounds( ) override; @@ -103,12 +97,6 @@ public: // SfxListener virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; - // XInterface - DECLARE_XINTERFACE() - - // XTypeProvider - DECLARE_XTYPEPROVIDER() - // XServiceInfo virtual OUString SAL_CALL getImplementationName() override; virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; @@ -118,15 +106,15 @@ public: virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; // XAccessibleContext - virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override; - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override; + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; - virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override; virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; virtual OUString SAL_CALL getAccessibleDescription( ) override; virtual OUString SAL_CALL getAccessibleName( ) override; virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; - virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override; + virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override; virtual css::lang::Locale SAL_CALL getLocale( ) override; // XAccessibleComponent @@ -141,13 +129,13 @@ public: virtual OUString SAL_CALL getToolTipText( ) override; // XAccessibleSelection - virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) override; - virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) override; + virtual void SAL_CALL selectAccessibleChild( sal_Int64 nChildIndex ) override; + virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int64 nChildIndex ) override; virtual void SAL_CALL clearAccessibleSelection() override; virtual void SAL_CALL selectAllAccessibleChildren( ) override; - virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) override; - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) override; - virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nChildIndex ) override; + virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + virtual void SAL_CALL deselectAccessibleChild( sal_Int64 nChildIndex ) override; }; } // namespace basctl diff --git a/basctl/source/inc/baside3.hxx b/basctl/source/inc/baside3.hxx index 15f157565fb2..14fc68f07951 100644 --- a/basctl/source/inc/baside3.hxx +++ b/basctl/source/inc/baside3.hxx @@ -43,7 +43,7 @@ class DlgEdView; class DialogWindowLayout; class ObjectCatalog; -bool implImportDialog(weld::Window* pWin, const OUString& rCurPath, const ScriptDocument& rDocument, const OUString& rLibName); +bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const OUString& rLibName); class DialogWindow: public BaseWindow { @@ -51,7 +51,6 @@ private: DialogWindowLayout& m_rLayout; std::unique_ptr<DlgEditor> m_pEditor; std::unique_ptr<SfxUndoManager> m_pUndoMgr; // never nullptr - OUString m_sCurPath; sal_uInt16 m_nControlSlotId; protected: @@ -68,7 +67,7 @@ protected: static void NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> ); virtual void DoInit() override; - virtual void DoScroll( ScrollBar* pCurScrollBar ) override; + virtual void DoScroll( Scrollable* pCurScrollBar ) override; virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; void InitSettings(); @@ -108,7 +107,7 @@ public: virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; - virtual char const* GetHid () const override; + virtual OUString GetHid () const override; virtual ItemType GetType () const override; }; diff --git a/basctl/source/inc/basidectrlr.hxx b/basctl/source/inc/basidectrlr.hxx index 7db0824df744..a32e1ffd94af 100644 --- a/basctl/source/inc/basidectrlr.hxx +++ b/basctl/source/inc/basidectrlr.hxx @@ -45,8 +45,8 @@ public: // XInterface virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - virtual void SAL_CALL acquire() throw() override; - virtual void SAL_CALL release() throw() override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; // XTypeProvider ( ::SfxBaseController ) virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; diff --git a/basctl/source/inc/basidesh.hxx b/basctl/source/inc/basidesh.hxx index f3127186ce93..afaa47c88ff4 100644 --- a/basctl/source/inc/basidesh.hxx +++ b/basctl/source/inc/basidesh.hxx @@ -26,7 +26,7 @@ #include <sfx2/viewsh.hxx> #include <svx/ifaceids.hxx> #include <svl/srchitem.hxx> -#include <vcl/scrbar.hxx> +#include <svtools/scrolladaptor.hxx> #include <map> #include <memory> #include <string_view> @@ -40,6 +40,12 @@ class StarBASIC; namespace basctl { + +// Used to control zoom level +constexpr sal_uInt16 MIN_ZOOM_LEVEL = 50; +constexpr sal_uInt16 DEFAULT_ZOOM_LEVEL = 100; +constexpr sal_uInt16 MAX_ZOOM_LEVEL = 400; + class Layout; class ModulWindow; class ModulWindowLayout; @@ -48,6 +54,7 @@ class DialogWindowLayout; class TabBar; class BaseWindow; class LocalizationMgr; +class BasicColorConfig; class Shell : public SfxViewShell, @@ -59,7 +66,7 @@ public: private: friend class JavaDebuggingListenerImpl; friend class LocalizationMgr; - friend bool implImportDialog(weld::Window* pWin, const OUString& rCurPath, const ScriptDocument& rDocument, const OUString& rLibName); // defined in baside3.cxx + friend bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const OUString& rLibName); // defined in baside3.cxx WindowTable aWindowTable; sal_uInt16 nCurKey; @@ -68,12 +75,16 @@ private: OUString m_aCurLibName; std::shared_ptr<LocalizationMgr> m_pCurLocalizationMgr; - VclPtr<ScrollBar> aHScrollBar; - VclPtr<ScrollBar> aVScrollBar; - VclPtr<ScrollBarBox> aScrollBarBox; + // Current value of the zoom slider + sal_uInt16 m_nCurrentZoomSliderValue; + VclPtr<ScrollAdaptor> aHScrollBar; + VclPtr<ScrollAdaptor> aVScrollBar; VclPtr<TabBar> pTabBar; // basctl::TabBar bool bCreatingWindow; + // Basic editor color configuration + std::shared_ptr<BasicColorConfig> m_aColorConfig; + // layout windows VclPtr<ModulWindowLayout> pModulLayout; VclPtr<DialogWindowLayout> pDialogLayout; @@ -93,13 +104,13 @@ private: void Init(); void InitTabBar(); void InitScrollBars(); + void InitZoomLevel(); void CheckWindows(); void RemoveWindows( const ScriptDocument& rDocument, std::u16string_view rLibName ); void UpdateWindows(); static void InvalidateBasicIDESlots(); void StoreAllWindowData( bool bPersistent = true ); void SetMDITitle(); - void EnableScrollbars( bool bEnable ); void SetCurLib( const ScriptDocument& rDocument, const OUString& aLibName, bool bUpdateWindows = true , bool bCheck = true ); void SetCurLibForLocalization( const ScriptDocument& rDocument, const OUString& aLibName ); @@ -149,7 +160,7 @@ private: static void InitInterface_Impl(); public: - Shell( SfxViewFrame *pFrame, SfxViewShell *pOldSh ); + Shell(SfxViewFrame& rFrame, SfxViewShell *pOldSh); virtual ~Shell() override; BaseWindow* GetCurWindow() const { return pCurWin; } @@ -164,12 +175,17 @@ public: SfxUndoManager* GetUndoManager() override; + void SetGlobalEditorZoomLevel(sal_uInt16 nNewZoomLevel); + sal_uInt16 GetCurrentZoomSliderValue() { return m_nCurrentZoomSliderValue; } + static sal_uInt16 GetMinZoom() { return MIN_ZOOM_LEVEL; } + static sal_uInt16 GetMaxZoom() { return MAX_ZOOM_LEVEL; } + virtual css::uno::Reference< css::view::XRenderable > GetRenderable() override; // virtual sal_uInt16 Print( SfxProgress &rProgress, sal_Bool bIsAPI, PrintDialog *pPrintDialog = 0 ); virtual SfxPrinter* GetPrinter( bool bCreate = false ) override; virtual sal_uInt16 SetPrinter( SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL ) override; - virtual OUString GetSelectionText( bool bCompleteWords = false ) override; + virtual OUString GetSelectionText( bool bCompleteWords = false, bool bOnlyASample = false ) override; virtual bool HasSelection( bool bText = true ) const override; void GetState( SfxItemSet& ); @@ -208,6 +224,8 @@ public: void UpdateObjectCatalog () { aObjectCatalog->UpdateEntries(); } void RemoveWindow (BaseWindow* pWindow, bool bDestroy, bool bAllowChangeCurWindow = true); + + const std::shared_ptr<BasicColorConfig>& GetColorConfig() const { return m_aColorConfig; } }; } // namespace basctl diff --git a/basctl/source/inc/basobj.hxx b/basctl/source/inc/basobj.hxx index 46d0f9392896..70c603d4548a 100644 --- a/basctl/source/inc/basobj.hxx +++ b/basctl/source/inc/basobj.hxx @@ -32,8 +32,7 @@ namespace weld { class Widget; class Window; } namespace basctl { - void Organize(weld::Window* pParent, sal_Int16 tabId); - + void Organize(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 tabId); // help methods for the general use: SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName ); @@ -45,7 +44,7 @@ namespace basctl void BasicStopped( bool* pbAppWindowDisabled = nullptr, bool* pbDispatcherLocked = nullptr, sal_uInt16* pnWaitCount = nullptr, SfxUInt16Item** ppSWActionCount = nullptr, SfxUInt16Item** ppSWLockViewCount = nullptr ); - bool IsValidSbxName( const OUString& rName ); + bool IsValidSbxName( std::u16string_view rName ); BasicManager* FindBasicManager( StarBASIC const * pLib ); diff --git a/basctl/source/inc/bastype2.hxx b/basctl/source/inc/bastype2.hxx index 3eb4de6beec9..22321b309757 100644 --- a/basctl/source/inc/bastype2.hxx +++ b/basctl/source/inc/bastype2.hxx @@ -45,7 +45,6 @@ namespace o3tl { namespace basctl { -using namespace ::com::sun::star::uno; enum EntryType { @@ -90,7 +89,7 @@ private: public: DocumentEntry ( - ScriptDocument const& rDocument, + ScriptDocument aDocument, LibraryLocation eLocation, EntryType eType = OBJ_TYPE_DOCUMENT ); @@ -109,7 +108,7 @@ public: LibEntry ( ScriptDocument const& rDocument, LibraryLocation eLocation, - OUString const& rLibName + OUString aLibName ); virtual ~LibEntry () override; @@ -129,20 +128,20 @@ class EntryDescriptor public: EntryDescriptor (); EntryDescriptor ( - ScriptDocument const& rDocument, + ScriptDocument aDocument, LibraryLocation eLocation, - OUString const& rLibName, - OUString const& rLibSubName, - OUString const& rName, + OUString aLibName, + OUString aLibSubName, + OUString aName, EntryType eType ); EntryDescriptor ( - ScriptDocument const& rDocument, + ScriptDocument aDocument, LibraryLocation eLocation, - OUString const& rLibName, - OUString const& rLibSubName, - OUString const& rName, - OUString const& rMethodName, + OUString aLibName, + OUString aLibSubName, + OUString aName, + OUString aMethodName, EntryType eType ); @@ -222,7 +221,7 @@ public: EntryDescriptor GetEntryDescriptor(const weld::TreeIter* pEntry); static ItemType ConvertType (EntryType eType); - bool IsValidEntry(weld::TreeIter& rEntry); + bool IsValidEntry(const weld::TreeIter& rEntry); void AddEntry(const OUString& rText, const OUString& rImage, const weld::TreeIter* pParent, bool bChildrenOnDemand, std::unique_ptr<Entry>&& rUserData, diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx index fecebced52ee..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. @@ -78,10 +79,10 @@ struct BasicStatus // basctl::DockingWindow -- special docking window for the Basic IDE // Not to be confused with ::DockingWindow from vcl. -class DockingWindow : public ::DockingWindow +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; @@ -102,7 +103,6 @@ protected: protected: std::unique_ptr<weld::Builder> m_xBuilder; - VclPtr<vcl::Window> m_xVclContentArea; std::unique_ptr<weld::Container> m_xContainer; private: @@ -156,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; @@ -170,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; @@ -181,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&); @@ -209,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; } @@ -234,7 +237,7 @@ public: void SetName( const OUString& aName ) { m_aName = aName; } virtual void OnNewDocument (); - virtual char const* GetHid () const = 0; + virtual OUString GetHid () const = 0; virtual ItemType GetType () const = 0; void InsertLibInfo () const; bool Is (ScriptDocument const&, std::u16string_view, std::u16string_view, ItemType, bool bFindSuspended); @@ -261,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 @@ -279,7 +282,7 @@ public: ItemType m_eCurrentType; public: - Item (OUString const& rCurrentName, ItemType eCurrentType); + Item (OUString aCurrentName, ItemType eCurrentType); const OUString& GetCurrentName() const { return m_aCurrentName; } ItemType GetCurrentType() const { return m_eCurrentType; } }; diff --git a/basctl/source/inc/colorscheme.hxx b/basctl/source/inc/colorscheme.hxx new file mode 100644 index 000000000000..96567f79f7ff --- /dev/null +++ b/basctl/source/inc/colorscheme.hxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <tools/color.hxx> + +namespace basctl +{ +// Defines a single color scheme +typedef struct +{ + OUString m_sSchemeName; + bool m_bIsDefault; + Color m_aGenericFontColor; + Color m_aIdentifierColor; + Color m_aNumberColor; + Color m_aStringColor; + Color m_aCommentColor; + Color m_aErrorColor; + Color m_aOperatorColor; + Color m_aKeywordColor; + Color m_aBackgroundColor; + Color m_aLineHighlightColor; +} ColorScheme; + +} // namespace basctl + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basctl/source/inc/dlged.hxx b/basctl/source/inc/dlged.hxx index 82d3a14f605d..c50faf51b36c 100644 --- a/basctl/source/inc/dlged.hxx +++ b/basctl/source/inc/dlged.hxx @@ -36,7 +36,7 @@ #include <memory> -class ScrollBar; +class ScrollAdaptor; class Printer; class KeyEvent; class MouseEvent; @@ -48,9 +48,8 @@ namespace basctl class DialogWindowLayout; -#define DLGED_PAGE_WIDTH_MIN 1280 -#define DLGED_PAGE_HEIGHT_MIN 1024 - +constexpr auto DLGED_PAGE_WIDTH_MIN = 1280; +constexpr auto DLGED_PAGE_HEIGHT_MIN = 1024; // DlgEdHint @@ -108,12 +107,12 @@ private: static void Print( Printer* pPrinter, const OUString& rTitle ); private: - VclPtr<ScrollBar> pHScroll; - VclPtr<ScrollBar> pVScroll; + VclPtr<ScrollAdaptor> pHScroll; + VclPtr<ScrollAdaptor> pVScroll; std::unique_ptr<DlgEdModel> pDlgEdModel; // never nullptr DlgEdPage* pDlgEdPage; // never nullptr std::unique_ptr<DlgEdView> pDlgEdView; // never nullptr - DlgEdForm* pDlgEdForm; // never nullptr + rtl::Reference<DlgEdForm> pDlgEdForm; // never nullptr css::uno::Reference< css::container::XNameContainer > m_xUnoControlDialogModel; css::uno::Reference< css::awt::XControlContainer > m_xControlContainer; css::uno::Sequence< css::datatransfer::DataFlavor > m_ClipboardDataFlavors; @@ -150,10 +149,10 @@ public: css::uno::Reference< css::awt::XControlContainer > const & GetWindowControlContainer(); - void SetScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll ); + void SetScrollBars(ScrollAdaptor* pHScroll, ScrollAdaptor* pVScroll); void InitScrollBars(); - ScrollBar* GetHScroll() const { return pHScroll; } - ScrollBar* GetVScroll() const { return pVScroll; } + ScrollAdaptor* GetHScroll() const { return pHScroll; } + ScrollAdaptor* GetVScroll() const { return pVScroll; } void DoScroll(); void UpdateScrollBars(); diff --git a/basctl/source/inc/dlgeddef.hxx b/basctl/source/inc/dlgeddef.hxx index 0cb0a6dc8573..c10ef16cd8d3 100644 --- a/basctl/source/inc/dlgeddef.hxx +++ b/basctl/source/inc/dlgeddef.hxx @@ -19,27 +19,27 @@ #pragma once -#include <svx/svdobjkind.hxx> +#include <rtl/ustring.hxx> namespace basctl { // control properties #define DLGED_PROP_BACKGROUNDCOLOR "BackgroundColor" -#define DLGED_PROP_DROPDOWN "Dropdown" -#define DLGED_PROP_FORMATSSUPPLIER "FormatsSupplier" -#define DLGED_PROP_HEIGHT "Height" -#define DLGED_PROP_LABEL "Label" -#define DLGED_PROP_NAME "Name" -#define DLGED_PROP_ORIENTATION "Orientation" -#define DLGED_PROP_POSITIONX "PositionX" -#define DLGED_PROP_POSITIONY "PositionY" -#define DLGED_PROP_STEP "Step" -#define DLGED_PROP_TABINDEX "TabIndex" +inline constexpr OUString DLGED_PROP_DROPDOWN = u"Dropdown"_ustr; +inline constexpr OUString DLGED_PROP_FORMATSSUPPLIER = u"FormatsSupplier"_ustr; +inline constexpr OUString DLGED_PROP_HEIGHT = u"Height"_ustr; +inline constexpr OUString DLGED_PROP_LABEL = u"Label"_ustr; +inline constexpr OUString DLGED_PROP_NAME = u"Name"_ustr; +inline constexpr OUString DLGED_PROP_ORIENTATION = u"Orientation"_ustr; +inline constexpr OUString DLGED_PROP_POSITIONX = u"PositionX"_ustr; +inline constexpr OUString DLGED_PROP_POSITIONY = u"PositionY"_ustr; +inline constexpr OUString DLGED_PROP_STEP = u"Step"_ustr; +inline constexpr OUString DLGED_PROP_TABINDEX = u"TabIndex"_ustr; #define DLGED_PROP_TEXTCOLOR "TextColor" #define DLGED_PROP_TEXTLINECOLOR "TextLineColor" -#define DLGED_PROP_WIDTH "Width" -#define DLGED_PROP_DECORATION "Decoration" +inline constexpr OUString DLGED_PROP_WIDTH = u"Width"_ustr; +inline constexpr OUString DLGED_PROP_DECORATION = u"Decoration"_ustr; } // namespace basctl diff --git a/basctl/source/inc/dlgedfac.hxx b/basctl/source/inc/dlgedfac.hxx index f780bc22bb95..5e583ada1729 100644 --- a/basctl/source/inc/dlgedfac.hxx +++ b/basctl/source/inc/dlgedfac.hxx @@ -32,10 +32,10 @@ class DlgEdFactory const css::uno::Reference<css::frame::XModel> mxModel; public: - DlgEdFactory(const css::uno::Reference<css::frame::XModel>& xModel); + DlgEdFactory(css::uno::Reference<css::frame::XModel> xModel); ~DlgEdFactory() COVERITY_NOEXCEPT_FALSE; - DECL_LINK(MakeObject, SdrObjCreatorParams, SdrObject*); + DECL_LINK(MakeObject, SdrObjCreatorParams, rtl::Reference<SdrObject>); }; } // namespace basctl diff --git a/basctl/source/inc/dlgedmod.hxx b/basctl/source/inc/dlgedmod.hxx index 2960135e0d3d..24a97905b1d3 100644 --- a/basctl/source/inc/dlgedmod.hxx +++ b/basctl/source/inc/dlgedmod.hxx @@ -37,7 +37,7 @@ public: DlgEdModel(); virtual ~DlgEdModel() override; - virtual SdrPage* AllocPage(bool bMasterPage) override; + virtual rtl::Reference<SdrPage> AllocPage(bool bMasterPage) override; }; } // namespace basctl diff --git a/basctl/source/inc/dlgedobj.hxx b/basctl/source/inc/dlgedobj.hxx index 8ae88ef5c80a..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; @@ -59,6 +59,8 @@ private: protected: DlgEdObj(SdrModel& rSdrModel); + // copy constructor + DlgEdObj(SdrModel& rSdrModel, DlgEdObj const & rSource); DlgEdObj( SdrModel& rSdrModel, const OUString& rModelName, @@ -91,22 +93,16 @@ protected: sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut ); public: - DlgEdObj(DlgEdObj const &) = delete; // due to SdrUnoObj - DlgEdObj(DlgEdObj &&) = delete; // due to SdrUnoObj - DlgEdObj & operator =(DlgEdObj const &) = default; - DlgEdObj & operator =(DlgEdObj &&) = default; - 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 - void clonedFrom(const DlgEdObj* _pSource); // 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/dlgedpage.hxx b/basctl/source/inc/dlgedpage.hxx index 7b8d48faa331..91efc12edd70 100644 --- a/basctl/source/inc/dlgedpage.hxx +++ b/basctl/source/inc/dlgedpage.hxx @@ -39,7 +39,7 @@ public: explicit DlgEdPage(DlgEdModel& rModel, bool bMasterPage = false); virtual ~DlgEdPage() override; - virtual SdrPage* CloneSdrPage(SdrModel& rTargetModel) const override; + virtual rtl::Reference<SdrPage> CloneSdrPage(SdrModel& rTargetModel) const override; void SetDlgEdForm(DlgEdForm* pForm) { pDlgEdForm = pForm; } DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; } diff --git a/basctl/source/inc/docsignature.hxx b/basctl/source/inc/docsignature.hxx index 94e7db2224dd..1681807d390e 100644 --- a/basctl/source/inc/docsignature.hxx +++ b/basctl/source/inc/docsignature.hxx @@ -20,7 +20,6 @@ #include <sfx2/signaturestate.hxx> #include <vcl/weld.hxx> -#include <memory> class SfxObjectShell; @@ -40,7 +39,6 @@ namespace basctl which does not support being signed, the DocumentSignature instance is invalid afterwards. */ explicit DocumentSignature (ScriptDocument const&); - ~DocumentSignature(); /** determines whether the instance is valid diff --git a/basctl/source/inc/iderid.hxx b/basctl/source/inc/iderid.hxx index 5d18586079e5..83cbc3d0c4aa 100644 --- a/basctl/source/inc/iderid.hxx +++ b/basctl/source/inc/iderid.hxx @@ -20,10 +20,11 @@ #pragma once #include <rtl/ustring.hxx> +#include <unotools/resmgr.hxx> namespace basctl { -OUString IDEResId(const char* pId); +OUString IDEResId(TranslateId aId); } // namespace basctl diff --git a/basctl/source/inc/localizationmgr.hxx b/basctl/source/inc/localizationmgr.hxx index 847ef0f75729..3e2ff0fc58a8 100644 --- a/basctl/source/inc/localizationmgr.hxx +++ b/basctl/source/inc/localizationmgr.hxx @@ -72,7 +72,7 @@ class LocalizationMgr void implEnableDisableResourceForAllLibraryDialogs( HandleResourceMode eMode ); public: - LocalizationMgr(Shell*, ScriptDocument const&, OUString const& aLibName, + LocalizationMgr(Shell*, ScriptDocument , OUString aLibName, const css::uno::Reference < css::resource::XStringResourceManager >& xStringResourceManager ); const css::uno::Reference< css::resource::XStringResourceManager >& getStringResourceManager() const diff --git a/basctl/source/inc/managelang.hxx b/basctl/source/inc/managelang.hxx index 722ec60c46ac..58dd4189057a 100644 --- a/basctl/source/inc/managelang.hxx +++ b/basctl/source/inc/managelang.hxx @@ -19,6 +19,7 @@ #pragma once +#include <utility> #include <vcl/weld.hxx> class SvxLanguageBox; @@ -33,9 +34,9 @@ struct LanguageEntry css::lang::Locale m_aLocale; bool m_bIsDefault; - LanguageEntry( const css::lang::Locale& _rLocale, + LanguageEntry( css::lang::Locale _aLocale, bool _bIsDefault ) : - m_aLocale( _rLocale ), + m_aLocale(std::move( _aLocale )), m_bIsDefault( _bIsDefault ) {} }; @@ -65,7 +66,7 @@ private: DECL_LINK(SelectHdl, weld::TreeView&, void); public: - ManageLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> const & _pLMgr); + ManageLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> _pLMgr); virtual ~ManageLanguageDialog() override; }; @@ -86,7 +87,7 @@ private: std::unique_ptr<SvxLanguageBox> m_xLanguageCB; public: - SetDefaultLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> const & xLMgr); + SetDefaultLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> xLMgr); virtual ~SetDefaultLanguageDialog() override; css::uno::Sequence< css::lang::Locale > GetLocales() const; diff --git a/basctl/source/inc/sbxitem.hxx b/basctl/source/inc/sbxitem.hxx index e5f8d65d900f..941ffd3e0ee9 100644 --- a/basctl/source/inc/sbxitem.hxx +++ b/basctl/source/inc/sbxitem.hxx @@ -44,8 +44,8 @@ class SbxItem : public SfxPoolItem public: static SfxPoolItem* CreateDefault(); - SbxItem(sal_uInt16 nWhich, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, ItemType); - SbxItem(sal_uInt16 nWhich, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, const OUString& aMethodName, ItemType eType); + SbxItem(sal_uInt16 nWhich, ScriptDocument aDocument, OUString aLibName, OUString aName, ItemType); + SbxItem(sal_uInt16 nWhich, ScriptDocument aDocument, OUString aLibName, OUString aName, OUString aMethodName, ItemType eType); virtual SbxItem* Clone(SfxItemPool *pPool = nullptr) const override; virtual bool operator==(const SfxPoolItem&) const override; diff --git a/basctl/uiconfig/basicide/menubar/menubar.xml b/basctl/uiconfig/basicide/menubar/menubar.xml index ac59065c9daf..bf41ce562bec 100644 --- a/basctl/uiconfig/basicide/menubar/menubar.xml +++ b/basctl/uiconfig/basicide/menubar/menubar.xml @@ -55,6 +55,7 @@ <menu:menuitem menu:id=".uno:Paste"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:SelectAll"/> + <menu:menuitem menu:id=".uno:ToggleComment"/> <menu:menuseparator/> <menu:menuitem menu:id="vnd.sun.star.findbar:FocusToFindbar"/> <menu:menuitem menu:id=".uno:SearchDialog"/> @@ -65,10 +66,13 @@ <menu:menupopup> <menu:menuitem menu:id=".uno:AvailableToolbars"/> <menu:menuitem menu:id=".uno:StatusBarVisible"/> + <menu:menuitem menu:id=".uno:BasicColorSchemeDialog"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:ShowLines"/> <menu:menuitem menu:id=".uno:ShowPropBrowser"/> <menu:menuitem menu:id=".uno:ObjectCatalog"/> + <menu:menuitem menu:id=".uno:WatchWindow"/> + <menu:menuitem menu:id=".uno:StackWindow"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:FullScreen"/> </menu:menupopup> @@ -174,4 +178,3 @@ </menu:menupopup> </menu:menu> </menu:menubar> - diff --git a/basctl/uiconfig/basicide/statusbar/statusbar.xml b/basctl/uiconfig/basicide/statusbar/statusbar.xml index 9e652719fdfb..a5bde3ad0a17 100644 --- a/basctl/uiconfig/basicide/statusbar/statusbar.xml +++ b/basctl/uiconfig/basicide/statusbar/statusbar.xml @@ -24,4 +24,6 @@ <statusbar:statusbaritem xlink:href=".uno:InsertMode" statusbar:align="center" statusbar:width="55"/> <statusbar:statusbaritem xlink:href=".uno:Signature" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="16"/> <statusbar:statusbaritem xlink:href=".uno:Size" statusbar:align="left" statusbar:autosize="true" statusbar:ownerdraw="true" statusbar:width="140"/> + <statusbar:statusbaritem xlink:href=".uno:ZoomSlider" statusbar:align="center" statusbar:ownerdraw="true" statusbar:mandatory="true" statusbar:width="130"/> + <statusbar:statusbaritem xlink:href=".uno:BasicIDEZoom" statusbar:align="center" statusbar:mandatory="true" statusbar:width="35"/> </statusbar:statusbar> diff --git a/basctl/uiconfig/basicide/toolbar/standardbar.xml b/basctl/uiconfig/basicide/toolbar/standardbar.xml index 41541aa91898..f41df28ab649 100644 --- a/basctl/uiconfig/basicide/toolbar/standardbar.xml +++ b/basctl/uiconfig/basicide/toolbar/standardbar.xml @@ -35,6 +35,9 @@ <toolbar:toolbaritem xlink:href=".uno:Redo"/> <toolbar:toolbarseparator/> <toolbar:toolbaritem xlink:href=".uno:ObjectCatalog"/> + <toolbar:toolbaritem xlink:href=".uno:WatchWindow"/> + <toolbar:toolbaritem xlink:href=".uno:StackWindow"/> + <toolbar:toolbarseparator/> <toolbar:toolbaritem xlink:href=".uno:ChooseMacro"/> <toolbar:toolbaritem xlink:href=".uno:ModuleDialog"/> <toolbar:toolbarseparator/> diff --git a/basctl/uiconfig/basicide/ui/basicmacrodialog.ui b/basctl/uiconfig/basicide/ui/basicmacrodialog.ui index ff6a0890450a..bdece2cca419 100644 --- a/basctl/uiconfig/basicide/ui/basicmacrodialog.ui +++ b/basctl/uiconfig/basicide/ui/basicmacrodialog.ui @@ -23,7 +23,7 @@ <object class="GtkDialog" id="BasicMacroDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> - <property name="title" translatable="yes" context="basicmacrodialog|BasicMacroDialog">Basic Macros</property> + <property name="title" translatable="yes" context="basicmacrodialog|BasicMacroDialog">BASIC Macros</property> <property name="modal">True</property> <property name="type_hint">dialog</property> <child internal-child="vbox"> @@ -166,7 +166,6 @@ <property name="can_focus">False</property> <property name="label" translatable="yes" context="basicmacrodialog|existingmacrosft">Existing Macros In:</property> <property name="ellipsize">end</property> - <property name="track_visited_links">False</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -354,7 +353,7 @@ <property name="use_underline">True</property> <child internal-child="accessible"> <object class="AtkObject" id="edit-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="basicmacrodialog|extended_tip|edit">Starts the %PRODUCTNAME Basic editor and opens the selected macro or dialog for editing.</property> + <property name="AtkObject::accessible-description" translatable="yes" context="basicmacrodialog|extended_tip|edit">Starts the Basic editor and opens the selected macro or dialog for editing.</property> </object> </child> </object> diff --git a/basctl/uiconfig/basicide/ui/colorscheme.ui b/basctl/uiconfig/basicide/ui/colorscheme.ui new file mode 100644 index 000000000000..7cc51fd7602f --- /dev/null +++ b/basctl/uiconfig/basicide/ui/colorscheme.ui @@ -0,0 +1,217 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.40.0 --> +<interface domain="basctl"> + <requires lib="gtk+" version="3.24"/> + <object class="GtkListStore" id="liststore1"> + <columns> + <!-- column-name scheme --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkDialog" id="ColorSchemeDialog"> + <property name="can-focus">False</property> + <property name="border-width">6</property> + <property name="title" translatable="yes" context="colorscheme|ColorSchemeDialog">Color Scheme</property> + <property name="resizable">False</property> + <property name="type-hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox"> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <child internal-child="action_area"> + <object class="GtkButtonBox"> + <property name="can-focus">False</property> + <property name="layout-style">end</property> + <child> + <object class="GtkButton" id="btn_help"> + <property name="label" translatable="yes" context="stock">_Help</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="use-underline">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="btn_ok"> + <property name="label" translatable="yes" context="stock">_OK</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="use-underline">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="btn_cancel"> + <property name="label" translatable="yes" context="stock">_Cancel</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="use-underline">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="options"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label-xalign">0</property> + <property name="shadow-type">none</property> + <child> + <object class="GtkAlignment"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="left-padding">12</property> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkRadioButton" id="opt_appcolors"> + <property name="label" translatable="yes" context="colorscheme|opt_appcolors">Use Application Colors</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="active">True</property> + <property name="draw-indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="opt_usescheme"> + <property name="label" translatable="yes" context="colorscheme|opt_usescheme">Choose Color Scheme</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="active">True</property> + <property name="draw-indicator">True</property> + <property name="group">opt_appcolors</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="lb_title"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="colorscheme|lb_title">Basic IDE Color Options</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkFrame"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-start">6</property> + <property name="margin-end">6</property> + <property name="margin-top">6</property> + <property name="margin-bottom">6</property> + <property name="label-xalign">0</property> + <property name="shadow-type">none</property> + <child> + <object class="GtkAlignment"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="left-padding">12</property> + <child> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="shadow-type">in</property> + <child> + <object class="GtkTreeView" id="schemelist"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers-visible">False</property> + <property name="headers-clickable">False</property> + <property name="search-column">0</property> + <property name="show-expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> + <child> + <object class="GtkTreeViewColumn"> + <child> + <object class="GtkCellRendererText" id="rendertext"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="lb_schemes"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-bottom">6</property> + <property name="label" translatable="yes" context="colorscheme|lb_schemes">Color Schemes</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="-11">btn_help</action-widget> + <action-widget response="-5">btn_ok</action-widget> + <action-widget response="-6">btn_cancel</action-widget> + </action-widgets> + </object> +</interface> diff --git a/basctl/uiconfig/basicide/ui/dialogpage.ui b/basctl/uiconfig/basicide/ui/dialogpage.ui index ae996b2ea490..373fc2f4f85b 100644 --- a/basctl/uiconfig/basicide/ui/dialogpage.ui +++ b/basctl/uiconfig/basicide/ui/dialogpage.ui @@ -125,7 +125,7 @@ <property name="use_underline">True</property> <child internal-child="accessible"> <object class="AtkObject" id="edit-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="dialogpage|extended_tip|edit">Opens the %PRODUCTNAME Basic editor so that you can modify the selected library.</property> + <property name="AtkObject::accessible-description" translatable="yes" context="dialogpage|extended_tip|edit">Opens the Basic editor so that you can modify the selected library.</property> </object> </child> </object> @@ -218,7 +218,7 @@ <property name="use_underline">True</property> <child internal-child="accessible"> <object class="AtkObject" id="import-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="dialogpage|extended_tip|import">Locate that %PRODUCTNAME Basic library that you want to add to the current list, and then click Open.</property> + <property name="AtkObject::accessible-description" translatable="yes" context="dialogpage|extended_tip|import">Locate the Basic library that you want to add to the current list, and then click Open.</property> </object> </child> </object> diff --git a/basctl/uiconfig/basicide/ui/gotolinedialog.ui b/basctl/uiconfig/basicide/ui/gotolinedialog.ui index e5b5e13ab0fe..971d0187ba69 100644 --- a/basctl/uiconfig/basicide/ui/gotolinedialog.ui +++ b/basctl/uiconfig/basicide/ui/gotolinedialog.ui @@ -1,32 +1,33 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.4 --> +<!-- Generated with glade 3.40.0 --> <interface domain="basctl"> <requires lib="gtk+" version="3.20"/> <object class="GtkDialog" id="GotoLineDialog"> - <property name="can_focus">False</property> - <property name="border_width">6</property> + <property name="can-focus">False</property> + <property name="border-width">6</property> <property name="title" translatable="yes" context="gotolinedialog|GotoLineDialog">Go to Line</property> + <property name="resizable">False</property> <property name="modal">True</property> - <property name="default_width">0</property> - <property name="default_height">0</property> - <property name="type_hint">dialog</property> + <property name="default-width">0</property> + <property name="default-height">0</property> + <property name="type-hint">dialog</property> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="orientation">vertical</property> <property name="spacing">12</property> <child internal-child="action_area"> <object class="GtkButtonBox" id="dialog-action_area1"> - <property name="can_focus">False</property> - <property name="layout_style">end</property> + <property name="can-focus">False</property> + <property name="layout-style">end</property> <child> <object class="GtkButton" id="ok"> <property name="label" translatable="yes" context="stock">_OK</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="receives_default">True</property> + <property name="can-focus">True</property> + <property name="can-default">True</property> + <property name="has-default">True</property> + <property name="receives-default">True</property> <property name="use-underline">True</property> </object> <packing> @@ -39,8 +40,8 @@ <object class="GtkButton" id="cancel"> <property name="label" translatable="yes" context="stock">_Cancel</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> <property name="use-underline">True</property> </object> <packing> @@ -49,63 +50,56 @@ <property name="position">1</property> </packing> </child> - <child> - <object class="GtkButton" id="help"> - <property name="label" translatable="yes" context="stock">_Help</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="margin-end">6</property> - <property name="use-underline">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - <property name="secondary">True</property> - </packing> - </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="pack_type">end</property> + <property name="pack-type">end</property> <property name="position">2</property> </packing> </child> <child> - <!-- n-columns=1 n-rows=1 --> + <!-- n-columns=3 n-rows=1 --> <object class="GtkGrid" id="grid3"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="hexpand">True</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> + <property name="row-spacing">12</property> + <property name="column-spacing">12</property> <child> <object class="GtkLabel" id="area"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="label" translatable="yes" context="gotolinedialog|area">_Line number:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">spin</property> <property name="xalign">0</property> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> + <property name="left-attach">0</property> + <property name="top-attach">0</property> </packing> </child> <child> - <object class="GtkEntry" id="entry"> + <object class="GtkSpinButton" id="spin"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> <property name="truncate-multiline">True</property> - <property name="activates_default">True</property> + <property name="can-focus">True</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="line_count"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="gotolinedialog|line_count">of $1</property> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> + <property name="left-attach">2</property> + <property name="top-attach">0</property> </packing> </child> </object> @@ -120,10 +114,6 @@ <action-widgets> <action-widget response="-5">ok</action-widget> <action-widget response="-6">cancel</action-widget> - <action-widget response="-11">help</action-widget> </action-widgets> - <child> - <placeholder/> - </child> </object> </interface> diff --git a/basctl/uiconfig/basicide/ui/importlibdialog.ui b/basctl/uiconfig/basicide/ui/importlibdialog.ui index f1a4877ac3b4..98066ca8272a 100644 --- a/basctl/uiconfig/basicide/ui/importlibdialog.ui +++ b/basctl/uiconfig/basicide/ui/importlibdialog.ui @@ -119,7 +119,7 @@ <property name="draw_indicator">True</property> <child internal-child="accessible"> <object class="AtkObject" id="ref-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="importlibdialog|extended_tip|ref">Adds the selected library as a read-only file. The library is reloaded each time you start %PRODUCTNAME.</property> + <property name="AtkObject::accessible-description" translatable="yes" context="importlibdialog|extended_tip|ref">Adds the selected library as a read-only file. The library is reloaded each time you start the office suite.</property> </object> </child> </object> diff --git a/basctl/uiconfig/basicide/ui/libpage.ui b/basctl/uiconfig/basicide/ui/libpage.ui index 1c10b43eb3d1..6047b0c906a9 100644 --- a/basctl/uiconfig/basicide/ui/libpage.ui +++ b/basctl/uiconfig/basicide/ui/libpage.ui @@ -183,7 +183,7 @@ <property name="use_underline">True</property> <child internal-child="accessible"> <object class="AtkObject" id="edit-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="libpage|extended_tip|edit">Opens the %PRODUCTNAME Basic editor so that you can modify the selected library.</property> + <property name="AtkObject::accessible-description" translatable="yes" context="libpage|extended_tip|edit">Opens the Basic editor so that you can modify the selected library.</property> </object> </child> </object> @@ -241,7 +241,7 @@ <property name="use_underline">True</property> <child internal-child="accessible"> <object class="AtkObject" id="import-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="libpage|extended_tip|import">Locate that %PRODUCTNAME Basic library that you want to add to the current list, and then click Open.</property> + <property name="AtkObject::accessible-description" translatable="yes" context="libpage|extended_tip|import">Locate the Basic library that you want to add to the current list, and then click Open.</property> </object> </child> </object> diff --git a/basctl/uiconfig/basicide/ui/managelanguages.ui b/basctl/uiconfig/basicide/ui/managelanguages.ui index c19e37f6bbbe..1b18eed23fba 100644 --- a/basctl/uiconfig/basicide/ui/managelanguages.ui +++ b/basctl/uiconfig/basicide/ui/managelanguages.ui @@ -96,6 +96,9 @@ <property name="wrap">True</property> <property name="max_width_chars">68</property> <property name="xalign">0</property> + <attributes> + <attribute name="scale" value="0.9"/> + </attributes> </object> <packing> <property name="left_attach">0</property> diff --git a/basctl/uiconfig/basicide/ui/modulepage.ui b/basctl/uiconfig/basicide/ui/modulepage.ui index 284a4b3f0077..328add73b63b 100644 --- a/basctl/uiconfig/basicide/ui/modulepage.ui +++ b/basctl/uiconfig/basicide/ui/modulepage.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.36.0 --> +<!-- Generated with glade 3.38.2 --> <interface domain="basctl"> <requires lib="gtk+" version="3.20"/> <object class="GtkTreeStore" id="liststore1"> @@ -15,59 +15,59 @@ <!-- n-columns=1 n-rows=1 --> <object class="GtkGrid" id="ModulePage"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="border_width">6</property> - <property name="row_spacing">12</property> + <property name="can-focus">False</property> + <property name="border-width">6</property> + <property name="row-spacing">12</property> <child> - <!-- n-columns=1 n-rows=1 --> + <!-- n-columns=2 n-rows=1 --> <object class="GtkGrid" id="grid2"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <property name="column_spacing">12</property> + <property name="column-spacing">12</property> <child> - <!-- n-columns=1 n-rows=1 --> + <!-- n-columns=1 n-rows=2 --> <object class="GtkGrid" id="grid3"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <property name="row_spacing">6</property> + <property name="row-spacing">6</property> <child> <object class="GtkLabel" id="label1"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="label" translatable="yes" context="modulepage|label1">M_odule:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">library</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">library</property> <property name="xalign">0</property> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> + <property name="left-attach">0</property> + <property name="top-attach">0</property> </packing> </child> <child> <object class="GtkScrolledWindow"> <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="can-focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <property name="shadow_type">in</property> + <property name="shadow-type">in</property> <child> <object class="GtkTreeView" id="library"> - <property name="width_request">-1</property> + <property name="width-request">-1</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> <property name="model">liststore1</property> - <property name="headers_visible">False</property> + <property name="headers-visible">False</property> <property name="reorderable">True</property> - <property name="search_column">1</property> - <property name="enable_tree_lines">True</property> + <property name="search-column">1</property> + <property name="enable-tree-lines">True</property> <child internal-child="selection"> <object class="GtkTreeSelection" id="Macro Library List-selection1"/> </child> @@ -99,33 +99,33 @@ </child> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> + <property name="left-attach">0</property> + <property name="top-attach">1</property> </packing> </child> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> + <property name="left-attach">0</property> + <property name="top-attach">0</property> </packing> </child> <child> <object class="GtkButtonBox" id="buttonbox1"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="orientation">vertical</property> <property name="spacing">6</property> - <property name="layout_style">start</property> + <property name="layout-style">start</property> <child> <object class="GtkButton" id="edit"> <property name="label" translatable="yes" context="stock">_Edit</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_underline">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="use-underline">True</property> <child internal-child="accessible"> <object class="AtkObject" id="edit-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="modulepage|extended_tip|edit">Opens the %PRODUCTNAME Basic editor so that you can modify the selected library.</property> + <property name="AtkObject::accessible-description" translatable="yes" context="modulepage|extended_tip|edit">Opens the Basic editor so that you can modify the selected library.</property> </object> </child> </object> @@ -139,9 +139,9 @@ <object class="GtkButton" id="newmodule"> <property name="label" translatable="yes" context="modulepage|newmodule">_New...</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_underline">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="use-underline">True</property> <child internal-child="accessible"> <object class="AtkObject" id="newmodule-atkobject"> <property name="AtkObject::accessible-description" translatable="yes" context="modulepage|extended_tip|newmodule">Opens the editor and creates a new module.</property> @@ -159,9 +159,9 @@ <object class="GtkButton" id="newdialog"> <property name="label" translatable="yes" context="modulepage|newdialog">_New...</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_underline">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="use-underline">True</property> <child internal-child="accessible"> <object class="AtkObject" id="newdialog-atkobject"> <property name="AtkObject::accessible-description" translatable="yes" context="modulepage|extended_tip|newdialog">Lets you manage the macro libraries.</property> @@ -179,9 +179,9 @@ <object class="GtkButton" id="delete"> <property name="label" translatable="yes" context="stock">_Delete</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_underline">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="use-underline">True</property> <child internal-child="accessible"> <object class="AtkObject" id="delete-atkobject"> <property name="AtkObject::accessible-description" translatable="yes" context="modulepage|extended_tip|delete">Creates a new macro, or deletes the selected macro.</property> @@ -198,10 +198,10 @@ <child> <object class="GtkButton" id="password"> <property name="label" translatable="yes" context="modulepage|password">_Password...</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="no_show_all">True</property> - <property name="use_underline">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="no-show-all">True</property> + <property name="use-underline">True</property> <child internal-child="accessible"> <object class="AtkObject" id="password-atkobject"> <property name="AtkObject::accessible-description" translatable="yes" context="modulepage|extended_tip|password">Assigns or edits the password for the selected library.</property> @@ -217,13 +217,13 @@ <child> <object class="GtkButton" id="import"> <property name="label" translatable="yes" context="modulepage|import">_Import...</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="no_show_all">True</property> - <property name="use_underline">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="no-show-all">True</property> + <property name="use-underline">True</property> <child internal-child="accessible"> <object class="AtkObject" id="import-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="modulepage|extended_tip|import">Locate that %PRODUCTNAME Basic library that you want to add to the current list, and then click Open.</property> + <property name="AtkObject::accessible-description" translatable="yes" context="modulepage|extended_tip|import">Locate the Basic library that you want to add to the current list, and then click Open.</property> </object> </child> </object> @@ -236,10 +236,10 @@ <child> <object class="GtkButton" id="export"> <property name="label" translatable="yes" context="modulepage|export">_Export...</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="no_show_all">True</property> - <property name="use_underline">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="no-show-all">True</property> + <property name="use-underline">True</property> </object> <packing> <property name="expand">False</property> @@ -249,14 +249,14 @@ </child> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> + <property name="left-attach">1</property> + <property name="top-attach">0</property> </packing> </child> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> + <property name="left-attach">0</property> + <property name="top-attach">0</property> </packing> </child> <child internal-child="accessible"> |