fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / vba / vbacomments.cxx
blobee965328216c8332159f24bfd5b8e83d66a2057e
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 "vbacomments.hxx"
21 #include <com/sun/star/container/XChild.hpp>
22 #include <com/sun/star/sheet/XSheetAnnotation.hpp>
24 #include "vbaglobals.hxx"
26 using namespace ::ooo::vba;
27 using namespace ::com::sun::star;
29 uno::Any AnnotationToComment( const uno::Any& aSource, uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel )
31 uno::Reference< sheet::XSheetAnnotation > xAnno( aSource, uno::UNO_QUERY_THROW );
32 uno::Reference< container::XChild > xChild( xAnno, uno::UNO_QUERY_THROW );
33 uno::Reference< table::XCellRange > xCellRange( xChild->getParent(), uno::UNO_QUERY_THROW );
35 // #FIXME needs to find the correct Parent
36 return uno::makeAny( uno::Reference< excel::XComment > (
37 new ScVbaComment( uno::Reference< XHelperInterface >(), xContext, xModel, xCellRange ) ) );
40 class CommentEnumeration : public EnumerationHelperImpl
42 css::uno::Reference< css::frame::XModel > mxModel;
43 public:
44 CommentEnumeration(
45 const uno::Reference< XHelperInterface >& xParent,
46 const uno::Reference< uno::XComponentContext >& xContext,
47 const uno::Reference< container::XEnumeration >& xEnumeration,
48 const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) :
49 EnumerationHelperImpl( xParent, xContext, xEnumeration ),
50 mxModel( xModel, uno::UNO_SET_THROW )
53 virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
55 return AnnotationToComment( m_xEnumeration->nextElement(), m_xContext, mxModel );
60 ScVbaComments::ScVbaComments(
61 const uno::Reference< XHelperInterface >& xParent,
62 const uno::Reference< uno::XComponentContext > & xContext,
63 const uno::Reference< frame::XModel >& xModel,
64 const uno::Reference< container::XIndexAccess >& xIndexAccess ) :
65 ScVbaComments_BASE( xParent, xContext, xIndexAccess ),
66 mxModel( xModel, uno::UNO_SET_THROW )
70 // public helper functions
72 uno::Reference< container::XEnumeration >
73 ScVbaComments::createEnumeration() throw (uno::RuntimeException)
75 uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
76 return new CommentEnumeration( mxParent, mxContext, xEnumAccess->createEnumeration(), mxModel );
79 uno::Any
80 ScVbaComments::createCollectionObject( const css::uno::Any& aSource )
82 return AnnotationToComment( aSource, mxContext, mxModel );
85 uno::Type
86 ScVbaComments::getElementType() throw (uno::RuntimeException)
88 return cppu::UnoType<excel::XComment>::get();
91 OUString
92 ScVbaComments::getServiceImplName()
94 return OUString("ScVbaComments");
97 css::uno::Sequence<OUString>
98 ScVbaComments::getServiceNames()
100 static uno::Sequence< OUString > sNames;
101 if ( sNames.getLength() == 0 )
103 sNames.realloc( 1 );
104 sNames[0] = "ooo.vba.excel.Comments";
106 return sNames;
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */