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 <tools/diagnose_ex.h>
22 #include <sal/log.hxx>
23 #include <com/sun/star/document/XRedlinesSupplier.hpp>
24 #include <com/sun/star/container/XIndexAccess.hpp>
25 #include "wordvbahelper.hxx"
26 #include <docsh.hxx>
27 #include <doc.hxx>
29 
30 using namespace ::ooo::vba;
31 using namespace ::com::sun::star;
32 
33 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 )
34 {
35 }
36 
38 {
39 }
40 
42 {
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++ )
48  {
49  uno::Reference< beans::XPropertySet > xProps( xRedlines->getByIndex( i ), uno::UNO_QUERY_THROW );
50  if( xProps == mxRedlineProps )
51  {
52  nPos = i;
53  SAL_INFO("sw.ui", "the redline position is " << nPos);
54  break;
55  }
56  }
57  if( nPos == -1 )
58  throw uno::RuntimeException();
59 
60  return nPos;
61 }
62 
63 void SAL_CALL
65 {
66  SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc();
67  if( pDoc )
69 }
70 
71 void SAL_CALL
73 {
74  SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc();
75  if( pDoc )
77 }
78 
79 OUString
81 {
82  return "SwVbaRevision";
83 }
84 
85 uno::Sequence< OUString >
87 {
88  static uno::Sequence< OUString > const aServiceNames
89  {
90  "ooo.vba.word.Revision"
91  };
92  return aServiceNames;
93 }
94 
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL Accept() override
Definition: vbarevision.cxx:64
css::uno::Reference< css::beans::XPropertySet > mxRedlineProps
Definition: vbarevision.hxx:31
Definition: doc.hxx:185
css::uno::Reference< css::frame::XModel2 > mxModel
virtual css::uno::Sequence< OUString > getServiceNames() override
Definition: vbarevision.cxx:86
virtual ~SwVbaRevision() override
Definition: vbarevision.cxx:37
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:367
virtual void SAL_CALL Reject() override
Definition: vbarevision.cxx:72
#define SAL_INFO(area, stream)
virtual OUString getServiceImplName() override
Definition: vbarevision.cxx:80
sal_Int32 GetPosition()
Definition: vbarevision.cxx:41
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:33
sal_Int32 nPos