merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / uno / warnpassword.cxx
blob01d27b636002e80cfd6f81d0db9d7538fe92ddaf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: warnpassword.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 + ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 // ============================================================================
34 #include "warnpassword.hxx"
35 #include <com/sun/star/task/XInteractionHandler.hpp>
36 #include <svtools/itemset.hxx>
37 #include <sfx2/docfile.hxx>
38 #include <sfx2/sfxsids.hrc>
39 #include <ucbhelper/simpleinteractionrequest.hxx>
40 #include <com/sun/star/ucb/InteractiveAppException.hpp>
41 #include <svx/svxerr.hxx>
43 using ::rtl::OUString;
45 using namespace ::com::sun::star;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::ucb;
48 using namespace ::com::sun::star::task;
50 bool SwWarnPassword::WarningOnPassword( SfxMedium& rMedium )
52 bool bReturn = true;
53 uno::Reference< task::XInteractionHandler > xHandler( rMedium.GetInteractionHandler());
54 if( xHandler.is() )
57 OUString empty;
58 uno::Any xException( makeAny(InteractiveAppException(empty,
59 uno::Reference <XInterface> (),
60 InteractionClassification_QUERY,
61 ERRCODE_SVX_EXPORT_FILTER_CRYPT)));
63 uno::Reference< ucbhelper::SimpleInteractionRequest > xRequest
64 = new ucbhelper::SimpleInteractionRequest(
65 xException,
66 ucbhelper::CONTINUATION_APPROVE
67 | ucbhelper::CONTINUATION_DISAPPROVE );
69 xHandler->handle( xRequest.get() );
71 const sal_Int32 nResp = xRequest->getResponse();
73 switch ( nResp )
75 case ucbhelper::CONTINUATION_UNKNOWN:
76 break;
78 case ucbhelper::CONTINUATION_APPROVE:
79 // Continue
80 break;
82 case ucbhelper::CONTINUATION_DISAPPROVE:
83 bReturn = false;
84 break;
87 return bReturn;