From 595af138a9819ed4711369d561c16c042a14a762 Mon Sep 17 00:00:00 2001 From: Oliver Bolte Date: Tue, 3 Mar 2009 10:51:13 +0000 Subject: CWS-TOOLING: integrate CWS cmis01 2009-02-03 20:05:24 +0100 tkr r267341 : #i95301# fixed crash due wrong array length + resolve merge conflicts 2009-01-12 08:35:39 +0100 tkr r266134 : #158978# support unescaped whitespaces in webdav 2009-01-12 08:33:10 +0100 tkr r266133 : #i95307# build error after rebasing fixed 2009-01-07 09:47:09 +0100 tkr r265948 : #159046# Add new path to the wntmsci12 search path 2009-01-05 15:34:19 +0100 tkr r265873 : CWS-TOOLING: rebase CWS cmis01 to trunk@265758 (milestone: DEV300:m38) 2008-12-23 09:38:53 +0100 tkr r265774 : #158537# new property 2008-12-23 09:36:25 +0100 tkr r265773 : #158537# new property 2008-10-29 13:08:30 +0100 mav r262791 : #i94273# let the interaction handler be used for authentication 2008-10-24 15:56:26 +0200 tkr r262649 : #i95310# NTLM support 2008-10-22 18:14:02 +0200 mav r262611 : #i94273# fix the http scenario 2008-10-22 12:41:12 +0200 tkr r262596 : #i95310# NTLM support repaired (new neon version) 2008-10-22 12:38:47 +0200 tkr r262595 : #i95310# NTLM support repaired (new neon version) 2008-10-22 12:38:31 +0200 tkr r262594 : #i95310# NTLM support repaired (new neon version) 2008-10-22 12:29:43 +0200 tkr r262593 : #i95307# Add blacklist support 2008-10-22 12:29:24 +0200 tkr r262592 : #i95307# Add blacklist support 2008-10-22 12:29:07 +0200 tkr r262591 : #i95307# Add blacklist support 2008-10-22 12:28:44 +0200 tkr r262590 : #i95307# Add blacklist support 2008-10-22 12:25:01 +0200 tkr r262589 : #i95307# Add blacklist support 2008-10-22 12:24:28 +0200 tkr r262588 : #i95307# Add blacklist support 2008-10-22 12:22:36 +0200 tkr r262587 : #i95307# Add blacklist support 2008-10-21 12:46:34 +0200 mav r262568 : #i94273# allow to specify the suggested on IO SaveAs directory and filename 2008-10-21 12:44:49 +0200 mav r262566 : #i94273# allow to specify the suggested on IO SaveAs directory and filename --- sfx2/inc/sfx2/filedlghelper.hxx | 10 +- sfx2/inc/sfx2/sfxsids.hrc | 6 +- sfx2/sdi/sfx.sdi | 31 ++++- sfx2/source/appl/appopen.cxx | 30 ++++- sfx2/source/appl/appuno.cxx | 28 ++++- sfx2/source/dialog/filedlghelper.cxx | 53 ++++++-- sfx2/source/dialog/filedlgimpl.hxx | 3 +- sfx2/source/doc/guisaveas.cxx | 235 ++++++++++++++++++++++------------- sfx2/source/doc/objstor.cxx | 4 + 9 files changed, 292 insertions(+), 108 deletions(-) (limited to 'sfx2') diff --git a/sfx2/inc/sfx2/filedlghelper.hxx b/sfx2/inc/sfx2/filedlghelper.hxx index 4fffe0b96c21..c93af303158c 100644 --- a/sfx2/inc/sfx2/filedlghelper.hxx +++ b/sfx2/inc/sfx2/filedlghelper.hxx @@ -179,7 +179,8 @@ public: sal_Int16 nDialog, SfxFilterFlags nMust, SfxFilterFlags nDont, - const String& rStandardDir); + const String& rStandardDir, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList); FileDialogHelper( sal_Int64 nFlags, const String& rFactory, @@ -198,7 +199,8 @@ public: sal_Int16 nDialog, SfxFilterFlags nMust, SfxFilterFlags nDont, - const String& rStandardDir ); + const String& rStandardDir, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList); FileDialogHelper( sal_Int64 nFlags ); @@ -211,6 +213,7 @@ public: const ::rtl::OUString& aFilterUIName, const ::rtl::OUString& aExtName, const ::rtl::OUString& rStandardDir, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList, Window* _pPreferredParent = NULL ); @@ -330,7 +333,8 @@ ErrCode FileOpenDialog_Impl( sal_Int64 nFlags, SfxItemSet *& rpSet, const String* pPath = NULL, sal_Int16 nDialog = SFX2_IMPL_DIALOG_CONFIG, - const String& rStandardDir = String::CreateFromAscii( "" )); + const String& rStandardDir = String::CreateFromAscii( "" ), + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList = ::com::sun::star::uno::Sequence< ::rtl::OUString >()); //#endif } diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index 64c7028dc0b1..b41ea004f3e3 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -296,7 +296,8 @@ #define SID_GRAFIC_DIALOG (SID_SFX_START + 305) #define SID_PATH (SID_SFX_START + 308) #define SID_SAVEDOCS (SID_SFX_START + 309) -#define SID_STANDARD_DIR (SID_SFX_START + 310) +#define SID_STANDARD_DIR (SID_SFX_START + 450) +#define SID_BLACK_LIST (SID_SFX_START + 451) // browse-ids #define SID_BROWSE_FORWARD (SID_SFX_START + 1300) @@ -569,7 +570,8 @@ #define SID_OPTIONS_PAGEURL (SID_SFX_START + 1713) #define SID_MORE_DICTIONARIES (SID_SFX_START + 1714) #define SID_ACTIVATE_STYLE_APPLY (SID_SFX_START + 1715) -#define SID_SFX_free_START (SID_SFX_START + 1716) +#define SID_DEFAULTFILENAME (SID_SFX_START + 1716) +#define SID_SFX_free_START (SID_SFX_START + 1717) #define SID_SFX_free_END (SID_SFX_START + 3999) #define SID_OPEN_NEW_VIEW (SID_SFX_START + 520) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index bc74b1be3946..b8597d853ddd 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -1646,7 +1646,34 @@ SfxStringItem DefaultFilePath SID_DEFAULTFILEPATH RecordPerSet; Synchron; - Readonly = FALSE, + Readonly = TRUE, + + /* config: */ + AccelConfig = FALSE, + MenuConfig = FALSE, + StatusBarConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = ; +] + +//-------------------------------------------------------------------------- +SfxStringItem DefaultFileName SID_DEFAULTFILENAME + +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = TRUE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + Readonly = TRUE, /* config: */ AccelConfig = FALSE, @@ -4697,7 +4724,7 @@ SfxStringItem OldPALK SID_OLD_PALK //-------------------------------------------------------------------------- SfxObjectItem Open SID_OPENDOC -(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem OpenFlags SID_OPTIONS,SfxStringItem Password SID_PASSWORD,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxInt16Item Version SID_VERSION,SfxStringItem Referer SID_REFERER) +(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem OpenFlags SID_OPTIONS,SfxStringItem Password SID_PASSWORD,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxInt16Item Version SID_VERSION,SfxStringItem Referer SID_REFERER,SfxStringItem SuggestedSaveAsDir SID_DEFAULTFILEPATH,SfxStringItem SuggestedSaveAsName SID_DEFAULTFILENAME) [ /* flags: */ AutoUpdate = FALSE, diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 93da3dd5e48b..c73a40dd75a7 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -53,8 +53,11 @@ #include #include #include +#include #include #include +#include + #include #include @@ -93,6 +96,7 @@ #include #include #include +#include #include "objshimp.hxx" #include "openflag.hxx" #include @@ -535,6 +539,13 @@ SfxObjectShellLock SfxApplication::NewDoc_Impl( const String& rFact, const SfxIt { if ( pSet ) { + // TODO/LATER: Should the other arguments be transfered as well? + SFX_ITEMSET_ARG( pSet, pDefaultPathItem, SfxStringItem, SID_DEFAULTFILEPATH, FALSE); + if ( pDefaultPathItem ) + xDoc->GetMedium()->GetItemSet()->Put( *pDefaultPathItem ); + SFX_ITEMSET_ARG( pSet, pDefaultNameItem, SfxStringItem, SID_DEFAULTFILENAME, FALSE); + if ( pDefaultNameItem ) + xDoc->GetMedium()->GetItemSet()->Put( *pDefaultNameItem ); SFX_ITEMSET_ARG( pSet, pTitleItem, SfxStringItem, SID_DOCINFO_TITLE, FALSE ); if ( pTitleItem ) xDoc->GetMedium()->GetItemSet()->Put( *pTitleItem ); @@ -573,12 +584,22 @@ void SfxApplication::NewDocDirectExec_Impl( SfxRequest& rReq ) else aFactName = SvtModuleOptions().GetDefaultModuleName(); + SfxRequest aReq( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, GetPool() ); String aFact = String::CreateFromAscii("private:factory/"); aFact += aFactName; aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aFact ) ); aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, GetFrame() ) ); aReq.AppendItem( SfxStringItem( SID_TARGETNAME, String::CreateFromAscii( "_default" ) ) ); + + // TODO/LATER: Should the other arguments be transfered as well? + SFX_REQUEST_ARG( rReq, pDefaultPathItem, SfxStringItem, SID_DEFAULTFILEPATH, FALSE); + if ( pDefaultPathItem ) + aReq.AppendItem( *pDefaultPathItem ); + SFX_REQUEST_ARG( rReq, pDefaultNameItem, SfxStringItem, SID_DEFAULTFILENAME, FALSE); + if ( pDefaultNameItem ) + aReq.AppendItem( *pDefaultNameItem ); + SFX_APP()->ExecuteSlot( aReq ); const SfxViewFrameItem* pItem = PTR_CAST( SfxViewFrameItem, aReq.GetReturnValue() ); if ( pItem ) @@ -877,8 +898,15 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) if ( pStandardDirItem ) sStandardDir = pStandardDirItem->GetValue(); + ::com::sun::star::uno::Sequence< ::rtl::OUString > aBlackList; + + SFX_REQUEST_ARG( rReq, pBlackListItem, SfxStringListItem, SID_BLACK_LIST, FALSE ); + if ( pBlackListItem ) + pBlackListItem->GetStringList( aBlackList ); + + ULONG nErr = sfx2::FileOpenDialog_Impl( - WB_OPEN | SFXWB_MULTISELECTION | SFXWB_SHOWVERSIONS, String(), pURLList, aFilter, pSet, &aPath, nDialog, sStandardDir ); + WB_OPEN | SFXWB_MULTISELECTION | SFXWB_SHOWVERSIONS, String(), pURLList, aFilter, pSet, &aPath, nDialog, sStandardDir, aBlackList ); if ( nErr == ERRCODE_ABORT ) { diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index f455dd24a869..90b12b484a01 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -193,6 +194,7 @@ static const String sNoAutoSave = String::CreateFromAscii( "NoAutoSave" ); static const String sFolderName = String::CreateFromAscii( "FolderName" ); static const String sUseSystemDialog = String::CreateFromAscii( "UseSystemDialog" ); static const String sStandardDir = String::CreateFromAscii( "StandardDir" ); +static const String sBlackList = String::CreateFromAscii( "BlackList" ); void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot ) { @@ -683,10 +685,22 @@ void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Seque { ::rtl::OUString sVal; sal_Bool bOK = ((rProp.Value >>= sVal) && sVal.getLength()); - DBG_ASSERT( bOK, "invalid type or value for FileName" ); + DBG_ASSERT( bOK, "invalid type or value for StanadardDir" ); if (bOK) rSet.Put( SfxStringItem( SID_STANDARD_DIR, sVal ) ); } + else if ( aName == sBlackList ) + { + ::com::sun::star::uno::Sequence< ::rtl::OUString > xVal; + sal_Bool bOK = (rProp.Value >>= xVal); + DBG_ASSERT( bOK, "invalid type or value for BlackList" ); + if (bOK) + { + SfxStringListItem stringList(SID_BLACK_LIST); + stringList.SetStringList( xVal ); + rSet.Put( stringList ); + } + } else if ( aName == sFileName ) { ::rtl::OUString sVal; @@ -974,6 +988,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta nAdditional++; if ( rSet.GetItemState( SID_STANDARD_DIR ) == SFX_ITEM_SET ) nAdditional++; + if ( rSet.GetItemState( SID_BLACK_LIST ) == SFX_ITEM_SET ) + nAdditional++; if ( rSet.GetItemState( SID_CONTENT ) == SFX_ITEM_SET ) nAdditional++; if ( rSet.GetItemState( SID_INPUTSTREAM ) == SFX_ITEM_SET ) @@ -1157,6 +1173,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta continue; if ( nId == SID_STANDARD_DIR ) continue; + if ( nId == SID_BLACK_LIST ) + continue; if ( nId == SID_CONTENTTYPE ) continue; if ( nId == SID_WIN_POSSIZE ) @@ -1454,6 +1472,14 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta pValue[nActProp].Name = sStandardDir; pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) ); } + if ( rSet.GetItemState( SID_BLACK_LIST, sal_False, &pItem ) == SFX_ITEM_SET ) + { + pValue[nActProp].Name = sBlackList; + + com::sun::star::uno::Sequence< rtl::OUString > aList; + ((SfxStringListItem*)pItem)->GetStringList( aList ); + pValue[nActProp++].Value <<= aList ; + } if ( rSet.GetItemState( SID_TARGETNAME, sal_False, &pItem ) == SFX_ITEM_SET ) { pValue[nActProp].Name = sFrameName; diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 7e24fdca9639..de74d88ab631 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -88,6 +88,7 @@ #include #include #include +#include #include #include #include @@ -904,7 +905,15 @@ sal_Bool lcl_isSystemFilePicker( const uno::Reference< XFilePicker >& _rxFP ) // ----------- FileDialogHelper_Impl --------------------------- // ------------------------------------------------------------------------ -FileDialogHelper_Impl::FileDialogHelper_Impl( FileDialogHelper* _pAntiImpl, sal_Int16 nDialogType, sal_Int64 nFlags, sal_Int16 nDialog, Window* _pPreferredParentWindow, const String& sStandardDir ) +FileDialogHelper_Impl::FileDialogHelper_Impl( + FileDialogHelper* _pAntiImpl, + sal_Int16 nDialogType, + sal_Int64 nFlags, + sal_Int16 nDialog, + Window* _pPreferredParentWindow, + const String& sStandardDir, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList + ) :m_nDialogType ( nDialogType ) ,meContext ( FileDialogHelper::UNKNOWN_CONTEXT ) { @@ -1065,7 +1074,7 @@ FileDialogHelper_Impl::FileDialogHelper_Impl( FileDialogHelper* _pAntiImpl, sal_ //Sequence < Any > aInitArguments( mbSystemPicker || !mpPreferredParentWindow ? 1 : 3 ); - Sequence < Any > aInitArguments( !mpPreferredParentWindow ? 2 : 3 ); + Sequence < Any > aInitArguments( !mpPreferredParentWindow ? 3 : 4 ); // This is a hack. We currently know that the internal file picker implementation // supports the extended arguments as specified below. @@ -1089,8 +1098,15 @@ FileDialogHelper_Impl::FileDialogHelper_Impl( FileDialogHelper* _pAntiImpl, sal_ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StandardDir" ) ), makeAny( sStandardDirTemp ) ); + + aInitArguments[2] <<= NamedValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BlackList" ) ), + makeAny( rBlackList ) + ); + + if ( mpPreferredParentWindow ) - aInitArguments[2] <<= NamedValue( + aInitArguments[3] <<= NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ) ), makeAny( VCLUnoHelper::GetInterface( mpPreferredParentWindow ) ) ); @@ -2298,9 +2314,10 @@ FileDialogHelper::FileDialogHelper( sal_Int16 nDialog, SfxFilterFlags nMust, SfxFilterFlags nDont, - const String& rStandardDir) + const String& rStandardDir, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList) { - mpImp = new FileDialogHelper_Impl( this, getDialogType( nFlags ), nFlags, nDialog, NULL , rStandardDir ); + mpImp = new FileDialogHelper_Impl( this, getDialogType( nFlags ), nFlags, nDialog, NULL , rStandardDir, rBlackList ); mxImp = mpImp; // create the list of filters @@ -2353,9 +2370,10 @@ FileDialogHelper::FileDialogHelper( sal_Int16 nDialog, SfxFilterFlags nMust, SfxFilterFlags nDont, - const String& rStandardDir ) + const String& rStandardDir, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList) { - mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags, nDialog, NULL, rStandardDir ); + mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags, nDialog, NULL, rStandardDir, rBlackList ); mxImp = mpImp; // create the list of filters @@ -2379,9 +2397,10 @@ FileDialogHelper::FileDialogHelper( const ::rtl::OUString& aFilterUIName, const ::rtl::OUString& aExtName, const ::rtl::OUString& rStandardDir, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList, Window* _pPreferredParent ) { - mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, _pPreferredParent,rStandardDir ); + mpImp = new FileDialogHelper_Impl( this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, _pPreferredParent,rStandardDir, rBlackList ); mxImp = mpImp; // the wildcard here is expected in form "*.extension" @@ -2571,10 +2590,21 @@ ErrCode FileDialogHelper::GetGraphic( Graphic& rGraphic ) const // ------------------------------------------------------------------------ static int impl_isFolder( const OUString& rPath ) { + uno::Reference< task::XInteractionHandler > xHandler; + try + { + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); + xHandler.set( xFactory->createInstance( DEFINE_CONST_OUSTRING( "com.sun.star.task.InteractionHandler" ) ), + uno::UNO_QUERY_THROW ); + } + catch ( Exception const & ) + { + } + try { ::ucbhelper::Content aContent( - rPath, uno::Reference< ucb::XCommandEnvironment >() ); + rPath, new ::ucbhelper::CommandEnvironment( xHandler, uno::Reference< ucb::XProgressHandler >() ) ); if ( aContent.isFolder() ) return 1; @@ -2733,10 +2763,11 @@ ErrCode FileOpenDialog_Impl( sal_Int64 nFlags, SfxItemSet *& rpSet, const String* pPath, sal_Int16 nDialog, - const String& rStandardDir ) + const String& rStandardDir, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList ) { ErrCode nRet; - FileDialogHelper aDialog( nFlags, rFact, nDialog, 0, 0, rStandardDir ); + FileDialogHelper aDialog( nFlags, rFact, nDialog, 0, 0, rStandardDir, rBlackList ); String aPath; if ( pPath ) diff --git a/sfx2/source/dialog/filedlgimpl.hxx b/sfx2/source/dialog/filedlgimpl.hxx index e747f9427f36..848719547ab4 100644 --- a/sfx2/source/dialog/filedlgimpl.hxx +++ b/sfx2/source/dialog/filedlgimpl.hxx @@ -195,7 +195,8 @@ namespace sfx2 sal_Int64 nFlags, sal_Int16 nDialog = SFX2_IMPL_DIALOG_CONFIG, Window* _pPreferredParentWindow = NULL, - const String& sStandardDir = String::CreateFromAscii( "" ) + const String& sStandardDir = String::CreateFromAscii( "" ), + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList = ::com::sun::star::uno::Sequence< ::rtl::OUString >() ); virtual ~FileDialogHelper_Impl(); diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 9a19f3751f69..e606c3b48690 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -227,13 +228,21 @@ public: sal_Bool OutputFileDialog( sal_Int8 nStoreMode, const ::comphelper::SequenceAsHashMap& aPreselectedFilterPropsHM, sal_Bool bSetStandardName, - ::rtl::OUString& aUserSelectedName, + ::rtl::OUString& aSuggestedName, sal_Bool bPreselectPassword, - const ::rtl::OUString& rPath, + const ::rtl::OUString& aSuggestedDir, sal_Int16 nDialog, - const ::rtl::OUString& rStandardDir); + const ::rtl::OUString& rStandardDir, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList + ); sal_Bool ShowDocumentInfoDialog(); + + ::rtl::OUString GetReccomendedDir( const ::rtl::OUString& aSuggestedDir, + const sfx2::FileDialogHelper::Context& aCtxt ); + ::rtl::OUString GetReccomendedName( const ::rtl::OUString& aSuggestedName, + const ::rtl::OUString& aTypeName ); + }; //------------------------------------------------------------------------- @@ -719,11 +728,12 @@ sal_Bool ModelData_Impl::CheckFilterOptionsDialogExistence() sal_Bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode, const ::comphelper::SequenceAsHashMap& aPreselectedFilterPropsHM, sal_Bool bSetStandardName, - ::rtl::OUString& aUserSelectedName, + ::rtl::OUString& aSuggestedName, sal_Bool bPreselectPassword, - const ::rtl::OUString& rPath, + const ::rtl::OUString& aSuggestedDir, sal_Int16 nDialog, - const ::rtl::OUString& rStandardDir ) + const ::rtl::OUString& rStandardDir, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList) { sal_Bool bUseFilterOptions = sal_False; @@ -785,13 +795,13 @@ sal_Bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode, ::rtl::OUString::createFromAscii( "UIName" ), ::rtl::OUString() ); - pFileDlg = new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aFilterUIName, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "pdf" ) ), rStandardDir ); + pFileDlg = new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aFilterUIName, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "pdf" ) ), rStandardDir, rBlackList ); pFileDlg->SetCurrentFilter( aFilterUIName ); } else { // This is the normal dialog - pFileDlg = new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aDocServiceName, nDialog, nMust, nDont, rStandardDir ); + pFileDlg = new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aDocServiceName, nDialog, nMust, nDont, rStandardDir, rBlackList ); } if( aDocServiceName.equalsAscii( "com.sun.star.drawing.DrawingDocument" ) ) @@ -819,103 +829,52 @@ sal_Bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode, else { // This is the normal dialog - pFileDlg = new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aDocServiceName, nDialog, nMust, nDont, rStandardDir ); + pFileDlg = new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aDocServiceName, nDialog, nMust, nDont, rStandardDir, rBlackList ); pFileDlg->CreateMatcher( aDocServiceName ); } - // the last used name might be provided by aUserSelectedName from the old selection - ::rtl::OUString aLastName = aUserSelectedName; + ::rtl::OUString aAdjustToType; - if ( ( aLastName.getLength() || GetStorable()->hasLocation() ) - && !GetMediaDescr().getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "RepairPackage" ), - sal_False ) ) + // bSetStandardName == true means that user agreed to store document in the default (default default ;-)) format + if ( bSetStandardName || GetStorable()->hasLocation() ) { - // --> PB 2004-11-05 #i36524# - aLastName must be an URL, not only a filename - if ( !aLastName.getLength() ) - aLastName = GetStorable()->getLocation(); - // <-- - - if ( !aLastName.getLength() ) - { - aLastName = GetDocProps().getUnpackedValueOrDefault( - ::rtl::OUString::createFromAscii( "Title" ), - ::rtl::OUString() ); - INetURLObject aObj( INetURLObject::GetAbsURL( SvtPathOptions().GetWorkPath(), aLastName ) ); - aLastName = aObj.GetMainURL( INetURLObject::NO_DECODE ); - } - uno::Sequence< beans::PropertyValue > aOldFilterProps; - sal_Int32 nOldFiltFlags = 0; ::rtl::OUString aOldFilterName = GetDocProps().getUnpackedValueOrDefault( - aFilterNameString, - ::rtl::OUString() ); + aFilterNameString, + ::rtl::OUString() ); if ( aOldFilterName.getLength() ) m_pOwner->GetFilterConfiguration()->getByName( aOldFilterName ) >>= aOldFilterProps; ::comphelper::SequenceAsHashMap aOldFiltPropsHM( aOldFilterProps ); - nOldFiltFlags = aOldFiltPropsHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Flags" ), - (sal_Int32)0 ); + sal_Int32 nOldFiltFlags = aOldFiltPropsHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Flags" ), (sal_Int32)0 ); - // bSetStandardName == true means that user agreed to store document in the default (default default ;-)) format if ( bSetStandardName || ( nOldFiltFlags & nMust ) != nMust || nOldFiltFlags & nDont ) { - ::rtl::OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( - ::rtl::OUString::createFromAscii( "UIName" ), - ::rtl::OUString() ); - ::rtl::OUString aTypeName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( + // the suggested type will be changed, the extension should be adjusted + aAdjustToType = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Type" ), ::rtl::OUString() ); - if( aLastName.getLength() ) - { - INetURLObject aObj( aLastName ); - if ( aTypeName.getLength() ) - { - uno::Reference< container::XNameAccess > xTypeDetection = uno::Reference< container::XNameAccess >( - m_pOwner->GetServiceFactory()->createInstance( - ::rtl::OUString::createFromAscii( "com.sun.star.document.TypeDetection" ) ), - uno::UNO_QUERY ); - if ( xTypeDetection.is() ) - { - uno::Sequence< beans::PropertyValue > aTypeNameProps; - if ( ( xTypeDetection->getByName( aTypeName ) >>= aTypeNameProps ) && aTypeNameProps.getLength() ) - { - ::comphelper::SequenceAsHashMap aTypeNamePropsHM( aTypeNameProps ); - uno::Sequence< ::rtl::OUString > aExtensions = aTypeNamePropsHM.getUnpackedValueOrDefault( - ::rtl::OUString::createFromAscii( "Extension" ), - ::uno::Sequence< ::rtl::OUString >() ); - if ( aExtensions.getLength() ) - aObj.SetExtension( aExtensions[0] ); - } - } - } - - pFileDlg->SetDisplayDirectory( aObj.GetMainURL( INetURLObject::NO_DECODE ) ); - } - + ::rtl::OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( + ::rtl::OUString::createFromAscii( "UIName" ), + ::rtl::OUString() ); pFileDlg->SetCurrentFilter( aFilterUIName ); } else { - if( aLastName.getLength() ) - pFileDlg->SetDisplayDirectory( aLastName ); - pFileDlg->SetCurrentFilter( aOldFiltPropsHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "UIName" ), ::rtl::OUString() ) ); } } - else - { - // pb: set graphic path if context == SD_EXPORT or SI_EXPORT else work path - String sDirectory = eCtxt != sfx2::FileDialogHelper::UNKNOWN_CONTEXT - ? SvtPathOptions().GetGraphicPath() : SvtPathOptions().GetWorkPath(); - pFileDlg->SetDisplayDirectory( sDirectory ); - } - if ( rPath.getLength() ) - pFileDlg->SetDisplayDirectory( rPath ); + ::rtl::OUString aReccomendedDir = GetReccomendedDir( aSuggestedDir, eCtxt ); + if ( aReccomendedDir.getLength() ) + pFileDlg->SetDisplayDirectory( aReccomendedDir ); + ::rtl::OUString aReccomendedName = GetReccomendedName( aSuggestedName, aAdjustToType ); + if ( aReccomendedName.getLength() ) + pFileDlg->SetFileName( aReccomendedName ); uno::Reference < view::XSelectionSupplier > xSel( GetModel()->getCurrentController(), uno::UNO_QUERY ); if ( xSel.is() && xSel->getSelection().hasValue() ) @@ -962,7 +921,7 @@ sal_Bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode, // get the path from the dialog INetURLObject aURL( pFileDlg->GetPath() ); // the path should be provided outside since it might be used for further calls to the dialog - aUserSelectedName = aURL.GetMainURL( INetURLObject::NO_DECODE ); + aSuggestedName = aURL.GetMainURL( INetURLObject::NO_DECODE ); // old filter options should be cleared in case different filter is used @@ -1089,6 +1048,95 @@ sal_Bool ModelData_Impl::ShowDocumentInfoDialog() return bDialogUsed; } +//------------------------------------------------------------------------- +::rtl::OUString ModelData_Impl::GetReccomendedDir( const ::rtl::OUString& aSuggestedDir, const sfx2::FileDialogHelper::Context& aCtxt ) +{ + ::rtl::OUString aReccomendedDir; + + if ( ( aSuggestedDir.getLength() || GetStorable()->hasLocation() ) + && !GetMediaDescr().getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "RepairPackage" ), + sal_False ) ) + { + INetURLObject aLocation; + if ( aSuggestedDir.getLength() ) + aLocation = INetURLObject( aSuggestedDir ); + else + { + ::rtl::OUString aOldURL = GetStorable()->getLocation(); + if ( aOldURL.getLength() ) + { + INetURLObject aTmp( aOldURL ); + if ( aTmp.removeSegment() ) + aLocation = aTmp; + } + + if ( aLocation.HasError() ) + aLocation = INetURLObject( SvtPathOptions().GetWorkPath() ); + } + + aLocation.setFinalSlash(); + if ( !aLocation.HasError() ) + aReccomendedDir = aLocation.GetMainURL( INetURLObject::NO_DECODE ); + } + else + { + // pb: set graphic path if context == SD_EXPORT or SI_EXPORT else work path + aReccomendedDir = ( aCtxt != sfx2::FileDialogHelper::UNKNOWN_CONTEXT ) + ? SvtPathOptions().GetGraphicPath() : SvtPathOptions().GetWorkPath(); + } + + return aReccomendedDir; +} + +//------------------------------------------------------------------------- +::rtl::OUString ModelData_Impl::GetReccomendedName( const ::rtl::OUString& aSuggestedName, const ::rtl::OUString& aTypeName ) +{ + // the last used name might be provided by aSuggestedName from the old selection, or from the MediaDescriptor + ::rtl::OUString aReccomendedName; + + if ( aSuggestedName.getLength() ) + aReccomendedName = aSuggestedName; + else + { + aReccomendedName = INetURLObject( GetStorable()->getLocation() ).GetName(); + if ( !aReccomendedName.getLength() ) + { + try { + uno::Reference< frame::XTitle > xTitle( GetModel(), uno::UNO_QUERY_THROW ); + aReccomendedName = xTitle->getTitle(); + } catch( uno::Exception& ) {} + } + + if ( aReccomendedName.getLength() && aTypeName.getLength() ) + { + // adjust the extension to the type + uno::Reference< container::XNameAccess > xTypeDetection = uno::Reference< container::XNameAccess >( + m_pOwner->GetServiceFactory()->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.document.TypeDetection" ) ), + uno::UNO_QUERY ); + if ( xTypeDetection.is() ) + { + INetURLObject aObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "file:///c:/" ) ) + aReccomendedName ); + + uno::Sequence< beans::PropertyValue > aTypeNameProps; + if ( ( xTypeDetection->getByName( aTypeName ) >>= aTypeNameProps ) && aTypeNameProps.getLength() ) + { + ::comphelper::SequenceAsHashMap aTypeNamePropsHM( aTypeNameProps ); + uno::Sequence< ::rtl::OUString > aExtensions = aTypeNamePropsHM.getUnpackedValueOrDefault( + ::rtl::OUString::createFromAscii( "Extensions" ), + ::uno::Sequence< ::rtl::OUString >() ); + if ( aExtensions.getLength() ) + aObj.SetExtension( aExtensions[0] ); + } + + aReccomendedName = aObj.GetName(); + } + } + } + + return aReccomendedName; +} + + //========================================================================= // class SfxStoringHelper //========================================================================= @@ -1175,7 +1223,7 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& const ::rtl::OUString& aSlotName, uno::Sequence< beans::PropertyValue >& aArgsSequence, sal_Bool bPreselectPassword, - ::rtl::OUString aUserSelectedName ) + ::rtl::OUString aSuggestedName ) { ModelData_Impl aModelData( *this, xModel, aArgsSequence ); @@ -1297,7 +1345,6 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& if ( aFileNameIter == aModelData.GetMediaDescr().end() ) { sal_Int16 nDialog = SFX2_IMPL_DIALOG_CONFIG; - ::rtl::OUString aPath; ::comphelper::SequenceAsHashMap::const_iterator aDlgIter = aModelData.GetMediaDescr().find( ::rtl::OUString::createFromAscii( "UseSystemDialog" ) ); if ( aDlgIter != aModelData.GetMediaDescr().end() ) @@ -1310,10 +1357,18 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& nDialog = SFX2_IMPL_DIALOG_OOO; } - ::comphelper::SequenceAsHashMap::const_iterator aPathIter = - aModelData.GetMediaDescr().find( ::rtl::OUString::createFromAscii( "FolderName" ) ); - if ( aPathIter != aModelData.GetMediaDescr().end() ) - aPathIter->second >>= aPath; + // The Dispatch supports parameter FolderName that overwrites SuggestedSaveAsDir + ::rtl::OUString aSuggestedDir = aModelData.GetMediaDescr().getUnpackedValueOrDefault( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FolderName" ) ), ::rtl::OUString() ); + if ( !aSuggestedDir.getLength() ) + { + aSuggestedDir = aModelData.GetMediaDescr().getUnpackedValueOrDefault( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SuggestedSaveAsDir" ) ), ::rtl::OUString() ); + if ( !aSuggestedDir.getLength() ) + aSuggestedDir = aModelData.GetDocProps().getUnpackedValueOrDefault( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SuggestedSaveAsDir" ) ), ::rtl::OUString() ); + } + + aSuggestedName = aModelData.GetMediaDescr().getUnpackedValueOrDefault( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SuggestedSaveAsName" ) ), ::rtl::OUString() ); + if ( !aSuggestedName.getLength() ) + aSuggestedName = aModelData.GetDocProps().getUnpackedValueOrDefault( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SuggestedSaveAsName" ) ), ::rtl::OUString() ); ::rtl::OUString sStandardDir; ::comphelper::SequenceAsHashMap::const_iterator aStdDirIter = @@ -1321,13 +1376,20 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& if ( aStdDirIter != aModelData.GetMediaDescr().end() ) aStdDirIter->second >>= sStandardDir; + ::com::sun::star::uno::Sequence< ::rtl::OUString > aBlackList; + + ::comphelper::SequenceAsHashMap::const_iterator aBlackListIter = + aModelData.GetMediaDescr().find( ::rtl::OUString::createFromAscii( "BlackList" ) ); + if ( aBlackListIter != aModelData.GetMediaDescr().end() ) + aBlackListIter->second >>= aBlackList; + sal_Bool bExit = sal_False; while ( !bExit ) { - bUseFilterOptions = aModelData.OutputFileDialog( nStoreMode, aFilterProps, bSetStandardName, aUserSelectedName, bPreselectPassword, aPath, nDialog, sStandardDir ); + bUseFilterOptions = aModelData.OutputFileDialog( nStoreMode, aFilterProps, bSetStandardName, aSuggestedName, bPreselectPassword, aSuggestedDir, nDialog, sStandardDir, aBlackList ); // in case the dialog is opend a second time the folder should be the same as before, not what was handed over by parameters - aPath = ::rtl::OUString(); + aSuggestedDir = ::rtl::OUString(); if ( nStoreMode == SAVEAS_REQUESTED ) { // in case of saving check filter for possible alien warning @@ -1657,4 +1719,3 @@ Window* SfxStoringHelper::GetModelWindow( const uno::Reference< frame::XModel >& return pWin; } - diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 5ec198c302cf..4eb5c6f417fd 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -2678,6 +2678,8 @@ sal_Bool SfxObjectShell::CommonSaveAs_Impl SfxItemSet *pSet = GetMedium()->GetItemSet(); pSet->ClearItem( SID_INTERACTIONHANDLER ); pSet->ClearItem( SID_PROGRESS_STATUSBAR_CONTROL ); + pSet->ClearItem( SID_STANDARD_DIR ); + pSet->ClearItem( SID_PATH ); if ( !bSaveTo ) { @@ -2694,6 +2696,8 @@ sal_Bool SfxObjectShell::CommonSaveAs_Impl //pSet->ClearItem( SID_USE_FILTEROPTIONS ); pSet->ClearItem( SID_EDITDOC ); pSet->ClearItem( SID_OVERWRITE ); + pSet->ClearItem( SID_DEFAULTFILEPATH ); + pSet->ClearItem( SID_DEFAULTFILENAME ); SFX_ITEMSET_GET( (*aParams), pFilterItem, SfxStringItem, SID_FILTER_NAME, sal_False ); if ( pFilterItem ) -- cgit v1.2.3