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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
/*************************************************************************
*
* $RCSfile: txtimppr.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 17:07:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 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
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#ifndef _COM_SUN_STAR_TABLE_BORDERLINE_HPP_
#include <com/sun/star/table/BorderLine.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_TEXTCONTENTANCHORTYPE_HPP
#include <com/sun/star/text/TextContentAnchorType.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_VERTORIENTATION_HPP_
#include <com/sun/star/text/VertOrientation.hpp>
#endif
#ifndef _XMLOFF_TEXTPRMAP_HXX_
#include "txtprmap.hxx"
#endif
#ifndef _XMLOFF_TXTIMPPR_HXX
#include "txtimppr.hxx"
#endif
#define XML_LINE_LEFT 0
#define XML_LINE_RIGHT 0
#define XML_LINE_TOP 0
#define XML_LINE_BOTTOM 0
#define MIN_BORDER_DIST 49
using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::table;
using namespace ::com::sun::star::text;
XMLTextImportPropertyMapper::XMLTextImportPropertyMapper(
const UniReference< XMLPropertySetMapper >& rMapper ) :
SvXMLImportPropertyMapper( rMapper )
{
}
XMLTextImportPropertyMapper::~XMLTextImportPropertyMapper()
{
}
void XMLTextImportPropertyMapper::finished(
::std::vector< XMLPropertyState >& rProperties ) const
{
XMLPropertyState* pFontName = 0;
XMLPropertyState* pFontStyleName = 0;
XMLPropertyState* pFontFamily = 0;
XMLPropertyState* pFontPitch = 0;
XMLPropertyState* pFontCharSet = 0;
XMLPropertyState* pAllBorderDistance = 0;
XMLPropertyState* pBorderDistances[4] = { 0, 0, 0, 0 };
XMLPropertyState* pNewBorderDistances[4] = { 0, 0, 0, 0 };
XMLPropertyState* pAllBorder = 0;
XMLPropertyState* pBorders[4] = { 0, 0, 0, 0 };
XMLPropertyState* pNewBorders[4] = { 0, 0, 0, 0 };
XMLPropertyState* pAllBorderWidth = 0;
XMLPropertyState* pBorderWidths[4] = { 0, 0, 0, 0 };
XMLPropertyState* pAnchorType = 0;
XMLPropertyState* pVertOrient = 0;
XMLPropertyState* pVertOrientRelAsChar = 0;
for( ::std::vector< XMLPropertyState >::iterator property = rProperties.begin();
property != rProperties.end();
property++ )
{
switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ) )
{
case CTF_FONTNAME: pFontName = property; break;
case CTF_FONTSTYLENAME: pFontStyleName = property; break;
case CTF_FONTFAMILY: pFontFamily = property; break;
case CTF_FONTPITCH: pFontPitch = property; break;
case CTF_FONTCHARSET: pFontCharSet = property; break;
case CTF_ALLBORDERDISTANCE: pAllBorderDistance = property; break;
case CTF_LEFTBORDERDISTANCE: pBorderDistances[XML_LINE_LEFT] = property; break;
case CTF_RIGHTBORDERDISTANCE: pBorderDistances[XML_LINE_RIGHT] = property; break;
case CTF_TOPBORDERDISTANCE: pBorderDistances[XML_LINE_TOP] = property; break;
case CTF_BOTTOMBORDERDISTANCE: pBorderDistances[XML_LINE_BOTTOM] = property; break;
case CTF_ALLBORDER: pAllBorder = property; break;
case CTF_LEFTBORDER: pBorders[XML_LINE_LEFT] = property; break;
case CTF_RIGHTBORDER: pBorders[XML_LINE_RIGHT] = property; break;
case CTF_TOPBORDER: pBorders[XML_LINE_TOP] = property; break;
case CTF_BOTTOMBORDER: pBorders[XML_LINE_BOTTOM] = property; break;
case CTF_ALLBORDERWIDTH: pAllBorderWidth = property; break;
case CTF_LEFTBORDERWIDTH: pBorderWidths[XML_LINE_LEFT] = property; break;
case CTF_RIGHTBORDERWIDTH: pBorderWidths[XML_LINE_RIGHT] = property; break;
case CTF_TOPBORDERWIDTH: pBorderWidths[XML_LINE_TOP] = property; break;
case CTF_BOTTOMBORDERWIDTH: pBorderWidths[XML_LINE_BOTTOM] = property; break;
case CTF_ANCHORTYPE: pAnchorType = property; break;
case CTF_VERTICALPOS: pVertOrient = property; break;
case CTF_VERTICALREL_ASCHAR: pVertOrientRelAsChar = property; break;
}
}
if( pFontName )
{
OUString sName;
pFontName->maValue >>= sName;
if( !sName.getLength() )
{
pFontName->mnIndex = -1;
pFontName = 0;
}
}
if( !pFontName )
{
if( pFontStyleName )
pFontStyleName->mnIndex = -1;
if( pFontFamily )
pFontFamily->mnIndex = -1;
if( pFontPitch )
pFontPitch->mnIndex = -1;
if( pFontCharSet )
pFontCharSet->mnIndex = -1;
}
for( sal_uInt16 i=0; i<4; i++ )
{
if( pAllBorderDistance && !pBorderDistances[i] )
{
#ifndef PRODUCT
sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
pAllBorderDistance->mnIndex + i + 1 );
DBG_ASSERT( nTmp >= CTF_LEFTBORDERDISTANCE &&
nTmp <= CTF_BOTTOMBORDERDISTANCE,
"wrong property context id" );
#endif
pNewBorderDistances[i] =
new XMLPropertyState( pAllBorderDistance->mnIndex + i + 1,
pAllBorderDistance->maValue );
pBorderDistances[i] = pNewBorderDistances[i];
}
if( pAllBorder && !pBorders[i] )
{
#ifndef PRODUCT
sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
pAllBorder->mnIndex + i + 1 );
DBG_ASSERT( nTmp >= CTF_LEFTBORDER && nTmp <= CTF_BOTTOMBORDER,
"wrong property context id" );
#endif
pNewBorders[i] = new XMLPropertyState( pAllBorder->mnIndex + i + 1,
pAllBorder->maValue );
pBorders[i] = pNewBorders[i];
}
if( !pBorderWidths[i] )
pBorderWidths[i] = pAllBorderWidth;
else
pBorderWidths[i]->mnIndex = -1;
#ifdef XML_CHECK_UI_CONSTRAINS
sal_Bool bHasBorder = sal_False;
if( pBorders[i] )
{
table::BorderLine aBorderLine;
pBorders[i]->maValue >>= aBorderLine;
if( pBorderWidths[i] )
{
table::BorderLine aBorderLineWidth;
pBorderWidths[i]->maValue >>= aBorderLineWidth;
aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
pBorders[i]->maValue <<= aBorderLine;
}
bHasBorder = (aBorderLine.OuterLineWidth +
aBorderLine.InnerLineWidth) > 0;
}
if( bHasBorder )
{
if( !pBorderDistances[i] )
{
#ifndef PRODUCT
sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
pBorders[i]->mnIndex + 5 );
DBG_ASSERT( nTmp >= CTF_LEFTBORDERDISTANCE &&
nTmp <= CTF_BOTTOMBORDERDISTANCE,
"wrong property context id" );
#endif
pNewBorderDistances[i] =
new XMLPropertyState( pBorders[i]->mnIndex + 5 );
pNewBorderDistances[i]->maValue <<= (sal_Int32)MIN_BORDER_DIST;
pBorderDistances[i] = pNewBorderDistances[i];
}
else
{
sal_Int32 nDist;
pBorderDistances[i]->maValue >>= nDist;
if( nDist < MIN_BORDER_DIST )
pBorderDistances[i]->maValue <<= (sal_Int32)MIN_BORDER_DIST;
}
}
else
{
if( pBorderDistances[i] )
{
sal_Int32 nDist;
pBorderDistances[i]->maValue >>= nDist;
if( nDist > 0 )
pBorderDistances[i]->maValue <<= (sal_Int32)0;
}
}
#else
if( pBorders[i] && pBorderWidths[i] )
{
table::BorderLine aBorderLine;
pBorders[i]->maValue >>= aBorderLine;
table::BorderLine aBorderLineWidth;
pBorderWidths[i]->maValue >>= aBorderLineWidth;
aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
pBorders[i]->maValue <<= aBorderLine;
}
#endif
}
if( pAllBorderDistance )
pAllBorderDistance->mnIndex = -1;
if( pAllBorder )
pAllBorder->mnIndex = -1;
if( pAllBorderWidth )
pAllBorderWidth->mnIndex = -1;
// insert newly created properties. This inavlidates all iterators!
for( i=0; i<4; i++ )
{
if( pNewBorderDistances[i] )
{
rProperties.push_back( *pNewBorderDistances[i] );
delete pNewBorderDistances[i];
}
if( pNewBorders[i] )
{
rProperties.push_back( *pNewBorders[i] );
delete pNewBorders[i];
}
}
if( pVertOrient && pVertOrientRelAsChar )
{
TextContentAnchorType eAnchorType;
if( pAnchorType && (pAnchorType->maValue >>= eAnchorType) &&
TextContentAnchorType_AS_CHARACTER == eAnchorType )
{
sal_Int16 nVertOrient;
pVertOrient->maValue >>= nVertOrient;
sal_Int16 nVertOrientRel;
pVertOrientRelAsChar->maValue >>= nVertOrientRel;
switch( nVertOrient )
{
case VertOrientation::TOP:
nVertOrient = nVertOrientRel;
break;
case VertOrientation::CENTER:
switch( nVertOrientRel )
{
case VertOrientation::CHAR_TOP:
nVertOrient = VertOrientation::CHAR_CENTER;
break;
case VertOrientation::LINE_TOP:
nVertOrient = VertOrientation::LINE_CENTER;
break;
}
break;
case VertOrientation::BOTTOM:
switch( nVertOrientRel )
{
case VertOrientation::CHAR_TOP:
nVertOrient = VertOrientation::CHAR_BOTTOM;
break;
case VertOrientation::LINE_TOP:
nVertOrient = VertOrientation::LINE_BOTTOM;
break;
}
break;
}
pVertOrient->maValue <<= nVertOrientRel;
}
pVertOrientRelAsChar->mnIndex = -1;
}
}
|