24#include <bitmaps.hlst>
36#include <sfx2/sfxsids.hrc>
45#include <com/sun/star/io/Pipe.hpp>
46#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
47#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
48#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
49#include <com/sun/star/script/DocumentScriptLibraryContainer.hpp>
50#include <com/sun/star/script/DocumentDialogLibraryContainer.hpp>
51#include <com/sun/star/script/XLibraryContainerPassword.hpp>
52#include <com/sun/star/script/XLibraryContainerExport.hpp>
53#include <com/sun/star/task/InteractionHandler.hpp>
54#include <com/sun/star/ucb/SimpleFileAccess.hpp>
55#include <com/sun/star/ucb/XCommandEnvironment.hpp>
56#include <com/sun/star/ucb/NameClash.hpp>
57#include <com/sun/star/packages/manifest/ManifestWriter.hpp>
60#include <com/sun/star/util/VetoException.hpp>
61#include <com/sun/star/script/ModuleSizeExceededRequest.hpp>
82class DummyInteractionHandler :
public ::cppu::WeakImplHelper< task::XInteractionHandler >
86 explicit DummyInteractionHandler(
const Reference<task::XInteractionHandler2>& xHandler)
91 virtual void SAL_CALL handle(
const Reference< task::XInteractionRequest >& rRequest )
override
95 script::ModuleSizeExceededRequest aModSizeException;
96 if ( rRequest->getRequest() >>= aModSizeException )
106 int FindEntry(
const weld::TreeView& rBox, std::u16string_view rName)
126 VclMessageType::Warning, VclButtonsType::Ok,
IDEResId(RID_STR_BADSBXNAME)));
128 m_xEdit->grab_focus();
133 : GenericDialogController(pParent,
"modules/BasicIDE/ui/newlibdialog.ui",
"NewLibDialog")
134 , m_xEdit(m_xBuilder->weld_entry(
"entry"))
136 , m_bCheckName(bCheckName)
157 : GenericDialogController(pParent,
"modules/BasicIDE/ui/gotolinedialog.ui",
"GotoLineDialog")
158 , m_xEdit(m_xBuilder->weld_entry(
"entry"))
171 return m_xEdit->get_text().toInt32();
179 m_xEdit->select_region(0, -1);
185 m_bExportAsPackage = m_xExportAsPackageButton->get_active();
190 : GenericDialogController(pParent,
"modules/BasicIDE/ui/exportdialog.ui",
"ExportDialog")
191 , m_bExportAsPackage(false)
192 , m_xExportAsPackageButton(m_xBuilder->weld_radio_button(
"extension"))
205 :
OrganizePage(pParent,
"modules/BasicIDE/ui/libpage.ui",
"LibPage", pDialog)
206 , m_xBasicsBox(m_xBuilder->weld_combo_box(
"location"))
207 , m_xLibBox(m_xBuilder->weld_tree_view(
"library"))
208 , m_xEditButton(m_xBuilder->weld_button(
"edit"))
209 , m_xPasswordButton(m_xBuilder->weld_button(
"password"))
210 , m_xNewLibButton(m_xBuilder->weld_button(
"new"))
211 , m_xInsertLibButton(m_xBuilder->weld_button(
"import"))
212 , m_xExportButton(m_xBuilder->weld_button(
"export"))
213 , m_xDelButton(m_xBuilder->weld_button(
"delete"))
247 OUString aLibName = m_xLibBox->get_text(rIter, 0);
249 if ( aLibName.equalsIgnoreAsciiCase(
"Standard" ) )
252 VclMessageType::Warning, VclButtonsType::Ok,
IDEResId(RID_STR_CANNOTCHANGENAMESTDLIB)));
260 if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) && !xModLibContainer->isLibraryLink( aLibName ) ) ||
261 ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) && !xDlgLibContainer->isLibraryLink( aLibName ) ) )
264 VclMessageType::Warning, VclButtonsType::Ok,
IDEResId(RID_STR_LIBISREADONLY)));
270 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && !xModLibContainer->isLibraryLoaded( aLibName ) )
275 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
278 bOK =
QueryPassword(m_pDialog->getDialog(), xModLibContainer, aLibName, aPassword);
292 OUString sNewName = rIterString.second;
294 bool bValid = sNewName.getLength() <= 30 &&
IsValidSbxName(sNewName);
295 OUString aOldName(m_xLibBox->get_text(rIter, 0));
297 if (bValid && aOldName != sNewName)
302 if ( xModLibContainer.is() )
303 xModLibContainer->renameLibrary( aOldName, sNewName );
306 if ( xDlgLibContainer.is() )
307 xDlgLibContainer->renameLibrary( aOldName, sNewName );
312 pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR );
313 pBindings->Update( SID_BASICIDE_LIBSELECTOR );
316 catch (
const container::ElementExistException& )
319 VclMessageType::Warning, VclButtonsType::Ok,
IDEResId(RID_STR_SBXNAMEALLREADYUSED)));
323 catch (
const container::NoSuchElementException& )
332 OUString sWarning(sNewName.getLength() > 30 ?
IDEResId(RID_STR_LIBNAMETOLONG) :
IDEResId(RID_STR_BADSBXNAME));
334 VclMessageType::Warning, VclButtonsType::Ok, sWarning));
357 std::unique_ptr<weld::TreeIter> xCur(
m_xLibBox->make_iterator());
361 OUString aLibName =
m_xLibBox->get_text(*xCur, 0);
372 else if ( aLibName.equalsIgnoreAsciiCase(
"Standard" ) )
380 else if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
381 ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) )
386 if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) && !xModLibContainer->isLibraryLink( aLibName ) ) ||
387 ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) && !xDlgLibContainer->isLibraryLink( aLibName ) ) )
394 if ( xModLibContainer.is() && !xModLibContainer->hasByName( aLibName ) )
424 if (&rButton == m_xEditButton.get())
427 SfxRequest aRequest( SID_BASICIDE_APPEAR, SfxCallMode::SYNCHRON, aArgs );
430 SfxUnoAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL,
Any( m_aCurDocument.getDocumentOrNull() ) );
432 std::unique_ptr<weld::TreeIter> xCurEntry(m_xLibBox->make_iterator());
433 if (!m_xLibBox->get_cursor(xCurEntry.get()))
435 OUString aLibName(m_xLibBox->get_text(*xCurEntry, 0));
436 SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
438 pDispatcher->ExecuteList( SID_BASICIDE_LIBSELECTED,
439 SfxCallMode::ASYNCHRON, { &aDocItem, &aLibNameItem });
443 else if (&rButton == m_xNewLibButton.get())
445 else if (&rButton == m_xInsertLibButton.get())
447 else if (&rButton == m_xExportButton.get())
449 else if (&rButton == m_xDelButton.get())
451 else if (&rButton == m_xPasswordButton.get())
453 std::unique_ptr<weld::TreeIter> xCurEntry(m_xLibBox->make_iterator());
454 if (!m_xLibBox->get_cursor(xCurEntry.get()))
456 OUString aLibName(m_xLibBox->get_text(*xCurEntry, 0));
460 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && !xModLibContainer->isLibraryLoaded( aLibName ) )
465 xModLibContainer->loadLibrary( aLibName );
472 if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && !xDlgLibContainer->isLibraryLoaded( aLibName ) )
477 xDlgLibContainer->loadLibrary( aLibName );
483 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
488 bool const bProtected = xPasswd->isLibraryPasswordProtected( aLibName );
491 SvxPasswordDialog aDlg(m_pDialog->getDialog(), !bProtected);
492 aDlg.SetCheckPasswordHdl(
LINK(
this,
LibPage, CheckPasswordHdl));
496 bool const bNewProtected = xPasswd->isLibraryPasswordProtected( aLibName );
498 if ( bNewProtected != bProtected )
500 int nPos = m_xLibBox->get_iter_index_in_parent(*xCurEntry);
501 m_xLibBox->remove(*xCurEntry);
502 ImpInsertLibEntry(aLibName,
nPos);
503 m_xLibBox->set_cursor(
nPos);
518 std::unique_ptr<weld::TreeIter> xCurEntry(m_xLibBox->make_iterator());
519 if (!m_xLibBox->get_cursor(xCurEntry.get()))
522 OUString aLibName(m_xLibBox->get_text(*xCurEntry, 0));
529 OUString aOldPassword( pDlg->GetOldPassword() );
530 OUString aNewPassword( pDlg->GetNewPassword() );
531 xPasswd->changeLibraryPassword( aLibName, aOldPassword, aNewPassword );
555 xFP->setTitle(
IDEResId(RID_STR_APPENDLIBS));
558 OUString aTitle(
IDEResId(RID_STR_BASIC));
559 xFP->appendFilter( aTitle,
"*.sbl;*.xlc;*.xlb"
572 OUString aLastFilter(
GetExtraData()->GetAddLibFilter());
573 if ( !aLastFilter.isEmpty() )
574 xFP->setCurrentFilter( aLastFilter );
576 xFP->setCurrentFilter(
IDEResId(RID_STR_BASIC) );
578 if ( xFP->execute() !=
RET_OK )
591 auto xModURLObj = std::make_shared<INetURLObject>(aURLObj);
592 auto xDlgURLObj = std::make_shared<INetURLObject>(aURLObj);
594 OUString aBase = aURLObj.
getBase();
595 OUString aModBase(
"script" );
596 OUString aDlgBase(
"dialog" );
598 if ( aBase == aModBase || aBase == aDlgBase )
600 xModURLObj->setBase( aModBase );
601 xDlgURLObj->setBase( aDlgBase );
607 if ( xSFA->exists( aModURL ) )
609 xModLibContImport = script::DocumentScriptLibraryContainer::createWithURL(xContext, aModURL);
613 if ( xSFA->exists( aDlgURL ) )
615 xDlgLibContImport = script::DocumentDialogLibraryContainer::createWithURL(xContext, aDlgURL);
618 if ( !xModLibContImport.is() && !xDlgLibContImport.is() )
621 std::shared_ptr<LibDialog> xLibDlg;
624 sal_Int32 nLibCount = aLibNames.getLength();
629 xLibDlg->SetStorageName(aURLObj.
getName());
634 const OUString* pLibNames = aLibNames.getConstArray();
635 for (sal_Int32
i = 0 ;
i < nLibCount; ++
i)
638 OUString aLibName( pLibNames[
i ] );
639 if ( !( ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) && xModLibContImport->isLibraryLink( aLibName ) ) ||
640 ( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aLibName ) && xDlgLibContImport->isLibraryLink( aLibName ) ) ) )
659 VclMessageType::Warning, VclButtonsType::Ok,
IDEResId(RID_STR_NOLIBINSTORAGE)));
665 OUString aLibExtension(
"xlb" );
666 OUString aContExtension(
"xlc" );
669 if ( aExtension != aLibExtension && aExtension != aContExtension )
670 xLibDlg->EnableReference(
false);
672 weld::DialogController::runAsync(xLibDlg, [aContExtension, xDlgURLObj, aExtension, aLibExtension, xModURLObj, xLibDlg, xDlgLibContImport, xModLibContImport,
this](sal_Int32 nResult)
677 bool bChanges =
false;
678 bool bRemove =
false;
679 bool bReplace = xLibDlg->IsReplace();
680 bool bReference = xLibDlg->IsReference();
682 for (
int nLib = 0, nChildren = rView.
n_children(); nLib < nChildren; ++nLib)
684 if (rView.get_toggle(nLib) == TRISTATE_TRUE)
686 OUString aLibName(rView.get_text(nLib));
687 Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
688 Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
691 if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) ) ||
692 ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) ) )
697 if ( aLibName ==
"Standard" )
699 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_pDialog->getDialog(),
700 VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_REPLACESTDLIB)));
706 if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) && !xModLibContainer->isLibraryLink( aLibName ) ) ||
707 ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) && !xDlgLibContainer->isLibraryLink( aLibName ) ) )
709 OUString aErrStr( IDEResId(RID_STR_REPLACELIB) );
710 aErrStr = aErrStr.replaceAll(
"XX", aLibName) +
"\n" + IDEResId(RID_STR_LIBISREADONLY);
711 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_pDialog->getDialog(),
712 VclMessageType::Warning, VclButtonsType::Ok, aErrStr));
724 aErrStr = IDEResId(RID_STR_REFNOTPOSSIBLE);
726 aErrStr = IDEResId(RID_STR_IMPORTNOTPOSSIBLE);
727 aErrStr = aErrStr.replaceAll(
"XX", aLibName) +
"\n" +IDEResId(RID_STR_SBXNAMEALLREADYUSED);
728 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_pDialog->getDialog(),
729 VclMessageType::Warning, VclButtonsType::Ok, aErrStr));
738 if ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) )
740 Reference< script::XLibraryContainerPassword > xPasswd( xModLibContImport, UNO_QUERY );
741 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) && !bReference )
743 bOK = QueryPassword(m_pDialog->getDialog(), xModLibContImport, aLibName, aPassword, true, true);
747 OUString aErrStr( IDEResId(RID_STR_NOIMPORT) );
748 aErrStr = aErrStr.replaceAll(
"XX", aLibName);
749 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_pDialog->getDialog(),
750 VclMessageType::Warning, VclButtonsType::Ok, aErrStr));
761 int nEntry_ = FindEntry(*m_xLibBox, aLibName);
763 m_xLibBox->remove(nEntry_);
766 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
767 xModLibContainer->removeLibrary( aLibName );
770 if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
771 xDlgLibContainer->removeLibrary( aLibName );
775 if ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) && xModLibContainer.is() && !xModLibContainer->hasByName( aLibName ) )
777 Reference< container::XNameContainer > xModLib;
781 INetURLObject aModStorageURLObj(*xModURLObj);
782 if ( aExtension == aContExtension )
784 sal_Int32 nCount = aModStorageURLObj.getSegmentCount();
785 aModStorageURLObj.insertName( aLibName, false, nCount-1 );
786 aModStorageURLObj.setExtension( aLibExtension );
787 aModStorageURLObj.setFinalSlash();
789 OUString aModStorageURL( aModStorageURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
792 xModLib.set( xModLibContainer->createLibraryLink( aLibName, aModStorageURL, true ), UNO_QUERY);
797 xModLib = xModLibContainer->createLibrary( aLibName );
801 Reference< container::XNameContainer > xModLibImport;
802 Any aElement = xModLibContImport->getByName( aLibName );
803 aElement >>= xModLibImport;
805 if ( xModLibImport.is() )
808 if ( !xModLibContImport->isLibraryLoaded( aLibName ) )
809 xModLibContImport->loadLibrary( aLibName );
812 Sequence< OUString > aModNames = xModLibImport->getElementNames();
813 sal_Int32 nModCount = aModNames.getLength();
814 const OUString* pModNames = aModNames.getConstArray();
815 for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
817 OUString aModName( pModNames[ i ] );
818 Any aElement_ = xModLibImport->getByName( aModName );
819 xModLib->insertByName( aModName, aElement_ );
825 Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
830 xPasswd->changeLibraryPassword( aLibName, OUString(), aPassword );
843 if ( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aLibName ) && xDlgLibContainer.is() && !xDlgLibContainer->hasByName( aLibName ) )
845 Reference< container::XNameContainer > xDlgLib;
849 INetURLObject aDlgStorageURLObj( *xDlgURLObj );
850 if ( aExtension == aContExtension )
852 sal_Int32 nCount = aDlgStorageURLObj.getSegmentCount();
853 aDlgStorageURLObj.insertName( aLibName, false, nCount - 1 );
854 aDlgStorageURLObj.setExtension( aLibExtension );
855 aDlgStorageURLObj.setFinalSlash();
857 OUString aDlgStorageURL( aDlgStorageURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
860 xDlgLib.set( xDlgLibContainer->createLibraryLink( aLibName, aDlgStorageURL, true ), UNO_QUERY);
865 xDlgLib = xDlgLibContainer->createLibrary( aLibName );
869 Reference< container::XNameContainer > xDlgLibImport;
870 Any aElement = xDlgLibContImport->getByName( aLibName );
871 aElement >>= xDlgLibImport;
873 if ( xDlgLibImport.is() )
876 if ( !xDlgLibContImport->isLibraryLoaded( aLibName ) )
877 xDlgLibContImport->loadLibrary( aLibName );
880 Sequence< OUString > aDlgNames = xDlgLibImport->getElementNames();
881 sal_Int32 nDlgCount = aDlgNames.getLength();
882 const OUString* pDlgNames = aDlgNames.getConstArray();
883 for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
885 OUString aDlgName( pDlgNames[ i ] );
886 Any aElement_ = xDlgLibImport->getByName( aDlgName );
887 xDlgLib->insertByName( aDlgName, aElement_ );
895 ImpInsertLibEntry( aLibName, m_xLibBox->n_children() );
896 m_xLibBox->set_cursor( m_xLibBox->find_text(aLibName) );
906void LibPage::Export()
908 std::unique_ptr<weld::TreeIter> xCurEntry(m_xLibBox->make_iterator());
909 if (!m_xLibBox->get_cursor(xCurEntry.get()))
911 OUString aLibName(m_xLibBox->get_text(*xCurEntry, 0));
916 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && !xModLibContainer->isLibraryLoaded( aLibName ) )
922 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
925 bOK =
QueryPassword(m_pDialog->getDialog(), xModLibContainer, aLibName, aPassword);
931 std::unique_ptr<ExportDialog> xNewDlg(
new ExportDialog(m_pDialog->getDialog()));
932 if (xNewDlg->run() !=
RET_OK)
937 bool bExportAsPackage = xNewDlg->isExportAsPackage();
941 if (bExportAsPackage)
942 ExportAsPackage( aLibName );
944 ExportAsBasic( aLibName );
946 catch(
const util::VetoException& )
951void LibPage::implExportLib(
const OUString& aLibName,
const OUString& aTargetURL,
955 ( m_aCurDocument.getLibraryContainer(
E_SCRIPTS ), UNO_QUERY );
957 ( m_aCurDocument.getLibraryContainer(
E_DIALOGS ), UNO_QUERY );
958 if ( xModLibContainerExport.is() )
959 xModLibContainerExport->exportLibrary( aLibName,
aTargetURL, Handler );
961 if (!xDlgLibContainerExport.is())
966 if (!xNameAcc->hasByName(aLibName))
968 xDlgLibContainerExport->exportLibrary(aLibName,
aTargetURL, Handler);
975class OLibCommandEnvironment :
public cppu::WeakImplHelper< XCommandEnvironment >
980 explicit OLibCommandEnvironment(
const Reference<task::XInteractionHandler>& xInteraction)
985 virtual Reference< task::XInteractionHandler > SAL_CALL getInteractionHandler()
override;
986 virtual Reference< XProgressHandler > SAL_CALL getProgressHandler()
override;
991Reference< task::XInteractionHandler > OLibCommandEnvironment::getInteractionHandler()
996Reference< XProgressHandler > OLibCommandEnvironment::getProgressHandler()
998 Reference< XProgressHandler > xRet;
1002void LibPage::ExportAsPackage(
const OUString& aLibName )
1005 sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, FileDialogFlags::NONE, m_pDialog->getDialog());
1013 xFP->setTitle(
IDEResId(RID_STR_EXPORTPACKAGE));
1016 OUString aTitle(
IDEResId(RID_STR_PACKAGE_BUNDLE));
1017 xFP->appendFilter( aTitle,
"*.oxt" );
1019 xFP->setCurrentFilter( aTitle );
1021 if ( xFP->execute() !=
RET_OK )
1028 if(
aURL.getExtension().isEmpty() )
1029 aURL.setExtension(
u"oxt" );
1037 if( xSFA->exists( aSourcePath ) )
1038 xSFA->kill( aSourcePath );
1040 implExportLib( aLibName, aTmpPath, xDummyHandler );
1046 OUString destFolder =
"vnd.sun.star.zip://" +
1047 ::rtl::Uri::encode( aPackageURL,
1048 rtl_UriCharClassRegName,
1049 rtl_UriEncodeIgnoreEscapes,
1050 RTL_TEXTENCODING_UTF8 ) +
1053 if( xSFA->exists( aPackageURL ) )
1054 xSFA->kill( aPackageURL );
1059 OUString(), NameClash::OVERWRITE );
1065 if( xSFA->exists( aMetaInfFolder ) )
1066 xSFA->kill( aMetaInfFolder );
1067 xSFA->createFolder( aMetaInfFolder );
1069 std::vector< Sequence<beans::PropertyValue> > manifest;
1071 OUString fullPath = aLibName
1073 auto attribs(::comphelper::InitPropertySequence({
1074 {
"FullPath",
Any(fullPath) },
1075 {
"MediaType",
Any(OUString(
"application/vnd.sun.star.basic-library")) }
1077 manifest.push_back( attribs );
1082 xManifestWriter->writeManifestSequence(
1084 manifest.data(), manifest.size() ) );
1096 OUString(), NameClash::OVERWRITE );
1098 if( xSFA->exists( aSourcePath ) )
1099 xSFA->kill( aSourcePath );
1100 if( xSFA->exists( aMetaInfFolder ) )
1101 xSFA->kill( aMetaInfFolder );
1104void LibPage::ExportAsBasic(
const OUString& aLibName )
1111 xFolderPicker->setTitle(
IDEResId(RID_STR_EXPORTBASIC));
1115 if( aPath.isEmpty() )
1119 xFolderPicker->setDisplayDirectory( aPath );
1120 short nRet = xFolderPicker->execute();
1123 OUString
aTargetURL = xFolderPicker->getDirectory();
1127 implExportLib( aLibName,
aTargetURL, xDummyHandler );
1131void LibPage::DeleteCurrent()
1133 std::unique_ptr<weld::TreeIter> xCurEntry(m_xLibBox->make_iterator());
1134 if (!m_xLibBox->get_cursor(xCurEntry.get()))
1136 OUString aLibName(m_xLibBox->get_text(*xCurEntry, 0));
1139 bool bIsLibraryLink =
false;
1142 if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryLink( aLibName ) ) ||
1143 ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryLink( aLibName ) ) )
1145 bIsLibraryLink =
true;
1148 if (!
QueryDelLib(aLibName, bIsLibraryLink, m_pDialog->getDialog()))
1152 SfxUnoAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL,
Any( m_aCurDocument.getDocumentOrNull() ) );
1153 SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
1155 pDispatcher->ExecuteList(SID_BASICIDE_LIBREMOVED,
1156 SfxCallMode::SYNCHRON, { &aDocItem, &aLibNameItem });
1159 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
1160 xModLibContainer->removeLibrary( aLibName );
1161 if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
1162 xDlgLibContainer->removeLibrary( aLibName );
1164 m_xLibBox->remove(*xCurEntry);
1168void LibPage::EndTabDialog()
1170 m_pDialog->response(
RET_OK);
1173void LibPage::FillListBox()
1178 ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::DocumentsSorted ) );
1179 for (
auto const& doc : aDocuments)
1187 OUString aEntryText(rDocument.
getTitle(eLocation));
1189 m_xBasicsBox->append(
sId, aEntryText);
1192void LibPage::SetCurLib()
1194 DocumentEntry* pEntry = weld::fromId<DocumentEntry*>(m_xBasicsBox->get_active_id());
1199 DBG_ASSERT(
aDocument.isAlive(),
"LibPage::SetCurLib: no document, or document is dead!" );
1203 if (
aDocument == m_aCurDocument && eLocation == m_eCurLocation )
1207 m_eCurLocation = eLocation;
1212 sal_Int32 nLibCount = aLibNames.getLength();
1213 const OUString* pLibNames = aLibNames.getConstArray();
1216 for (
int i = 0 ;
i < nLibCount; ++
i)
1218 OUString aLibName(pLibNames[
i]);
1219 if (eLocation ==
aDocument.getLibraryLocation(aLibName))
1220 ImpInsertLibEntry(aLibName, nEntry++);
1223 int nEntry_ = FindEntry(*m_xLibBox,
u"Standard");
1224 if (nEntry_ == -1 && m_xLibBox->n_children())
1226 m_xLibBox->set_cursor(nEntry_);
1229void LibPage::ImpInsertLibEntry(
const OUString& rLibName,
int nPos )
1232 bool bProtected =
false;
1234 if ( xModLibContainer.is() && xModLibContainer->hasByName( rLibName ) )
1239 bProtected = xPasswd->isLibraryPasswordProtected( rLibName );
1243 m_xLibBox->insert_text(
nPos, rLibName);
1246 m_xLibBox->set_image(
nPos, RID_BMP_LOCKED);
1249 if ( xModLibContainer.is() && xModLibContainer->hasByName( rLibName ) && xModLibContainer->isLibraryLink( rLibName ) )
1251 OUString aLinkURL = xModLibContainer->getLibraryLinkURL( rLibName );
1252 m_xLibBox->set_text(
nPos, aLinkURL, 1);
1260 OSL_ENSURE( rDocument.
isAlive(),
"createLibImpl: invalid document!" );
1266 bool bValid =
false;
1270 aLibName =
"Library" + OUString::number(
i );
1285 if ( aLibName.getLength() > 30 )
1288 VclMessageType::Warning, VclButtonsType::Ok,
IDEResId(RID_STR_LIBNAMETOLONG)));
1294 VclMessageType::Warning, VclButtonsType::Ok,
IDEResId(RID_STR_BADSBXNAME)));
1300 VclMessageType::Warning, VclButtonsType::Ok,
IDEResId(RID_STR_SBXNAMEALLREADYUSED2)));
1319 OUString sModuleCode;
1320 if ( !rDocument.
createModule( aLibName, aModName,
true, sModuleCode ) )
1321 throw Exception(
"could not create module " + aModName,
nullptr);
1332 if (xModPersLibContainer.is())
1333 xModPersLibContainer->storeLibraries();
1336 if (xDlgPersLibContainer.is())
1337 xDlgPersLibContainer->storeLibraries();
1339 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName,
TYPE_MODULE );
1341 pDispatcher->ExecuteList(SID_BASICIDE_SBXINSERTED,
1342 SfxCallMode::SYNCHRON, { &aSbxItem });
1346 std::unique_ptr<weld::TreeIter> xIter(pBasicBox->
make_iterator(
nullptr));
1347 bool bValidIter = pBasicBox->
get_cursor(xIter.get());
1348 std::unique_ptr<weld::TreeIter> xRootEntry(pBasicBox->
make_iterator(xIter.get()));
1357 const auto sId = bDlgMode ? OUString(RID_BMP_DLGLIB) : OUString(RID_BMP_MODLIB);
1359 pBasicBox->
AddEntry(aModName, RID_BMP_MODULE, xRootEntry.get(),
false, std::make_unique<Entry>(
OBJ_TYPE_MODULE));
1361 pBasicBox->
select(*xRootEntry);
1364 catch (
const uno::Exception& )
SfxApplication * SfxGetpApp()
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString getExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString getBase(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool insertName(std::u16string_view rTheName, bool bAppendFinalSlash=false, sal_Int32 nIndex=LAST_SEGMENT, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
vcl::Window & GetWindow() const
SfxViewFrame & GetViewFrame() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const OUString & GetWorkPath() const
const OUString & GetTempPath() const
LibraryLocation GetLocation() const
ScriptDocument const & GetDocument() const
virtual ~ExportDialog() override
ExportDialog(weld::Window *pParent)
std::unique_ptr< weld::RadioButton > m_xExportAsPackageButton
std::unique_ptr< weld::Button > m_xOKButton
virtual ~GotoLineDialog() override
sal_Int32 GetLineNumber() const
std::unique_ptr< weld::Button > m_xOKButton
std::unique_ptr< weld::Entry > m_xEdit
GotoLineDialog(weld::Window *pParent)
LibPage(weld::Container *pParent, OrganizeDialog *pDialog)
std::unique_ptr< weld::TreeView > m_xLibBox
std::unique_ptr< weld::Button > m_xInsertLibButton
virtual void ActivatePage() override
virtual ~LibPage() override
std::unique_ptr< weld::Button > m_xEditButton
std::unique_ptr< weld::ComboBox > m_xBasicsBox
std::unique_ptr< weld::Button > m_xNewLibButton
std::unique_ptr< weld::Button > m_xPasswordButton
std::unique_ptr< weld::Button > m_xExportButton
ScriptDocument m_aCurDocument
LibraryLocation m_eCurLocation
std::unique_ptr< weld::Button > m_xDelButton
std::unique_ptr< weld::Button > m_xOKButton
OUString GetObjectName() const
NewObjectDialog(weld::Window *pParent, ObjectMode, bool bCheckName=false)
void SetObjectName(const OUString &rName)
OrganizeDialog * m_pDialog
bool get_cursor(weld::TreeIter *pIter) const
void set_cursor(const weld::TreeIter &rIter)
std::unique_ptr< weld::TreeIter > make_iterator(const weld::TreeIter *pIter=nullptr) const
void select(const weld::TreeIter &rIter)
void AddEntry(const OUString &rText, const OUString &rImage, const weld::TreeIter *pParent, bool bChildrenOnDemand, std::unique_ptr< Entry > &&rUserData, weld::TreeIter *pRet=nullptr)
BrowseMode GetMode() const
bool iter_parent(weld::TreeIter &rIter) const
void copy_iterator(const weld::TreeIter &rSource, weld::TreeIter &rDest) const
encapsulates a document which contains Basic scripts and dialogs
css::uno::Reference< css::container::XNameContainer > getOrCreateLibrary(LibraryContainerType _eType, const OUString &_rLibName) const
creates a script or dialog library in the document, or returns an existing one
OUString getTitle(LibraryLocation _eLocation, LibraryType _eType=LibraryType::All) const
returns the title for the document
bool hasLibrary(LibraryContainerType _eType, const OUString &_rLibName) const
determines whether there exists a library of the given type, with the given name
css::uno::Reference< css::script::XLibraryContainer > getLibraryContainer(LibraryContainerType _eType) const
returns the Basic or Dialog library container of the document
bool createModule(const OUString &_rLibName, const OUString &_rModName, bool _bCreateMain, OUString &_out_rNewModuleCode) const
creates a module with the given name in the given library
bool isAlive() const
determines whether the document instance is alive
OUString createObjectName(LibraryContainerType _eType, const OUString &_rLibName) const
retrieves a name for a newly to be created module or dialog
const css::uno::Reference< css::ui::dialogs::XFilePicker3 > & GetFilePicker() const
void SetContext(Context _eNewContext)
void transferContent(const Content &rSourceContent, InsertOperation eOperation, const OUString &rTitle, const sal_Int32 nNameClashAction, const OUString &rMimeType=OUString(), bool bMajorVersion=false, const OUString &rCommentVersion=OUString(), OUString *pResultURL=nullptr, const OUString &rDocumentId=OUString()) const
void writeStream(const css::uno::Reference< css::io::XInputStream > &rStream, bool bReplaceExisting)
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
virtual Dialog * getDialog() override
std::shared_ptr< weld::Dialog > m_xDialog
virtual void make_sorted()=0
virtual void set_text(int row, const OUString &rText, int col=-1)=0
virtual int find_text(const OUString &rText) const=0
virtual OUString get_text(int row, int col=-1) const=0
void append_text(const OUString &rStr)
virtual void set_toggle(int row, TriState eState, int col=-1)=0
virtual int n_children() const=0
void append(TreeIter *pRet=nullptr)
virtual void set_cursor(int pos)=0
virtual void make_unsorted()=0
#define DBG_ASSERT(sCon, aError)
#define DBG_UNHANDLED_EXCEPTION(...)
std::unique_ptr< weld::Button > m_xOKButton
#define LINK(Instance, Class, Member)
Reference< task::XInteractionHandler2 > m_xHandler
Reference< task::XInteractionHandler > mxInteraction
SfxBindings * GetBindingsPtr()
bool QueryDelLib(std::u16string_view rName, bool bRef, weld::Widget *pParent)
bool IsValidSbxName(std::u16string_view rName)
void createLibImpl(weld::Window *pWin, const ScriptDocument &rDocument, weld::TreeView *pLibBox, SbTreeListBox *pBasicBox)
bool QueryPassword(weld::Widget *pDialogParent, const Reference< script::XLibraryContainer > &xLibContainer, const OUString &rLibName, OUString &rPassword, bool bRepeat, bool bNewTitle)
@ LIBRARY_LOCATION_UNKNOWN
@ LIBRARY_LOCATION_DOCUMENT
ExtraData * GetExtraData()
SfxDispatcher * GetDispatcher()
void MarkDocumentModified(const ScriptDocument &rDocument)
IMPL_LINK(AccessibleDialogWindow, WindowEventListener, VclWindowEvent &, rEvent, void)
std::vector< ScriptDocument > ScriptDocuments
Sequence< OUString > GetMergedLibraryNames(const Reference< script::XLibraryContainer > &xModLibContainer, const Reference< script::XLibraryContainer > &xDlgLibContainer)
IMPL_LINK_NOARG(EditorWindow, SetSourceInBasicHdl, void *, void)
OUString IDEResId(TranslateId aId)
Reference< XComponentContext > getProcessComponentContext()
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &rContext, weld::Window *pPreferredParent)
OUString toId(const void *pValue)