1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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"
27 #include <vbahelper/vbashapes.hxx>
29 using namespace ::ooo::vba
;
30 using namespace ::com::sun::star
;
32 SwVbaHeaderFooter::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
)
36 sal_Bool SAL_CALL
SwVbaHeaderFooter::getIsHeader()
41 sal_Bool SAL_CALL
SwVbaHeaderFooter::getLinkToPrevious()
47 void SAL_CALL
SwVbaHeaderFooter::setLinkToPrevious( sal_Bool
/*_linktoprevious*/ )
49 // not support in Writer
52 uno::Reference
< word::XRange
> SAL_CALL
SwVbaHeaderFooter::getRange()
54 OUString sPropsNameText
;
57 sPropsNameText
= "HeaderText";
61 sPropsNameText
= "FooterText";
63 if( mnIndex
== word::WdHeaderFooterIndex::wdHeaderFooterEvenPages
)
65 sPropsNameText
+= "Left";
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
) );
74 SwVbaHeaderFooter::Shapes( const uno::Any
& index
)
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
);
87 SwVbaHeaderFooter::getServiceImplName()
89 return "SwVbaHeaderFooter";
92 uno::Sequence
< OUString
>
93 SwVbaHeaderFooter::getServiceNames()
95 static uno::Sequence
< OUString
> const aServiceNames
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */