diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-05-22 23:47:11 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-05-23 02:23:07 -0400 |
commit | e58eb031374fb18aa82654c01d0f0841a437c667 (patch) | |
tree | 50ed77ce50312f0fc0508fb00e772222a50726c3 /sfx2 | |
parent | 7e656661684669b6d34d3f813d53fad9d9ffd047 (diff) |
Add mechanism to pass doc service name to the descriptor when opening a file.
This info will be used during type detection for more clever filter
selection.
Change-Id: I66a52ff6f425e97884afd1c85831c11381fb695d
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/sfxsids.hrc | 1 | ||||
-rw-r--r-- | sfx2/source/appl/appopen.cxx | 11 | ||||
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 19 |
3 files changed, 30 insertions, 1 deletions
diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index fbd8995215d4..53fd3ee87b1c 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -160,6 +160,7 @@ #define SID_RELOAD (SID_SFX_START + 508) #define SID_PRINTDOCDIRECT (SID_SFX_START + 509) #define SID_PICKLIST (SID_SFX_START + 510) +#define SID_DOC_SERVICE (SID_SFX_START + 511) #define SID_ATTR_XWINDOW (SID_SFX_START + 777) #define SID_PLUGIN_MODE (SID_SFX_START + 827) #define SID_EXPORTDOC (SID_SFX_START + 829) diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index ae5a6968e3f4..33b5183b0e13 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -689,6 +689,11 @@ bool lcl_isFilterNativelySupported(const SfxFilter& rFilter) void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) { + rtl::OUString aDocService; + SFX_REQUEST_ARG(rReq, pDocSrvItem, SfxStringItem, SID_DOC_SERVICE, false); + if (pDocSrvItem) + aDocService = pDocSrvItem->GetValue(); + sal_uInt16 nSID = rReq.GetSlot(); SFX_REQUEST_ARG( rReq, pFileNameItem, SfxStringItem, SID_FILE_NAME, sal_False ); if ( pFileNameItem ) @@ -798,6 +803,12 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) ::framework::PreventDuplicateInteraction::InteractionInfo aRule (aInteraction, 1); pHandler->addInteractionRule(aRule); + if (!aDocService.isEmpty()) + { + rReq.RemoveItem(SID_DOC_SERVICE); + rReq.AppendItem(SfxStringItem(SID_DOC_SERVICE, aDocService)); + } + for(std::vector<rtl::OUString>::const_iterator i = pURLList.begin(); i != pURLList.end(); ++i) { rReq.RemoveItem( SID_FILE_NAME ); diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 8dfb849996cf..5d13416d47b4 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -185,6 +185,7 @@ static char const sModifyPasswordInfo[] = "ModifyPasswordInfo"; static char const sSuggestedSaveAsDir[] = "SuggestedSaveAsDir"; static char const sSuggestedSaveAsName[] = "SuggestedSaveAsName"; static char const sEncryptionData[] = "EncryptionData"; +static char const sDocumentService[] = "DocumentService"; void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot ) @@ -871,6 +872,13 @@ void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Seque if (bOK) rSet.Put( SfxStringItem( SID_SUGGESTEDSAVEASNAME, sVal ) ); } + else if (aName == sDocumentService) + { + rtl::OUString aVal; + bool bOK = ((rProp.Value >>= aVal) && !aVal.isEmpty()); + if (bOK) + rSet.Put(SfxStringItem(SID_DOC_SERVICE, aVal)); + } #ifdef DBG_UTIL else --nFoundArgs; @@ -1094,6 +1102,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta nAdditional++; if ( rSet.GetItemState( SID_SUGGESTEDSAVEASNAME ) == SFX_ITEM_SET ) nAdditional++; + if ( rSet.GetItemState( SID_DOC_SERVICE ) == SFX_ITEM_SET ) + nAdditional++; // consider additional arguments nProps += nAdditional; @@ -1229,7 +1239,9 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta continue; if ( nId == SID_NOAUTOSAVE ) continue; - if ( nId == SID_ENCRYPTIONDATA ) + if ( nId == SID_ENCRYPTIONDATA ) + continue; + if ( nId == SID_DOC_SERVICE ) continue; // used only internally @@ -1629,6 +1641,11 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sSuggestedSaveAsName)); pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) ); } + if ( rSet.GetItemState( SID_DOC_SERVICE, sal_False, &pItem ) == SFX_ITEM_SET ) + { + pValue[nActProp].Name = rtl::OUString(sDocumentService); + pValue[nActProp++].Value <<= rtl::OUString(static_cast<const SfxStringItem*>(pItem)->GetValue()); + } } } |