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