LibreOffice Module sw (master) 1
vbaheaderfooter.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 "vbaheaderfooter.hxx"
20#include <ooo/vba/word/WdHeaderFooterIndex.hpp>
21#include <com/sun/star/beans/XPropertySet.hpp>
22#include <com/sun/star/text/XText.hpp>
23#include <com/sun/star/text/XTextDocument.hpp>
24#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
25#include "vbarange.hxx"
26#include <utility>
28
29using namespace ::ooo::vba;
30using namespace ::com::sun::star;
31
32SwVbaHeaderFooter::SwVbaHeaderFooter( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< frame::XModel > xModel, uno::Reference< beans::XPropertySet > xProps, bool isHeader, sal_Int32 index ) : SwVbaHeaderFooter_BASE( rParent, rContext ), mxModel(std::move( xModel )), mxPageStyleProps(std::move( xProps )), mbHeader( isHeader ), mnIndex( index )
33{
34}
35
37{
38 return mbHeader;
39}
40
42{
43 // seems always false
44 return false;
45}
46
47void SAL_CALL SwVbaHeaderFooter::setLinkToPrevious( sal_Bool /*_linktoprevious*/ )
48{
49 // not support in Writer
50}
51
52uno::Reference< word::XRange > SAL_CALL SwVbaHeaderFooter::getRange()
53{
54 OUString sPropsNameText;
55 if( mbHeader )
56 {
57 sPropsNameText = "HeaderText";
58 }
59 else
60 {
61 sPropsNameText = "FooterText";
62 }
63 if( mnIndex == word::WdHeaderFooterIndex::wdHeaderFooterEvenPages )
64 {
65 sPropsNameText += "Left";
66 }
67
68 uno::Reference< text::XText > xText( mxPageStyleProps->getPropertyValue( sPropsNameText ), uno::UNO_QUERY_THROW );
69 uno::Reference< text::XTextDocument > xDocument( mxModel, uno::UNO_QUERY_THROW );
70 return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, xDocument, xText->getStart(), xText->getEnd(), xText ) );
71}
72
73uno::Any SAL_CALL
75{
76 // #FIXME: only get the shapes in the current header/footer
77 uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxModel, uno::UNO_QUERY_THROW );
78 //uno::Reference< drawing::XShapes > xShapes( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
79 uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
80 uno::Reference< XCollection > xCol( new ScVbaShapes( this, mxContext, xIndexAccess, mxModel ) );
81 if ( index.hasValue() )
82 return xCol->Item( index, uno::Any() );
83 return uno::Any( xCol );
84}
85
86OUString
88{
89 return "SwVbaHeaderFooter";
90}
91
92uno::Sequence< OUString >
94{
95 static uno::Sequence< OUString > const aServiceNames
96 {
97 "ooo.vba.word.Pane"
98 };
99 return aServiceNames;
100}
101
102/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
int mnIndex
css::uno::Reference< css::frame::XModel2 > mxModel
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual sal_Bool SAL_CALL getLinkToPrevious() override
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual css::uno::Any SAL_CALL Shapes(const css::uno::Any &aIndex) override
SwVbaHeaderFooter(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< css::uno::XComponentContext > &rContext, css::uno::Reference< css::frame::XModel > xModel, css::uno::Reference< css::beans::XPropertySet > xProps, bool isHeader, sal_Int32 index)
virtual OUString getServiceImplName() override
virtual css::uno::Reference< ::ooo::vba::word::XRange > SAL_CALL getRange() override
css::uno::Reference< css::beans::XPropertySet > mxPageStyleProps
virtual sal_Bool SAL_CALL getIsHeader() override
css::uno::Reference< css::frame::XModel > mxModel
virtual void SAL_CALL setLinkToPrevious(sal_Bool _linktoprevious) override
Sequence< OUString > aServiceNames
index
Reference< XModel > xModel
unsigned char sal_Bool