LibreOffice Module sw (master)  1
vbatableofcontents.cxx
Go to the documentation of this file.
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 <com/sun/star/beans/XPropertySet.hpp>
22 #include <ooo/vba/word/WdTabLeader.hpp>
23 
24 using namespace ::ooo::vba;
25 using namespace ::com::sun::star;
26 
27 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 ) :
28  SwVbaTableOfContents_BASE( rParent, rContext ), mxTextDocument( xDoc ), mxDocumentIndex( xDocumentIndex )
29 {
30  mxTocProps.set( mxDocumentIndex, uno::UNO_QUERY_THROW );
31 }
32 
34 {
35 }
36 
38 {
39  sal_Int16 nLevel = 0;
40  mxTocProps->getPropertyValue("Level") >>= nLevel;
41  return nLevel;
42 }
43 
44 void SAL_CALL SwVbaTableOfContents::setLowerHeadingLevel( ::sal_Int32 _lowerheadinglevel )
45 {
46  mxTocProps->setPropertyValue("Level", uno::makeAny( sal_Int8( _lowerheadinglevel ) ) );
47 }
48 
49 ::sal_Int32 SAL_CALL SwVbaTableOfContents::getTabLeader()
50 {
51  // not support in Writer
52  return word::WdTabLeader::wdTabLeaderDots;
53 }
54 
55 void SAL_CALL SwVbaTableOfContents::setTabLeader( ::sal_Int32 /*_tableader*/ )
56 {
57  // not support in Writer
58 }
59 
61 {
62  bool bUseFields = false;
63  mxTocProps->getPropertyValue("CreateFromMarks") >>= bUseFields;
64  return bUseFields;
65 }
66 
67 void SAL_CALL SwVbaTableOfContents::setUseFields( sal_Bool _useFields )
68 {
69  mxTocProps->setPropertyValue("CreateFromMarks", uno::makeAny( _useFields ) );
70 }
71 
73 {
74  bool bUseOutlineLevels = false;
75  mxTocProps->getPropertyValue("CreateFromOutline") >>= bUseOutlineLevels;
76  return bUseOutlineLevels;
77 }
78 
79 void SAL_CALL SwVbaTableOfContents::setUseOutlineLevels( sal_Bool _useOutlineLevels )
80 {
81  mxTocProps->setPropertyValue("CreateFromOutline", uno::makeAny( _useOutlineLevels ) );
82 }
83 
85 {
86  uno::Reference< text::XTextContent > xTextContent( mxDocumentIndex, uno::UNO_QUERY_THROW );
87  mxTextDocument->getText()->removeTextContent( xTextContent );
88 }
89 
91 {
92  mxDocumentIndex->update();
93 }
94 
95 OUString
97 {
98  return "SwVbaTableOfContents";
99 }
100 
101 uno::Sequence< OUString >
103 {
104  static uno::Sequence< OUString > const aServiceNames
105  {
106  "ooo.vba.word.TableOfContents"
107  };
108  return aServiceNames;
109 }
110 
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual OUString getServiceImplName() override
signed char sal_Int8
Sequence< OUString > aServiceNames
virtual void SAL_CALL setLowerHeadingLevel(::sal_Int32 _lowerheadinglevel) override
css::uno::Reference< css::text::XTextDocument > mxTextDocument
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual void SAL_CALL Delete() override
virtual void SAL_CALL setUseOutlineLevels(sal_Bool _useOutlineLevels) override
virtual void SAL_CALL setUseFields(sal_Bool _useFields) override
virtual sal_Bool SAL_CALL getUseOutlineLevels() override
unsigned char sal_Bool
SwVbaTableOfContents(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< css::uno::XComponentContext > &rContext, const css::uno::Reference< css::text::XTextDocument > &xDoc, const css::uno::Reference< css::text::XDocumentIndex > &xDocumentIndex)
css::uno::Reference< css::text::XDocumentIndex > mxDocumentIndex
virtual sal_Bool SAL_CALL getUseFields() override
css::uno::Reference< css::beans::XPropertySet > mxTocProps
virtual void SAL_CALL Update() override
virtual ::sal_Int32 SAL_CALL getLowerHeadingLevel() override
virtual ~SwVbaTableOfContents() override
virtual ::sal_Int32 SAL_CALL getTabLeader() override
virtual void SAL_CALL setTabLeader(::sal_Int32 _tableader) override