android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / ui / vba / vbarevision.cxx
blobf8b1c5978d5fed9246a3553c3cafb691339232df
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "vbarevision.hxx"
20 #include <sal/log.hxx>
21 #include <com/sun/star/document/XRedlinesSupplier.hpp>
22 #include <com/sun/star/container/XIndexAccess.hpp>
23 #include <com/sun/star/frame/XModel.hpp>
24 #include "wordvbahelper.hxx"
25 #include <docsh.hxx>
26 #include <doc.hxx>
27 #include <IDocumentRedlineAccess.hxx>
28 #include <utility>
30 using namespace ::ooo::vba;
31 using namespace ::com::sun::star;
33 SwVbaRevision::SwVbaRevision( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< frame::XModel > xModel, uno::Reference< beans::XPropertySet > xRedlineProps ) : SwVbaRevision_BASE( rParent, rContext ), mxModel(std::move( xModel )), mxRedlineProps(std::move( xRedlineProps ))
37 SwVbaRevision::~SwVbaRevision()
41 sal_Int32 SwVbaRevision::GetPosition()
43 sal_Int32 nPos = -1;
44 uno::Reference< document::XRedlinesSupplier > xRedlinesSupp( mxModel, uno::UNO_QUERY_THROW );
45 uno::Reference< container::XIndexAccess > xRedlines( xRedlinesSupp->getRedlines(), uno::UNO_QUERY_THROW );
46 sal_Int32 nCount = xRedlines->getCount();
47 for( sal_Int32 i = 0; i < nCount; i++ )
49 uno::Reference< beans::XPropertySet > xProps( xRedlines->getByIndex( i ), uno::UNO_QUERY_THROW );
50 if( xProps == mxRedlineProps )
52 nPos = i;
53 SAL_INFO("sw.ui", "the redline position is " << nPos);
54 break;
57 if( nPos == -1 )
58 throw uno::RuntimeException();
60 return nPos;
63 void SAL_CALL
64 SwVbaRevision::Accept()
66 SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc();
67 if( pDoc )
68 pDoc->getIDocumentRedlineAccess().AcceptRedline( GetPosition(), true );
71 void SAL_CALL
72 SwVbaRevision::Reject( )
74 SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc();
75 if( pDoc )
76 pDoc->getIDocumentRedlineAccess().RejectRedline( GetPosition(), true );
79 OUString
80 SwVbaRevision::getServiceImplName()
82 return "SwVbaRevision";
85 uno::Sequence< OUString >
86 SwVbaRevision::getServiceNames()
88 static uno::Sequence< OUString > const aServiceNames
90 "ooo.vba.word.Revision"
92 return aServiceNames;
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */