2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-04 15:25:45 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2005-04-13 07:49:02 +00:00
|
|
|
|
2006-09-16 16:49:45 +00:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
#include "OfficeFilePicker.hxx"
|
|
|
|
#include "iodlg.hxx"
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
#include <functional>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#include <com/sun/star/uno/Any.hxx>
|
|
|
|
#include <com/sun/star/ui/dialogs/FilePickerEvent.hpp>
|
|
|
|
#include <com/sun/star/ui/dialogs/FilePreviewImageFormats.hpp>
|
|
|
|
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
|
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#include <com/sun/star/awt/XWindow.hpp>
|
|
|
|
#include <com/sun/star/beans/StringPair.hpp>
|
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
2008-03-18 16:30:23 +00:00
|
|
|
#include <com/sun/star/beans/NamedValue.hpp>
|
2005-04-13 07:49:02 +00:00
|
|
|
#include <unotools/ucbhelper.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/pathoptions.hxx>
|
2005-04-13 07:49:02 +00:00
|
|
|
#include <comphelper/sequence.hxx>
|
2013-09-25 15:41:29 -03:00
|
|
|
#include <cppuhelper/supportsservice.hxx>
|
2005-04-13 07:49:02 +00:00
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
2010-10-16 03:18:35 -05:00
|
|
|
#include "osl/mutex.hxx"
|
2005-04-13 07:49:02 +00:00
|
|
|
#include "vcl/svapp.hxx"
|
|
|
|
|
|
|
|
// using ----------------------------------------------------------------
|
|
|
|
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::ui::dialogs;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::awt;
|
|
|
|
using namespace ::utl;
|
|
|
|
|
|
|
|
|
2014-02-25 18:51:57 +01:00
|
|
|
|
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
struct FilterEntry
|
|
|
|
{
|
|
|
|
protected:
|
2012-12-08 13:42:54 +02:00
|
|
|
OUString m_sTitle;
|
|
|
|
OUString m_sFilter;
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
UnoFilterList m_aSubFilters;
|
|
|
|
|
|
|
|
public:
|
2012-12-08 13:42:54 +02:00
|
|
|
FilterEntry( const OUString& _rTitle, const OUString& _rFilter )
|
2005-04-13 07:49:02 +00:00
|
|
|
:m_sTitle( _rTitle )
|
|
|
|
,m_sFilter( _rFilter )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
FilterEntry( const OUString& _rTitle, const UnoFilterList& _rSubFilters );
|
2005-04-13 07:49:02 +00:00
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
OUString getTitle() const { return m_sTitle; }
|
|
|
|
OUString getFilter() const { return m_sFilter; }
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
/// determines if the filter has sub filter (i.e., the filter is a filter group in real)
|
2014-04-22 12:40:46 +02:00
|
|
|
bool hasSubFilters( ) const;
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
/** retrieves the filters belonging to the entry
|
|
|
|
@return
|
|
|
|
the number of sub filters
|
|
|
|
*/
|
|
|
|
sal_Int32 getSubFilters( UnoFilterList& _rSubFilterList );
|
|
|
|
|
|
|
|
// helpers for iterating the sub filters
|
|
|
|
const UnoFilterEntry* beginSubFilters() const { return m_aSubFilters.getConstArray(); }
|
|
|
|
const UnoFilterEntry* endSubFilters() const { return m_aSubFilters.getConstArray() + m_aSubFilters.getLength(); }
|
|
|
|
};
|
|
|
|
|
2014-02-25 18:51:57 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
FilterEntry::FilterEntry( const OUString& _rTitle, const UnoFilterList& _rSubFilters )
|
2005-04-13 07:49:02 +00:00
|
|
|
:m_sTitle( _rTitle )
|
|
|
|
,m_aSubFilters( _rSubFilters )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-04-22 12:40:46 +02:00
|
|
|
bool FilterEntry::hasSubFilters( ) const
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
return ( 0 < m_aSubFilters.getLength() );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
sal_Int32 FilterEntry::getSubFilters( UnoFilterList& _rSubFilterList )
|
|
|
|
{
|
|
|
|
_rSubFilterList = m_aSubFilters;
|
|
|
|
return m_aSubFilters.getLength();
|
|
|
|
}
|
|
|
|
|
|
|
|
// struct ElementEntry_Impl ----------------------------------------------
|
|
|
|
|
|
|
|
struct ElementEntry_Impl
|
|
|
|
{
|
|
|
|
sal_Int16 m_nElementID;
|
|
|
|
sal_Int16 m_nControlAction;
|
|
|
|
Any m_aValue;
|
2012-12-08 13:42:54 +02:00
|
|
|
OUString m_aLabel;
|
2014-04-22 12:40:46 +02:00
|
|
|
bool m_bEnabled : 1;
|
2005-04-13 07:49:02 +00:00
|
|
|
|
2014-04-22 12:40:46 +02:00
|
|
|
bool m_bHasValue : 1;
|
|
|
|
bool m_bHasLabel : 1;
|
|
|
|
bool m_bHasEnabled : 1;
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
ElementEntry_Impl( sal_Int16 nId );
|
|
|
|
|
2014-04-22 12:40:46 +02:00
|
|
|
void setValue( const Any& rVal ) { m_aValue = rVal; m_bHasValue = true; }
|
2005-04-13 07:49:02 +00:00
|
|
|
void setAction( sal_Int16 nAction ) { m_nControlAction = nAction; }
|
2014-04-22 12:40:46 +02:00
|
|
|
void setLabel( const OUString& rVal ) { m_aLabel = rVal; m_bHasLabel = true; }
|
|
|
|
void setEnabled( bool bEnabled ) { m_bEnabled = bEnabled; m_bHasEnabled = true; }
|
2005-04-13 07:49:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ElementEntry_Impl::ElementEntry_Impl( sal_Int16 nId )
|
|
|
|
: m_nElementID( nId )
|
|
|
|
, m_nControlAction( 0 )
|
2014-04-22 12:40:46 +02:00
|
|
|
, m_bEnabled( false )
|
|
|
|
, m_bHasValue( false )
|
|
|
|
, m_bHasLabel( false )
|
|
|
|
, m_bHasEnabled( false )
|
2005-04-13 07:49:02 +00:00
|
|
|
{}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2006-11-22 09:14:13 +00:00
|
|
|
void SvtFilePicker::prepareExecute()
|
|
|
|
{
|
|
|
|
// set the default directory
|
|
|
|
// --**-- doesn't match the spec yet
|
2011-12-25 19:31:22 -02:00
|
|
|
if ( !m_aDisplayDirectory.isEmpty() || !m_aDefaultName.isEmpty() )
|
2006-11-22 09:14:13 +00:00
|
|
|
{
|
2011-12-25 19:31:22 -02:00
|
|
|
if ( !m_aDisplayDirectory.isEmpty() )
|
2006-11-22 09:14:13 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
INetURLObject aPath( m_aDisplayDirectory );
|
2011-12-25 19:31:22 -02:00
|
|
|
if ( !m_aDefaultName.isEmpty() )
|
2006-11-22 09:14:13 +00:00
|
|
|
{
|
|
|
|
aPath.insertName( m_aDefaultName );
|
|
|
|
getDialog()->SetHasFilename( true );
|
|
|
|
}
|
|
|
|
getDialog()->SetPath( aPath.GetMainURL( INetURLObject::NO_DECODE ) );
|
|
|
|
}
|
2011-12-25 19:31:22 -02:00
|
|
|
else if ( !m_aDefaultName.isEmpty() )
|
2006-11-22 09:14:13 +00:00
|
|
|
{
|
|
|
|
getDialog()->SetPath( m_aDefaultName );
|
|
|
|
getDialog()->SetHasFilename( true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Default-Standard-Dir setzen
|
|
|
|
INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() );
|
|
|
|
getDialog()->SetPath( aStdDirObj.GetMainURL( INetURLObject::NO_DECODE ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// set the control values and set the control labels, too
|
|
|
|
if ( m_pElemList && !m_pElemList->empty() )
|
|
|
|
{
|
|
|
|
::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() );
|
|
|
|
|
|
|
|
ElementList::iterator aListIter;
|
|
|
|
for ( aListIter = m_pElemList->begin();
|
|
|
|
aListIter != m_pElemList->end(); ++aListIter )
|
|
|
|
{
|
|
|
|
ElementEntry_Impl& rEntry = *aListIter;
|
|
|
|
if ( rEntry.m_bHasValue )
|
|
|
|
aAccess.setValue( rEntry.m_nElementID, rEntry.m_nControlAction, rEntry.m_aValue );
|
|
|
|
if ( rEntry.m_bHasLabel )
|
|
|
|
aAccess.setLabel( rEntry.m_nElementID, rEntry.m_aLabel );
|
|
|
|
if ( rEntry.m_bHasEnabled )
|
|
|
|
aAccess.enableControl( rEntry.m_nElementID, rEntry.m_bEnabled );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_pFilterList && !m_pFilterList->empty() )
|
|
|
|
{
|
|
|
|
for ( FilterList::iterator aListIter = m_pFilterList->begin();
|
|
|
|
aListIter != m_pFilterList->end();
|
|
|
|
++aListIter
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if ( aListIter->hasSubFilters() )
|
|
|
|
{ // it's a filter group
|
|
|
|
UnoFilterList aSubFilters;
|
|
|
|
aListIter->getSubFilters( aSubFilters );
|
|
|
|
|
|
|
|
getDialog()->AddFilterGroup( aListIter->getTitle(), aSubFilters );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// it's a single filter
|
|
|
|
getDialog()->AddFilter( aListIter->getTitle(), aListIter->getFilter() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// set the default filter
|
2011-12-25 19:31:22 -02:00
|
|
|
if ( !m_aCurrentFilter.isEmpty() )
|
2006-11-22 09:14:13 +00:00
|
|
|
getDialog()->SetCurFilter( m_aCurrentFilter );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2006-11-22 09:14:13 +00:00
|
|
|
IMPL_LINK( SvtFilePicker, DialogClosedHdl, Dialog*, pDlg )
|
|
|
|
{
|
|
|
|
if ( m_xDlgClosedListener.is() )
|
|
|
|
{
|
|
|
|
sal_Int16 nRet = static_cast< sal_Int16 >( pDlg->GetResult() );
|
|
|
|
::com::sun::star::ui::dialogs::DialogClosedEvent aEvent( *this, nRet );
|
|
|
|
m_xDlgClosedListener->dialogClosed( aEvent );
|
|
|
|
m_xDlgClosedListener.clear();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
// SvtFilePicker
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
WinBits SvtFilePicker::getWinBits( WinBits& rExtraBits )
|
|
|
|
{
|
|
|
|
// set the winbits for creating the filedialog
|
|
|
|
WinBits nBits = 0L;
|
|
|
|
rExtraBits = 0L;
|
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
// set the standard bits according to the service name
|
2005-04-13 07:49:02 +00:00
|
|
|
if ( m_nServiceType == TemplateDescription::FILEOPEN_SIMPLE )
|
|
|
|
{
|
|
|
|
nBits = WB_OPEN;
|
|
|
|
}
|
|
|
|
else if ( m_nServiceType == TemplateDescription::FILESAVE_SIMPLE )
|
|
|
|
{
|
|
|
|
nBits = WB_SAVEAS;
|
|
|
|
}
|
|
|
|
else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION )
|
|
|
|
{
|
|
|
|
nBits = WB_SAVEAS;
|
|
|
|
rExtraBits = SFX_EXTRA_AUTOEXTENSION;
|
|
|
|
}
|
|
|
|
else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD )
|
|
|
|
{
|
|
|
|
nBits = WB_SAVEAS | SFXWB_PASSWORD;
|
|
|
|
rExtraBits = SFX_EXTRA_AUTOEXTENSION;
|
|
|
|
}
|
|
|
|
else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS )
|
|
|
|
{
|
|
|
|
nBits = WB_SAVEAS | SFXWB_PASSWORD;
|
|
|
|
rExtraBits = SFX_EXTRA_AUTOEXTENSION | SFX_EXTRA_FILTEROPTIONS;
|
|
|
|
}
|
|
|
|
else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE )
|
|
|
|
{
|
|
|
|
nBits = WB_SAVEAS;
|
|
|
|
rExtraBits = SFX_EXTRA_AUTOEXTENSION | SFX_EXTRA_TEMPLATES;
|
|
|
|
}
|
|
|
|
else if ( m_nServiceType == TemplateDescription::FILESAVE_AUTOEXTENSION_SELECTION )
|
|
|
|
{
|
|
|
|
nBits = WB_SAVEAS;
|
|
|
|
rExtraBits = SFX_EXTRA_AUTOEXTENSION | SFX_EXTRA_SELECTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ( m_nServiceType == TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE )
|
|
|
|
{
|
|
|
|
nBits = WB_OPEN;
|
|
|
|
rExtraBits = SFX_EXTRA_INSERTASLINK | SFX_EXTRA_SHOWPREVIEW | SFX_EXTRA_IMAGE_TEMPLATE;
|
|
|
|
}
|
|
|
|
else if ( m_nServiceType == TemplateDescription::FILEOPEN_PLAY )
|
|
|
|
{
|
|
|
|
nBits = WB_OPEN;
|
|
|
|
rExtraBits = SFX_EXTRA_PLAYBUTTON;
|
|
|
|
}
|
|
|
|
else if ( m_nServiceType == TemplateDescription::FILEOPEN_READONLY_VERSION )
|
|
|
|
{
|
|
|
|
nBits = WB_OPEN | SFXWB_READONLY;
|
|
|
|
rExtraBits = SFX_EXTRA_SHOWVERSIONS;
|
|
|
|
}
|
|
|
|
else if ( m_nServiceType == TemplateDescription::FILEOPEN_LINK_PREVIEW )
|
|
|
|
{
|
|
|
|
nBits = WB_OPEN;
|
|
|
|
rExtraBits = SFX_EXTRA_INSERTASLINK | SFX_EXTRA_SHOWPREVIEW;
|
|
|
|
}
|
|
|
|
if ( m_bMultiSelection && ( ( nBits & WB_OPEN ) == WB_OPEN ) )
|
|
|
|
nBits |= SFXWB_MULTISELECTION;
|
|
|
|
|
|
|
|
return nBits;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
void SvtFilePicker::notify( sal_Int16 _nEventId, sal_Int16 _nControlId )
|
|
|
|
{
|
|
|
|
if ( !m_xListener.is() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
FilePickerEvent aEvent( *this, _nControlId );
|
|
|
|
|
|
|
|
switch ( _nEventId )
|
|
|
|
{
|
|
|
|
case FILE_SELECTION_CHANGED:
|
|
|
|
m_xListener->fileSelectionChanged( aEvent );
|
|
|
|
break;
|
|
|
|
case DIRECTORY_CHANGED:
|
|
|
|
m_xListener->directoryChanged( aEvent );
|
|
|
|
break;
|
|
|
|
case HELP_REQUESTED:
|
|
|
|
m_xListener->helpRequested( aEvent );
|
|
|
|
break;
|
|
|
|
case CTRL_STATE_CHANGED:
|
|
|
|
m_xListener->controlStateChanged( aEvent );
|
|
|
|
break;
|
|
|
|
case DIALOG_SIZE_CHANGED:
|
|
|
|
m_xListener->dialogSizeChanged();
|
|
|
|
break;
|
|
|
|
default:
|
2012-01-16 23:15:55 +01:00
|
|
|
SAL_WARN( "fpicker.office", "SvtFilePicker::notify(): Unknown event id!" );
|
2005-04-13 07:49:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
namespace {
|
2014-02-25 18:51:57 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
struct FilterTitleMatch : public ::std::unary_function< FilterEntry, bool >
|
|
|
|
{
|
|
|
|
protected:
|
2012-12-08 13:42:54 +02:00
|
|
|
const OUString& rTitle;
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
public:
|
2012-12-08 13:42:54 +02:00
|
|
|
FilterTitleMatch( const OUString& _rTitle ) : rTitle( _rTitle ) { }
|
2005-04-13 07:49:02 +00:00
|
|
|
|
2014-02-25 18:51:57 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
bool operator () ( const FilterEntry& _rEntry )
|
|
|
|
{
|
2014-04-22 12:40:46 +02:00
|
|
|
bool bMatch;
|
2005-04-13 07:49:02 +00:00
|
|
|
if ( !_rEntry.hasSubFilters() )
|
|
|
|
// a real filter
|
|
|
|
bMatch = ( _rEntry.getTitle() == rTitle );
|
|
|
|
else
|
|
|
|
// a filter group -> search the sub filters
|
|
|
|
bMatch =
|
|
|
|
_rEntry.endSubFilters() != ::std::find_if(
|
|
|
|
_rEntry.beginSubFilters(),
|
|
|
|
_rEntry.endSubFilters(),
|
|
|
|
*this
|
|
|
|
);
|
|
|
|
|
2014-05-02 15:42:25 +02:00
|
|
|
return bMatch;
|
2005-04-13 07:49:02 +00:00
|
|
|
}
|
|
|
|
bool operator () ( const UnoFilterEntry& _rEntry )
|
|
|
|
{
|
2014-05-02 15:42:25 +02:00
|
|
|
return _rEntry.First == rTitle;
|
2005-04-13 07:49:02 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-04-22 12:40:46 +02:00
|
|
|
bool SvtFilePicker::FilterNameExists( const OUString& rTitle )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
2014-04-22 12:40:46 +02:00
|
|
|
bool bRet = false;
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
if ( m_pFilterList )
|
|
|
|
bRet =
|
|
|
|
m_pFilterList->end() != ::std::find_if(
|
|
|
|
m_pFilterList->begin(),
|
|
|
|
m_pFilterList->end(),
|
|
|
|
FilterTitleMatch( rTitle )
|
|
|
|
);
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-04-22 12:40:46 +02:00
|
|
|
bool SvtFilePicker::FilterNameExists( const UnoFilterList& _rGroupedFilters )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
2014-04-22 12:40:46 +02:00
|
|
|
bool bRet = false;
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
if ( m_pFilterList )
|
|
|
|
{
|
|
|
|
const UnoFilterEntry* pStart = _rGroupedFilters.getConstArray();
|
|
|
|
const UnoFilterEntry* pEnd = pStart + _rGroupedFilters.getLength();
|
|
|
|
for ( ; pStart != pEnd; ++pStart )
|
|
|
|
if ( m_pFilterList->end() != ::std::find_if( m_pFilterList->begin(), m_pFilterList->end(), FilterTitleMatch( pStart->First ) ) )
|
|
|
|
break;
|
|
|
|
|
|
|
|
bRet = pStart != pEnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
void SvtFilePicker::ensureFilterList( const OUString& _rInitialCurrentFilter )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
if ( !m_pFilterList )
|
|
|
|
{
|
|
|
|
m_pFilterList = new FilterList;
|
|
|
|
|
|
|
|
// set the first filter to the current filter
|
2011-12-25 19:31:22 -02:00
|
|
|
if ( m_aCurrentFilter.isEmpty() )
|
2005-04-13 07:49:02 +00:00
|
|
|
m_aCurrentFilter = _rInitialCurrentFilter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
// class SvtFilePicker
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
SvtFilePicker::SvtFilePicker( const Reference < XMultiServiceFactory >& xFactory )
|
|
|
|
:OCommonPicker( xFactory )
|
|
|
|
,m_pFilterList ( NULL )
|
|
|
|
,m_pElemList ( NULL )
|
2014-04-22 12:40:46 +02:00
|
|
|
,m_bMultiSelection ( false )
|
2005-04-13 07:49:02 +00:00
|
|
|
,m_nServiceType ( TemplateDescription::FILEOPEN_SIMPLE )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SvtFilePicker::~SvtFilePicker()
|
|
|
|
{
|
|
|
|
if ( m_pFilterList && !m_pFilterList->empty() )
|
|
|
|
m_pFilterList->erase( m_pFilterList->begin(), m_pFilterList->end() );
|
|
|
|
delete m_pFilterList;
|
|
|
|
|
|
|
|
if ( m_pElemList && !m_pElemList->empty() )
|
|
|
|
m_pElemList->erase( m_pElemList->begin(), m_pElemList->end() );
|
|
|
|
delete m_pElemList;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
sal_Int16 SvtFilePicker::implExecutePicker( )
|
|
|
|
{
|
|
|
|
getDialog()->SetFileCallback( this );
|
|
|
|
|
2006-11-22 09:14:13 +00:00
|
|
|
prepareExecute();
|
2005-04-13 07:49:02 +00:00
|
|
|
|
2014-04-22 12:40:46 +02:00
|
|
|
getDialog()->EnableAutocompletion( true );
|
2005-04-13 07:49:02 +00:00
|
|
|
// now we are ready to execute the dialog
|
|
|
|
sal_Int16 nRet = getDialog()->Execute();
|
|
|
|
|
2006-03-24 11:49:09 +00:00
|
|
|
// the execution of the dialog yields, so it is possible the at this point the window or the dialog is closed
|
|
|
|
if ( getDialog() )
|
|
|
|
getDialog()->SetFileCallback( NULL );
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
SvtFileDialog* SvtFilePicker::implCreateDialog( Window* _pParent )
|
|
|
|
{
|
|
|
|
WinBits nExtraBits;
|
|
|
|
WinBits nBits = getWinBits( nExtraBits );
|
|
|
|
|
2008-03-18 16:30:23 +00:00
|
|
|
SvtFileDialog* dialog = new SvtFileDialog( _pParent, nBits, nExtraBits );
|
|
|
|
|
|
|
|
// Set StandardDir if present
|
2011-12-25 19:31:22 -02:00
|
|
|
if ( !m_aStandardDir.isEmpty())
|
2008-03-18 16:30:23 +00:00
|
|
|
{
|
2013-09-20 16:47:36 +02:00
|
|
|
OUString sStandardDir = m_aStandardDir;
|
2008-03-18 16:30:23 +00:00
|
|
|
dialog->SetStandardDir( sStandardDir );
|
2009-03-03 10:51:13 +00:00
|
|
|
dialog->SetBlackList( m_aBlackList );
|
2008-03-18 16:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return dialog;
|
2005-04-13 07:49:02 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
// disambiguate XInterface
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
IMPLEMENT_FORWARD_XINTERFACE2( SvtFilePicker, OCommonPicker, SvtFilePicker_Base )
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
// disambiguate XTypeProvider
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvtFilePicker, OCommonPicker, SvtFilePicker_Base )
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
// XExecutableDialog functions
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void SAL_CALL SvtFilePicker::setTitle( const OUString& _rTitle ) throw (RuntimeException, std::exception)
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
OCommonPicker::setTitle( _rTitle );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int16 SAL_CALL SvtFilePicker::execute( ) throw (RuntimeException, std::exception)
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
return OCommonPicker::execute();
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2006-11-22 09:14:13 +00:00
|
|
|
// XAsynchronousExecutableDialog functions
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void SAL_CALL SvtFilePicker::setDialogTitle( const OUString& _rTitle ) throw (RuntimeException, std::exception)
|
2006-11-22 09:14:13 +00:00
|
|
|
{
|
|
|
|
setTitle( _rTitle );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-13 13:13:31 +00:00
|
|
|
void SAL_CALL SvtFilePicker::startExecuteModal( const Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener >& xListener )
|
|
|
|
throw (RuntimeException,
|
|
|
|
std::exception)
|
2006-11-22 09:14:13 +00:00
|
|
|
{
|
|
|
|
m_xDlgClosedListener = xListener;
|
|
|
|
prepareDialog();
|
|
|
|
prepareExecute();
|
2014-04-22 12:40:46 +02:00
|
|
|
getDialog()->EnableAutocompletion( true );
|
2006-11-22 09:14:13 +00:00
|
|
|
getDialog()->StartExecuteModal( LINK( this, SvtFilePicker, DialogClosedHdl ) );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
// XFilePicker functions
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void SAL_CALL SvtFilePicker::setMultiSelectionMode( sal_Bool bMode ) throw( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
m_bMultiSelection = bMode;
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void SAL_CALL SvtFilePicker::setDefaultName( const OUString& aName ) throw( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
m_aDefaultName = aName;
|
|
|
|
}
|
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
void SAL_CALL SvtFilePicker::setDisplayDirectory( const OUString& aDirectory )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw( IllegalArgumentException, RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
m_aDisplayDirectory = aDirectory;
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString SAL_CALL SvtFilePicker::getDisplayDirectory() throw( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
if ( getDialog() )
|
|
|
|
{
|
2012-12-08 13:42:54 +02:00
|
|
|
OUString aPath = getDialog()->GetPath();
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
// #97148# ----
|
|
|
|
if( m_aOldHideDirectory == aPath )
|
|
|
|
return m_aOldDisplayDirectory;
|
|
|
|
m_aOldHideDirectory = aPath;
|
|
|
|
|
|
|
|
// #102204# -----
|
|
|
|
if( !getDialog()->ContentIsFolder( aPath ) )
|
|
|
|
{
|
|
|
|
INetURLObject aFolder( aPath );
|
|
|
|
aFolder.CutLastName();
|
|
|
|
aPath = aFolder.GetMainURL( INetURLObject::NO_DECODE );
|
|
|
|
}
|
|
|
|
m_aOldDisplayDirectory = aPath;
|
|
|
|
return aPath;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return m_aDisplayDirectory;
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
Sequence< OUString > SAL_CALL SvtFilePicker::getFiles() throw( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
if ( ! getDialog() )
|
|
|
|
{
|
2012-12-08 13:42:54 +02:00
|
|
|
Sequence< OUString > aEmpty;
|
2005-04-13 07:49:02 +00:00
|
|
|
return aEmpty;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if there is more than one path we have to return the path to the
|
|
|
|
// files first and then the list of the selected entries
|
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
std::vector<OUString> aPathList(getDialog()->GetPathList());
|
2012-01-11 21:27:38 -05:00
|
|
|
size_t nCount = aPathList.size();
|
|
|
|
size_t nTotal = nCount > 1 ? nCount+1: nCount;
|
2005-04-13 07:49:02 +00:00
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
Sequence< OUString > aPath( nTotal );
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
if ( nCount == 1 )
|
2013-11-15 11:05:19 +02:00
|
|
|
aPath[0] = aPathList[0];
|
2005-04-13 07:49:02 +00:00
|
|
|
else if ( nCount > 1 )
|
|
|
|
{
|
2012-01-11 21:27:38 -05:00
|
|
|
INetURLObject aObj(aPathList[0]);
|
2005-04-13 07:49:02 +00:00
|
|
|
aObj.removeSegment();
|
|
|
|
aPath[0] = aObj.GetMainURL( INetURLObject::NO_DECODE );
|
|
|
|
|
2012-01-11 21:27:38 -05:00
|
|
|
for(size_t i = 0; i < aPathList.size(); ++i)
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
2012-01-11 21:27:38 -05:00
|
|
|
aObj.SetURL(aPathList[i]);
|
2012-08-24 16:25:02 +04:00
|
|
|
aPath[i + 1] = aObj.getName();
|
2005-04-13 07:49:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aPath;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
// XFilePickerControlAccess functions
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
void SAL_CALL SvtFilePicker::setValue( sal_Int16 nElementID,
|
|
|
|
sal_Int16 nControlAction,
|
|
|
|
const Any& rValue )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
if ( getDialog() )
|
|
|
|
{
|
|
|
|
::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() );
|
|
|
|
aAccess.setValue( nElementID, nControlAction, rValue );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( !m_pElemList )
|
|
|
|
m_pElemList = new ElementList;
|
|
|
|
|
2014-04-22 12:40:46 +02:00
|
|
|
bool bFound = false;
|
2005-04-13 07:49:02 +00:00
|
|
|
ElementList::iterator aListIter;
|
|
|
|
|
|
|
|
for ( aListIter = m_pElemList->begin();
|
|
|
|
aListIter != m_pElemList->end(); ++aListIter )
|
|
|
|
{
|
|
|
|
ElementEntry_Impl& rEntry = *aListIter;
|
|
|
|
if ( ( rEntry.m_nElementID == nElementID ) &&
|
|
|
|
( !rEntry.m_bHasValue || ( rEntry.m_nControlAction == nControlAction ) ) )
|
|
|
|
{
|
|
|
|
rEntry.setAction( nControlAction );
|
|
|
|
rEntry.setValue( rValue );
|
2014-04-22 12:40:46 +02:00
|
|
|
bFound = true;
|
2005-04-13 07:49:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bFound )
|
|
|
|
{
|
|
|
|
ElementEntry_Impl aNew( nElementID );
|
|
|
|
aNew.setAction( nControlAction );
|
|
|
|
aNew.setValue( rValue );
|
|
|
|
m_pElemList->insert( m_pElemList->end(), aNew );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
Any SAL_CALL SvtFilePicker::getValue( sal_Int16 nElementID, sal_Int16 nControlAction )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
Any aAny;
|
|
|
|
|
|
|
|
// execute() called?
|
|
|
|
if ( getDialog() )
|
|
|
|
{
|
|
|
|
::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() );
|
|
|
|
aAny = aAccess.getValue( nElementID, nControlAction );
|
|
|
|
}
|
|
|
|
else if ( m_pElemList && !m_pElemList->empty() )
|
|
|
|
{
|
|
|
|
ElementList::iterator aListIter;
|
|
|
|
for ( aListIter = m_pElemList->begin();
|
|
|
|
aListIter != m_pElemList->end(); ++aListIter )
|
|
|
|
{
|
|
|
|
ElementEntry_Impl& rEntry = *aListIter;
|
|
|
|
if ( ( rEntry.m_nElementID == nElementID ) &&
|
|
|
|
( rEntry.m_bHasValue ) &&
|
|
|
|
( rEntry.m_nControlAction == nControlAction ) )
|
|
|
|
{
|
|
|
|
aAny = rEntry.m_aValue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aAny;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
void SAL_CALL SvtFilePicker::setLabel( sal_Int16 nLabelID, const OUString& rValue )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw ( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
if ( getDialog() )
|
|
|
|
{
|
|
|
|
::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() );
|
|
|
|
aAccess.setLabel( nLabelID, rValue );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( !m_pElemList )
|
|
|
|
m_pElemList = new ElementList;
|
|
|
|
|
2014-04-22 12:40:46 +02:00
|
|
|
bool bFound = false;
|
2005-04-13 07:49:02 +00:00
|
|
|
ElementList::iterator aListIter;
|
|
|
|
|
|
|
|
for ( aListIter = m_pElemList->begin();
|
|
|
|
aListIter != m_pElemList->end(); ++aListIter )
|
|
|
|
{
|
|
|
|
ElementEntry_Impl& rEntry = *aListIter;
|
|
|
|
if ( rEntry.m_nElementID == nLabelID )
|
|
|
|
{
|
|
|
|
rEntry.setLabel( rValue );
|
2014-04-22 12:40:46 +02:00
|
|
|
bFound = true;
|
2005-04-13 07:49:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bFound )
|
|
|
|
{
|
|
|
|
ElementEntry_Impl aNew( nLabelID );
|
|
|
|
aNew.setLabel( rValue );
|
|
|
|
m_pElemList->insert( m_pElemList->end(), aNew );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
OUString SAL_CALL SvtFilePicker::getLabel( sal_Int16 nLabelID )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw ( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2012-12-08 13:42:54 +02:00
|
|
|
OUString aLabel;
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
if ( getDialog() )
|
|
|
|
{
|
|
|
|
::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() );
|
|
|
|
aLabel = aAccess.getLabel( nLabelID );
|
|
|
|
}
|
|
|
|
else if ( m_pElemList && !m_pElemList->empty() )
|
|
|
|
{
|
|
|
|
ElementList::iterator aListIter;
|
|
|
|
for ( aListIter = m_pElemList->begin();
|
|
|
|
aListIter != m_pElemList->end(); ++aListIter )
|
|
|
|
{
|
|
|
|
ElementEntry_Impl& rEntry = *aListIter;
|
|
|
|
if ( rEntry.m_nElementID == nLabelID )
|
|
|
|
{
|
|
|
|
if ( rEntry.m_bHasLabel )
|
|
|
|
aLabel = rEntry.m_aLabel;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aLabel;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
void SAL_CALL SvtFilePicker::enableControl( sal_Int16 nElementID, sal_Bool bEnable )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
if ( getDialog() )
|
|
|
|
{
|
|
|
|
::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() );
|
|
|
|
aAccess.enableControl( nElementID, bEnable );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( !m_pElemList )
|
|
|
|
m_pElemList = new ElementList;
|
|
|
|
|
2014-04-22 12:40:46 +02:00
|
|
|
bool bFound = false;
|
2005-04-13 07:49:02 +00:00
|
|
|
ElementList::iterator aListIter;
|
|
|
|
|
|
|
|
for ( aListIter = m_pElemList->begin();
|
|
|
|
aListIter != m_pElemList->end(); ++aListIter )
|
|
|
|
{
|
|
|
|
ElementEntry_Impl& rEntry = *aListIter;
|
|
|
|
if ( rEntry.m_nElementID == nElementID )
|
|
|
|
{
|
|
|
|
rEntry.setEnabled( bEnable );
|
2014-04-22 12:40:46 +02:00
|
|
|
bFound = true;
|
2005-04-13 07:49:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bFound )
|
|
|
|
{
|
|
|
|
ElementEntry_Impl aNew( nElementID );
|
|
|
|
aNew.setEnabled( bEnable );
|
|
|
|
m_pElemList->insert( m_pElemList->end(), aNew );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
// XFilePickerNotifier functions
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void SAL_CALL SvtFilePicker::addFilePickerListener( const Reference< XFilePickerListener >& xListener ) throw ( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
m_xListener = xListener;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void SAL_CALL SvtFilePicker::removeFilePickerListener( const Reference< XFilePickerListener >& ) throw ( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
m_xListener.clear();
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
// XFilePreview functions
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
Sequence< sal_Int16 > SAL_CALL SvtFilePicker::getSupportedImageFormats()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw ( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
Sequence< sal_Int16 > aFormats( 1 );
|
|
|
|
|
|
|
|
aFormats[0] = FilePreviewImageFormats::BITMAP;
|
|
|
|
|
|
|
|
return aFormats;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int32 SAL_CALL SvtFilePicker::getTargetColorDepth() throw ( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
sal_Int32 nDepth = 0;
|
|
|
|
|
|
|
|
if ( getDialog() )
|
|
|
|
nDepth = getDialog()->getTargetColorDepth();
|
|
|
|
|
|
|
|
return nDepth;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int32 SAL_CALL SvtFilePicker::getAvailableWidth() throw ( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
sal_Int32 nWidth = 0;
|
|
|
|
|
|
|
|
if ( getDialog() )
|
|
|
|
nWidth = getDialog()->getAvailableWidth();
|
|
|
|
|
|
|
|
return nWidth;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Int32 SAL_CALL SvtFilePicker::getAvailableHeight() throw ( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2013-11-23 23:21:52 +01:00
|
|
|
sal_Int32 nHeight = 0;
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
if ( getDialog() )
|
2013-11-23 23:21:52 +01:00
|
|
|
nHeight = getDialog()->getAvailableHeight();
|
2005-04-13 07:49:02 +00:00
|
|
|
|
2013-11-23 23:21:52 +01:00
|
|
|
return nHeight;
|
2005-04-13 07:49:02 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
void SAL_CALL SvtFilePicker::setImage( sal_Int16 aImageFormat, const Any& rImage )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw ( IllegalArgumentException, RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
if ( getDialog() )
|
|
|
|
getDialog()->setImage( aImageFormat, rImage );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
sal_Bool SAL_CALL SvtFilePicker::setShowState( sal_Bool bShowState )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw ( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2014-04-22 12:40:46 +02:00
|
|
|
bool bRet = false;
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
if ( getDialog() )
|
|
|
|
bRet = getDialog()->setShowState( bShowState );
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool SAL_CALL SvtFilePicker::getShowState() throw ( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2014-04-22 12:40:46 +02:00
|
|
|
bool bRet = false;
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
if ( getDialog() )
|
|
|
|
bRet = getDialog()->getShowState();
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
// XFilterGroupManager functions
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
void SAL_CALL SvtFilePicker::appendFilterGroup( const OUString& sGroupTitle,
|
2005-04-13 07:49:02 +00:00
|
|
|
const Sequence< StringPair >& aFilters )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw ( IllegalArgumentException, RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
// check the names
|
|
|
|
if ( FilterNameExists( aFilters ) )
|
2009-05-22 16:22:30 +02:00
|
|
|
throw IllegalArgumentException(
|
2014-05-28 12:50:02 +02:00
|
|
|
"filter name exists",
|
2009-05-22 16:22:30 +02:00
|
|
|
static_cast< OWeakObject * >(this), 1);
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
// ensure that we have a filter list
|
2012-12-08 13:42:54 +02:00
|
|
|
OUString sInitialCurrentFilter;
|
2005-04-13 07:49:02 +00:00
|
|
|
if ( aFilters.getLength() )
|
|
|
|
sInitialCurrentFilter = aFilters[0].First;
|
|
|
|
ensureFilterList( sInitialCurrentFilter );
|
|
|
|
|
|
|
|
// append the filter
|
|
|
|
m_pFilterList->insert( m_pFilterList->end(), FilterEntry( sGroupTitle, aFilters ) );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
// XFilterManager functions
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
void SAL_CALL SvtFilePicker::appendFilter( const OUString& aTitle,
|
|
|
|
const OUString& aFilter )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw( IllegalArgumentException, RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
// check the name
|
|
|
|
if ( FilterNameExists( aTitle ) )
|
|
|
|
// TODO: a more precise exception message
|
|
|
|
throw IllegalArgumentException();
|
|
|
|
|
|
|
|
// ensure that we have a filter list
|
|
|
|
ensureFilterList( aTitle );
|
|
|
|
|
|
|
|
// append the filter
|
|
|
|
m_pFilterList->insert( m_pFilterList->end(), FilterEntry( aTitle, aFilter ) );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
void SAL_CALL SvtFilePicker::setCurrentFilter( const OUString& aTitle )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw( IllegalArgumentException, RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2005-04-13 07:49:02 +00:00
|
|
|
if ( ! FilterNameExists( aTitle ) )
|
|
|
|
throw IllegalArgumentException();
|
|
|
|
|
|
|
|
m_aCurrentFilter = aTitle;
|
|
|
|
|
|
|
|
if ( getDialog() )
|
|
|
|
getDialog()->SetCurFilter( aTitle );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2012-12-08 13:42:54 +02:00
|
|
|
OUString SAL_CALL SvtFilePicker::getCurrentFilter()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2010-10-13 02:47:36 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2012-12-08 13:42:54 +02:00
|
|
|
OUString aFilter = getDialog() ? OUString( getDialog()->GetCurFilter() ) :
|
|
|
|
OUString( m_aCurrentFilter );
|
2005-04-13 07:49:02 +00:00
|
|
|
return aFilter;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
// XInitialization functions
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
void SAL_CALL SvtFilePicker::initialize( const Sequence< Any >& _rArguments )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw ( Exception, RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
checkAlive();
|
|
|
|
|
2009-02-11 14:19:26 +00:00
|
|
|
Sequence< Any > aArguments( _rArguments.getLength());
|
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
m_nServiceType = TemplateDescription::FILEOPEN_SIMPLE;
|
|
|
|
|
2008-03-18 16:30:23 +00:00
|
|
|
if ( _rArguments.getLength() >= 1 )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
// compatibility: one argument, type sal_Int16 , specifies the service type
|
2009-02-11 14:19:26 +00:00
|
|
|
int index = 0;
|
2008-03-18 16:30:23 +00:00
|
|
|
|
2009-02-11 14:19:26 +00:00
|
|
|
if (_rArguments[0] >>= m_nServiceType)
|
|
|
|
{
|
|
|
|
// skip the first entry if it was the ServiceType, because it's not needed in OCommonPicker::initialize and it's not a NamedValue
|
|
|
|
NamedValue emptyNamedValue;
|
|
|
|
aArguments[0] <<= emptyNamedValue;
|
|
|
|
index = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
for ( int i = index; i < _rArguments.getLength(); i++)
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
2008-03-18 16:30:23 +00:00
|
|
|
NamedValue namedValue;
|
2009-02-11 14:19:26 +00:00
|
|
|
aArguments[i] <<= _rArguments[i];
|
2008-03-18 16:30:23 +00:00
|
|
|
|
2009-02-11 14:19:26 +00:00
|
|
|
if (aArguments[i] >>= namedValue )
|
2008-03-18 16:30:23 +00:00
|
|
|
{
|
2009-02-11 14:19:26 +00:00
|
|
|
|
2012-04-06 14:09:04 +02:00
|
|
|
if ( namedValue.Name == "StandardDir" )
|
2008-03-18 16:30:23 +00:00
|
|
|
{
|
2012-12-08 13:42:54 +02:00
|
|
|
OUString sStandardDir;
|
2008-03-18 16:30:23 +00:00
|
|
|
|
|
|
|
namedValue.Value >>= sStandardDir;
|
|
|
|
|
|
|
|
// Set the directory for the "back to the default dir" button
|
2011-12-25 19:31:22 -02:00
|
|
|
if ( !sStandardDir.isEmpty() )
|
2008-03-18 16:30:23 +00:00
|
|
|
{
|
|
|
|
m_aStandardDir = sStandardDir;
|
|
|
|
}
|
|
|
|
}
|
2012-04-06 14:09:04 +02:00
|
|
|
else if ( namedValue.Name == "BlackList" )
|
2009-03-03 10:51:13 +00:00
|
|
|
{
|
|
|
|
namedValue.Value >>= m_aBlackList;
|
|
|
|
}
|
2008-03-18 16:30:23 +00:00
|
|
|
}
|
2005-04-13 07:49:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// let the base class analyze the sequence (will call into implHandleInitializationArgument)
|
2009-02-11 14:19:26 +00:00
|
|
|
OCommonPicker::initialize( aArguments );
|
2005-04-13 07:49:02 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-06-05 08:16:59 +02:00
|
|
|
bool SvtFilePicker::implHandleInitializationArgument( const OUString& _rName, const Any& _rValue )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
2012-04-06 14:28:18 +02:00
|
|
|
if ( _rName == "TemplateDescription" )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
m_nServiceType = TemplateDescription::FILEOPEN_SIMPLE;
|
|
|
|
OSL_VERIFY( _rValue >>= m_nServiceType );
|
2014-04-22 12:40:46 +02:00
|
|
|
return true;
|
2005-04-13 07:49:02 +00:00
|
|
|
}
|
2012-04-06 14:28:18 +02:00
|
|
|
if ( _rName == "StandardDir" )
|
2008-06-04 08:42:24 +00:00
|
|
|
{
|
|
|
|
OSL_VERIFY( _rValue >>= m_aStandardDir );
|
2014-04-22 12:40:46 +02:00
|
|
|
return true;
|
2008-06-04 08:42:24 +00:00
|
|
|
}
|
|
|
|
|
2012-04-06 14:28:18 +02:00
|
|
|
if ( _rName == "BlackList" )
|
2009-03-03 10:51:13 +00:00
|
|
|
{
|
|
|
|
OSL_VERIFY( _rValue >>= m_aBlackList );
|
2014-04-22 12:40:46 +02:00
|
|
|
return true;
|
2009-03-03 10:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-04 08:42:24 +00:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
return OCommonPicker::implHandleInitializationArgument( _rName, _rValue );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
// XServiceInfo
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-04-13 07:49:02 +00:00
|
|
|
|
|
|
|
/* XServiceInfo */
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString SAL_CALL SvtFilePicker::getImplementationName() throw( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
return impl_getStaticImplementationName();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XServiceInfo */
|
2014-02-25 21:31:58 +01:00
|
|
|
sal_Bool SAL_CALL SvtFilePicker::supportsService( const OUString& sServiceName ) throw( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
2013-09-25 15:41:29 -03:00
|
|
|
return cppu::supportsService(this, sServiceName);
|
2005-04-13 07:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* XServiceInfo */
|
2014-02-25 21:31:58 +01:00
|
|
|
Sequence< OUString > SAL_CALL SvtFilePicker::getSupportedServiceNames() throw( RuntimeException, std::exception )
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
|
|
|
return impl_getStaticSupportedServiceNames();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper for XServiceInfo */
|
2012-12-08 13:42:54 +02:00
|
|
|
Sequence< OUString > SvtFilePicker::impl_getStaticSupportedServiceNames()
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
2012-12-08 13:42:54 +02:00
|
|
|
Sequence< OUString > seqServiceNames( 1 );
|
|
|
|
OUString* pArray = seqServiceNames.getArray();
|
2013-11-15 11:05:19 +02:00
|
|
|
pArray[0] = "com.sun.star.ui.dialogs.OfficeFilePicker";
|
2005-04-13 07:49:02 +00:00
|
|
|
return seqServiceNames ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper for XServiceInfo */
|
2012-12-08 13:42:54 +02:00
|
|
|
OUString SvtFilePicker::impl_getStaticImplementationName()
|
2005-04-13 07:49:02 +00:00
|
|
|
{
|
2012-12-08 13:42:54 +02:00
|
|
|
return OUString( "com.sun.star.svtools.OfficeFilePicker" );
|
2005-04-13 07:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper for registry */
|
|
|
|
Reference< XInterface > SAL_CALL SvtFilePicker::impl_createInstance(
|
|
|
|
const Reference< XComponentContext >& rxContext) throw( Exception )
|
|
|
|
{
|
|
|
|
Reference< XMultiServiceFactory > xServiceManager (rxContext->getServiceManager(), UNO_QUERY_THROW);
|
|
|
|
return Reference< XInterface >( *new SvtFilePicker( xServiceManager ) );
|
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|