Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 : : *
5 : : * The contents of this file are subject to the Mozilla Public License Version
6 : : * 1.1 (the "License"); you may not use this file except in compliance with
7 : : * the License. You may obtain a copy of the License at
8 : : * http://www.mozilla.org/MPL/
9 : : *
10 : : * Software distributed under the License is distributed on an "AS IS" basis,
11 : : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : : * for the specific language governing rights and limitations under the
13 : : * License.
14 : : *
15 : : * The Initial Developer of the Original Code is
16 : : * Novell Inc.
17 : : * Portions created by the Initial Developer are Copyright (C) 2010 the
18 : : * Initial Developer. All Rights Reserved.
19 : : *
20 : : * Contributor(s): Pei Feng Lin <pflin@novell.com>
21 : : *
22 : : * Alternatively, the contents of this file may be used under the terms of
23 : : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
24 : : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
25 : : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
26 : : * instead of those above.
27 : : */
28 : : #include "vbamenubars.hxx"
29 : : #include "vbamenubar.hxx"
30 : : #include <ooo/vba/excel/XlSheetType.hpp>
31 : :
32 : : using namespace com::sun::star;
33 : : using namespace ooo::vba;
34 : :
35 : :
36 : : typedef ::cppu::WeakImplHelper1< container::XEnumeration > MenuBarEnumeration_BASE;
37 : :
38 [ # # ]: 0 : class MenuBarEnumeration : public MenuBarEnumeration_BASE
39 : : {
40 : : uno::Reference< XHelperInterface > m_xParent;
41 : : uno::Reference< uno::XComponentContext > m_xContext;
42 : : uno::Reference< container::XEnumeration > m_xEnumeration;
43 : : public:
44 : 0 : MenuBarEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_xEnumeration( xEnumeration )
45 : : {
46 : 0 : }
47 : 0 : virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException )
48 : : {
49 : 0 : return m_xEnumeration->hasMoreElements();
50 : : }
51 : 0 : virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
52 : : {
53 : : // FIXME: should be add menubar
54 [ # # ]: 0 : if( hasMoreElements() )
55 : : {
56 [ # # ][ # # ]: 0 : uno::Reference< XCommandBar > xCommandBar( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
[ # # ]
57 [ # # ][ # # ]: 0 : uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( m_xParent, m_xContext, xCommandBar ) );
[ # # ]
58 [ # # ]: 0 : return uno::makeAny( xMenuBar );
59 : : }
60 : : else
61 [ # # ]: 0 : throw container::NoSuchElementException();
62 : : }
63 : : };
64 : :
65 [ # # ]: 0 : ScVbaMenuBars::ScVbaMenuBars( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCommandBars >& xCommandBars ) throw ( uno::RuntimeException ) : MenuBars_BASE( xParent, xContext, uno::Reference< container::XIndexAccess>() ), m_xCommandBars( xCommandBars )
66 : : {
67 : 0 : }
68 : :
69 : 0 : ScVbaMenuBars::~ScVbaMenuBars()
70 : : {
71 [ # # ]: 0 : }
72 : :
73 : : // XEnumerationAccess
74 : : uno::Type SAL_CALL
75 : 0 : ScVbaMenuBars::getElementType() throw ( uno::RuntimeException )
76 : : {
77 : 0 : return excel::XMenuBar::static_type( 0 );
78 : : }
79 : :
80 : : uno::Reference< container::XEnumeration >
81 : 0 : ScVbaMenuBars::createEnumeration() throw ( uno::RuntimeException )
82 : : {
83 [ # # ]: 0 : uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xCommandBars, uno::UNO_QUERY_THROW );
84 [ # # ][ # # ]: 0 : return uno::Reference< container::XEnumeration >( new MenuBarEnumeration( this, mxContext, xEnumAccess->createEnumeration() ) );
[ # # ][ # # ]
[ # # ][ # # ]
85 : : }
86 : :
87 : : uno::Any
88 : 0 : ScVbaMenuBars::createCollectionObject( const uno::Any& aSource )
89 : : {
90 : : // make no sense
91 : 0 : return aSource;
92 : : }
93 : :
94 : : sal_Int32 SAL_CALL
95 : 0 : ScVbaMenuBars::getCount() throw(css::uno::RuntimeException)
96 : : {
97 : 0 : return m_xCommandBars->getCount();
98 : : }
99 : :
100 : : // ScVbaCollectionBaseImpl
101 : : uno::Any SAL_CALL
102 : 0 : ScVbaMenuBars::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) throw( uno::RuntimeException )
103 : : {
104 : 0 : sal_Int16 nIndex = 0;
105 : 0 : aIndex >>= nIndex;
106 [ # # ]: 0 : if( nIndex == excel::XlSheetType::xlWorksheet )
107 : : {
108 : 0 : uno::Any aSource;
109 [ # # ][ # # ]: 0 : aSource <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Worksheet Menu Bar" ));
110 [ # # ][ # # ]: 0 : uno::Reference< XCommandBar > xCommandBar( m_xCommandBars->Item( aSource, uno::Any() ), uno::UNO_QUERY_THROW );
[ # # ]
111 [ # # ][ # # ]: 0 : uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( this, mxContext, xCommandBar ) );
[ # # ][ # # ]
112 [ # # ]: 0 : return uno::makeAny( xMenuBar );
113 : : }
114 : :
115 [ # # ][ # # ]: 0 : throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
116 : : }
117 : :
118 : : // XHelperInterface
119 : : rtl::OUString
120 : 0 : ScVbaMenuBars::getServiceImplName()
121 : : {
122 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaMenuBars"));
123 : : }
124 : :
125 : : uno::Sequence<rtl::OUString>
126 : 0 : ScVbaMenuBars::getServiceNames()
127 : : {
128 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
129 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
130 : : {
131 : 0 : aServiceNames.realloc( 1 );
132 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.MenuBars" ) );
133 : : }
134 : 0 : return aServiceNames;
135 : : }
136 : :
137 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|