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