LibreOffice Module sw (master)  1
vbarevision.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #include "vbarevision.hxx"
20 #include <vbahelper/vbahelper.hxx>
21 #include <sal/log.hxx>
22 #include <com/sun/star/document/XRedlinesSupplier.hpp>
23 #include <com/sun/star/container/XIndexAccess.hpp>
24 #include "wordvbahelper.hxx"
25 #include <docsh.hxx>
26 #include <doc.hxx>
28 
29 using namespace ::ooo::vba;
30 using namespace ::com::sun::star;
31 
32 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 ) : SwVbaRevision_BASE( rParent, rContext ), mxModel( xModel ), mxRedlineProps( xRedlineProps )
33 {
34 }
35 
37 {
38 }
39 
41 {
42  sal_Int32 nPos = -1;
43  uno::Reference< document::XRedlinesSupplier > xRedlinesSupp( mxModel, uno::UNO_QUERY_THROW );
44  uno::Reference< container::XIndexAccess > xRedlines( xRedlinesSupp->getRedlines(), uno::UNO_QUERY_THROW );
45  sal_Int32 nCount = xRedlines->getCount();
46  for( sal_Int32 i = 0; i < nCount; i++ )
47  {
48  uno::Reference< beans::XPropertySet > xProps( xRedlines->getByIndex( i ), uno::UNO_QUERY_THROW );
49  if( xProps == mxRedlineProps )
50  {
51  nPos = i;
52  SAL_INFO("sw.ui", "the redline position is " << nPos);
53  break;
54  }
55  }
56  if( nPos == -1 )
57  throw uno::RuntimeException();
58 
59  return nPos;
60 }
61 
62 void SAL_CALL
64 {
65  SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc();
66  if( pDoc )
68 }
69 
70 void SAL_CALL
72 {
73  SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc();
74  if( pDoc )
76 }
77 
78 OUString
80 {
81  return "SwVbaRevision";
82 }
83 
84 uno::Sequence< OUString >
86 {
87  static uno::Sequence< OUString > const aServiceNames
88  {
89  "ooo.vba.word.Revision"
90  };
91  return aServiceNames;
92 }
93 
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL Accept() override
Definition: vbarevision.cxx:63
css::uno::Reference< css::beans::XPropertySet > mxRedlineProps
Definition: vbarevision.hxx:31
Definition: doc.hxx:186
css::uno::Reference< css::frame::XModel2 > mxModel
Sequence< OUString > aServiceNames
virtual css::uno::Sequence< OUString > getServiceNames() override
Definition: vbarevision.cxx:85
int nCount
virtual ~SwVbaRevision() override
Definition: vbarevision.cxx:36
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:203
int i
css::uno::Reference< css::frame::XModel > mxModel
Definition: vbarevision.hxx:30
SwDocShell * getDocShell(const uno::Reference< frame::XModel > &xModel)
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:334
virtual void SAL_CALL Reject() override
Definition: vbarevision.cxx:71
#define SAL_INFO(area, stream)
virtual OUString getServiceImplName() override
Definition: vbarevision.cxx:79
sal_Int32 GetPosition()
Definition: vbarevision.cxx:40
virtual bool AcceptRedline(SwRedlineTable::size_type nPos, bool bCallDelete)=0
virtual bool RejectRedline(SwRedlineTable::size_type nPos, bool bCallDelete)=0
SwVbaRevision(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< css::uno::XComponentContext > &rContext, const css::uno::Reference< css::frame::XModel > &xModel, const css::uno::Reference< css::beans::XPropertySet > &xRedlineProps)
Definition: vbarevision.cxx:32
sal_uInt16 nPos