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 : :
29 : : #include <xmloff/xmlnmspe.hxx>
30 : : #include <xmloff/xmltoken.hxx>
31 : : #include <com/sun/star/text/XText.hpp>
32 : : #include <com/sun/star/beans/XPropertySet.hpp>
33 : : #include "XMLTableMasterPageExport.hxx"
34 : : #include <comphelper/extract.hxx>
35 : :
36 : : #include "unonames.hxx"
37 : : #include "xmlexprt.hxx"
38 : :
39 : : using ::rtl::OUString;
40 : : using namespace ::com::sun::star;
41 : : using namespace ::com::sun::star::uno;
42 : : using namespace ::com::sun::star::text;
43 : : using namespace ::com::sun::star::beans;
44 : : using namespace xmloff::token;
45 : :
46 : 4 : XMLTableMasterPageExport::XMLTableMasterPageExport( ScXMLExport& rExp ) :
47 : 4 : XMLTextMasterPageExport ( rExp )
48 : : {
49 : 4 : }
50 : :
51 : 4 : XMLTableMasterPageExport::~XMLTableMasterPageExport()
52 : : {
53 [ - + ]: 8 : }
54 : :
55 : 116 : void XMLTableMasterPageExport::exportHeaderFooterContent(
56 : : const Reference< XText >& rText,
57 : : sal_Bool bAutoStyles, sal_Bool bProgress )
58 : : {
59 : : OSL_ENSURE( rText.is(), "There is the text" );
60 : :
61 [ + + ]: 116 : if( bAutoStyles )
62 : 96 : GetExport().GetTextParagraphExport()
63 [ + - ][ + - ]: 96 : ->collectTextAutoStyles( rText, bProgress, false );
64 : : else
65 : : {
66 [ + - ][ + - ]: 20 : GetExport().GetTextParagraphExport()->exportTextDeclarations( rText );
67 [ + - ][ + - ]: 20 : GetExport().GetTextParagraphExport()->exportText( rText, bProgress, false );
68 : : }
69 : 116 : }
70 : :
71 : 32 : void XMLTableMasterPageExport::exportHeaderFooter(const com::sun::star::uno::Reference < com::sun::star::sheet::XHeaderFooterContent >& xHeaderFooter,
72 : : const XMLTokenEnum aName,
73 : : const sal_Bool bDisplay)
74 : : {
75 [ + - ]: 32 : if( xHeaderFooter.is() )
76 : : {
77 [ + - ][ + - ]: 32 : Reference < XText > xCenter(xHeaderFooter->getCenterText());
78 [ + - ][ + - ]: 32 : Reference < XText > xLeft(xHeaderFooter->getLeftText());
79 [ + - ][ + - ]: 32 : Reference < XText > xRight(xHeaderFooter->getRightText());
80 [ + - ][ + - ]: 32 : if (xCenter.is() && xLeft.is() && xRight.is())
[ + - ][ + - ]
81 : : {
82 [ + - ][ + - ]: 32 : rtl::OUString sCenter (xCenter->getString());
83 [ + - ][ + - ]: 32 : rtl::OUString sLeft (xLeft->getString());
84 [ + - ][ + - ]: 32 : rtl::OUString sRight (xRight->getString());
85 : :
86 [ + + ]: 32 : if( !bDisplay )
87 : 16 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
88 [ + - ]: 16 : XML_DISPLAY, XML_FALSE );
89 : 32 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
90 [ + - ]: 32 : aName, sal_True, sal_True );
91 [ + + ][ + - ]: 32 : if (!sCenter.isEmpty() && sLeft.isEmpty() && sRight.isEmpty())
[ + - ][ + + ]
92 [ + - ]: 12 : exportHeaderFooterContent( xCenter, false, false );
93 : : else
94 : : {
95 [ + + ]: 20 : if (!sLeft.isEmpty())
96 : : {
97 : 4 : SvXMLElementExport aSubElem( GetExport(), XML_NAMESPACE_STYLE,
98 [ + - ]: 4 : XML_REGION_LEFT, sal_True, sal_True );
99 [ + - ][ + - ]: 4 : exportHeaderFooterContent( xLeft, false, false );
100 : : }
101 [ - + ]: 20 : if (!sCenter.isEmpty())
102 : : {
103 : 0 : SvXMLElementExport aSubElem( GetExport(), XML_NAMESPACE_STYLE,
104 [ # # ]: 0 : XML_REGION_CENTER, sal_True, sal_True );
105 [ # # ][ # # ]: 0 : exportHeaderFooterContent( xCenter, false, false );
106 : : }
107 [ + + ]: 20 : if (!sRight.isEmpty())
108 : : {
109 : 4 : SvXMLElementExport aSubElem( GetExport(), XML_NAMESPACE_STYLE,
110 [ + - ]: 4 : XML_REGION_RIGHT, sal_True, sal_True );
111 [ + - ][ + - ]: 4 : exportHeaderFooterContent( xRight, false, false );
112 : : }
113 [ + - ]: 32 : }
114 : 32 : }
115 : : }
116 : 32 : }
117 : :
118 : 16 : void XMLTableMasterPageExport::exportMasterPageContent(
119 : : const Reference < XPropertySet > & rPropSet,
120 : : sal_Bool bAutoStyles )
121 : : {
122 [ + - ][ + - ]: 16 : Reference < sheet::XHeaderFooterContent > xHeader(rPropSet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_RIGHTHDRCON ) ) ), uno::UNO_QUERY);
[ + - ][ + - ]
123 : :
124 [ + - ][ + - ]: 16 : Reference < sheet::XHeaderFooterContent > xHeaderLeft(rPropSet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_LEFTHDRCONT ) ) ), uno::UNO_QUERY);
[ + - ][ + - ]
125 : :
126 [ + - ][ + - ]: 16 : Reference < sheet::XHeaderFooterContent > xFooter(rPropSet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_RIGHTFTRCON ) ) ), uno::UNO_QUERY);
[ + - ][ + - ]
127 : :
128 [ + - ][ + - ]: 16 : Reference < sheet::XHeaderFooterContent > xFooterLeft(rPropSet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_LEFTFTRCONT ) ) ), uno::UNO_QUERY);
[ + - ][ + - ]
129 : :
130 [ + + ]: 16 : if( bAutoStyles )
131 : : {
132 [ + - ]: 8 : if( xHeader.is() )
133 : : {
134 [ + - ][ + - ]: 8 : exportHeaderFooterContent( xHeader->getCenterText(), sal_True, false );
[ + - ]
135 [ + - ][ + - ]: 8 : exportHeaderFooterContent( xHeader->getLeftText(), sal_True, false );
[ + - ]
136 [ + - ][ + - ]: 8 : exportHeaderFooterContent( xHeader->getRightText(), sal_True, false );
[ + - ]
137 : : }
138 [ + - ]: 8 : if( xHeaderLeft.is())
139 : : {
140 [ + - ][ + - ]: 8 : exportHeaderFooterContent( xHeaderLeft->getCenterText(), sal_True, false );
[ + - ]
141 [ + - ][ + - ]: 8 : exportHeaderFooterContent( xHeaderLeft->getLeftText(), sal_True, false );
[ + - ]
142 [ + - ][ + - ]: 8 : exportHeaderFooterContent( xHeaderLeft->getRightText(), sal_True, false );
[ + - ]
143 : : }
144 [ + - ]: 8 : if( xFooter.is() )
145 : : {
146 [ + - ][ + - ]: 8 : exportHeaderFooterContent( xFooter->getCenterText(), sal_True, false );
[ + - ]
147 [ + - ][ + - ]: 8 : exportHeaderFooterContent( xFooter->getLeftText(), sal_True, false );
[ + - ]
148 [ + - ][ + - ]: 8 : exportHeaderFooterContent( xFooter->getRightText(), sal_True, false );
[ + - ]
149 : : }
150 [ + - ]: 8 : if( xFooterLeft.is())
151 : : {
152 [ + - ][ + - ]: 8 : exportHeaderFooterContent( xFooterLeft->getCenterText(), sal_True, false );
[ + - ]
153 [ + - ][ + - ]: 8 : exportHeaderFooterContent( xFooterLeft->getLeftText(), sal_True, false );
[ + - ]
154 [ + - ][ + - ]: 8 : exportHeaderFooterContent( xFooterLeft->getRightText(), sal_True, false );
[ + - ]
155 : : }
156 : : }
157 : : else
158 : : {
159 [ + - ][ + - ]: 8 : sal_Bool bHeader(::cppu::any2bool(rPropSet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_HDRON ) ) )));
[ + - ][ + - ]
160 : :
161 [ + - ]: 8 : exportHeaderFooter(xHeader, XML_HEADER, bHeader );
162 : :
163 [ + - ][ + - ]: 8 : sal_Bool bLeftHeader(!::cppu::any2bool(rPropSet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_HDRSHARED ) ) )) && bHeader);
[ + - ][ + - ]
[ - + ][ # # ]
[ + - ][ + - ]
[ # # # # ]
164 : :
165 [ + - ]: 8 : exportHeaderFooter( xHeaderLeft, XML_HEADER_LEFT, bLeftHeader );
166 : :
167 [ + - ][ + - ]: 8 : sal_Bool bFooter(::cppu::any2bool(rPropSet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_FTRON ) ) )));
[ + - ][ + - ]
168 : :
169 [ + - ]: 8 : exportHeaderFooter( xFooter, XML_FOOTER, bFooter );
170 : :
171 [ + - ][ + - ]: 8 : sal_Bool bLeftFooter = (!::cppu::any2bool(rPropSet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_UNO_PAGE_FTRSHARED ) ) )) && bFooter);
[ + - ][ + - ]
[ - + ][ # # ]
[ + - ][ + - ]
[ # # # # ]
172 : :
173 [ + - ]: 8 : exportHeaderFooter( xFooterLeft, XML_FOOTER_LEFT, bLeftFooter );
174 : 16 : }
175 : 16 : }
176 : :
177 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|