Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #include "vbatableofcontents.hxx"
20 : #include <vbahelper/vbahelper.hxx>
21 : #include <tools/diagnose_ex.h>
22 : #include <ooo/vba/word/WdTabLeader.hpp>
23 :
24 : using namespace ::ooo::vba;
25 : using namespace ::com::sun::star;
26 :
27 0 : SwVbaTableOfContents::SwVbaTableOfContents( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& xDoc, const uno::Reference< text::XDocumentIndex >& xDocumentIndex ) throw ( uno::RuntimeException ) :
28 0 : SwVbaTableOfContents_BASE( rParent, rContext ), mxTextDocument( xDoc ), mxDocumentIndex( xDocumentIndex )
29 : {
30 0 : mxTocProps.set( mxDocumentIndex, uno::UNO_QUERY_THROW );
31 0 : }
32 :
33 :
34 0 : SwVbaTableOfContents::~SwVbaTableOfContents()
35 : {
36 0 : }
37 :
38 0 : ::sal_Int32 SAL_CALL SwVbaTableOfContents::getLowerHeadingLevel() throw (uno::RuntimeException)
39 : {
40 0 : sal_Int16 nLevel = 0;
41 0 : mxTocProps->getPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Level") ) ) >>= nLevel;
42 0 : return nLevel;
43 : }
44 :
45 0 : void SAL_CALL SwVbaTableOfContents::setLowerHeadingLevel( ::sal_Int32 _lowerheadinglevel ) throw (uno::RuntimeException)
46 : {
47 0 : mxTocProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Level") ), uno::makeAny( sal_Int8( _lowerheadinglevel ) ) );
48 0 : }
49 :
50 0 : ::sal_Int32 SAL_CALL SwVbaTableOfContents::getTabLeader() throw (uno::RuntimeException)
51 : {
52 : // not support in Writer
53 0 : return word::WdTabLeader::wdTabLeaderDots;
54 : }
55 :
56 0 : void SAL_CALL SwVbaTableOfContents::setTabLeader( ::sal_Int32 /*_tableader*/ ) throw (uno::RuntimeException)
57 : {
58 : // not support in Writer
59 0 : }
60 :
61 0 : ::sal_Bool SAL_CALL SwVbaTableOfContents::getUseFields() throw (css::uno::RuntimeException)
62 : {
63 0 : sal_Bool bUseFields = sal_False;
64 0 : mxTocProps->getPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CreateFromMarks") ) ) >>= bUseFields;
65 0 : return bUseFields;
66 : }
67 :
68 0 : void SAL_CALL SwVbaTableOfContents::setUseFields( ::sal_Bool _useFields ) throw (css::uno::RuntimeException)
69 : {
70 0 : mxTocProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CreateFromMarks") ), uno::makeAny( _useFields ) );
71 0 : }
72 :
73 0 : ::sal_Bool SAL_CALL SwVbaTableOfContents::getUseOutlineLevels() throw (css::uno::RuntimeException)
74 : {
75 0 : sal_Bool bUseOutlineLevels = sal_False;
76 0 : mxTocProps->getPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CreateFromOutline") ) ) >>= bUseOutlineLevels;
77 0 : return bUseOutlineLevels;
78 : }
79 :
80 0 : void SAL_CALL SwVbaTableOfContents::setUseOutlineLevels( ::sal_Bool _useOutlineLevels ) throw (css::uno::RuntimeException)
81 : {
82 0 : mxTocProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CreateFromOutline") ), uno::makeAny( _useOutlineLevels ) );
83 0 : }
84 :
85 0 : void SAL_CALL SwVbaTableOfContents::Delete( ) throw (uno::RuntimeException)
86 : {
87 0 : uno::Reference< text::XTextContent > xTextContent( mxDocumentIndex, uno::UNO_QUERY_THROW );
88 0 : mxTextDocument->getText()->removeTextContent( xTextContent );
89 0 : }
90 :
91 0 : void SAL_CALL SwVbaTableOfContents::Update( ) throw (uno::RuntimeException)
92 : {
93 0 : mxDocumentIndex->update();
94 0 : }
95 :
96 : rtl::OUString
97 0 : SwVbaTableOfContents::getServiceImplName()
98 : {
99 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaTableOfContents"));
100 : }
101 :
102 : uno::Sequence< rtl::OUString >
103 0 : SwVbaTableOfContents::getServiceNames()
104 : {
105 0 : static uno::Sequence< rtl::OUString > aServiceNames;
106 0 : if ( aServiceNames.getLength() == 0 )
107 : {
108 0 : aServiceNames.realloc( 1 );
109 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.TableOfContents" ) );
110 : }
111 0 : return aServiceNames;
112 : }
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|