Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include "vbaheaderfooter.hxx"
29 : : #include <vbahelper/vbahelper.hxx>
30 : : #include <tools/diagnose_ex.h>
31 : : #include <ooo/vba/word/WdHeaderFooterIndex.hpp>
32 : : #include <com/sun/star/text/XText.hpp>
33 : : #include <com/sun/star/text/XTextDocument.hpp>
34 : : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
35 : : #include "vbarange.hxx"
36 : : #include <vbahelper/vbashapes.hxx>
37 : :
38 : : using namespace ::ooo::vba;
39 : : using namespace ::com::sun::star;
40 : :
41 : 0 : SwVbaHeaderFooter::SwVbaHeaderFooter( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& rProps, sal_Bool isHeader, sal_Int32 index ) throw ( uno::RuntimeException ) : SwVbaHeaderFooter_BASE( rParent, rContext ), mxModel( xModel ), mxPageStyleProps( rProps ), mbHeader( isHeader ), mnIndex( index )
42 : : {
43 : 0 : }
44 : :
45 : 0 : sal_Bool SAL_CALL SwVbaHeaderFooter::getIsHeader() throw (uno::RuntimeException)
46 : : {
47 : 0 : return mbHeader;
48 : : }
49 : :
50 : 0 : sal_Bool SAL_CALL SwVbaHeaderFooter::getLinkToPrevious() throw (uno::RuntimeException)
51 : : {
52 : : // seems always false
53 : 0 : return sal_False;
54 : : }
55 : :
56 : 0 : void SAL_CALL SwVbaHeaderFooter::setLinkToPrevious( ::sal_Bool /*_linktoprevious*/ ) throw (uno::RuntimeException)
57 : : {
58 : : // not support in Writer
59 : 0 : }
60 : :
61 : 0 : uno::Reference< word::XRange > SAL_CALL SwVbaHeaderFooter::getRange() throw (uno::RuntimeException)
62 : : {
63 : 0 : rtl::OUString sPropsNameText;
64 [ # # ]: 0 : if( mbHeader )
65 : : {
66 [ # # ]: 0 : sPropsNameText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderText") );
67 : : }
68 : : else
69 : : {
70 [ # # ]: 0 : sPropsNameText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterText") );
71 : : }
72 [ # # ]: 0 : if( mnIndex == word::WdHeaderFooterIndex::wdHeaderFooterEvenPages )
73 : : {
74 [ # # ]: 0 : sPropsNameText.concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Left") ) );
75 : : }
76 : :
77 [ # # ][ # # ]: 0 : uno::Reference< text::XText > xText( mxPageStyleProps->getPropertyValue( sPropsNameText ), uno::UNO_QUERY_THROW );
[ # # ]
78 [ # # ]: 0 : uno::Reference< text::XTextDocument > xDocument( mxModel, uno::UNO_QUERY_THROW );
79 [ # # ][ # # ]: 0 : return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, xDocument, xText->getStart(), xText->getEnd(), xText ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
80 : : }
81 : :
82 : : uno::Any SAL_CALL
83 : 0 : SwVbaHeaderFooter::Shapes( const uno::Any& index ) throw (uno::RuntimeException)
84 : : {
85 : : // #FIXME: only get the shapes in the current header/footer
86 [ # # ]: 0 : uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxModel, uno::UNO_QUERY_THROW );
87 : : //uno::Reference< drawing::XShapes > xShapes( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
88 [ # # ][ # # ]: 0 : uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
[ # # ]
89 [ # # ][ # # ]: 0 : uno::Reference< XCollection > xCol( new ScVbaShapes( this, mxContext, xIndexAccess, mxModel ) );
[ # # ][ # # ]
90 [ # # ]: 0 : if ( index.hasValue() )
91 [ # # ][ # # ]: 0 : return xCol->Item( index, uno::Any() );
92 [ # # ]: 0 : return uno::makeAny( xCol );
93 : : }
94 : :
95 : : rtl::OUString
96 : 0 : SwVbaHeaderFooter::getServiceImplName()
97 : : {
98 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaHeaderFooter"));
99 : : }
100 : :
101 : : uno::Sequence< rtl::OUString >
102 : 0 : SwVbaHeaderFooter::getServiceNames()
103 : : {
104 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
105 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
106 : : {
107 : 0 : aServiceNames.realloc( 1 );
108 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Pane" ) );
109 : : }
110 : 0 : return aServiceNames;
111 : : }
112 : :
113 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|