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 0 : SwVbaTableOfContents::~SwVbaTableOfContents()
34 : {
35 0 : }
36 :
37 0 : ::sal_Int32 SAL_CALL SwVbaTableOfContents::getLowerHeadingLevel() throw (uno::RuntimeException, std::exception)
38 : {
39 0 : sal_Int16 nLevel = 0;
40 0 : mxTocProps->getPropertyValue("Level") >>= nLevel;
41 0 : return nLevel;
42 : }
43 :
44 0 : void SAL_CALL SwVbaTableOfContents::setLowerHeadingLevel( ::sal_Int32 _lowerheadinglevel ) throw (uno::RuntimeException, std::exception)
45 : {
46 0 : mxTocProps->setPropertyValue("Level", uno::makeAny( sal_Int8( _lowerheadinglevel ) ) );
47 0 : }
48 :
49 0 : ::sal_Int32 SAL_CALL SwVbaTableOfContents::getTabLeader() throw (uno::RuntimeException, std::exception)
50 : {
51 : // not support in Writer
52 0 : return word::WdTabLeader::wdTabLeaderDots;
53 : }
54 :
55 0 : void SAL_CALL SwVbaTableOfContents::setTabLeader( ::sal_Int32 /*_tableader*/ ) throw (uno::RuntimeException, std::exception)
56 : {
57 : // not support in Writer
58 0 : }
59 :
60 0 : sal_Bool SAL_CALL SwVbaTableOfContents::getUseFields() throw (css::uno::RuntimeException, std::exception)
61 : {
62 0 : bool bUseFields = false;
63 0 : mxTocProps->getPropertyValue("CreateFromMarks") >>= bUseFields;
64 0 : return bUseFields;
65 : }
66 :
67 0 : void SAL_CALL SwVbaTableOfContents::setUseFields( sal_Bool _useFields ) throw (css::uno::RuntimeException, std::exception)
68 : {
69 0 : mxTocProps->setPropertyValue("CreateFromMarks", uno::makeAny( _useFields ) );
70 0 : }
71 :
72 0 : sal_Bool SAL_CALL SwVbaTableOfContents::getUseOutlineLevels() throw (css::uno::RuntimeException, std::exception)
73 : {
74 0 : bool bUseOutlineLevels = false;
75 0 : mxTocProps->getPropertyValue("CreateFromOutline") >>= bUseOutlineLevels;
76 0 : return bUseOutlineLevels;
77 : }
78 :
79 0 : void SAL_CALL SwVbaTableOfContents::setUseOutlineLevels( sal_Bool _useOutlineLevels ) throw (css::uno::RuntimeException, std::exception)
80 : {
81 0 : mxTocProps->setPropertyValue("CreateFromOutline", uno::makeAny( _useOutlineLevels ) );
82 0 : }
83 :
84 0 : void SAL_CALL SwVbaTableOfContents::Delete( ) throw (uno::RuntimeException, std::exception)
85 : {
86 0 : uno::Reference< text::XTextContent > xTextContent( mxDocumentIndex, uno::UNO_QUERY_THROW );
87 0 : mxTextDocument->getText()->removeTextContent( xTextContent );
88 0 : }
89 :
90 0 : void SAL_CALL SwVbaTableOfContents::Update( ) throw (uno::RuntimeException, std::exception)
91 : {
92 0 : mxDocumentIndex->update();
93 0 : }
94 :
95 : OUString
96 0 : SwVbaTableOfContents::getServiceImplName()
97 : {
98 0 : return OUString("SwVbaTableOfContents");
99 : }
100 :
101 : uno::Sequence< OUString >
102 0 : SwVbaTableOfContents::getServiceNames()
103 : {
104 0 : static uno::Sequence< OUString > aServiceNames;
105 0 : if ( aServiceNames.getLength() == 0 )
106 : {
107 0 : aServiceNames.realloc( 1 );
108 0 : aServiceNames[ 0 ] = "ooo.vba.word.TableOfContents";
109 : }
110 0 : return aServiceNames;
111 : }
112 :
113 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|