Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2008 by Sun Microsystems, Inc.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include "vbarevision.hxx"
29 : : #include <vbahelper/vbahelper.hxx>
30 : : #include <tools/diagnose_ex.h>
31 : : #include <com/sun/star/document/XRedlinesSupplier.hpp>
32 : : #include "wordvbahelper.hxx"
33 : : #include <docsh.hxx>
34 : : #include <doc.hxx>
35 : :
36 : : using namespace ::ooo::vba;
37 : : using namespace ::com::sun::star;
38 : :
39 : 0 : SwVbaRevision::SwVbaRevision( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& xRedlineProps ) throw ( uno::RuntimeException ) : SwVbaRevision_BASE( rParent, rContext ), mxModel( xModel ), mxRedlineProps( xRedlineProps )
40 : : {
41 : 0 : }
42 : :
43 : 0 : SwVbaRevision::~SwVbaRevision()
44 : : {
45 [ # # ]: 0 : }
46 : :
47 : 0 : sal_Int32 SwVbaRevision::GetPosition() throw (css::uno::RuntimeException)
48 : : {
49 : 0 : sal_Int32 nPos = -1;
50 [ # # ]: 0 : uno::Reference< document::XRedlinesSupplier > xRedlinesSupp( mxModel, uno::UNO_QUERY_THROW );
51 [ # # ][ # # ]: 0 : uno::Reference< container::XIndexAccess > xRedlines( xRedlinesSupp->getRedlines(), uno::UNO_QUERY_THROW );
[ # # ]
52 [ # # ][ # # ]: 0 : sal_Int32 nCount = xRedlines->getCount();
53 [ # # ]: 0 : for( sal_Int32 i = 0; i < nCount; i++ )
54 : : {
55 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( xRedlines->getByIndex( i ), uno::UNO_QUERY_THROW );
[ # # ]
56 [ # # ][ # # ]: 0 : if( xProps == mxRedlineProps )
57 : : {
58 : 0 : nPos = i;
59 : : OSL_TRACE(" SwVbaRevision::SwVbaRevision, the redline position is %d, ", nPos );
60 : : break;
61 : : }
62 [ # # ]: 0 : }
63 [ # # ]: 0 : if( nPos == -1 )
64 [ # # ]: 0 : throw uno::RuntimeException();
65 : :
66 : 0 : return nPos;
67 : : }
68 : :
69 : : void SAL_CALL
70 : 0 : SwVbaRevision::Accept() throw ( css::uno::RuntimeException )
71 : : {
72 : 0 : SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc();
73 [ # # ]: 0 : if( pDoc )
74 : 0 : pDoc->AcceptRedline( GetPosition(), sal_True );
75 : 0 : }
76 : :
77 : : void SAL_CALL
78 : 0 : SwVbaRevision::Reject( ) throw ( css::uno::RuntimeException )
79 : : {
80 : 0 : SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc();
81 [ # # ]: 0 : if( pDoc )
82 : 0 : pDoc->RejectRedline( GetPosition(), sal_True );
83 : 0 : }
84 : :
85 : : rtl::OUString
86 : 0 : SwVbaRevision::getServiceImplName()
87 : : {
88 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaRevision"));
89 : : }
90 : :
91 : : uno::Sequence< rtl::OUString >
92 : 0 : SwVbaRevision::getServiceNames()
93 : : {
94 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
95 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
96 : : {
97 : 0 : aServiceNames.realloc( 1 );
98 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Revision" ) );
99 : : }
100 : 0 : return aServiceNames;
101 : : }
102 : :
103 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|