1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
27 #include <IDocumentRedlineAccess.hxx>
28 #include <unotxdoc.hxx>
29 #include <unoredlines.hxx>
32 using namespace ::ooo::vba
;
33 using namespace ::com::sun::star
;
35 SwVbaRevision::SwVbaRevision( const uno::Reference
< ooo::vba::XHelperInterface
>& rParent
,
36 const uno::Reference
< uno::XComponentContext
>& rContext
,
37 rtl::Reference
< SwXTextDocument
> xModel
,
38 uno::Reference
< beans::XPropertySet
> xRedlineProps
)
39 : SwVbaRevision_BASE( rParent
, rContext
),
40 mxModel(std::move( xModel
)),
41 mxRedlineProps(std::move( xRedlineProps
))
45 SwVbaRevision::~SwVbaRevision()
49 sal_Int32
SwVbaRevision::GetPosition()
52 rtl::Reference
< SwXRedlines
> xRedlines( mxModel
->getSwRedlines() );
53 sal_Int32 nCount
= xRedlines
->getCount();
54 for( sal_Int32 i
= 0; i
< nCount
; i
++ )
56 uno::Reference
< beans::XPropertySet
> xProps( xRedlines
->getByIndex( i
), uno::UNO_QUERY_THROW
);
57 if( xProps
== mxRedlineProps
)
60 SAL_INFO("sw.ui", "the redline position is " << nPos
);
65 throw uno::RuntimeException();
71 SwVbaRevision::Accept()
73 SwDoc
* pDoc
= mxModel
->GetDocShell()->GetDoc();
75 pDoc
->getIDocumentRedlineAccess().AcceptRedline( GetPosition(), true );
79 SwVbaRevision::Reject( )
81 SwDoc
* pDoc
= mxModel
->GetDocShell()->GetDoc();
83 pDoc
->getIDocumentRedlineAccess().RejectRedline( GetPosition(), true );
87 SwVbaRevision::getServiceImplName()
89 return u
"SwVbaRevision"_ustr
;
92 uno::Sequence
< OUString
>
93 SwVbaRevision::getServiceNames()
95 static uno::Sequence
< OUString
> const aServiceNames
97 u
"ooo.vba.word.Revision"_ustr
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */