summaryrefslogtreecommitdiff
path: root/sc/source/filter/ftools/fapihelper.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/filter/ftools/fapihelper.cxx')
-rw-r--r--sc/source/filter/ftools/fapihelper.cxx34
1 files changed, 23 insertions, 11 deletions
diff --git a/sc/source/filter/ftools/fapihelper.cxx b/sc/source/filter/ftools/fapihelper.cxx
index eeef52aed550..185923b28277 100644
--- a/sc/source/filter/ftools/fapihelper.cxx
+++ b/sc/source/filter/ftools/fapihelper.cxx
@@ -38,6 +38,8 @@
#include <tools/urlobj.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/docfile.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/frame.hxx>
#include <sfx2/sfxsids.hrc>
#include <svl/stritem.hxx>
#include <svl/itemset.hxx>
@@ -59,6 +61,8 @@ using ::com::sun::star::lang::XServiceName;
using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::task::PasswordRequestMode_PASSWORD_ENTER;
+using namespace ::com::sun::star;
+
// Static helper functions ====================================================
OUString ScfApiHelper::GetServiceName( Reference< XInterface > xInt )
@@ -136,25 +140,33 @@ Reference< XInterface > ScfApiHelper::CreateInstanceWithArgs(
return CreateInstanceWithArgs( ::comphelper::getProcessServiceFactory(), rServiceName, rArgs );
}
-String ScfApiHelper::QueryPasswordForMedium( SfxMedium& rMedium,
+uno::Sequence< beans::NamedValue > ScfApiHelper::QueryEncryptionDataForMedium( SfxMedium& rMedium,
::comphelper::IDocPasswordVerifier& rVerifier, const ::std::vector< OUString >* pDefaultPasswords )
{
- OUString aMediaPassword;
- SfxItemSet* pItemSet = rMedium.GetItemSet();
- const SfxPoolItem *pPasswordItem;
- if( pItemSet && (SFX_ITEM_SET == pItemSet->GetItemState( SID_PASSWORD, TRUE, &pPasswordItem )) )
- aMediaPassword = static_cast< const SfxStringItem* >( pPasswordItem )->GetValue();
+ uno::Sequence< beans::NamedValue > aEncryptionData;
+ SFX_ITEMSET_ARG( rMedium.GetItemSet(), pEncryptionDataItem, SfxUnoAnyItem, SID_ENCRYPTIONDATA, sal_False);
+ if ( pEncryptionDataItem )
+ pEncryptionDataItem->GetValue() >>= aEncryptionData;
+
+ ::rtl::OUString aPassword;
+ SFX_ITEMSET_ARG( rMedium.GetItemSet(), pPasswordItem, SfxStringItem, SID_PASSWORD, sal_False);
+ if ( pPasswordItem )
+ aPassword = pPasswordItem->GetValue();
+
OUString aDocName = INetURLObject( rMedium.GetOrigURL() ).GetName( INetURLObject::DECODE_WITH_CHARSET );
bool bIsDefaultPassword = false;
- OUString aPassword = ::comphelper::DocPasswordHelper::requestAndVerifyDocPassword(
- rVerifier, aMediaPassword, rMedium.GetInteractionHandler(), aDocName,
+ aEncryptionData = ::comphelper::DocPasswordHelper::requestAndVerifyDocPassword(
+ rVerifier, aEncryptionData, aPassword, rMedium.GetInteractionHandler(), aDocName,
::comphelper::DocPasswordRequestType_MS, pDefaultPasswords, &bIsDefaultPassword );
- if( !bIsDefaultPassword && (aPassword.getLength() > 0) && pItemSet )
- pItemSet->Put( SfxStringItem( SID_PASSWORD, aPassword ) );
+ rMedium.GetItemSet()->ClearItem( SID_PASSWORD );
+ rMedium.GetItemSet()->ClearItem( SID_ENCRYPTIONDATA );
+
+ if( !bIsDefaultPassword && (aEncryptionData.getLength() > 0) )
+ rMedium.GetItemSet()->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) ) );
- return aPassword;
+ return aEncryptionData;
}
// Property sets ==============================================================