fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / vba / vbastyle.cxx
blob09181f83db5b01ceaa57403970a6b5338996f213
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 .
20 #include "vbastyle.hxx"
21 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
23 using namespace ::ooo::vba;
24 using namespace ::com::sun::star;
26 static const char DISPLAYNAME[] = "DisplayName";
28 uno::Reference< container::XNameAccess >
29 ScVbaStyle::getStylesNameContainer( const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException )
31 uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( xModel, uno::UNO_QUERY_THROW);
32 uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName("CellStyles"), uno::UNO_QUERY_THROW );
33 return xStylesAccess;
36 static uno::Reference< beans::XPropertySet >
37 lcl_getStyleProps( const OUString& sStyleName, const uno::Reference< frame::XModel >& xModel ) throw ( script::BasicErrorException, uno::RuntimeException )
40 uno::Reference< beans::XPropertySet > xStyleProps( ScVbaStyle::getStylesNameContainer( xModel )->getByName( sStyleName ), uno::UNO_QUERY_THROW );
41 return xStyleProps;
44 void ScVbaStyle::initialise() throw ( uno::RuntimeException, script::BasicErrorException )
46 if (!mxModel.is() )
47 DebugHelper::basicexception(SbERR_METHOD_FAILED, OUString( "XModel Interface could not be retrieved") );
48 uno::Reference< lang::XServiceInfo > xServiceInfo( mxPropertySet, uno::UNO_QUERY_THROW );
49 if ( !xServiceInfo->supportsService("com.sun.star.style.CellStyle") )
51 DebugHelper::basicexception(SbERR_METHOD_FAILED, OUString() );
53 mxStyle.set( mxPropertySet, uno::UNO_QUERY_THROW );
55 uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxModel, uno::UNO_QUERY_THROW );
56 mxStyleFamilyNameContainer.set( ScVbaStyle::getStylesNameContainer( mxModel ), uno::UNO_QUERY_THROW );
60 ScVbaStyle::ScVbaStyle( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const 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 )
62 try
64 initialise();
66 catch (const uno::Exception& )
68 DebugHelper::basicexception(SbERR_METHOD_FAILED, OUString());
72 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 )
74 try
76 initialise();
78 catch (const uno::Exception& )
80 DebugHelper::basicexception(SbERR_METHOD_FAILED, OUString());
84 sal_Bool SAL_CALL
85 ScVbaStyle::BuiltIn() throw (script::BasicErrorException, uno::RuntimeException, std::exception)
87 return !mxStyle->isUserDefined();
90 void SAL_CALL
91 ScVbaStyle::setName( const OUString& Name ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
93 mxStyle->setName(Name);
96 OUString SAL_CALL
97 ScVbaStyle::getName() throw (script::BasicErrorException, uno::RuntimeException, std::exception)
99 return mxStyle->getName();
102 void SAL_CALL
103 ScVbaStyle::setNameLocal( const OUString& NameLocal ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
107 mxPropertySet->setPropertyValue(DISPLAYNAME, uno::makeAny( NameLocal ) );
109 catch (const uno::Exception& e)
111 DebugHelper::basicexception(e);
115 OUString SAL_CALL
116 ScVbaStyle::getNameLocal() throw (script::BasicErrorException, uno::RuntimeException, std::exception)
118 OUString sName;
121 mxPropertySet->getPropertyValue(DISPLAYNAME) >>= sName;
123 catch (const uno::Exception& )
125 DebugHelper::basicexception(SbERR_METHOD_FAILED, OUString() );
127 return sName;
130 void SAL_CALL
131 ScVbaStyle::Delete() throw (script::BasicErrorException, uno::RuntimeException, std::exception)
135 mxStyleFamilyNameContainer->removeByName(mxStyle->getName());
137 catch (const uno::Exception& )
139 DebugHelper::basicexception(SbERR_METHOD_FAILED, OUString());
143 void SAL_CALL
144 ScVbaStyle::setMergeCells( const uno::Any& /*MergeCells*/ ) throw (script::BasicErrorException, uno::RuntimeException)
146 DebugHelper::basicexception(SbERR_NOT_IMPLEMENTED, OUString());
149 uno::Any SAL_CALL
150 ScVbaStyle::getMergeCells( ) throw (script::BasicErrorException, uno::RuntimeException)
152 DebugHelper::basicexception(SbERR_NOT_IMPLEMENTED, OUString());
153 return uno::Any();
156 OUString
157 ScVbaStyle::getServiceImplName()
159 return OUString("ScVbaStyle");
162 uno::Sequence< OUString >
163 ScVbaStyle::getServiceNames()
165 static uno::Sequence< OUString > aServiceNames;
166 if ( aServiceNames.getLength() == 0 )
168 aServiceNames.realloc( 1 );
169 aServiceNames[ 0 ] = "ooo.vba.excel.XStyle";
171 return aServiceNames;
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */