summaryrefslogtreecommitdiffstats
path: root/basctl/source/basicide/moduldl2.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basctl/source/basicide/moduldl2.cxx')
-rw-r--r--basctl/source/basicide/moduldl2.cxx72
1 files changed, 54 insertions, 18 deletions
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index 2515cace9800..cfb9adf03553 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -38,7 +38,7 @@
#include <svl/stritem.hxx>
#include <tools/debug.hxx>
#include <tools/urlobj.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
@@ -63,6 +63,7 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
#include <cppuhelper/implbase.hxx>
+#include <o3tl/string_view.hxx>
#include <cassert>
@@ -102,12 +103,12 @@ public:
namespace
{
- int FindEntry(const weld::TreeView& rBox, const OUString& rName)
+ int FindEntry(const weld::TreeView& rBox, std::u16string_view rName)
{
int nCount = rBox.n_children();
for (int i = 0; i < nCount; ++i)
{
- if (rName.equalsIgnoreAsciiCase(rBox.get_text(i, 0)))
+ if (o3tl::equalsIgnoreAsciiCase(rName, rBox.get_text(i, 0)))
return i;
}
return -1;
@@ -152,12 +153,24 @@ NewObjectDialog::NewObjectDialog(weld::Window * pParent, ObjectMode eMode, bool
}
// GotoLineDialog
-GotoLineDialog::GotoLineDialog(weld::Window* pParent )
+GotoLineDialog::GotoLineDialog(weld::Window* pParent, sal_uInt32 nCurLine, sal_uInt32 nLineCount)
: GenericDialogController(pParent, "modules/BasicIDE/ui/gotolinedialog.ui", "GotoLineDialog")
- , m_xEdit(m_xBuilder->weld_entry("entry"))
+ , m_xSpinButton(m_xBuilder->weld_spin_button("spin"))
+ , m_xLineCount(m_xBuilder->weld_label("line_count"))
, m_xOKButton(m_xBuilder->weld_button("ok"))
+ , m_nCurLine(nCurLine)
+ , m_nLineCount(nLineCount)
{
- m_xEdit->grab_focus();
+ // Adjust line count label
+ OUString sLabel = m_xLineCount->get_label();
+ m_xLineCount->set_label(sLabel.replaceFirst("$1", OUString::number(m_nLineCount)));
+
+ // Initialize the spin button
+ m_xSpinButton->set_text(OUString::number(m_nCurLine));
+ m_xSpinButton->set_range(1, m_nLineCount);
+ m_xSpinButton->grab_focus();
+ m_xSpinButton->select_region(0, -1);
+
m_xOKButton->connect_clicked(LINK(this, GotoLineDialog, OkButtonHandler));
}
@@ -167,15 +180,22 @@ GotoLineDialog::~GotoLineDialog()
sal_Int32 GotoLineDialog::GetLineNumber() const
{
- return m_xEdit->get_text().toInt32();
+ return m_xSpinButton->get_text().toInt32();
}
IMPL_LINK_NOARG(GotoLineDialog, OkButtonHandler, weld::Button&, void)
{
- if (GetLineNumber())
+ // The number must be in the range between 1 and the number of lines in the module
+ sal_Int32 nNumber = GetLineNumber();
+ if (nNumber && nNumber >= 1 && nNumber <= static_cast<sal_Int32>(m_nLineCount))
+ {
m_xDialog->response(RET_OK);
+ }
else
- m_xEdit->select_region(0, -1);
+ {
+ m_xSpinButton->set_text(OUString::number(m_nCurLine));
+ m_xSpinButton->select_region(0, -1);
+ }
}
// ExportDialog
@@ -345,7 +365,7 @@ LibPage::~LibPage()
const sal_Int32 nCount = m_xBasicsBox->get_count();
for (sal_Int32 i = 0; i < nCount; ++i)
{
- DocumentEntry* pEntry = reinterpret_cast<DocumentEntry*>(m_xBasicsBox->get_id(i).toInt64());
+ DocumentEntry* pEntry = weld::fromId<DocumentEntry*>(m_xBasicsBox->get_id(i));
delete pEntry;
}
}
@@ -460,10 +480,10 @@ IMPL_LINK( LibPage, ButtonHdl, weld::Button&, rButton, void )
{
Shell* pShell = GetShell();
if (pShell)
- pShell->GetViewFrame()->GetWindow().EnterWait();
+ pShell->GetViewFrame().GetWindow().EnterWait();
xModLibContainer->loadLibrary( aLibName );
if (pShell)
- pShell->GetViewFrame()->GetWindow().LeaveWait();
+ pShell->GetViewFrame().GetWindow().LeaveWait();
}
// load dialog library (if not loaded)
@@ -472,10 +492,10 @@ IMPL_LINK( LibPage, ButtonHdl, weld::Button&, rButton, void )
{
Shell* pShell = GetShell();
if (pShell)
- pShell->GetViewFrame()->GetWindow().EnterWait();
+ pShell->GetViewFrame().GetWindow().EnterWait();
xDlgLibContainer->loadLibrary( aLibName );
if (pShell)
- pShell->GetViewFrame()->GetWindow().LeaveWait();
+ pShell->GetViewFrame().GetWindow().LeaveWait();
}
// check, if library is password protected
@@ -1184,13 +1204,13 @@ void LibPage::FillListBox()
void LibPage::InsertListBoxEntry( const ScriptDocument& rDocument, LibraryLocation eLocation )
{
OUString aEntryText(rDocument.getTitle(eLocation));
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(new DocumentEntry(rDocument, eLocation))));
+ OUString sId(weld::toId(new DocumentEntry(rDocument, eLocation)));
m_xBasicsBox->append(sId, aEntryText);
}
void LibPage::SetCurLib()
{
- DocumentEntry* pEntry = reinterpret_cast<DocumentEntry*>(m_xBasicsBox->get_active_id().toInt64());
+ DocumentEntry* pEntry = weld::fromId<DocumentEntry*>(m_xBasicsBox->get_active_id());
if (!pEntry)
return;
@@ -1219,7 +1239,7 @@ void LibPage::SetCurLib()
ImpInsertLibEntry(aLibName, nEntry++);
}
- int nEntry_ = FindEntry(*m_xLibBox, "Standard");
+ int nEntry_ = FindEntry(*m_xLibBox, u"Standard");
if (nEntry_ == -1 && m_xLibBox->n_children())
nEntry_ = 0;
m_xLibBox->set_cursor(nEntry_);
@@ -1319,6 +1339,22 @@ void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
if ( !rDocument.createModule( aLibName, aModName, true, sModuleCode ) )
throw Exception("could not create module " + aModName, nullptr);
+ // tdf#151741 - store all libraries to the file system, otherwise they
+ // cannot be renamed/moved since the SfxLibraryContainer::renameLibrary
+ // moves the folders/files on the file system
+ Reference<script::XLibraryContainer2> xModLibContainer(
+ rDocument.getLibraryContainer(E_SCRIPTS), UNO_QUERY);
+ Reference<script::XLibraryContainer2> xDlgLibContainer(
+ rDocument.getLibraryContainer(E_DIALOGS), UNO_QUERY);
+ Reference<script::XPersistentLibraryContainer> xModPersLibContainer(xModLibContainer,
+ UNO_QUERY);
+ if (xModPersLibContainer.is())
+ xModPersLibContainer->storeLibraries();
+ Reference<script::XPersistentLibraryContainer> xDlgPersLibContainer(xDlgLibContainer,
+ UNO_QUERY);
+ if (xDlgPersLibContainer.is())
+ xDlgPersLibContainer->storeLibraries();
+
SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, TYPE_MODULE );
if (SfxDispatcher* pDispatcher = GetDispatcher())
pDispatcher->ExecuteList(SID_BASICIDE_SBXINSERTED,
@@ -1337,7 +1373,7 @@ void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
BrowseMode nMode = pBasicBox->GetMode();
bool bDlgMode = ( nMode & BrowseMode::Dialogs ) && !( nMode & BrowseMode::Modules );
- const auto sId = bDlgMode ? OUString(RID_BMP_DLGLIB) : OUString(RID_BMP_MODLIB);
+ const auto sId = bDlgMode ? RID_BMP_DLGLIB : RID_BMP_MODLIB;
pBasicBox->AddEntry(aLibName, sId, xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_LIBRARY));
pBasicBox->AddEntry(aModName, RID_BMP_MODULE, xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_MODULE));
pBasicBox->set_cursor(*xRootEntry);