1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: PageMasterImportContext.cxx,v $
*
* $Revision: 1.14 $
*
* last change: $Author: kz $ $Date: 2008-03-07 16:17:29 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_xmloff.hxx"
#ifndef _XMLOFF_PAGEMASTERIMPORTCONTEXT_HXX
#include "PageMasterImportContext.hxx"
#endif
#ifndef _XMLOFF_XMLNMSPE_HXX
#include "xmlnmspe.hxx"
#endif
#ifndef _XMLOFF_XMLTOKEN_HXX
#include <xmloff/xmltoken.hxx>
#endif
#ifndef _XMLOFF_PAGEMASTERPROPHDL_HXX_
#include "PageMasterPropHdl.hxx"
#endif
#ifndef _XMLOFF_PAGEPROPERTYSETCONTEXT_HXX
#include "PagePropertySetContext.hxx"
#endif
#ifndef _XMLOFF_PAGEPHEADERFOOTERCONTEXT_HXX
#include "PageHeaderFooterContext.hxx"
#endif
#ifndef _XMLOFF_PAGEMASTERPROPMAPPER_HXX
#include "PageMasterPropMapper.hxx"
#endif
#ifndef _XMLOFF_PAGEMASTERIMPORTPROPMAPPER_HXX
#include "PageMasterImportPropMapper.hxx"
#endif
#ifndef _XMLOFF_PAGEMASTERSTYLEMAP_HXX
#include <xmloff/PageMasterStyleMap.hxx>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
using namespace ::com::sun::star;
using namespace ::xmloff::token;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
void PageStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
const rtl::OUString& rLocalName,
const rtl::OUString& rValue )
{
// TODO: use a map here
if( XML_NAMESPACE_STYLE == nPrefixKey && IsXMLToken( rLocalName, XML_PAGE_USAGE ) )
{
sPageUsage = rValue;
}
else
{
XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
}
}
TYPEINIT1( PageStyleContext, XMLPropStyleContext );
PageStyleContext::PageStyleContext( SvXMLImport& rImport,
sal_uInt16 nPrfx, const rtl::OUString& rLName,
const uno::Reference< xml::sax::XAttributeList > & xAttrList,
SvXMLStylesContext& rStyles,
sal_Bool bDefaultStyle) :
XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, XML_STYLE_FAMILY_PAGE_MASTER, bDefaultStyle),
sPageUsage()
{
}
PageStyleContext::~PageStyleContext()
{
}
SvXMLImportContext *PageStyleContext::CreateChildContext(
sal_uInt16 nPrefix,
const rtl::OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList > & xAttrList )
{
SvXMLImportContext *pContext = NULL;
if( XML_NAMESPACE_STYLE == nPrefix &&
((IsXMLToken(rLocalName, XML_HEADER_STYLE )) ||
(IsXMLToken(rLocalName, XML_FOOTER_STYLE )) ) )
{
sal_Bool bHeader = IsXMLToken(rLocalName, XML_HEADER_STYLE);
UniReference < SvXMLImportPropertyMapper > xImpPrMap =
GetStyles()->GetImportPropertyMapper( GetFamily() );
if( xImpPrMap.is() )
{
const UniReference< XMLPropertySetMapper >& rMapper = xImpPrMap->getPropertySetMapper();
sal_Int32 nFlag;
if (bHeader)
nFlag = CTF_PM_HEADERFLAG;
else
nFlag = CTF_PM_FOOTERFLAG;
sal_Int32 nStartIndex (-1);
sal_Int32 nEndIndex (-1);
sal_Bool bFirst(sal_False);
sal_Bool bEnd(sal_False);
sal_Int32 nIndex = 0;
while ( nIndex < rMapper->GetEntryCount() && !bEnd)
{
if ((rMapper->GetEntryContextId( nIndex ) & CTF_PM_FLAGMASK) == nFlag)
{
if (!bFirst)
{
bFirst = sal_True;
nStartIndex = nIndex;
}
}
else if (bFirst)
{
bEnd = sal_True;
nEndIndex = nIndex;
}
nIndex++;
}
if (!bEnd)
nEndIndex = nIndex;
pContext = new PageHeaderFooterContext(GetImport(), nPrefix, rLocalName,
xAttrList, GetProperties(), xImpPrMap, nStartIndex, nEndIndex, bHeader);
}
}
if( XML_NAMESPACE_STYLE == nPrefix &&
IsXMLToken(rLocalName, XML_PAGE_LAYOUT_PROPERTIES) )
{
UniReference < SvXMLImportPropertyMapper > xImpPrMap =
GetStyles()->GetImportPropertyMapper( GetFamily() );
if( xImpPrMap.is() )
{
const UniReference< XMLPropertySetMapper >& rMapper = xImpPrMap->getPropertySetMapper();
sal_Int32 nEndIndex (-1);
sal_Bool bEnd(sal_False);
sal_Int32 nIndex = 0;
sal_Int16 nContextID;
while ( nIndex < rMapper->GetEntryCount() && !bEnd)
{
nContextID = rMapper->GetEntryContextId( nIndex );
if (nContextID && ((nContextID & CTF_PM_FLAGMASK) != XML_PM_CTF_START))
{
nEndIndex = nIndex;
bEnd = sal_True;
}
nIndex++;
}
if (!bEnd)
nEndIndex = nIndex;
PageContextType aType = Page;
pContext = new PagePropertySetContext( GetImport(), nPrefix,
rLocalName, xAttrList,
XML_TYPE_PROP_PAGE_LAYOUT,
GetProperties(),
xImpPrMap, 0, nEndIndex, aType);
}
}
if (!pContext)
pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName,
xAttrList );
return pContext;
}
void PageStyleContext::FillPropertySet(
const uno::Reference<beans::XPropertySet > & rPropSet )
{
XMLPropStyleContext::FillPropertySet(rPropSet);
if (sPageUsage.getLength())
{
uno::Any aPageUsage;
XMLPMPropHdl_PageStyleLayout aPageUsageHdl;
if (aPageUsageHdl.importXML(sPageUsage, aPageUsage, GetImport().GetMM100UnitConverter()))
rPropSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PageStyleLayout")), aPageUsage);
}
}
// text grid enhancement for better CJK support
//set default page layout style
void PageStyleContext::SetDefaults( )
{
Reference < XMultiServiceFactory > xFactory ( GetImport().GetModel(), UNO_QUERY);
if (xFactory.is())
{
Reference < XInterface > xInt = xFactory->createInstance (
rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.Defaults" ) ) );
Reference < beans::XPropertySet > xProperties ( xInt, UNO_QUERY );
if ( xProperties.is() )
FillPropertySet ( xProperties );
}
}
|