Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include "vbacomments.hxx"
29 : :
30 : : #include <com/sun/star/container/XChild.hpp>
31 : : #include <com/sun/star/sheet/XSheetAnnotation.hpp>
32 : :
33 : : #include "vbaglobals.hxx"
34 : :
35 : : using namespace ::ooo::vba;
36 : : using namespace ::com::sun::star;
37 : :
38 : 0 : uno::Any AnnotationToComment( const uno::Any& aSource, uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel )
39 : : {
40 [ # # ]: 0 : uno::Reference< sheet::XSheetAnnotation > xAnno( aSource, uno::UNO_QUERY_THROW );
41 [ # # ]: 0 : uno::Reference< container::XChild > xChild( xAnno, uno::UNO_QUERY_THROW );
42 [ # # ][ # # ]: 0 : uno::Reference< table::XCellRange > xCellRange( xChild->getParent(), uno::UNO_QUERY_THROW );
[ # # ]
43 : :
44 : : // #FIXME needs to find the correct Parent
45 : : return uno::makeAny( uno::Reference< excel::XComment > (
46 [ # # ][ # # ]: 0 : new ScVbaComment( uno::Reference< XHelperInterface >(), xContext, xModel, xCellRange ) ) );
[ # # ][ # # ]
47 : : }
48 : :
49 [ # # ]: 0 : class CommentEnumeration : public EnumerationHelperImpl
50 : : {
51 : : css::uno::Reference< css::frame::XModel > mxModel;
52 : : public:
53 : 0 : CommentEnumeration(
54 : : const uno::Reference< XHelperInterface >& xParent,
55 : : const uno::Reference< uno::XComponentContext >& xContext,
56 : : const uno::Reference< container::XEnumeration >& xEnumeration,
57 : : const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) :
58 : : EnumerationHelperImpl( xParent, xContext, xEnumeration ),
59 [ # # ]: 0 : mxModel( xModel, uno::UNO_SET_THROW )
60 : 0 : {}
61 : :
62 : 0 : virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
63 : : {
64 [ # # ]: 0 : return AnnotationToComment( m_xEnumeration->nextElement(), m_xContext, mxModel );
65 : : }
66 : :
67 : : };
68 : :
69 : 0 : ScVbaComments::ScVbaComments(
70 : : const uno::Reference< XHelperInterface >& xParent,
71 : : const uno::Reference< uno::XComponentContext > & xContext,
72 : : const uno::Reference< frame::XModel >& xModel,
73 : : const uno::Reference< container::XIndexAccess >& xIndexAccess ) :
74 : : ScVbaComments_BASE( xParent, xContext, xIndexAccess ),
75 [ # # ]: 0 : mxModel( xModel, uno::UNO_SET_THROW )
76 : : {
77 : 0 : }
78 : :
79 : : // public helper functions
80 : :
81 : : uno::Reference< container::XEnumeration >
82 : 0 : ScVbaComments::createEnumeration() throw (uno::RuntimeException)
83 : : {
84 [ # # ]: 0 : uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
85 [ # # ][ # # ]: 0 : return new CommentEnumeration( mxParent, mxContext, xEnumAccess->createEnumeration(), mxModel );
[ # # ][ # # ]
[ # # ][ # # ]
86 : : }
87 : :
88 : : uno::Any
89 : 0 : ScVbaComments::createCollectionObject( const css::uno::Any& aSource )
90 : : {
91 : 0 : return AnnotationToComment( aSource, mxContext, mxModel );
92 : : }
93 : :
94 : : uno::Type
95 : 0 : ScVbaComments::getElementType() throw (uno::RuntimeException)
96 : : {
97 : 0 : return excel::XComment::static_type(0);
98 : : }
99 : :
100 : : rtl::OUString
101 : 0 : ScVbaComments::getServiceImplName()
102 : : {
103 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaComments"));
104 : : }
105 : :
106 : : css::uno::Sequence<rtl::OUString>
107 : 0 : ScVbaComments::getServiceNames()
108 : : {
109 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > sNames;
[ # # ][ # # ]
110 [ # # ]: 0 : if ( sNames.getLength() == 0 )
111 : : {
112 : 0 : sNames.realloc( 1 );
113 [ # # ]: 0 : sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Comments") );
114 : : }
115 : 0 : return sNames;
116 : : }
117 : :
118 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|