1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sc.hxx" 26 27 // ============================================================================ 28 #include "warnpassword.hxx" 29 #include <com/sun/star/task/XInteractionHandler.hpp> 30 #include <com/sun/star/task/XInteractionRequest.hpp> 31 #include <svl/itemset.hxx> 32 #include <sfx2/docfile.hxx> 33 #include <sfx2/sfxsids.hrc> 34 #include <ucbhelper/simpleinteractionrequest.hxx> 35 #include <com/sun/star/task/InteractionClassification.hpp> 36 #include <com/sun/star/ucb/InteractiveAppException.hpp> 37 #include <com/sun/star/ucb/XContent.hpp> 38 #include <svx/svxerr.hxx> 39 40 41 using ::rtl::OUString; 42 using ::com::sun::star::uno::makeAny; 43 using ::com::sun::star::uno::Any; 44 using ::com::sun::star::uno::Reference; 45 using ::com::sun::star::uno::Exception; 46 using ::com::sun::star::uno::XInterface; 47 using ::com::sun::star::task::InteractionClassification_QUERY; 48 using ::com::sun::star::task::XInteractionHandler; 49 using ::com::sun::star::task::XInteractionRequest; 50 using ::com::sun::star::ucb::InteractiveAppException; 51 WarningOnPassword(SfxMedium & rMedium)52bool ScWarnPassword::WarningOnPassword( SfxMedium& rMedium ) 53 { 54 bool bReturn = true; 55 Reference< XInteractionHandler > xHandler( rMedium.GetInteractionHandler()); 56 if( xHandler.is() ) 57 { 58 59 OUString empty; 60 Any xException( makeAny(InteractiveAppException(empty, 61 Reference <XInterface> (), 62 InteractionClassification_QUERY, 63 ERRCODE_SVX_EXPORT_FILTER_CRYPT))); 64 65 Reference< ucbhelper::SimpleInteractionRequest > xRequest 66 = new ucbhelper::SimpleInteractionRequest( 67 xException, 68 ucbhelper::CONTINUATION_APPROVE 69 | ucbhelper::CONTINUATION_DISAPPROVE ); 70 71 xHandler->handle( xRequest.get() ); 72 73 const sal_Int32 nResp = xRequest->getResponse(); 74 75 switch ( nResp ) 76 { 77 case ucbhelper::CONTINUATION_UNKNOWN: 78 break; 79 80 case ucbhelper::CONTINUATION_APPROVE: 81 // Continue 82 break; 83 84 case ucbhelper::CONTINUATION_DISAPPROVE: 85 bReturn = false; 86 break; 87 } 88 } 89 return bReturn; 90 } 91 92