29#include <sfx2/sfxsids.hrc>
30#include <com/sun/star/ui/dialogs/ControlActions.hpp>
31#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
32#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
33#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
34#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
35#include <com/sun/star/lang/IllegalArgumentException.hpp>
79 : m_pParent ( pParent )
80 , m_sDocFactory (
std::move( sFactory ))
81 , m_nDlgFlags ( lcl_map_mode_to_flags(
mode) )
97 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
106 std::unique_ptr<SfxMedium> pMedium;
109 DBG_ASSERT(
m_pURLList.size() == 1,
"DocumentInserter::CreateMedium(): invalid URL list count" );
113 pMedium->UseInteractionHandler(
true );
114 std::optional<SfxFilterMatcher> pMatcher;
120 std::shared_ptr<const SfxFilter> pFilter;
121 ErrCode nError = pMatcher->DetectFilter( *pMedium, pFilter );
125 pMatcher.emplace(OUString::createFromAscii(pFallbackHack));
126 nError = pMatcher->DetectFilter( *pMedium, pFilter );
129 pMedium->SetFilter( pFilter );
147 std::unique_ptr<SfxMedium> pMedium(
new SfxMedium(
151 pMedium->UseInteractionHandler(
true );
154 std::shared_ptr<const SfxFilter> pFilter;
157 pMedium->SetFilter( pFilter );
162 aMediumList.push_back( std::move(pMedium) );
171 DBG_ASSERT( _pFileDlg,
"DocumentInserter::fillURLList(): invalid file dialog" );
175 if ( aPathSeq.hasElements() )
179 std::transform(aPathSeq.begin(), aPathSeq.end(), std::back_inserter(_rpURLList),
180 [](
const OUString& rPath) -> OUString {
181 INetURLObject aPathObj( rPath );
182 return aPathObj.GetMainURL(INetURLObject::DecodeMechanism::NONE);
189 DBG_ASSERT( m_pFileDlg,
"DocumentInserter::DialogClosedHdl(): no file dialog" );
191 m_nError = m_pFileDlg->GetError();
195 Reference < XFilePicker3 > xFP = m_pFileDlg->GetFilePicker();
196 Reference < XFilePickerControlAccess > xCtrlAccess( xFP, UNO_QUERY );
197 if ( xCtrlAccess.is() )
200 m_xItemSet = std::make_shared<SfxAllItemSet>(
SfxGetpApp()->GetPool() );
202 short nDlgType = m_pFileDlg->GetDialogType();
203 bool bHasPassword = (
204 TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD == nDlgType
205 || TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS == nDlgType );
208 if ( bHasPassword && m_pFileDlg->IsPasswordEnabled() )
212 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0 );
213 bool bPassWord =
false;
214 if ( ( aValue >>= bPassWord ) && bPassWord )
219 short nRet = aPasswordDlg.
run();
231 catch(
const IllegalArgumentException& ){}
238 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0 );
239 bool bSelection =
false;
240 if ( aValue >>= bSelection )
241 m_xItemSet->Put(
SfxBoolItem( SID_SELECTION, bSelection ) );
243 catch(
const IllegalArgumentException& )
245 TOOLS_WARN_EXCEPTION(
"sfx.doc",
"FileDialogHelper_Impl::execute: caught an IllegalArgumentException!" );
252 m_xItemSet->Put(
SfxBoolItem( SID_DOC_READONLY,
true ) );
255 if ( TemplateDescription::FILEOPEN_READONLY_VERSION == nDlgType )
259 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::CHECKBOX_READONLY, 0 );
264 catch(
const IllegalArgumentException& )
266 TOOLS_WARN_EXCEPTION(
"sfx.doc",
"FileDialogHelper_Impl::execute: caught an IllegalArgumentException!" );
271 if ( TemplateDescription::FILEOPEN_READONLY_VERSION == nDlgType )
275 Any aValue = xCtrlAccess->getValue( ExtendedFilePickerElementIds::LISTBOX_VERSION,
276 ControlActions::GET_SELECTED_ITEM_INDEX );
282 catch(
const IllegalArgumentException& ){}
288 m_aDialogClosedLink.Call( m_pFileDlg.get() );
SfxApplication * SfxGetpApp()
ErrCode CheckPasswd_Impl(SfxObjectShell *pDoc, SfxMedium *pFile)
const sal_uInt16 nVersion
ErrCode DetectFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &) const
OUString GetPassword() const
virtual short run() override
void ShowExtras(SfxShowExtras nExtras)
FileDialogFlags const m_nDlgFlags
std::shared_ptr< SfxItemSet > m_xItemSet
Link< sfx2::FileDialogHelper *, void > m_aDialogClosedLink
std::vector< OUString > m_pURLList
void StartExecuteModal(const Link< sfx2::FileDialogHelper *, void > &_rDialogClosedLink)
std::unique_ptr< sfx2::FileDialogHelper > m_pFileDlg
SfxMediumList CreateMediumList()
std::unique_ptr< SfxMedium > CreateMedium(char const *pFallbackHack=nullptr)
DocumentInserter(weld::Window *pParent, OUString aFactory, const Mode mode=Mode::Insert)
css::uno::Sequence< OUString > GetSelectedFiles() const
Provides the selected files with full path information.
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
::std::vector< std::unique_ptr< SfxMedium > > SfxMediumList
@ InsertMerge
Special insertion ("Compare" caption)
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(SvDDELinkEditDialog, EditHdl_Impl, weld::Entry &, void)
static void impl_FillURLList(sfx2::FileDialogHelper const *_pFileDlg, std::vector< OUString > &_rpURLList)
#define SFX_STREAM_READONLY