summaryrefslogtreecommitdiff
path: root/basctl/source/basicide
diff options
context:
space:
mode:
Diffstat (limited to 'basctl/source/basicide')
-rw-r--r--basctl/source/basicide/IDEComboBox.cxx14
-rw-r--r--basctl/source/basicide/ObjectCatalog.cxx4
-rw-r--r--basctl/source/basicide/basdoc.cxx2
-rw-r--r--basctl/source/basicide/basdoc.hxx2
-rw-r--r--basctl/source/basicide/basicrenderable.cxx2
-rw-r--r--basctl/source/basicide/baside2.cxx51
-rw-r--r--basctl/source/basicide/baside2.hxx39
-rw-r--r--basctl/source/basicide/baside2b.cxx249
-rw-r--r--basctl/source/basicide/baside3.cxx85
-rw-r--r--basctl/source/basicide/basides1.cxx204
-rw-r--r--basctl/source/basicide/basides2.cxx15
-rw-r--r--basctl/source/basicide/basides3.cxx4
-rw-r--r--basctl/source/basicide/basidesh.cxx100
-rw-r--r--basctl/source/basicide/basobj2.cxx58
-rw-r--r--basctl/source/basicide/basobj3.cxx50
-rw-r--r--basctl/source/basicide/bastype2.cxx55
-rw-r--r--basctl/source/basicide/bastype3.cxx6
-rw-r--r--basctl/source/basicide/bastypes.cxx120
-rw-r--r--basctl/source/basicide/brkdlg.cxx6
-rw-r--r--basctl/source/basicide/doceventnotifier.cxx2
-rw-r--r--basctl/source/basicide/docsignature.cxx4
-rw-r--r--basctl/source/basicide/documentenumeration.cxx22
-rw-r--r--basctl/source/basicide/documentenumeration.hxx4
-rw-r--r--basctl/source/basicide/linenumberwindow.cxx17
-rw-r--r--basctl/source/basicide/localizationmgr.cxx17
-rw-r--r--basctl/source/basicide/macrodlg.cxx47
-rw-r--r--basctl/source/basicide/moduldl2.cxx42
-rw-r--r--basctl/source/basicide/moduldlg.cxx84
-rw-r--r--basctl/source/basicide/moduldlg.hxx7
-rw-r--r--basctl/source/basicide/sbxitem.cxx29
-rw-r--r--basctl/source/basicide/scriptdocument.cxx43
-rw-r--r--basctl/source/basicide/unomodel.cxx1
32 files changed, 887 insertions, 498 deletions
diff --git a/basctl/source/basicide/IDEComboBox.cxx b/basctl/source/basicide/IDEComboBox.cxx
index e295e44ff1ed..423e5c5d1cda 100644
--- a/basctl/source/basicide/IDEComboBox.cxx
+++ b/basctl/source/basicide/IDEComboBox.cxx
@@ -222,7 +222,7 @@ void LibBox::FillBox()
// create list box entries
LibEntry* pEntry = new LibEntry(ScriptDocument::getApplicationScriptDocument(),
LIBRARY_LOCATION_UNKNOWN, OUString());
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
+ OUString sId(weld::toId(pEntry));
m_xWidget->append(sId, IDEResId(RID_STR_ALL));
InsertEntries(ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER);
@@ -261,7 +261,7 @@ void LibBox::InsertEntries(const ScriptDocument& rDocument, LibraryLocation eLoc
OUString aName(rDocument.getTitle(eLocation));
OUString aEntryText(CreateMgrAndLibStr(aName, aLibName));
LibEntry* pEntry = new LibEntry(rDocument, eLocation, aLibName);
- m_xWidget->append(OUString::number(reinterpret_cast<sal_Int64>(pEntry)), aEntryText);
+ m_xWidget->append(weld::toId(pEntry), aEntryText);
}
}
}
@@ -320,7 +320,7 @@ void LibBox::Select()
void LibBox::NotifyIDE()
{
- LibEntry* pEntry = reinterpret_cast<LibEntry*>(m_xWidget->get_active_id().toInt64());
+ LibEntry* pEntry = weld::fromId<LibEntry*>(m_xWidget->get_active_id());
if (pEntry)
{
const ScriptDocument& aDocument(pEntry->GetDocument());
@@ -340,7 +340,7 @@ void LibBox::ClearBox()
sal_Int32 nCount = m_xWidget->get_count();
for (sal_Int32 i = 0; i < nCount; ++i)
{
- LibEntry* pEntry = reinterpret_cast<LibEntry*>(m_xWidget->get_id(i).toInt64());
+ LibEntry* pEntry = weld::fromId<LibEntry*>(m_xWidget->get_id(i));
delete pEntry;
}
m_xWidget->clear();
@@ -440,7 +440,7 @@ void LanguageBox::FillBox()
sLanguage += " " + msDefaultLanguageStr;
}
LanguageEntry* pEntry = new LanguageEntry(pLocale[i], bIsDefault);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
+ OUString sId(weld::toId(pEntry));
m_xWidget->append(sId, sLanguage);
if (bIsCurrent)
@@ -467,7 +467,7 @@ void LanguageBox::ClearBox()
sal_Int32 nCount = m_xWidget->get_count();
for (sal_Int32 i = 0; i < nCount; ++i)
{
- LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xWidget->get_id(i).toInt64());
+ LanguageEntry* pEntry = weld::fromId<LanguageEntry*>(m_xWidget->get_id(i));
delete pEntry;
}
m_xWidget->clear();
@@ -475,7 +475,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/ObjectCatalog.cxx b/basctl/source/basicide/ObjectCatalog.cxx
index 89b3f4e2b824..13069ed46621 100644
--- a/basctl/source/basicide/ObjectCatalog.cxx
+++ b/basctl/source/basicide/ObjectCatalog.cxx
@@ -67,7 +67,9 @@ void ObjectCatalog::ToggleFloatingMode()
DockingWindow::ToggleFloatingMode();
bool const bFloating = IsFloatingMode();
- m_xTitle->set_visible(!bFloating);
+ // tdf#152154: m_xTitle will be null during disposing
+ if (m_xTitle)
+ m_xTitle->set_visible(!bFloating);
}
void ObjectCatalog::SetCurrentEntry(BaseWindow* pCurWin)
diff --git a/basctl/source/basicide/basdoc.cxx b/basctl/source/basicide/basdoc.cxx
index 83a3f1781630..ffd22b9063c7 100644
--- a/basctl/source/basicide/basdoc.cxx
+++ b/basctl/source/basicide/basdoc.cxx
@@ -82,7 +82,7 @@ void DocShell::FillClass( SvGlobalName*, SotClipboardFormatId*, OUString*, sal_I
DBG_ASSERT( !bTemplate, "No template for Basic" );
}
-void DocShell::Draw( OutputDevice *, const JobSetup &, sal_uInt16 )
+void DocShell::Draw( OutputDevice *, const JobSetup &, sal_uInt16, bool )
{}
} // namespace basctl
diff --git a/basctl/source/basicide/basdoc.hxx b/basctl/source/basicide/basdoc.hxx
index d5b3aabcf961..bb847a0a9b1a 100644
--- a/basctl/source/basicide/basdoc.hxx
+++ b/basctl/source/basicide/basdoc.hxx
@@ -34,7 +34,7 @@ class DocShell: public SfxObjectShell
protected:
virtual void Draw( OutputDevice *, const JobSetup & rSetup,
- sal_uInt16 nAspect ) override;
+ sal_uInt16 nAspect, bool bOutputForScreen ) override;
virtual void FillClass( SvGlobalName * pClassName,
SotClipboardFormatId * pFormat,
OUString * pFullTypeName,
diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx
index 79e381399703..648f234cbdb0 100644
--- a/basctl/source/basicide/basicrenderable.cxx
+++ b/basctl/source/basicide/basicrenderable.cxx
@@ -88,7 +88,7 @@ VclPtr< Printer > Renderable::getPrinter() const
if( aValue >>= xRenderDevice )
{
- VCLXDevice* pDevice = comphelper::getFromUnoTunnel<VCLXDevice>(xRenderDevice);
+ VCLXDevice* pDevice = dynamic_cast<VCLXDevice*>(xRenderDevice.get());
VclPtr< OutputDevice > pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >();
pPrinter = dynamic_cast<Printer*>(pOut.get());
}
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index c7f99e8b8e03..12a78d9b65f4 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -38,7 +38,7 @@
#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>
@@ -56,6 +56,7 @@
#include <svl/whiter.hxx>
#include <svx/svxids.hrc>
#include <tools/debug.hxx>
+#include <utility>
#include <vcl/locktoplevels.hxx>
#include <vcl/errinf.hxx>
#include <vcl/event.hxx>
@@ -182,7 +183,7 @@ void lcl_ConvertTabsToSpaces( OUString& rLine )
OUStringBuffer aBlanker;
string::padToLength(aBlanker, ( 4 - ( nPos % 4 ) ), ' ');
aResult.remove( nPos, 1 );
- aResult.insert( nPos, aBlanker.makeStringAndClear() );
+ aResult.insert( nPos, aBlanker );
nMax = aResult.getLength();
}
++nPos;
@@ -193,12 +194,12 @@ 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))
{
m_aXEditorWindow->Show();
SetBackground();
@@ -254,9 +255,6 @@ void ModulWindow::GetFocus()
void ModulWindow::DoInit()
{
- if (GetVScrollBar())
- GetVScrollBar()->Hide();
- GetHScrollBar()->Show();
GetEditorWindow().InitScrollBars();
}
@@ -284,7 +282,7 @@ void ModulWindow::CheckCompileBasic()
bool bDone = false;
- GetShell()->GetViewFrame()->GetWindow().EnterWait();
+ GetShell()->GetViewFrame().GetWindow().EnterWait();
AssertValidEditEngine();
GetEditorWindow().SetSourceInBasic();
@@ -304,7 +302,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;
@@ -459,7 +457,6 @@ void ModulWindow::LoadBasic()
void ModulWindow::SaveBasicSource()
{
- Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD,
FileDialogFlags::NONE, this->GetFrameWeld());
aDlg.SetContext(sfx2::FileDialogHelper::BasicExportSource);
@@ -615,7 +612,7 @@ void ModulWindow::ManageBreakPoints()
void ModulWindow::BasicErrorHdl( StarBASIC const * pBasic )
{
- GetShell()->GetViewFrame()->ToTop();
+ GetShell()->GetViewFrame().ToTop();
// Return value: BOOL
// FALSE: cancel
@@ -1133,6 +1130,9 @@ void ModulWindow::GetState( SfxItemSet &rSet )
if (!sProcName.isEmpty())
aTitle += "." + sProcName;
+ if (IsReadOnly())
+ aTitle += " (" + IDEResId(RID_STR_READONLY) + ")";
+
SfxStringItem aTitleItem( SID_BASICIDE_STAT_TITLE, aTitle );
rSet.Put( aTitleItem );
}
@@ -1164,7 +1164,7 @@ void ModulWindow::GetState( SfxItemSet &rSet )
}
}
-void ModulWindow::DoScroll( ScrollBar* pCurScrollBar )
+void ModulWindow::DoScroll( Scrollable* pCurScrollBar )
{
if ( ( pCurScrollBar == GetHScrollBar() ) && GetEditView() )
{
@@ -1381,12 +1381,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;
@@ -1516,6 +1511,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));
@@ -1564,7 +1571,7 @@ void ModulWindowLayout::SyntaxColors::NewConfig (bool bFirst)
{ TokenType::Keywords, svtools::BASICKEYWORD },
};
- Color aDocColor = aConfig.GetColorValue(svtools::DOCCOLOR).nColor;
+ Color aDocColor = aConfig.GetColorValue(svtools::BASICEDITOR).nColor;
if (bFirst || aDocColor != m_aBackgroundColor)
{
m_aBackgroundColor = aDocColor;
@@ -1584,10 +1591,10 @@ void ModulWindowLayout::SyntaxColors::NewConfig (bool bFirst)
}
bool bChanged = false;
- for (unsigned i = 0; i != SAL_N_ELEMENTS(vIds); ++i)
+ for (const auto& vId: vIds)
{
- Color const aColor = aConfig.GetColorValue(vIds[i].eEntry).nColor;
- Color& rMyColor = aColors[vIds[i].eTokenType];
+ Color const aColor = aConfig.GetColorValue(vId.eEntry).nColor;
+ Color& rMyColor = aColors[vId.eTokenType];
if (bFirst || aColor != rMyColor)
{
rMyColor = aColor;
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index e59c148bc3b5..73b98ef7412e 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -20,6 +20,7 @@
#pragma once
#include <memory>
+#include <mutex>
#include <layout.hxx>
#include "breakpoint.hxx"
#include "linenumberwindow.hxx"
@@ -31,6 +32,7 @@
#include <vcl/weld.hxx>
#include <svtools/colorcfg.hxx>
+#include <svtools/scrolladaptor.hxx>
#include <o3tl/enumarray.hxx>
#include <rtl/ustrbuf.hxx>
@@ -73,7 +75,7 @@ private:
ModulWindow& rModulWindow;
rtl::Reference< ChangesListener > listener_;
- osl::Mutex mutex_;
+ std::mutex mutex_;
css::uno::Reference< css::beans::XMultiPropertySet >
notifier_;
@@ -93,8 +95,9 @@ 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;
@@ -103,7 +106,7 @@ private:
virtual css::uno::Reference< css::awt::XWindowPeer > 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,7 +125,7 @@ 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();
@@ -137,8 +140,8 @@ public:
void CreateProgress( const OUString& rText, sal_uInt32 nRange );
void DestroyProgress();
- void ParagraphInsertedDeleted( sal_uLong nNewPara, bool bInserted );
- void DoDelayedSyntaxHighlight( sal_uLong nPara );
+ void ParagraphInsertedDeleted( sal_uInt32 nNewPara, bool bInserted );
+ void DoDelayedSyntaxHighlight( sal_uInt32 nPara );
void CreateEditEngine();
void SetScrollBarRanges();
@@ -152,7 +155,10 @@ public:
void ChangeFontColor( Color aColor );
void UpdateSyntaxHighlighting ();
- 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 +258,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 +273,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);
};
@@ -293,10 +301,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;
@@ -359,7 +367,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(); }
@@ -400,6 +409,10 @@ 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); }
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 9da55fa318a8..d24955ea3788 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -40,11 +40,14 @@
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/script/XLibraryContainer2.hpp>
#include <comphelper/string.hxx>
+#include <comphelper/diagnose_ex.hxx>
+#include <o3tl/string_view.hxx>
#include <officecfg/Office/Common.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/progress.hxx>
#include <sfx2/viewfrm.hxx>
#include <tools/debug.hxx>
+#include <utility>
#include <vcl/image.hxx>
#include <vcl/weld.hxx>
#include <vcl/weldutils.hxx>
@@ -60,12 +63,15 @@
#include <vcl/svapp.hxx>
#include <vcl/taskpanelist.hxx>
#include <vcl/help.hxx>
+#include <o3tl/string_view.hxx>
#include <cppuhelper/implbase.hxx>
#include <vector>
#include <com/sun/star/reflection/theCoreReflection.hpp>
#include <unotools/charclass.hxx>
+#include <o3tl/string_view.hxx>
#include "textwindowpeer.hxx"
#include "uiobject.hxx"
+#include <basegfx/utils/zoomtools.hxx>
namespace basctl
{
@@ -202,7 +208,7 @@ private:
virtual void SAL_CALL disposing(lang::EventObject const &) override
{
- osl::MutexGuard g(editor_.mutex_);
+ std::unique_lock g(editor_.mutex_);
editor_.notifier_.clear();
}
@@ -230,7 +236,7 @@ public:
}
private:
- sal_uLong nCurState;
+ sal_uInt32 nCurState;
};
EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) :
@@ -246,7 +252,9 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) :
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);
SetPointer( PointerStyle::Text );
SetHelpId( HID_BASICIDE_EDITORWINDOW );
@@ -255,9 +263,13 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) :
officecfg::Office::Common::Font::SourceViewFont::get(),
UNO_QUERY_THROW);
{
- osl::MutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
notifier_ = n;
}
+
+ // The zoom level applied to the editor window is the zoom slider value in the shell
+ nCurrentZoomLevel = GetShell()->GetCurrentZoomSliderValue();
+
const Sequence<OUString> aPropertyNames{"FontHeight", "FontName"};
n->addPropertiesChangeListener(aPropertyNames, listener_);
}
@@ -278,7 +290,7 @@ void EditorWindow::dispose()
Reference< beans::XMultiPropertySet > n;
{
- osl::MutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
n = notifier_;
}
if (n.is()) {
@@ -467,8 +479,9 @@ void EditorWindow::MouseButtonUp( const MouseEvent &rEvt )
void EditorWindow::MouseButtonDown( const MouseEvent &rEvt )
{
GrabFocus();
- if ( pEditView )
- pEditView->MouseButtonDown( rEvt );
+ if (!pEditView)
+ return;
+ pEditView->MouseButtonDown(rEvt);
if( pCodeCompleteWnd->IsVisible() )
{
if (pEditView->GetSelection() != pCodeCompleteWnd->GetTextSelection())
@@ -489,8 +502,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->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 )
{
@@ -599,6 +629,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 );
@@ -714,9 +751,9 @@ TextSelection EditorWindow::GetLastHighlightPortionTextSelection() const
if( aPortions.empty() )
return TextSelection();
- OUString sStr = aLine.copy( r.nBegin, r.nEnd - r.nBegin );
+ std::u16string_view sStr = aLine.subView( r.nBegin, r.nEnd - r.nBegin );
TextPaM aStart( nLine, r.nBegin );
- TextPaM aEnd( nLine, r.nBegin + sStr.getLength() );
+ TextPaM aEnd( nLine, r.nBegin + sStr.size() );
return TextSelection( aStart, aEnd );
}
@@ -792,17 +829,17 @@ void EditorWindow::HandleProcedureCompletion()
if( aCurrPortions.size() >= 3 )
{//at least 3 tokens: (sub|function) whitespace identifier...
HighlightPortion& r = aCurrPortions.front();
- OUString sStr = aCurrLine.copy(r.nBegin, r.nEnd - r.nBegin);
+ std::u16string_view sStr = aCurrLine.subView(r.nBegin, r.nEnd - r.nBegin);
if( r.tokenType == TokenType::Keywords )
{
- if( sStr.equalsIgnoreAsciiCase("sub") || sStr.equalsIgnoreAsciiCase("function") )
+ if( o3tl::equalsIgnoreAsciiCase(sStr, u"sub") || o3tl::equalsIgnoreAsciiCase(sStr, u"function") )
{
pEditView->InsertText( sText );//append to the end
GetEditView()->SetSelection(aSel);
break;
}
- if( sStr.equalsIgnoreAsciiCase("end") )
+ if( o3tl::equalsIgnoreAsciiCase(sStr, u"end") )
break;
}
}
@@ -810,7 +847,7 @@ void EditorWindow::HandleProcedureCompletion()
}
}
-bool EditorWindow::GetProcedureName(OUString const & rLine, OUString& rProcType, OUString& rProcName) const
+bool EditorWindow::GetProcedureName(std::u16string_view rLine, OUString& rProcType, OUString& rProcName) const
{
std::vector<HighlightPortion> aPortions;
aHighlighter.getHighlightPortions(rLine, aPortions);
@@ -823,10 +860,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;
@@ -970,20 +1007,14 @@ void EditorWindow::SetSourceInBasic()
// Returns the position of the last character of any of the following
// EOL char combinations: CR, CR/LF, LF, return -1 if no EOL is found
-sal_Int32 searchEOL( const OUString& rStr, sal_Int32 fromIndex )
+sal_Int32 searchEOL( std::u16string_view rStr, sal_Int32 fromIndex )
{
- sal_Int32 iRetPos = -1;
+ size_t iLF = rStr.find( LINE_SEP, fromIndex );
+ if( iLF != std::u16string_view::npos )
+ return iLF;
- sal_Int32 iLF = rStr.indexOf( LINE_SEP, fromIndex );
- if( iLF != -1 )
- {
- iRetPos = iLF;
- }
- else
- {
- iRetPos = rStr.indexOf( LINE_SEP_CR, fromIndex );
- }
- return iRetPos;
+ size_t iCR = rStr.find( LINE_SEP_CR, fromIndex );
+ return iCR == std::u16string_view::npos ? -1 : iCR;
}
void EditorWindow::CreateEditEngine()
@@ -1016,7 +1047,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 +1109,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 +1132,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();
@@ -1140,7 +1168,7 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
}
}
-OUString EditorWindow::GetActualSubName( sal_uLong nLine )
+OUString EditorWindow::GetActualSubName( sal_uInt32 nLine )
{
SbxArrayRef pMethods = rModulWindow.GetSbModule()->GetMethods();
for (sal_uInt32 i = 0; i < pMethods->Count(); i++)
@@ -1165,10 +1193,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 +1210,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;
@@ -1233,6 +1256,7 @@ void EditorWindow::UpdateSyntaxHighlighting ()
void EditorWindow::ImplSetFont()
{
+ // Get default font name and height defined in the Options dialog
OUString sFontName(officecfg::Office::Common::Font::SourceViewFont::FontName::get().value_or(OUString()));
if (sFontName.isEmpty())
{
@@ -1241,7 +1265,12 @@ void EditorWindow::ImplSetFont()
GetDefaultFontFlags::NONE, GetOutDev()));
sFontName = aTmpFont.GetFamilyName();
}
- Size aFontSize(0, officecfg::Office::Common::Font::SourceViewFont::FontHeight::get());
+ sal_uInt16 nDefaultFontHeight = officecfg::Office::Common::Font::SourceViewFont::FontHeight::get();
+
+ // Calculate font size considering zoom level
+ sal_uInt16 nNewFontHeight = nDefaultFontHeight * (static_cast<float>(nCurrentZoomLevel) / 100);
+ Size aFontSize(0, nNewFontHeight);
+
vcl::Font aFont(sFontName, aFontSize);
aFont.SetColor(rModulWindow.GetLayout().GetFontColor());
SetPointFont(*GetOutDev(), aFont); // FIXME RenderContext
@@ -1249,6 +1278,7 @@ void EditorWindow::ImplSetFont()
rModulWindow.GetBreakPointWindow().SetFont(aFont);
rModulWindow.GetLineNumberWindow().SetFont(aFont);
+ rModulWindow.Invalidate();
if (pEditEngine)
{
@@ -1256,9 +1286,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 +1320,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 +1362,7 @@ IMPL_LINK_NOARG(EditorWindow, SyntaxTimerHdl, Timer *, void)
bHighlighting = false;
}
-void EditorWindow::ParagraphInsertedDeleted( sal_uLong nPara, bool bInserted )
+void EditorWindow::ParagraphInsertedDeleted( sal_uInt32 nPara, bool bInserted )
{
if ( pProgress )
pProgress->StepProgress();
@@ -1346,7 +1395,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
));
@@ -1588,8 +1637,8 @@ struct WatchItem
WatchItem* mpArrayParentItem;
- explicit WatchItem (OUString const& rName):
- maName(rName),
+ explicit WatchItem (OUString aName):
+ maName(std::move(aName)),
nDimLevel(0),
nDimCount(0),
mpArrayParentItem(nullptr)
@@ -1668,7 +1717,7 @@ void WatchWindow::dispose()
// Destroy user data
m_xTreeListBox->all_foreach([this](weld::TreeIter& rEntry){
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rEntry));
delete pItem;
return false;
});
@@ -1729,7 +1778,7 @@ void WatchWindow::AddWatch( const OUString& rVName )
lcl_SeparateNameAndIndex( rVName, aVar, aIndex );
WatchItem* pWatchItem = new WatchItem(aVar);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pWatchItem)));
+ OUString sId(weld::toId(pWatchItem));
std::unique_ptr<weld::TreeIter> xRet = m_xTreeListBox->make_iterator();
m_xTreeListBox->insert(nullptr, -1, &aVar, &sId, nullptr, nullptr, false, xRet.get());
m_xTreeListBox->set_text(*xRet, "", 1);
@@ -1752,7 +1801,7 @@ void WatchWindow::RemoveSelectedWatch()
m_xTreeListBox->remove(*xEntry);
bEntry = m_xTreeListBox->get_cursor(xEntry.get());
if (bEntry)
- m_xEdit->set_text(reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(*xEntry).toInt64())->maName);
+ m_xEdit->set_text(weld::fromId<WatchItem*>(m_xTreeListBox->get_id(*xEntry))->maName);
else
m_xEdit->set_text(OUString());
if ( !m_xTreeListBox->n_children() )
@@ -1772,7 +1821,7 @@ IMPL_LINK_NOARG(WatchWindow, TreeListHdl, weld::TreeView&, void)
bool bCurEntry = m_xTreeListBox->get_cursor(xCurEntry.get());
if (!bCurEntry)
return;
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(*xCurEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(*xCurEntry));
if (!pItem)
return;
m_xEdit->set_text(pItem->maName);
@@ -1941,7 +1990,8 @@ 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))
{
aEdtWindow->Show();
aBrkWindow->Show();
@@ -1950,6 +2000,11 @@ ComplexEditorWindow::ComplexEditorWindow( ModulWindow* pParent ) :
aEWVScrollBar->SetPageSize(nScrollPage);
aEWVScrollBar->SetScrollHdl( LINK( this, ComplexEditorWindow, ScrollHdl ) );
aEWVScrollBar->Show();
+
+ aEWHScrollBar->SetLineSize(nScrollLine);
+ aEWHScrollBar->SetPageSize(nScrollPage);
+ aEWHScrollBar->SetScrollHdl( LINK( this, ComplexEditorWindow, ScrollHdl ) );
+ aEWHScrollBar->Show();
}
ComplexEditorWindow::~ComplexEditorWindow()
@@ -1963,6 +2018,7 @@ void ComplexEditorWindow::dispose()
aLineNumberWindow.disposeAndClear();
aEdtWindow.disposeAndClear();
aEWVScrollBar.disposeAndClear();
+ aEWHScrollBar.disposeAndClear();
vcl::Window::dispose();
}
@@ -1974,39 +2030,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() );
}
}
@@ -2069,7 +2128,7 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo
if (m_xTreeListBox->iter_has_child(rParent))
return true;
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rParent).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rParent));
std::unique_ptr<weld::TreeIter> xRet = m_xTreeListBox->make_iterator();
SbxDimArray* pArray = pItem->mpArray.get();
@@ -2097,7 +2156,7 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo
OUString const& rName = pItem->maMemberList.back();
WatchItem* pWatchItem = new WatchItem(rName);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pWatchItem)));
+ OUString sId(weld::toId(pWatchItem));
m_xTreeListBox->insert(&rParent, -1, &rName, &sId, nullptr, nullptr, false, xRet.get());
m_xTreeListBox->set_text(*xRet, "", 1);
@@ -2148,7 +2207,7 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo
aDisplayName += aIndexStr;
pChildItem->maDisplayName = aDisplayName;
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pChildItem)));
+ OUString sId(weld::toId(pChildItem));
m_xTreeListBox->insert(&rParent, -1, &aDisplayName, &sId, nullptr, nullptr, false,
xRet.get());
@@ -2178,12 +2237,12 @@ SbxBase* WatchWindow::ImplGetSBXForEntry(const weld::TreeIter& rEntry, bool& rbA
SbxBase* pSBX = nullptr;
rbArrayElement = false;
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rEntry));
OUString aVName( pItem->maName );
std::unique_ptr<weld::TreeIter> xParentEntry = m_xTreeListBox->make_iterator(&rEntry);
bool bParentEntry = m_xTreeListBox->iter_parent(*xParentEntry);
- WatchItem* pParentItem = bParentEntry ? reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(*xParentEntry).toInt64()) : nullptr;
+ WatchItem* pParentItem = bParentEntry ? weld::fromId<WatchItem*>(m_xTreeListBox->get_id(*xParentEntry)) : nullptr;
if( pParentItem )
{
SbxObject* pObj = pParentItem->mpObject.get();
@@ -2216,7 +2275,7 @@ SbxBase* WatchWindow::ImplGetSBXForEntry(const weld::TreeIter& rEntry, bool& rbA
IMPL_LINK(WatchWindow, EditingEntryHdl, const weld::TreeIter&, rIter, bool)
{
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rIter).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rIter));
bool bEdit = false;
if (StarBASIC::IsRunning() && StarBASIC::GetActiveMethod() && !SbxBase::IsError())
@@ -2293,7 +2352,7 @@ void implCollapseModifiedObjectEntry(const weld::TreeIter& rParent, weld::TreeVi
{
implCollapseModifiedObjectEntry(*xDeleteEntry, rTree);
- WatchItem* pItem = reinterpret_cast<WatchItem*>(rTree.get_id(*xDeleteEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(rTree.get_id(*xDeleteEntry));
delete pItem;
rTree.remove(*xDeleteEntry);
rTree.copy_iterator(rParent, *xDeleteEntry);
@@ -2352,7 +2411,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;
@@ -2591,7 +2650,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;
@@ -2657,8 +2716,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;
@@ -2688,7 +2747,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;
}
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
index 920e82da3d0a..309caa0357c9 100644
--- a/basctl/source/basicide/baside3.cxx
+++ b/basctl/source/basicide/baside3.cxx
@@ -39,7 +39,7 @@
#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>
@@ -50,7 +50,7 @@
#include <svl/whiter.hxx>
#include <svx/svdundo.hxx>
#include <svx/svxids.hrc>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <tools/urlobj.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/weld.hxx>
@@ -232,12 +232,10 @@ void DialogWindow::NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> )
void DialogWindow::DoInit()
{
- GetHScrollBar()->Show();
- GetVScrollBar()->Show();
m_pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
}
-void DialogWindow::DoScroll( ScrollBar* )
+void DialogWindow::DoScroll( Scrollable* )
{
m_pEditor->DoScroll();
}
@@ -315,7 +313,7 @@ void DialogWindow::GetState( SfxItemSet& rSet )
case SID_SHOW_PROPERTYBROWSER:
{
Shell* pShell = GetShell();
- SfxViewFrame* pViewFrame = pShell ? pShell->GetViewFrame() : nullptr;
+ SfxViewFrame* pViewFrame = pShell ? &pShell->GetViewFrame() : nullptr;
if ( pViewFrame && !pViewFrame->HasChildWindow( SID_SHOW_PROPERTYBROWSER ) && !m_pEditor->GetView().AreObjectsMarked() )
rSet.DisableItem( nWh );
@@ -392,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 )
{
@@ -425,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;
@@ -556,7 +554,7 @@ void DialogWindow::ExecuteCommand( SfxRequest& rReq )
break;
}
- if ( nInsertObj )
+ if ( nInsertObj != SdrObjKind::NONE )
{
m_nControlSlotId = nSlotId;
GetEditor().SetMode( DlgEditor::INSERT );
@@ -682,7 +680,7 @@ void DialogWindow::SaveDialog()
if( bResource )
{
- INetURLObject aURLObj("");
+ INetURLObject aURLObj(u"");
aURLObj.removeExtension();
OUString aDialogName( aURLObj.getName() );
aURLObj.removeSegment();
@@ -851,7 +849,7 @@ bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const
xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All );
xFP->setCurrentFilter( aDialogStr );
- if( aDlg.Execute() != ERRCODE_NONE )
+ if( aDlg.Execute() == ERRCODE_NONE )
{
Sequence< OUString > aPaths = xFP->getSelectedFiles();
@@ -1236,7 +1234,7 @@ void DialogWindow::InitSettings()
SetTextColor( rStyleSettings.GetFieldTextColor() );
SetTextFillColor();
- SetBackground( rStyleSettings.GetFieldColor() );
+ SetBackground(rStyleSettings.GetFaceColor());
}
css::uno::Reference< css::accessibility::XAccessible > DialogWindow::CreateAccessible()
@@ -1248,6 +1246,7 @@ OString DialogWindow::GetHid () const
{
return HID_BASICIDE_DIALOGWINDOW;
}
+
ItemType DialogWindow::GetType () const
{
return TYPE_DIALOG;
diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx
index 70991525331a..66820cd21881 100644
--- a/basctl/source/basicide/basides1.cxx
+++ b/basctl/source/basicide/basides1.cxx
@@ -56,6 +56,9 @@
#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>
constexpr sal_Int32 TAB_HEIGHT_MARGIN = 10;
@@ -66,6 +69,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 +104,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 +187,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 +272,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 +352,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 +411,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 );
@@ -417,6 +430,30 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
pBindings->Invalidate(SID_BASICIDE_OBJCAT);
break;
+ case SID_BASICIDE_WATCH:
+ {
+ // Toggling the watch window can only be done from a ModulWindow
+ if (!dynamic_cast<ModulWindowLayout*>(pLayout.get()))
+ return;
+
+ pModulLayout->ShowWatchWindow(!pModulLayout->IsWatchWindowVisible());
+ if (SfxBindings* pBindings = GetBindingsPtr())
+ pBindings->Invalidate(SID_BASICIDE_WATCH);
+ }
+ break;
+
+ case SID_BASICIDE_STACK:
+ {
+ // Toggling the stack window can only be done from a ModulWindow
+ if (!dynamic_cast<ModulWindowLayout*>(pLayout.get()))
+ return;
+
+ pModulLayout->ShowStackWindow(!pModulLayout->IsStackWindowVisible());
+ if (SfxBindings* pBindings = GetBindingsPtr())
+ pBindings->Invalidate(SID_BASICIDE_STACK);
+ }
+ break;
+
case SID_BASICIDE_NAMECHANGEDONTAB:
{
DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
@@ -763,6 +800,32 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
}
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 +899,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 +1102,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 +1130,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:
@@ -1110,6 +1220,30 @@ 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_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 +1282,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 +1323,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();
@@ -1220,7 +1353,7 @@ void Shell::ManageToolbars()
return;
Reference< beans::XPropertySet > xFrameProps
- ( GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
+ ( GetViewFrame().GetFrame().GetFrameInterface(), uno::UNO_QUERY );
if ( !xFrameProps.is() )
return;
@@ -1301,7 +1434,7 @@ BasicDebugFlags Shell::CallBasicBreakHdl( StarBASIC const * pBasic )
{
Shell* pShell = GetShell();
for ( sal_uInt16 n = 0; n < nWaitCount; n++ )
- pShell->GetViewFrame()->GetWindow().EnterWait();
+ pShell->GetViewFrame().GetWindow().EnterWait();
}
}
}
@@ -1345,27 +1478,38 @@ VclPtr<ModulWindow> Shell::ShowActiveModuleWindow( StarBASIC const * pBasic )
void Shell::AdjustPosSizePixel( const Point &rPos, const Size &rSize )
{
// not if iconified because the whole text would be displaced then at restore
- if ( GetViewFrame()->GetWindow().GetOutputSizePixel().Height() == 0 )
+ if ( GetViewFrame().GetWindow().GetOutputSizePixel().Height() == 0 )
return;
Size aTabBarSize;
- aTabBarSize.setHeight( GetViewFrame()->GetWindow().GetFont().GetFontHeight() + TAB_HEIGHT_MARGIN );
+ aTabBarSize.setHeight( GetViewFrame().GetWindow().GetFont().GetFontHeight() + TAB_HEIGHT_MARGIN );
aTabBarSize.setWidth( rSize.Width() );
Size aSz( rSize );
- Size aScrollBarBoxSz( aScrollBarBox->GetSizePixel() );
- aSz.AdjustHeight( -(aScrollBarBoxSz.Height()) );
- aSz.AdjustHeight( -(aTabBarSize.Height()) );
+ auto nScrollBarSz(Application::GetSettings().GetStyleSettings().GetScrollBarSize());
+ aSz.AdjustHeight(-aTabBarSize.Height());
Size aOutSz( aSz );
- aSz.AdjustWidth( -(aScrollBarBoxSz.Width()) );
- aScrollBarBox->SetPosPixel( Point( rSize.Width() - aScrollBarBoxSz.Width(), rSize.Height() - aScrollBarBoxSz.Height() ) );
- aVScrollBar->SetPosSizePixel( Point( rPos.X()+aSz.Width(), rPos.Y() ), Size( aScrollBarBoxSz.Width(), aSz.Height() ) );
- aHScrollBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( aSz.Width(), aScrollBarBoxSz.Height() ) );
- pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aScrollBarBoxSz.Height()+aSz.Height()), aTabBarSize );
+ aSz.AdjustWidth(-nScrollBarSz);
+ aSz.AdjustHeight(-nScrollBarSz);
+ aVScrollBar->SetPosSizePixel( Point( rPos.X()+aSz.Width(), rPos.Y() ), Size( nScrollBarSz, aSz.Height() ) );
+ aHScrollBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( aOutSz.Width(), nScrollBarSz ) );
+ pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y() + nScrollBarSz + aSz.Height()), aTabBarSize );
+ // The size to be applied depends on whether it is a DialogWindow or a ModulWindow
if (pLayout)
- pLayout->SetPosSizePixel(rPos, dynamic_cast<DialogWindow*>(pCurWin.get()) ? aSz : aOutSz);
+ {
+ if (dynamic_cast<DialogWindow*>(pCurWin.get()))
+ {
+ pCurWin->ShowShellScrollBars();
+ pLayout->SetPosSizePixel(rPos, aSz);
+ }
+ else
+ {
+ pCurWin->ShowShellScrollBars(false);
+ pLayout->SetPosSizePixel(rPos, aOutSz);
+ }
+ }
}
Reference< XModel > Shell::GetCurrentDocument() const
diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx
index fedebcb1d98b..5bd69b76f380 100644
--- a/basctl/source/basicide/basides2.cxx
+++ b/basctl/source/basicide/basides2.cxx
@@ -56,7 +56,7 @@ bool Shell::HasSelection( bool /* bText */ ) const
return false;
}
-OUString Shell::GetSelectionText( bool bWholeWord )
+OUString Shell::GetSelectionText( bool bWholeWord, bool /*bOnlyASample*/ )
{
OUString aText;
if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get()))
@@ -82,7 +82,7 @@ SfxPrinter* Shell::GetPrinter( bool bCreate )
{
if ( pCurWin )
{
- DocShell* pDocShell = static_cast<DocShell*>(GetViewFrame()->GetObjectShell());
+ DocShell* pDocShell = static_cast<DocShell*>(GetViewFrame().GetObjectShell());
assert(pDocShell && "DocShell ?!");
return pDocShell->GetPrinter( bCreate );
}
@@ -91,7 +91,7 @@ SfxPrinter* Shell::GetPrinter( bool bCreate )
sal_uInt16 Shell::SetPrinter( SfxPrinter *pNewPrinter, SfxPrinterChangeFlags )
{
- DocShell* pDocShell = static_cast<DocShell*>(GetViewFrame()->GetObjectShell());
+ DocShell* pDocShell = static_cast<DocShell*>(GetViewFrame().GetObjectShell());
assert(pDocShell && "DocShell ?!");
pDocShell->SetPrinter( pNewPrinter );
return 0;
@@ -114,11 +114,8 @@ void Shell::SetMDITitle()
aTitle += " " + IDEResId(RID_STR_SIGNED) + " ";
}
- SfxViewFrame* pViewFrame = GetViewFrame();
- if ( !pViewFrame )
- return;
-
- SfxObjectShell* pShell = pViewFrame->GetObjectShell();
+ SfxViewFrame& rViewFrame = GetViewFrame();
+ SfxObjectShell* pShell = rViewFrame.GetObjectShell();
if ( pShell && pShell->GetTitle( SFX_TITLE_CAPTION ) != aTitle )
{
pShell->SetTitle( aTitle );
@@ -168,7 +165,7 @@ VclPtr<ModulWindow> Shell::CreateBasWin( const ScriptDocument& rDocument, const
{
// new module window
if (!pModulLayout)
- pModulLayout.reset(VclPtr<ModulWindowLayout>::Create(&GetViewFrame()->GetWindow(), *aObjectCatalog));
+ pModulLayout.reset(VclPtr<ModulWindowLayout>::Create(&GetViewFrame().GetWindow(), *aObjectCatalog));
pWin = VclPtr<ModulWindow>::Create(pModulLayout.get(), rDocument, aLibName, aModName, aModule);
nKey = InsertWindowInTable( pWin );
}
diff --git a/basctl/source/basicide/basides3.cxx b/basctl/source/basicide/basides3.cxx
index fb827a5104cc..44bc54ba624f 100644
--- a/basctl/source/basicide/basides3.cxx
+++ b/basctl/source/basicide/basides3.cxx
@@ -27,7 +27,7 @@
#include <sfx2/sfxsids.hrc>
#include <sfx2/viewfrm.hxx>
#include <tools/debug.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
@@ -81,7 +81,7 @@ VclPtr<DialogWindow> Shell::CreateDlgWin( const ScriptDocument& rDocument, const
// new dialog window
if (!pDialogLayout)
- pDialogLayout.reset(VclPtr<DialogWindowLayout>::Create(&GetViewFrame()->GetWindow(), *aObjectCatalog));
+ pDialogLayout.reset(VclPtr<DialogWindowLayout>::Create(&GetViewFrame().GetWindow(), *aObjectCatalog));
pWin = VclPtr<DialogWindow>::Create(pDialogLayout.get(), rDocument, aLibName, aDlgName, xDialogModel);
nKey = InsertWindowInTable( pWin );
}
diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx
index 0e85219824b2..73d27e2eea34 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 */
@@ -74,6 +77,8 @@
namespace basctl
{
+constexpr OUStringLiteral BASIC_IDE_EDITOR_WINDOW = u"BasicIDEEditorWindow";
+constexpr OUStringLiteral BASIC_IDE_CURRENT_ZOOM = u"CurrentZoom";
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
@@ -156,14 +161,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 +190,22 @@ void Shell::Init()
LibBoxControl::RegisterControl( SID_BASICIDE_LIBSELECTOR );
LanguageBoxControl::RegisterControl( SID_BASICIDE_CURRENT_LANG );
+ SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER );
- GetViewFrame()->GetWindow().SetBackground(
- GetViewFrame()->GetWindow().GetSettings().GetStyleSettings().GetWindowColor()
+ GetViewFrame().GetWindow().SetBackground(
+ GetViewFrame().GetWindow().GetSettings().GetStyleSettings().GetWindowColor()
);
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();
SetCurLib( ScriptDocument::getApplicationScriptDocument(), "Standard", false, false );
@@ -231,7 +237,6 @@ Shell::~Shell()
SetCurWindow( nullptr );
aObjectCatalog.disposeAndClear();
- aScrollBarBox.disposeAndClear();
aVScrollBar.disposeAndClear();
aHScrollBar.disposeAndClear();
@@ -255,6 +260,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 +366,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 +427,16 @@ void Shell::StoreAllWindowData( bool bPersistent )
}
}
-
bool Shell::PrepareClose( bool bUI )
{
// reset here because it's modified after printing etc. (DocInfo)
- GetViewFrame()->GetObjectShell()->SetModified(false);
+ GetViewFrame().GetObjectShell()->SetModified(false);
if ( StarBASIC::IsRunning() )
{
if( bUI )
{
- std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetViewFrame()->GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetViewFrame().GetFrameWeld(),
VclMessageType::Info, VclButtonsType::Ok,
IDEResId(RID_STR_CANNOTCLOSE)));
xInfoBox->run();
@@ -410,14 +456,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 +465,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 +627,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 +706,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 +736,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 +765,12 @@ void Shell::UpdateWindows()
if ( bChangeCurWindow )
{
- if ( !pNextActiveWindow )
+ if ( nTotalTabs == 0 )
+ {
+ // If no tabs are opened, create a generic module and make it visible
+ pNextActiveWindow = CreateBasWin( m_aCurDocument, m_aCurLibName, OUString() );
+ }
+ else if ( !pNextActiveWindow )
{
pNextActiveWindow = FindApplicationWindow().get();
}
@@ -891,12 +939,6 @@ void Shell::InvalidateControlSlots()
pBindings->Invalidate( SID_CHOOSE_CONTROLS );
}
-void Shell::EnableScrollbars( bool bEnable )
-{
- aHScrollBar->Enable(bEnable);
- aVScrollBar->Enable(bEnable);
-}
-
void Shell::SetCurLib( const ScriptDocument& rDocument, const OUString& aLibName, bool bUpdateWindows, bool bCheck )
{
if ( bCheck && rDocument == m_aCurDocument && aLibName == m_aCurLibName )
diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx
index f14535cbd3f1..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 = (
@@ -160,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;
}
@@ -215,9 +217,9 @@ namespace
// in case this is a document-local macro, try to protect the document's Undo Manager from
// flawed scripts
- std::unique_ptr< ::framework::DocumentUndoGuard > pUndoGuard;
+ std::optional< ::framework::DocumentUndoGuard > pUndoGuard;
if ( pData->aDocument.isDocument() )
- pUndoGuard.reset( new ::framework::DocumentUndoGuard( pData->aDocument.getDocument() ) );
+ pUndoGuard.emplace( pData->aDocument.getDocument() );
RunMethod( pData->xMethod.get() );
}
diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx
index 06f7c6a9e08c..4672cdd52c2b 100644
--- a/basctl/source/basicide/basobj3.cxx
+++ b/basctl/source/basicide/basobj3.cxx
@@ -105,9 +105,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 +178,24 @@ bool RenameDialog (
if ( !rDocument.renameDialog( rLibName, rOldName, rNewName, xExistingDialog ) )
return false;
- if (pWin && pShell)
- {
- // set new name in window
- pWin->SetName( rNewName );
+ if (!pWin || !pShell)
+ return true;
- // update property browser
- pWin->UpdateBrowser();
+ // set new name in window
+ pWin->SetName( rNewName );
- // update tabwriter
- sal_uInt16 nId = pShell->GetWindowId( pWin );
- DBG_ASSERT( nId, "No entry in Tabbar!" );
- if ( nId )
- {
- TabBar& rTabBar = pShell->GetTabBar();
- rTabBar.SetPageText( nId, rNewName );
- rTabBar.Sort();
- rTabBar.MakeVisible( rTabBar.GetCurPageId() );
- }
+ // update property browser
+ pWin->UpdateBrowser();
+
+ // update tabwriter
+ sal_uInt16 nId = pShell->GetWindowId( pWin );
+ DBG_ASSERT( nId, "No entry in Tabbar!" );
+ if ( nId )
+ {
+ TabBar& rTabBar = pShell->GetTabBar();
+ rTabBar.SetPageText( nId, rNewName );
+ rTabBar.Sort();
+ rTabBar.MakeVisible( rTabBar.GetCurPageId() );
}
return true;
}
@@ -323,9 +321,9 @@ void BasicStopped(
if (Shell* pShell = GetShell())
{
sal_uInt16 nWait = 0;
- while ( pShell->GetViewFrame()->GetWindow().IsWait() )
+ while ( pShell->GetViewFrame().GetWindow().IsWait() )
{
- pShell->GetViewFrame()->GetWindow().LeaveWait();
+ pShell->GetViewFrame().GetWindow().LeaveWait();
nWait++;
}
if ( pnWaitCount )
@@ -432,7 +430,7 @@ SfxBindings* GetBindingsPtr()
SfxViewFrame* pFrame = nullptr;
if (Shell* pShell = GetShell())
{
- pFrame = pShell->GetViewFrame();
+ pFrame = &pShell->GetViewFrame();
}
else
{
@@ -456,9 +454,11 @@ SfxBindings* GetBindingsPtr()
SfxDispatcher* GetDispatcher ()
{
if (Shell* pShell = GetShell())
- if (SfxViewFrame* pViewFrame = pShell->GetViewFrame())
- if (SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher())
- return pDispatcher;
+ {
+ SfxViewFrame& rViewFrame = pShell->GetViewFrame();
+ if (SfxDispatcher* pDispatcher = rViewFrame.GetDispatcher())
+ return pDispatcher;
+ }
return nullptr;
}
} // namespace basctl
diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
index afff27b75dfd..fec1303d8474 100644
--- a/basctl/source/basicide/bastype2.cxx
+++ b/basctl/source/basicide/bastype2.cxx
@@ -25,7 +25,7 @@
#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>
@@ -41,6 +41,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 +88,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 +105,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 +121,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 +177,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);
}
@@ -577,7 +578,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 +605,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 +655,7 @@ void SbTreeListBox::AddEntry(
std::unique_ptr<weld::TreeIter> xScratch = pRet ? nullptr : m_xControl->make_iterator();
if (!pRet)
pRet = xScratch.get();
- OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(rUserData.release())));
+ OUString sId(weld::toId(rUserData.release()));
m_xControl->insert(pParent, -1, &rText, &sId, nullptr, nullptr, bChildrenOnDemand, pRet);
m_xControl->set_image(*pRet, rImage);
}
diff --git a/basctl/source/basicide/bastype3.cxx b/basctl/source/basicide/bastype3.cxx
index edf4c5bae04a..43f1b970209e 100644
--- a/basctl/source/basicide/bastype3.cxx
+++ b/basctl/source/basicide/bastype3.cxx
@@ -156,7 +156,7 @@ SbxVariable* SbTreeListBox::FindVariable(const weld::TreeIter* pEntry)
do
{
sal_uInt16 nDepth = m_xControl->get_iter_depth(*xIter);
- Entry* pBE = reinterpret_cast<Entry*>(m_xControl->get_id(*xIter).toInt64());
+ Entry* pBE = weld::fromId<Entry*>(m_xControl->get_id(*xIter));
switch (nDepth)
{
case 4:
@@ -257,7 +257,7 @@ EntryDescriptor SbTreeListBox::GetEntryDescriptor(const weld::TreeIter* pEntry)
do
{
sal_uInt16 nDepth = m_xControl->get_iter_depth(*xIter);
- Entry* pBE = reinterpret_cast<Entry*>(m_xControl->get_id(*xIter).toInt64());
+ Entry* pBE = weld::fromId<Entry*>(m_xControl->get_id(*xIter));
switch (nDepth)
{
case 4:
@@ -421,7 +421,7 @@ bool SbTreeListBox::FindRootEntry( const ScriptDocument& rDocument, LibraryLocat
bool bValidIter = m_xControl->get_iter_first(rIter);
while (bValidIter)
{
- DocumentEntry* pBDEntry = reinterpret_cast<DocumentEntry*>(m_xControl->get_id(rIter).toInt64());
+ DocumentEntry* pBDEntry = weld::fromId<DocumentEntry*>(m_xControl->get_id(rIter));
if (pBDEntry && pBDEntry->GetDocument() == rDocument && pBDEntry->GetLocation() == eLocation)
return true;
bValidIter = m_xControl->iter_next_sibling(rIter);
diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx
index e0ad3daceca5..5fd607108dc1 100644
--- a/basctl/source/basicide/bastypes.cxx
+++ b/basctl/source/basicide/bastypes.cxx
@@ -35,11 +35,14 @@
#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 <utility>
#include <vcl/commandevent.hxx>
#include <vcl/event.hxx>
#include <vcl/svapp.hxx>
@@ -50,17 +53,20 @@
namespace basctl
{
+// ID used for the read-only infobar
+constexpr OUStringLiteral BASIC_IDE_READONLY_INFOBAR = u"readonly";
+
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
-BaseWindow::BaseWindow( vcl::Window* pParent, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName )
+BaseWindow::BaseWindow( vcl::Window* pParent, ScriptDocument aDocument, OUString aLibName, OUString aName )
:Window( pParent, WinBits( WB_3DLOOK ) )
,pShellHScrollBar( nullptr)
,pShellVScrollBar( nullptr)
,nStatus( 0)
- ,m_aDocument( rDocument )
- ,m_aLibName( aLibName )
- ,m_aName( aName )
+ ,m_aDocument(std::move( aDocument ))
+ ,m_aLibName(std::move( aLibName ))
+ ,m_aName(std::move( aName ))
{
}
@@ -71,55 +77,63 @@ BaseWindow::~BaseWindow()
void BaseWindow::dispose()
{
- if ( pShellVScrollBar )
- pShellVScrollBar->SetScrollHdl( Link<ScrollBar*,void>() );
- if ( pShellHScrollBar )
- pShellHScrollBar->SetScrollHdl( Link<ScrollBar*,void>() );
+ if (pShellVScrollBar && !pShellVScrollBar->isDisposed())
+ pShellVScrollBar->SetScrollHdl( Link<weld::Scrollbar&,void>() );
+ if (pShellHScrollBar && !pShellHScrollBar->isDisposed())
+ pShellHScrollBar->SetScrollHdl( Link<weld::Scrollbar&,void>() );
pShellVScrollBar.clear();
pShellHScrollBar.clear();
vcl::Window::dispose();
}
-
void BaseWindow::Init()
{
if ( pShellVScrollBar )
- pShellVScrollBar->SetScrollHdl( LINK( this, BaseWindow, ScrollHdl ) );
+ pShellVScrollBar->SetScrollHdl( LINK( this, BaseWindow, VertScrollHdl ) );
if ( pShellHScrollBar )
- pShellHScrollBar->SetScrollHdl( LINK( this, BaseWindow, ScrollHdl ) );
+ pShellHScrollBar->SetScrollHdl( LINK( this, BaseWindow, HorzScrollHdl ) );
+
+ // Show the read-only infobar if the module/dialog is read-only
+ GetShell()->GetViewFrame().RemoveInfoBar(BASIC_IDE_READONLY_INFOBAR);
+ if (IsReadOnly())
+ ShowReadOnlyInfoBar();
+
DoInit(); // virtual...
}
-
void BaseWindow::DoInit()
-{ }
-
+{
+}
-void BaseWindow::GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll )
+void BaseWindow::GrabScrollBars(ScrollAdaptor* pHScroll, ScrollAdaptor* pVScroll)
{
pShellHScrollBar = pHScroll;
pShellVScrollBar = pVScroll;
-// Init(); // does not make sense, leads to flickering and errors...
}
+IMPL_LINK_NOARG(BaseWindow, VertScrollHdl, weld::Scrollbar&, void)
+{
+ DoScroll(pShellVScrollBar);
+}
-IMPL_LINK( BaseWindow, ScrollHdl, ScrollBar *, pCurScrollBar, void )
+IMPL_LINK_NOARG(BaseWindow, HorzScrollHdl, weld::Scrollbar&, void)
{
- DoScroll( pCurScrollBar );
+ DoScroll(pShellHScrollBar);
}
void BaseWindow::ExecuteCommand (SfxRequest&)
-{ }
+{
+}
void BaseWindow::ExecuteGlobal (SfxRequest&)
-{ }
-
+{
+}
bool BaseWindow::EventNotify( NotifyEvent& rNEvt )
{
bool bDone = false;
- if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
+ if ( rNEvt.GetType() == NotifyEventType::KEYINPUT )
{
KeyEvent aKEvt = *rNEvt.GetKeyEvent();
vcl::KeyCode aCode = aKEvt.GetKeyCode();
@@ -144,11 +158,39 @@ bool BaseWindow::EventNotify( NotifyEvent& rNEvt )
return bDone || Window::EventNotify( rNEvt );
}
-
-void BaseWindow::DoScroll( ScrollBar* )
+void BaseWindow::ShowShellScrollBars(bool bVisible)
{
+ if (bVisible)
+ {
+ if (pShellHScrollBar)
+ {
+ pShellHScrollBar->Enable();
+ pShellHScrollBar->Show();
+ }
+ if (pShellVScrollBar)
+ {
+ pShellVScrollBar->Enable();
+ pShellVScrollBar->Show();
+ }
+ }
+ else
+ {
+ if (pShellHScrollBar)
+ {
+ pShellHScrollBar->Disable();
+ pShellHScrollBar->Hide();
+ }
+ if (pShellVScrollBar)
+ {
+ pShellVScrollBar->Disable();
+ pShellVScrollBar->Hide();
+ }
+ }
}
+void BaseWindow::DoScroll( Scrollable* )
+{
+}
void BaseWindow::StoreData()
{
@@ -159,7 +201,6 @@ bool BaseWindow::AllowUndo()
return true;
}
-
void BaseWindow::UpdateData()
{
}
@@ -190,6 +231,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()
{
}
@@ -583,9 +637,7 @@ void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines )
else
nEndPos++;
- OUString aEndStr = rStr.copy( nEndPos );
- rStr = rStr.copy( 0, nStartPos );
- rStr += aEndStr;
+ rStr = OUString::Concat(rStr.subView( 0, nStartPos )) + rStr.subView( nEndPos );
// erase trailing empty lines
{
@@ -599,9 +651,7 @@ void CutLines( OUString& rStr, sal_Int32 nStartLine, sal_Int32 nLines )
if ( n > nStartPos )
{
- aEndStr = rStr.copy( n );
- rStr = rStr.copy( 0, nStartPos );
- rStr += aEndStr;
+ rStr = OUString::Concat(rStr.subView( 0, nStartPos )) + rStr.subView( n );
}
}
}
@@ -667,8 +717,8 @@ LibInfo::Item const* LibInfo::GetInfo (
return it != m_aMap.end() ? &it->second : nullptr;
}
-LibInfo::Key::Key (ScriptDocument const& rDocument, OUString const& rLibName) :
- m_aDocument(rDocument), m_aLibName(rLibName)
+LibInfo::Key::Key (ScriptDocument aDocument, OUString aLibName) :
+ m_aDocument(std::move(aDocument)), m_aLibName(std::move(aLibName))
{ }
bool LibInfo::Key::operator == (Key const& rKey) const
@@ -685,10 +735,10 @@ size_t LibInfo::Key::Hash::operator () (Key const& rKey) const
}
LibInfo::Item::Item (
- OUString const& rCurrentName,
+ OUString aCurrentName,
ItemType eCurrentType
) :
- m_aCurrentName(rCurrentName),
+ m_aCurrentName(std::move(aCurrentName)),
m_eCurrentType(eCurrentType)
{ }
diff --git a/basctl/source/basicide/brkdlg.cxx b/basctl/source/basicide/brkdlg.cxx
index 6a79d0e1da54..37ba1dbb60ae 100644
--- a/basctl/source/basicide/brkdlg.cxx
+++ b/basctl/source/basicide/brkdlg.cxx
@@ -125,16 +125,14 @@ void BreakPointDialog::CheckButtons()
m_xNewButton->set_sensitive(true);
m_xOKButton->set_sensitive(false);
m_xDelButton->set_sensitive(false);
- m_xDelButton->set_has_default(false);
- m_xNewButton->set_has_default(true);
+ m_xDialog->change_default_widget(m_xDelButton.get(), m_xNewButton.get());
}
else
{
m_xNewButton->set_sensitive(false);
m_xOKButton->set_sensitive(true);
m_xDelButton->set_sensitive(true);
- m_xNewButton->set_has_default(false);
- m_xDelButton->set_has_default(true);
+ m_xDialog->change_default_widget(m_xNewButton.get(), m_xDelButton.get());
}
}
diff --git a/basctl/source/basicide/doceventnotifier.cxx b/basctl/source/basicide/doceventnotifier.cxx
index 83d2ea04dff3..d98598e8a3f3 100644
--- a/basctl/source/basicide/doceventnotifier.cxx
+++ b/basctl/source/basicide/doceventnotifier.cxx
@@ -24,7 +24,7 @@
#include <vcl/svapp.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <comphelper/processfactory.hxx>
diff --git a/basctl/source/basicide/docsignature.cxx b/basctl/source/basicide/docsignature.cxx
index 701c9d478f1a..08d7a1ab9c13 100644
--- a/basctl/source/basicide/docsignature.cxx
+++ b/basctl/source/basicide/docsignature.cxx
@@ -51,10 +51,6 @@ namespace basctl
m_pShell = pShell;
}
- DocumentSignature::~DocumentSignature()
- {
- }
-
bool DocumentSignature::supportsSignatures() const
{
return ( m_pShell != nullptr );
diff --git a/basctl/source/basicide/documentenumeration.cxx b/basctl/source/basicide/documentenumeration.cxx
index e3acf9d4587a..d71e02139e02 100644
--- a/basctl/source/basicide/documentenumeration.cxx
+++ b/basctl/source/basicide/documentenumeration.cxx
@@ -27,7 +27,7 @@
#include <com/sun/star/frame/XModel2.hpp>
#include <com/sun/star/frame/FrameSearchFlag.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
namespace basctl::docs {
@@ -48,22 +48,10 @@ namespace basctl::docs {
namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag;
- // DocumentEnumeration_Data
- struct DocumentEnumeration_Data
- {
- Reference< css::uno::XComponentContext > aContext;
- const IDocumentDescriptorFilter* pFilter;
-
- DocumentEnumeration_Data( Reference< css::uno::XComponentContext > const & _rContext, const IDocumentDescriptorFilter* _pFilter )
- :aContext( _rContext )
- ,pFilter( _pFilter )
- {
- }
- };
-
// DocumentEnumeration
DocumentEnumeration::DocumentEnumeration( Reference< css::uno::XComponentContext > const & _rContext, const IDocumentDescriptorFilter* _pFilter )
- :m_pData( new DocumentEnumeration_Data( _rContext, _pFilter ) )
+ : m_xContext( _rContext )
+ , m_pFilter( _pFilter )
{
}
@@ -152,11 +140,11 @@ namespace basctl::docs {
try
{
- const Reference< XDesktop2 > xDesktop = Desktop::create( m_pData->aContext );
+ const Reference< XDesktop2 > xDesktop = Desktop::create( m_xContext );
const Reference< XFrames > xFrames( xDesktop->getFrames(), UNO_SET_THROW );
const Sequence< Reference< XFrame > > aFrames( xFrames->queryFrames( FrameSearchFlag::ALL ) );
- lcl_getDocuments_nothrow( aFrames, _out_rDocuments, m_pData->pFilter );
+ lcl_getDocuments_nothrow( aFrames, _out_rDocuments, m_pFilter );
}
catch( const Exception& )
{
diff --git a/basctl/source/basicide/documentenumeration.hxx b/basctl/source/basicide/documentenumeration.hxx
index 084a4aa0cf09..dfd4d2e8172f 100644
--- a/basctl/source/basicide/documentenumeration.hxx
+++ b/basctl/source/basicide/documentenumeration.hxx
@@ -51,7 +51,6 @@ namespace basctl::docs {
};
- struct DocumentEnumeration_Data;
/** is a helper class for enumerating documents in OOo
If you need a list of all open documents in OOo, this is little bit of
@@ -81,7 +80,8 @@ namespace basctl::docs {
) const;
private:
- std::unique_ptr< DocumentEnumeration_Data > m_pData;
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+ const IDocumentDescriptorFilter* m_pFilter;
};
diff --git a/basctl/source/basicide/linenumberwindow.cxx b/basctl/source/basicide/linenumberwindow.cxx
index 7dcbff0ddd7f..18420199e2a9 100644
--- a/basctl/source/basicide/linenumberwindow.cxx
+++ b/basctl/source/basicide/linenumberwindow.cxx
@@ -21,7 +21,9 @@ LineNumberWindow::LineNumberWindow(vcl::Window* pParent, ModulWindow* pModulWind
, m_pModulWindow(pModulWindow)
, m_nCurYOffset(0)
{
- SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetWindowColor()));
+ const Wallpaper aBackground(GetSettings().GetStyleSettings().GetWindowColor());
+ SetBackground(aBackground);
+ GetWindow(GetWindowType::Border)->SetBackground(aBackground);
m_FontColor = GetSettings().GetStyleSettings().GetWindowTextColor();
m_nBaseWidth = GetTextWidth("8");
m_nWidth = m_nBaseWidth * 3 + m_nBaseWidth / 2;
@@ -48,8 +50,6 @@ void LineNumberWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Re
if (!txtView)
return;
- GetParent()->Resize();
-
int windowHeight = rRenderContext.GetOutputSize().Height();
int nLineHeight = rRenderContext.GetTextHeight();
if (!nLineHeight)
@@ -81,7 +81,16 @@ void LineNumberWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Re
sal_Int64 y = (nStartLine - 1) * static_cast<sal_Int64>(nLineHeight);
rRenderContext.SetTextColor(m_FontColor);
for (sal_uInt32 n = nStartLine; n <= nEndLine; ++n, y += nLineHeight)
- rRenderContext.DrawText(Point(0, y - m_nCurYOffset), OUString::number(n));
+ {
+ 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);
+ }
+
+ // 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/localizationmgr.cxx b/basctl/source/basicide/localizationmgr.cxx
index 6dd07a021d32..17371bed2968 100644
--- a/basctl/source/basicide/localizationmgr.cxx
+++ b/basctl/source/basicide/localizationmgr.cxx
@@ -37,6 +37,7 @@
#include <sfx2/sfxsids.hrc>
#include <sfx2/viewfrm.hxx>
#include <tools/debug.hxx>
+#include <utility>
#include <osl/diagnose.h>
namespace basctl
@@ -59,14 +60,14 @@ constexpr OUStringLiteral aSemi(u";");
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 ()
@@ -81,7 +82,7 @@ void LocalizationMgr::handleTranslationbar ()
static constexpr OUStringLiteral aToolBarResName = u"private:resource/toolbar/translationbar";
Reference< beans::XPropertySet > xFrameProps
- ( m_pShell->GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
+ ( m_pShell->GetViewFrame().GetFrame().GetFrameInterface(), uno::UNO_QUERY );
if ( !xFrameProps.is() )
return;
@@ -975,7 +976,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;
@@ -1002,7 +1003,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;
@@ -1084,7 +1085,7 @@ void LocalizationMgr::copyResourceForDialog(
if( !xDialogModel.is() || !xSourceStringResolver.is() || !xTargetStringResourceManager.is() )
return;
- OUString aDummyName;
+ std::u16string_view aDummyName;
Any aDialogCtrl;
aDialogCtrl <<= xDialogModel;
implHandleControlResourceProperties
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index 511abf83591e..e2511ee53b6b 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -31,7 +31,7 @@
#include <basic/sbmeth.hxx>
#include <basic/sbmod.hxx>
#include <com/sun/star/script/XLibraryContainer2.hpp>
-
+#include <sal/log.hxx>
#include <sfx2/app.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/frame.hxx>
@@ -122,7 +122,8 @@ MacroChooser::~MacroChooser()
void MacroChooser::StoreMacroDescription()
{
- m_xBasicBox->get_selected(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_selected(m_xBasicBoxIter.get()))
+ return;
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
OUString aMethodName;
if (m_xMacroBox->get_selected(m_xMacroBoxIter.get()))
@@ -141,6 +142,9 @@ void MacroChooser::StoreMacroDescription()
void MacroChooser::RestoreMacroDescription()
{
+ // The following call is a workaround to ensure the last used macro is scrolled to in kf5
+ m_xDialog->resize_to_request();
+
EntryDescriptor aDesc;
if (Shell* pShell = GetShell())
{
@@ -291,7 +295,11 @@ void MacroChooser::DeleteMacro()
SbMethod* MacroChooser::CreateMacro()
{
SbMethod* pMethod = nullptr;
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return nullptr;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
OSL_ENSURE( aDocument.isAlive(), "MacroChooser::CreateMacro: no document!" );
@@ -470,8 +478,9 @@ IMPL_LINK_NOARG(MacroChooser, MacroSelectHdl, weld::TreeView&, void)
IMPL_LINK_NOARG(MacroChooser, BasicSelectHdl, weld::TreeView&, void)
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
- SbModule* pModule = m_xBasicBox->FindModule(m_xBasicBoxIter.get());
+ SbModule* pModule = nullptr;
+ if (m_xBasicBox->get_cursor(m_xBasicBoxIter.get()))
+ pModule = m_xBasicBox->FindModule(m_xBasicBoxIter.get());
m_xMacroBox->clear();
if (pModule)
{
@@ -610,7 +619,11 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
}
else if (&rButton == m_xEditButton.get() || &rButton == m_xDelButton.get() || &rButton == m_xNewButton.get())
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
DBG_ASSERT( aDocument.isAlive(), "MacroChooser::ButtonHdl: no document, or document is dead!" );
@@ -693,7 +706,11 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
}
else if (&rButton == m_xAssignButton.get())
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
DBG_ASSERT( aDocument.isAlive(), "MacroChooser::ButtonHdl: no document, or document is dead!" );
@@ -714,20 +731,28 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
if (m_xDocumentFrame.is())
aInternalSet.Put(SfxUnoFrameItem(SID_FILLFRAME, m_xDocumentFrame));
- SfxRequest aRequest(SID_CONFIG, SfxCallMode::SYNCHRON, Args, aInternalSet);
+ SfxRequest aRequest(SID_CONFIGACCEL, SfxCallMode::SYNCHRON, Args, aInternalSet);
aRequest.AppendItem( aItem );
SfxGetpApp()->ExecuteSlot( aRequest );
}
else if (&rButton == m_xNewLibButton.get())
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
createLibImpl(m_xDialog.get(), aDocument, nullptr, m_xBasicBox.get());
}
else if (&rButton == m_xNewModButton.get())
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
const OUString& aLibName( aDesc.GetLibName() );
@@ -738,7 +763,7 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
StoreMacroDescription();
m_xBasicBox->get_selected(m_xBasicBoxIter.get());
- auto xDlg(std::make_shared<OrganizeDialog>(m_xDialog.get(), 0));
+ auto xDlg(std::make_shared<OrganizeDialog>(m_xDialog.get(), nullptr, 0));
weld::DialogController::runAsync(xDlg, [this](sal_Int32 nRet) {
if (nRet == RET_OK) // not only closed
{
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index 7786ab408de4..f66f8cfd0e23 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
{
@@ -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;
@@ -346,7 +346,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 +461,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 +473,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
@@ -1185,13 +1185,13 @@ void LibPage::FillListBox()
void LibPage::InsertListBoxEntry( const ScriptDocument& rDocument, LibraryLocation eLocation )
{
OUString aEntryText(rDocument.getTitle(eLocation));
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(new DocumentEntry(rDocument, eLocation))));
+ OUString sId(weld::toId(new DocumentEntry(rDocument, eLocation)));
m_xBasicsBox->append(sId, aEntryText);
}
void LibPage::SetCurLib()
{
- DocumentEntry* pEntry = reinterpret_cast<DocumentEntry*>(m_xBasicsBox->get_active_id().toInt64());
+ DocumentEntry* pEntry = weld::fromId<DocumentEntry*>(m_xBasicsBox->get_active_id());
if (!pEntry)
return;
@@ -1220,7 +1220,7 @@ void LibPage::SetCurLib()
ImpInsertLibEntry(aLibName, nEntry++);
}
- int nEntry_ = FindEntry(*m_xLibBox, "Standard");
+ int nEntry_ = FindEntry(*m_xLibBox, u"Standard");
if (nEntry_ == -1 && m_xLibBox->n_children())
nEntry_ = 0;
m_xLibBox->set_cursor(nEntry_);
@@ -1320,6 +1320,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,
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
index 2e3c8c2530d1..617d80e7f033 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,24 @@ 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;
+ ScriptDocument aScriptDocument(xModel);
+ EntryDescriptor aDesc(aScriptDocument, 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,6 +209,8 @@ OrganizeDialog::OrganizeDialog(weld::Window* pParent, sal_Int16 tabId )
{
m_xTabCtrl->connect_enter_page(LINK(this, OrganizeDialog, ActivatePageHdl));
+ SetCurrentEntry(xDocFrame);
+
OString sPage;
if (tabId == 0)
sPage = "modules";
@@ -246,6 +265,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 +278,31 @@ private:
if (nDepth >= 2)
{
nMode = DND_ACTION_COPY;
- EntryDescriptor aDesc = m_rTreeView.GetEntryDescriptor(xEntry.get());
- const ScriptDocument& aDocument( aDesc.GetDocument() );
- const OUString& aLibName( aDesc.GetLibName() );
- // allow MOVE mode only for libraries, which are not readonly
- Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
- Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
- if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
- ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) )
+ if (bCheckForMove)
{
- // Only allow copy for localized libraries
- bool bAllowMove = true;
- if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
+ EntryDescriptor aDesc = m_rTreeView.GetEntryDescriptor(xEntry.get());
+ const ScriptDocument& aDocument( aDesc.GetDocument() );
+ const OUString& aLibName( aDesc.GetLibName() );
+ // allow MOVE mode only for libraries, which are not readonly
+ Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) )
{
- // Get StringResourceManager
- Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, aLibName, true ) );
- Reference< XStringResourceManager > xSourceMgr =
- LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
- if( xSourceMgr.is() )
- bAllowMove = ( xSourceMgr->getLocales().getLength() == 0 );
+ // Only allow copy for localized libraries
+ bool bAllowMove = true;
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
+ {
+ // Get StringResourceManager
+ Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, aLibName, true ) );
+ Reference< XStringResourceManager > xSourceMgr =
+ LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
+ if( xSourceMgr.is() )
+ bAllowMove = ( xSourceMgr->getLocales().getLength() == 0 );
+ }
+ if( bAllowMove )
+ nMode |= DND_ACTION_MOVE;
}
- if( bAllowMove )
- nMode |= DND_ACTION_MOVE;
}
}
}
@@ -390,7 +416,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 +522,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)
@@ -562,6 +595,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 +721,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 +879,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 63be9953a290..37e8567b5e6c 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>
@@ -151,6 +150,8 @@ public:
ObjectPage(weld::Container* pParent, const OString& rName, BrowseMode nMode, OrganizeDialog* pDialog);
virtual ~ObjectPage() override;
+ void SetCurrentEntry(const EntryDescriptor& rDesc) { m_xBasicBox->SetCurrentEntry(rDesc); }
+
virtual void ActivatePage() override;
};
@@ -207,8 +208,10 @@ private:
DECL_LINK(ActivatePageHdl, const OString&, 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 fcef9e78802b..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;
}
}
diff --git a/basctl/source/basicide/unomodel.cxx b/basctl/source/basicide/unomodel.cxx
index 4a9ee759f060..5d3946b426c6 100644
--- a/basctl/source/basicide/unomodel.cxx
+++ b/basctl/source/basicide/unomodel.cxx
@@ -33,7 +33,6 @@ 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;