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 : :
29 : : #include "vbastyle.hxx"
30 : : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
31 : :
32 : : using namespace ::ooo::vba;
33 : : using namespace ::com::sun::star;
34 : :
35 : 3 : static rtl::OUString DISPLAYNAME( RTL_CONSTASCII_USTRINGPARAM("DisplayName") );
36 : :
37 : :
38 : :
39 : : uno::Reference< container::XNameAccess >
40 : 0 : ScVbaStyle::getStylesNameContainer( const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException )
41 : : {
42 [ # # ]: 0 : uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( xModel, uno::UNO_QUERY_THROW);
43 [ # # ][ # # ]: 0 : uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CellStyles" ) ) ), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
[ # # ][ # # ]
44 : 0 : return xStylesAccess;
45 : : }
46 : :
47 : : uno::Reference< beans::XPropertySet >
48 : 0 : lcl_getStyleProps( const rtl::OUString& sStyleName, const uno::Reference< frame::XModel >& xModel ) throw ( script::BasicErrorException, uno::RuntimeException )
49 : : {
50 : :
51 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xStyleProps( ScVbaStyle::getStylesNameContainer( xModel )->getByName( sStyleName ), uno::UNO_QUERY_THROW );
[ # # ]
52 : 0 : return xStyleProps;
53 : : }
54 : :
55 : :
56 : 0 : void ScVbaStyle::initialise() throw ( uno::RuntimeException )
57 : : {
58 [ # # ]: 0 : if (!mxModel.is() )
59 [ # # ][ # # ]: 0 : DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XModel Interface could not be retrieved")) );
60 [ # # ]: 0 : uno::Reference< lang::XServiceInfo > xServiceInfo( mxPropertySet, uno::UNO_QUERY_THROW );
61 [ # # ][ # # ]: 0 : if ( !xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.CellStyle" ) ) ) )
[ # # ][ # # ]
62 : : {
63 [ # # ]: 0 : DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
64 : : }
65 [ # # ]: 0 : mxStyle.set( mxPropertySet, uno::UNO_QUERY_THROW );
66 : :
67 [ # # ]: 0 : uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxModel, uno::UNO_QUERY_THROW );
68 [ # # ][ # # ]: 0 : mxStyleFamilyNameContainer.set( ScVbaStyle::getStylesNameContainer( mxModel ), uno::UNO_QUERY_THROW );
69 : :
70 : 0 : }
71 : :
72 [ # # ]: 0 : ScVbaStyle::ScVbaStyle( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const rtl::OUString& sStyleName, const uno::Reference< frame::XModel >& _xModel ) throw ( script::BasicErrorException, uno::RuntimeException ) : ScVbaStyle_BASE( xParent, xContext, lcl_getStyleProps( sStyleName, _xModel ), _xModel, false ), mxModel( _xModel )
73 : : {
74 : : try
75 : : {
76 [ # # ]: 0 : initialise();
77 : : }
78 [ # # # # ]: 0 : catch (const uno::Exception& )
79 : : {
80 [ # # ]: 0 : DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
81 : : }
82 : 0 : }
83 : :
84 : 0 : ScVbaStyle::ScVbaStyle( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet, const uno::Reference< frame::XModel >& _xModel ) throw ( script::BasicErrorException, uno::RuntimeException ) : ScVbaStyle_BASE( xParent, xContext, _xPropertySet, _xModel, false ), mxModel( _xModel )
85 : : {
86 : : try
87 : : {
88 [ # # ]: 0 : initialise();
89 : : }
90 [ # # # # ]: 0 : catch (const uno::Exception& )
91 : : {
92 [ # # ]: 0 : DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
93 : : }
94 : 0 : }
95 : :
96 : :
97 : : ::sal_Bool SAL_CALL
98 : 0 : ScVbaStyle::BuiltIn() throw (script::BasicErrorException, uno::RuntimeException)
99 : : {
100 : 0 : return !mxStyle->isUserDefined();
101 : :
102 : : }
103 : : void SAL_CALL
104 : 0 : ScVbaStyle::setName( const ::rtl::OUString& Name ) throw (script::BasicErrorException, uno::RuntimeException)
105 : : {
106 : 0 : mxStyle->setName(Name);
107 : 0 : }
108 : :
109 : : ::rtl::OUString SAL_CALL
110 : 0 : ScVbaStyle::getName() throw (script::BasicErrorException, uno::RuntimeException)
111 : : {
112 : 0 : return mxStyle->getName();
113 : : }
114 : :
115 : : void SAL_CALL
116 : 0 : ScVbaStyle::setNameLocal( const ::rtl::OUString& NameLocal ) throw (script::BasicErrorException, uno::RuntimeException)
117 : : {
118 : : try
119 : : {
120 [ # # ][ # # ]: 0 : mxPropertySet->setPropertyValue(DISPLAYNAME, uno::makeAny( NameLocal ) );
[ # # ]
121 : : }
122 [ # # ]: 0 : catch (const uno::Exception& e)
123 : : {
124 [ # # ]: 0 : DebugHelper::exception(e);
125 : : }
126 : 0 : }
127 : :
128 : : ::rtl::OUString SAL_CALL
129 : 0 : ScVbaStyle::getNameLocal() throw (script::BasicErrorException, uno::RuntimeException)
130 : : {
131 : 0 : rtl::OUString sName;
132 : : try
133 : : {
134 [ # # ][ # # ]: 0 : mxPropertySet->getPropertyValue(DISPLAYNAME) >>= sName;
135 : : }
136 [ # # # # ]: 0 : catch (const uno::Exception& )
137 : : {
138 [ # # ]: 0 : DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
139 : : }
140 : 0 : return sName;
141 : : }
142 : :
143 : : void SAL_CALL
144 : 0 : ScVbaStyle::Delete() throw (script::BasicErrorException, uno::RuntimeException)
145 : : {
146 : : try
147 : : {
148 [ # # ][ # # ]: 0 : mxStyleFamilyNameContainer->removeByName(mxStyle->getName());
[ # # ][ # # ]
149 : : }
150 [ # # ]: 0 : catch (const uno::Exception& )
151 : : {
152 [ # # ]: 0 : DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
153 : : }
154 : 0 : }
155 : :
156 : : void SAL_CALL
157 : 0 : ScVbaStyle::setMergeCells( const uno::Any& /*MergeCells*/ ) throw (script::BasicErrorException, uno::RuntimeException)
158 : : {
159 [ # # ]: 0 : DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
160 : 0 : }
161 : :
162 : : uno::Any SAL_CALL
163 : 0 : ScVbaStyle::getMergeCells( ) throw (script::BasicErrorException, uno::RuntimeException)
164 : : {
165 [ # # ]: 0 : DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
166 : 0 : return uno::Any();
167 : : }
168 : :
169 : : rtl::OUString
170 : 0 : ScVbaStyle::getServiceImplName()
171 : : {
172 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaStyle"));
173 : : }
174 : :
175 : : uno::Sequence< rtl::OUString >
176 : 0 : ScVbaStyle::getServiceNames()
177 : : {
178 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
179 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
180 : : {
181 : 0 : aServiceNames.realloc( 1 );
182 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.XStyle" ) );
183 : : }
184 : 0 : return aServiceNames;
185 [ + - ][ + - ]: 9 : }
186 : :
187 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|