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 "vbastyles.hxx"
29 : : #include "vbastyle.hxx"
30 : : #include <cppuhelper/implbase3.hxx>
31 : : #include <com/sun/star/container/XEnumerationAccess.hpp>
32 : : #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
33 : : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
34 : : #include <com/sun/star/style/XStyle.hpp>
35 : : #include <ooo/vba/word/WdBuiltinStyle.hpp>
36 : : #include <ooo/vba/word/WdStyleType.hpp>
37 : :
38 : : using namespace ::ooo::vba;
39 : : using namespace ::com::sun::star;
40 : :
41 : : struct BuiltinStyleTable
42 : : {
43 : : sal_Int32 wdBuiltinStyle;
44 : : const sal_Char* pOOoStyleName;
45 : : sal_Int32 wdStyleType;
46 : : };
47 : :
48 : : static const BuiltinStyleTable aBuiltinStyleTable[] =
49 : : {
50 : : { word::WdBuiltinStyle::wdStyleBlockQuotation, "", word::WdStyleType::wdStyleTypeParagraph },
51 : : { word::WdBuiltinStyle::wdStyleBodyText, "Text body", word::WdStyleType::wdStyleTypeParagraph },
52 : : { word::WdBuiltinStyle::wdStyleBodyText2, "", word::WdStyleType::wdStyleTypeParagraph },
53 : : { word::WdBuiltinStyle::wdStyleBodyText3, "", word::WdStyleType::wdStyleTypeParagraph },
54 : : { word::WdBuiltinStyle::wdStyleBodyTextFirstIndent, "First line indent", word::WdStyleType::wdStyleTypeParagraph },
55 : : { word::WdBuiltinStyle::wdStyleBodyTextFirstIndent2, "", word::WdStyleType::wdStyleTypeParagraph },
56 : : { word::WdBuiltinStyle::wdStyleBodyTextIndent, "Text body indent", word::WdStyleType::wdStyleTypeParagraph },
57 : : { word::WdBuiltinStyle::wdStyleBodyTextIndent2, "", word::WdStyleType::wdStyleTypeParagraph },
58 : : { word::WdBuiltinStyle::wdStyleBodyTextIndent3, "", word::WdStyleType::wdStyleTypeParagraph },
59 : : { word::WdBuiltinStyle::wdStyleCaption, "", word::WdStyleType::wdStyleTypeParagraph },
60 : : { word::WdBuiltinStyle::wdStyleClosing, "", word::WdStyleType::wdStyleTypeParagraph },
61 : : { word::WdBuiltinStyle::wdStyleCommentReference, "", word::WdStyleType::wdStyleTypeParagraph },
62 : : { word::WdBuiltinStyle::wdStyleCommentText, "", word::WdStyleType::wdStyleTypeParagraph },
63 : : { word::WdBuiltinStyle::wdStyleDate, "", word::WdStyleType::wdStyleTypeParagraph },
64 : : { word::WdBuiltinStyle::wdStyleDefaultParagraphFont, "", word::WdStyleType::wdStyleTypeParagraph },
65 : : { word::WdBuiltinStyle::wdStyleEmphasis, "", word::WdStyleType::wdStyleTypeParagraph },
66 : : { word::WdBuiltinStyle::wdStyleEndnoteReference, "", word::WdStyleType::wdStyleTypeParagraph },
67 : : { word::WdBuiltinStyle::wdStyleEndnoteText, "Endnote", word::WdStyleType::wdStyleTypeParagraph },
68 : : { word::WdBuiltinStyle::wdStyleEnvelopeAddress, "", word::WdStyleType::wdStyleTypeParagraph },
69 : : { word::WdBuiltinStyle::wdStyleEnvelopeReturn, "", word::WdStyleType::wdStyleTypeParagraph },
70 : : { word::WdBuiltinStyle::wdStyleFooter, "", word::WdStyleType::wdStyleTypeParagraph },
71 : : { word::WdBuiltinStyle::wdStyleFootnoteReference, "", word::WdStyleType::wdStyleTypeParagraph },
72 : : { word::WdBuiltinStyle::wdStyleFootnoteText, "Footnote", word::WdStyleType::wdStyleTypeParagraph },
73 : : { word::WdBuiltinStyle::wdStyleHeader, "Header", word::WdStyleType::wdStyleTypeParagraph },
74 : : { word::WdBuiltinStyle::wdStyleHeading1, "Heading 1", word::WdStyleType::wdStyleTypeParagraph },
75 : : { word::WdBuiltinStyle::wdStyleHeading2, "Heading 2", word::WdStyleType::wdStyleTypeParagraph },
76 : : { word::WdBuiltinStyle::wdStyleHeading3, "Heading 3", word::WdStyleType::wdStyleTypeParagraph },
77 : : { word::WdBuiltinStyle::wdStyleHeading4, "Heading 4", word::WdStyleType::wdStyleTypeParagraph },
78 : : { word::WdBuiltinStyle::wdStyleHeading5, "Heading 5", word::WdStyleType::wdStyleTypeParagraph },
79 : : { word::WdBuiltinStyle::wdStyleHeading6, "Heading 6", word::WdStyleType::wdStyleTypeParagraph },
80 : : { word::WdBuiltinStyle::wdStyleHeading7, "Heading 7", word::WdStyleType::wdStyleTypeParagraph },
81 : : { word::WdBuiltinStyle::wdStyleHeading8, "Heading 8", word::WdStyleType::wdStyleTypeParagraph },
82 : : { word::WdBuiltinStyle::wdStyleHeading9, "Heading 9", word::WdStyleType::wdStyleTypeParagraph },
83 : : { word::WdBuiltinStyle::wdStyleHtmlAcronym, "", word::WdStyleType::wdStyleTypeParagraph },
84 : : { word::WdBuiltinStyle::wdStyleHtmlAddress, "", word::WdStyleType::wdStyleTypeParagraph },
85 : : { word::WdBuiltinStyle::wdStyleHtmlCite, "", word::WdStyleType::wdStyleTypeParagraph },
86 : : { word::WdBuiltinStyle::wdStyleHtmlCode, "", word::WdStyleType::wdStyleTypeParagraph },
87 : : { word::WdBuiltinStyle::wdStyleHtmlDfn, "", word::WdStyleType::wdStyleTypeParagraph },
88 : : { word::WdBuiltinStyle::wdStyleHtmlKbd, "", word::WdStyleType::wdStyleTypeParagraph },
89 : : { word::WdBuiltinStyle::wdStyleHtmlNormal, "", word::WdStyleType::wdStyleTypeParagraph },
90 : : { word::WdBuiltinStyle::wdStyleHtmlPre, "", word::WdStyleType::wdStyleTypeParagraph },
91 : : { word::WdBuiltinStyle::wdStyleHtmlSamp, "", word::WdStyleType::wdStyleTypeParagraph },
92 : : { word::WdBuiltinStyle::wdStyleHtmlTt, "", word::WdStyleType::wdStyleTypeParagraph },
93 : : { word::WdBuiltinStyle::wdStyleHtmlVar, "", word::WdStyleType::wdStyleTypeParagraph },
94 : : { word::WdBuiltinStyle::wdStyleHyperlink, "", word::WdStyleType::wdStyleTypeParagraph },
95 : : { word::WdBuiltinStyle::wdStyleHyperlinkFollowed, "", word::WdStyleType::wdStyleTypeParagraph },
96 : : { word::WdBuiltinStyle::wdStyleIndex1, "Index 1", word::WdStyleType::wdStyleTypeParagraph },
97 : : { word::WdBuiltinStyle::wdStyleIndex2, "Index 2", word::WdStyleType::wdStyleTypeParagraph },
98 : : { word::WdBuiltinStyle::wdStyleIndex3, "Index 3", word::WdStyleType::wdStyleTypeParagraph },
99 : : { word::WdBuiltinStyle::wdStyleIndex4, "", word::WdStyleType::wdStyleTypeParagraph },
100 : : { word::WdBuiltinStyle::wdStyleIndex5, "", word::WdStyleType::wdStyleTypeParagraph },
101 : : { word::WdBuiltinStyle::wdStyleIndex6, "", word::WdStyleType::wdStyleTypeParagraph },
102 : : { word::WdBuiltinStyle::wdStyleIndex7, "", word::WdStyleType::wdStyleTypeParagraph },
103 : : { word::WdBuiltinStyle::wdStyleIndex8, "", word::WdStyleType::wdStyleTypeParagraph },
104 : : { word::WdBuiltinStyle::wdStyleIndex9, "", word::WdStyleType::wdStyleTypeParagraph },
105 : : { word::WdBuiltinStyle::wdStyleIndexHeading, "Index Heading", word::WdStyleType::wdStyleTypeParagraph },
106 : : { word::WdBuiltinStyle::wdStyleLineNumber, "", word::WdStyleType::wdStyleTypeParagraph },
107 : : { word::WdBuiltinStyle::wdStyleList, "List", word::WdStyleType::wdStyleTypeParagraph },
108 : : { word::WdBuiltinStyle::wdStyleList2, "List 2", word::WdStyleType::wdStyleTypeParagraph },
109 : : { word::WdBuiltinStyle::wdStyleList3, "List 3", word::WdStyleType::wdStyleTypeParagraph },
110 : : { word::WdBuiltinStyle::wdStyleList4, "List 4", word::WdStyleType::wdStyleTypeParagraph },
111 : : { word::WdBuiltinStyle::wdStyleList5, "List 5", word::WdStyleType::wdStyleTypeParagraph },
112 : : { word::WdBuiltinStyle::wdStyleListBullet, "List 1", word::WdStyleType::wdStyleTypeList },
113 : : { word::WdBuiltinStyle::wdStyleListBullet2, "List 2", word::WdStyleType::wdStyleTypeList },
114 : : { word::WdBuiltinStyle::wdStyleListBullet3, "List 3", word::WdStyleType::wdStyleTypeList },
115 : : { word::WdBuiltinStyle::wdStyleListBullet4, "List 4", word::WdStyleType::wdStyleTypeList },
116 : : { word::WdBuiltinStyle::wdStyleListBullet5, "List 5", word::WdStyleType::wdStyleTypeList },
117 : : { word::WdBuiltinStyle::wdStyleListContinue, "", word::WdStyleType::wdStyleTypeParagraph },
118 : : { word::WdBuiltinStyle::wdStyleListContinue2, "", word::WdStyleType::wdStyleTypeParagraph },
119 : : { word::WdBuiltinStyle::wdStyleListContinue3, "", word::WdStyleType::wdStyleTypeParagraph },
120 : : { word::WdBuiltinStyle::wdStyleListContinue4, "", word::WdStyleType::wdStyleTypeParagraph },
121 : : { word::WdBuiltinStyle::wdStyleListContinue5, "", word::WdStyleType::wdStyleTypeParagraph },
122 : : { word::WdBuiltinStyle::wdStyleListNumber, "Numbering 1", word::WdStyleType::wdStyleTypeList },
123 : : { word::WdBuiltinStyle::wdStyleListNumber2, "Numbering 2", word::WdStyleType::wdStyleTypeList },
124 : : { word::WdBuiltinStyle::wdStyleListNumber3, "Numbering 3", word::WdStyleType::wdStyleTypeList },
125 : : { word::WdBuiltinStyle::wdStyleListNumber4, "Numbering 4", word::WdStyleType::wdStyleTypeList },
126 : : { word::WdBuiltinStyle::wdStyleListNumber5, "Numbering 5", word::WdStyleType::wdStyleTypeList },
127 : : { word::WdBuiltinStyle::wdStyleMacroText, "", word::WdStyleType::wdStyleTypeParagraph },
128 : : { word::WdBuiltinStyle::wdStyleMessageHeader, "", word::WdStyleType::wdStyleTypeParagraph },
129 : : { word::WdBuiltinStyle::wdStyleNavPane, "", word::WdStyleType::wdStyleTypeParagraph },
130 : : { word::WdBuiltinStyle::wdStyleNormal, "Default", word::WdStyleType::wdStyleTypeParagraph },
131 : : { word::WdBuiltinStyle::wdStyleNormalIndent, "", word::WdStyleType::wdStyleTypeParagraph },
132 : : { word::WdBuiltinStyle::wdStyleNormalTable, "Table", word::WdStyleType::wdStyleTypeParagraph },
133 : : { word::WdBuiltinStyle::wdStyleNoteHeading, "", word::WdStyleType::wdStyleTypeParagraph },
134 : : { word::WdBuiltinStyle::wdStylePageNumber, "", word::WdStyleType::wdStyleTypeParagraph },
135 : : { word::WdBuiltinStyle::wdStylePlainText, "", word::WdStyleType::wdStyleTypeParagraph },
136 : : { word::WdBuiltinStyle::wdStyleSalutation, "", word::WdStyleType::wdStyleTypeParagraph },
137 : : { word::WdBuiltinStyle::wdStyleSignature, "", word::WdStyleType::wdStyleTypeParagraph },
138 : : { word::WdBuiltinStyle::wdStyleStrong, "", word::WdStyleType::wdStyleTypeParagraph },
139 : : { word::WdBuiltinStyle::wdStyleSubtitle, "", word::WdStyleType::wdStyleTypeParagraph },
140 : : { word::WdBuiltinStyle::wdStyleTableOfAuthorities, "", word::WdStyleType::wdStyleTypeParagraph },
141 : : { word::WdBuiltinStyle::wdStyleTableOfFigures, "", word::WdStyleType::wdStyleTypeParagraph },
142 : : { word::WdBuiltinStyle::wdStyleTitle, "Title", word::WdStyleType::wdStyleTypeParagraph },
143 : : { word::WdBuiltinStyle::wdStyleTOAHeading, "Contents Heading", word::WdStyleType::wdStyleTypeParagraph },
144 : : { word::WdBuiltinStyle::wdStyleTOC1, "Contents 1", word::WdStyleType::wdStyleTypeParagraph },
145 : : { word::WdBuiltinStyle::wdStyleTOC2, "Contents 2", word::WdStyleType::wdStyleTypeParagraph },
146 : : { word::WdBuiltinStyle::wdStyleTOC3, "Contents 3", word::WdStyleType::wdStyleTypeParagraph },
147 : : { word::WdBuiltinStyle::wdStyleTOC4, "Contents 4", word::WdStyleType::wdStyleTypeParagraph },
148 : : { word::WdBuiltinStyle::wdStyleTOC5, "Contents 5", word::WdStyleType::wdStyleTypeParagraph },
149 : : { word::WdBuiltinStyle::wdStyleTOC6, "Contents 6", word::WdStyleType::wdStyleTypeParagraph },
150 : : { word::WdBuiltinStyle::wdStyleTOC7, "Contents 7", word::WdStyleType::wdStyleTypeParagraph },
151 : : { word::WdBuiltinStyle::wdStyleTOC8, "Contents 8", word::WdStyleType::wdStyleTypeParagraph },
152 : : { word::WdBuiltinStyle::wdStyleTOC9, "Contents 9", word::WdStyleType::wdStyleTypeParagraph },
153 : : { 0, 0, 0 }
154 : : };
155 : :
156 : : struct MSOStyleNameTable
157 : : {
158 : : const sal_Char* pMSOStyleName;
159 : : const sal_Char* pOOoStyleName;
160 : : const sal_Char* pOOoStyleType;
161 : : };
162 : :
163 : : static const MSOStyleNameTable aMSOStyleNameTable[] =
164 : : {
165 : : { "Normal", "Default", "ParagraphStyles" },
166 : : { 0, 0, 0 }
167 : : };
168 : :
169 : : typedef ::cppu::WeakImplHelper3< container::XNameAccess, container::XIndexAccess, container::XEnumerationAccess > StyleCollectionHelper_BASE;
170 : :
171 [ # # ]: 0 : class StyleCollectionHelper : public StyleCollectionHelper_BASE
172 : : {
173 : : private:
174 : : uno::Reference< frame::XModel > mxModel;
175 : : uno::Reference< container::XNameAccess > mxParaStyles;
176 : : uno::Any cachePos;
177 : : public:
178 : 0 : StyleCollectionHelper( const uno::Reference< frame::XModel >& _xModel ) : mxModel( _xModel )
179 : : {
180 : : // we only concern about the Paragraph styles
181 [ # # ]: 0 : uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( _xModel, uno::UNO_QUERY_THROW);
182 [ # # ][ # # ]: 0 : uno::Reference< container::XNameAccess > xStyleFamilies = xStyleSupplier->getStyleFamilies();
183 [ # # ][ # # ]: 0 : mxParaStyles.set( xStyleFamilies->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") ) ), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
184 : 0 : }
185 : : // XElementAccess
186 : 0 : virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { return style::XStyle::static_type(0); }
187 : 0 : virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) { return getCount() > 0; }
188 : : // XNameAcess
189 : 0 : virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
190 : : {
191 [ # # ]: 0 : if ( !hasByName(aName) )
192 [ # # ]: 0 : throw container::NoSuchElementException();
193 : 0 : return cachePos;
194 : : }
195 : 0 : virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException)
196 : : {
197 : 0 : return mxParaStyles->getElementNames();
198 : : }
199 : 0 : virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
200 : : {
201 : : // search in the MSOStyleName table first
202 [ # # ]: 0 : for( const MSOStyleNameTable* pTable = aMSOStyleNameTable; pTable->pMSOStyleName != NULL; pTable++ )
203 : : {
204 [ # # ]: 0 : if( aName.equalsIgnoreAsciiCaseAscii( pTable->pMSOStyleName ) )
205 : : {
206 : : //Found it
207 : 0 : rtl::OUString sStyleName = rtl::OUString::createFromAscii( pTable->pOOoStyleName );
208 [ # # ][ # # ]: 0 : if( mxParaStyles->hasByName( sStyleName ) )
[ # # ]
209 : : {
210 [ # # ][ # # ]: 0 : cachePos = mxParaStyles->getByName( sStyleName );
211 : 0 : return sal_True;
212 : : }
213 : 0 : return sal_False;
214 : : }
215 : : }
216 : :
217 [ # # ]: 0 : if( mxParaStyles->hasByName( aName ) )
218 : : {
219 : 0 : cachePos = mxParaStyles->getByName( aName );
220 : 0 : return sal_True;
221 : : }
222 : : else
223 : : {
224 [ # # ][ # # ]: 0 : uno::Sequence< rtl::OUString > sElementNames = mxParaStyles->getElementNames();
225 [ # # ]: 0 : for( sal_Int32 j = 0; j < sElementNames.getLength(); j++ )
226 : : {
227 [ # # ]: 0 : rtl::OUString aStyleName = sElementNames[j];
228 [ # # ]: 0 : if( aStyleName.equalsIgnoreAsciiCase( aName ) )
229 : : {
230 [ # # ][ # # ]: 0 : cachePos = mxParaStyles->getByName( aStyleName );
231 : 0 : return sal_True;
232 : : }
233 [ # # ][ # # ]: 0 : }
[ # # ]
234 : : }
235 : 0 : return sal_False;
236 : : }
237 : :
238 : : // XIndexAccess
239 : 0 : virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
240 : : {
241 [ # # ]: 0 : uno::Reference< container::XIndexAccess > xIndexAccess( mxParaStyles, uno::UNO_QUERY_THROW );
242 [ # # ][ # # ]: 0 : return xIndexAccess->getCount();
243 : : }
244 : 0 : virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
245 : : {
246 [ # # ][ # # ]: 0 : if ( Index < 0 || Index >= getCount() )
[ # # ][ # # ]
247 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
248 : :
249 [ # # ]: 0 : uno::Reference< container::XIndexAccess > xIndexAccess( mxParaStyles, uno::UNO_QUERY_THROW );
250 [ # # ][ # # ]: 0 : return xIndexAccess->getByIndex( Index );
251 : : }
252 : : // XEnumerationAccess
253 : 0 : virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException)
254 : : {
255 [ # # ][ # # ]: 0 : throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
256 : : }
257 : : };
258 : :
259 [ # # ]: 0 : class StylesEnumWrapper : public EnumerationHelper_BASE
260 : : {
261 : : SwVbaStyles* pStyles;
262 : : sal_Int32 nIndex;
263 : : public:
264 : 0 : StylesEnumWrapper( SwVbaStyles* _pStyles ) : pStyles( _pStyles ), nIndex( 1 ) {}
265 : 0 : virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
266 : : {
267 : 0 : return ( nIndex <= pStyles->getCount() );
268 : : }
269 : :
270 : 0 : virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
271 : : {
272 [ # # ]: 0 : if ( nIndex <= pStyles->getCount() )
273 [ # # ][ # # ]: 0 : return pStyles->Item( uno::makeAny( nIndex++ ), uno::Any() );
274 [ # # ]: 0 : throw container::NoSuchElementException();
275 : : }
276 : : };
277 : :
278 [ # # ][ # # ]: 0 : SwVbaStyles::SwVbaStyles( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ) throw ( script::BasicErrorException ) : SwVbaStyles_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new StyleCollectionHelper( xModel ) ) ), mxModel( xModel )
[ # # ]
279 : : {
280 [ # # ]: 0 : mxMSF.set( mxModel, uno::UNO_QUERY_THROW );
281 : 0 : }
282 : :
283 : : uno::Any
284 : 0 : SwVbaStyles::createCollectionObject(const uno::Any& aObject)
285 : : {
286 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xStyleProp( aObject, uno::UNO_QUERY_THROW );
287 [ # # ][ # # ]: 0 : return uno::makeAny( uno::Reference< word::XStyle >( new SwVbaStyle( this, mxContext, mxModel, xStyleProp ) ) );
[ # # ][ # # ]
[ # # ]
288 : : }
289 : :
290 : : uno::Type SAL_CALL
291 : 0 : SwVbaStyles::getElementType() throw (uno::RuntimeException)
292 : : {
293 : 0 : return word::XStyle::static_type(0);
294 : : }
295 : :
296 : : uno::Reference< container::XEnumeration > SAL_CALL
297 : 0 : SwVbaStyles::createEnumeration() throw (uno::RuntimeException)
298 : : {
299 [ # # ][ # # ]: 0 : return new StylesEnumWrapper( this );
300 : : }
301 : :
302 : : uno::Any SAL_CALL
303 : 0 : SwVbaStyles::Item( const uno::Any& Index1, const uno::Any& Index2 ) throw (uno::RuntimeException)
304 : : {
305 : : //handle WdBuiltinStyle
306 : 0 : sal_Int32 nIndex = 0;
307 [ # # ][ # # ]: 0 : if( ( Index1 >>= nIndex ) && ( nIndex < 0 ) )
[ # # ]
308 : : {
309 [ # # ]: 0 : for( const BuiltinStyleTable* pTable = aBuiltinStyleTable; pTable != NULL; pTable++ )
310 : : {
311 [ # # ]: 0 : if( nIndex == pTable->wdBuiltinStyle )
312 : : {
313 : 0 : rtl::OUString aStyleName = rtl::OUString::createFromAscii( pTable->pOOoStyleName );
314 [ # # ]: 0 : if( !aStyleName.isEmpty() )
315 : : {
316 : 0 : rtl::OUString aStyleType;
317 [ # # # # ]: 0 : switch( pTable->wdStyleType )
318 : : {
319 : : case word::WdStyleType::wdStyleTypeParagraph:
320 : : case word::WdStyleType::wdStyleTypeTable:
321 : : {
322 [ # # ]: 0 : aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") );
323 : 0 : break;
324 : : }
325 : : case word::WdStyleType::wdStyleTypeCharacter:
326 : : {
327 [ # # ]: 0 : aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharacterStyles") );
328 : 0 : break;
329 : : }
330 : : case word::WdStyleType::wdStyleTypeList:
331 : : {
332 : : // should use Paragraph style and set the property "NumberingStyleName"
333 [ # # ]: 0 : aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") );
334 : 0 : break;
335 : : }
336 : : default:
337 [ # # ]: 0 : DebugHelper::exception( SbERR_INTERNAL_ERROR, rtl::OUString() );
338 : : }
339 [ # # ]: 0 : uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxModel, uno::UNO_QUERY_THROW);
340 [ # # ][ # # ]: 0 : uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName( aStyleType ), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
[ # # ]
341 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xStyleProps( xStylesAccess->getByName( aStyleName ), uno::UNO_QUERY_THROW );
[ # # ]
342 : : // set the property "NumberingStyleName" if it is a listbullet
343 [ # # ]: 0 : if( pTable->wdStyleType == word::WdStyleType::wdStyleTypeList )
344 : : {
345 [ # # ][ # # ]: 0 : xStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingStyleName") ), uno::makeAny( aStyleName ) );
[ # # ][ # # ]
346 : : }
347 [ # # ][ # # ]: 0 : return uno::makeAny( uno::Reference< word::XStyle >( new SwVbaStyle( this, mxContext, mxModel, xStyleProps ) ) );
[ # # ][ # # ]
[ # # ]
348 : : }
349 : : else
350 : : {
351 : : OSL_TRACE("SwVbaStyles::Item: the builtin style type is not implemented");
352 [ # # ][ # # ]: 0 : throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
353 : 0 : }
354 : : }
355 : : }
356 : : }
357 [ # # ]: 0 : return SwVbaStyles_BASE::Item( Index1, Index2 );
358 : : }
359 : :
360 : : rtl::OUString
361 : 0 : SwVbaStyles::getServiceImplName()
362 : : {
363 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaStyles"));
364 : : }
365 : :
366 : : uno::Sequence< rtl::OUString >
367 : 0 : SwVbaStyles::getServiceNames()
368 : : {
369 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
370 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
371 : : {
372 : 0 : aServiceNames.realloc( 1 );
373 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.XStyles" ) );
374 : : }
375 : 0 : return aServiceNames;
376 : : }
377 : :
378 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|