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 <comphelper/string.hxx>
30 : : #include <vcl/metaact.hxx>
31 : : #include <svl/zforlist.hxx>
32 : : #include <tools/urlobj.hxx>
33 : :
34 : : #define _SVX_FLDITEM_CXX
35 : : #include <unotools/localfilehelper.hxx>
36 : :
37 : : #include <editeng/flditem.hxx>
38 : : #include <editeng/measfld.hxx>
39 : : #include "editeng/unonames.hxx"
40 : :
41 : : #include <tools/tenccvt.hxx>
42 : :
43 : : #include <com/sun/star/beans/XPropertySet.hpp>
44 : : #include <com/sun/star/text/XTextContent.hpp>
45 : : #include <com/sun/star/text/FilenameDisplayFormat.hpp>
46 : : #include <com/sun/star/util/DateTime.hpp>
47 : :
48 : : using namespace com::sun::star;
49 : :
50 : 81 : SvxFieldData* SvxFieldData::Create(const uno::Reference<text::XTextContent>& xTextContent)
51 : : {
52 [ + - ]: 81 : uno::Reference<beans::XPropertySet> xPropSet(xTextContent, uno::UNO_QUERY);
53 [ + + ]: 81 : if (!xPropSet.is())
54 : 5 : return NULL;
55 : :
56 [ + - ][ + - ]: 76 : uno::Any aAny = xPropSet->getPropertyValue(UNO_TC_PROP_TEXTFIELD_TYPE);
57 [ + - ]: 76 : sal_Int32 nFieldType = aAny.get<sal_Int32>();
58 : :
59 [ + - + - : 76 : switch (nFieldType)
- - - - -
+ + + - ]
60 : : {
61 : : case text::textfield::Type::TIME:
62 : : case text::textfield::Type::EXTENDED_TIME:
63 : : case text::textfield::Type::DATE:
64 : : {
65 : 12 : sal_Bool bIsDate = false;
66 [ + - ][ + - ]: 12 : xPropSet->getPropertyValue(UNO_TC_PROP_IS_DATE) >>= bIsDate;
67 : :
68 [ + + ]: 12 : if (bIsDate)
69 : : {
70 [ + - ][ + - ]: 9 : util::DateTime aDateTime = xPropSet->getPropertyValue(UNO_TC_PROP_DATE_TIME).get<util::DateTime>();
[ + - ]
71 : 9 : Date aDate(aDateTime.Day, aDateTime.Month, aDateTime.Year);
72 : 9 : sal_Bool bIsFixed = false;
73 [ + - ][ + - ]: 9 : xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
74 : :
75 [ + - ][ + - ]: 9 : SvxDateField* pData = new SvxDateField(aDate, bIsFixed ? SVXDATETYPE_FIX : SVXDATETYPE_VAR);
76 : 9 : sal_Int32 nNumFmt = -1;
77 [ + - ][ + - ]: 9 : xPropSet->getPropertyValue(UNO_TC_PROP_NUMFORMAT) >>= nNumFmt;
78 [ + - ][ + - ]: 9 : if (nNumFmt >= SVXDATEFORMAT_APPDEFAULT && nNumFmt <= SVXDATEFORMAT_F)
79 : 9 : pData->SetFormat(static_cast<SvxDateFormat>(nNumFmt));
80 : :
81 : 9 : return pData;
82 : : }
83 : :
84 [ + - ][ + - ]: 3 : if (nFieldType != text::textfield::Type::TIME && nFieldType != text::textfield::Type::DATE)
85 : : {
86 [ + - ][ + - ]: 3 : util::DateTime aDateTime = xPropSet->getPropertyValue(UNO_TC_PROP_DATE_TIME).get<util::DateTime>();
[ + - ]
87 [ + - ]: 3 : Time aTime(aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.HundredthSeconds);
88 : :
89 : 3 : sal_Bool bIsFixed = false;
90 [ + - ][ + - ]: 3 : xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
91 : :
92 [ + - ][ + - ]: 3 : SvxExtTimeField* pData = new SvxExtTimeField(aTime, bIsFixed ? SVXTIMETYPE_FIX : SVXTIMETYPE_VAR);
93 : :
94 : 3 : sal_Int32 nNumFmt = -1;
95 [ + - ][ + - ]: 3 : xPropSet->getPropertyValue(UNO_TC_PROP_NUMFORMAT) >>= nNumFmt;
96 [ + - ][ + - ]: 3 : if (nNumFmt >= SVXTIMEFORMAT_APPDEFAULT && nNumFmt <= SVXTIMEFORMAT_AM_HMSH)
97 : 3 : pData->SetFormat(static_cast<SvxTimeFormat>(nNumFmt));
98 : :
99 : 3 : return pData;
100 : : }
101 : :
102 [ # # ][ # # ]: 12 : return new SvxTimeField();
103 : : }
104 : : case text::textfield::Type::URL:
105 : : {
106 : 0 : rtl::OUString aRep, aTarget, aURL;
107 : 0 : sal_Int16 nFmt = -1;
108 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_URL_REPRESENTATION) >>= aRep;
109 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_URL_TARGET) >>= aTarget;
110 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_URL) >>= aURL;
111 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_URL_FORMAT) >>= nFmt;
112 [ # # ][ # # ]: 0 : SvxURLField* pData = new SvxURLField(aURL, aRep, aRep.isEmpty() ? SVXURLFORMAT_URL : SVXURLFORMAT_REPR);
[ # # ]
113 : 0 : pData->SetTargetFrame(aTarget);
114 [ # # ][ # # ]: 0 : if (nFmt >= SVXURLFORMAT_APPDEFAULT && nFmt <= SVXURLFORMAT_REPR)
115 : 0 : pData->SetFormat(static_cast<SvxURLFormat>(nFmt));
116 : :
117 : 0 : return pData;
118 : : }
119 : : case text::textfield::Type::PAGE:
120 [ + - ][ + - ]: 24 : return new SvxPageField();
121 : : case text::textfield::Type::PAGES:
122 [ # # ][ # # ]: 0 : return new SvxPagesField();
123 : : case text::textfield::Type::DOCINFO_TITLE:
124 [ # # ][ # # ]: 0 : return new SvxFileField();
125 : : case text::textfield::Type::TABLE:
126 : : {
127 : 0 : sal_Int32 nTab = 0;
128 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_TABLE_POSITION) >>= nTab;
129 [ # # ][ # # ]: 0 : return new SvxTableField(nTab);
130 : : }
131 : : case text::textfield::Type::EXTENDED_FILE:
132 : : {
133 : 0 : rtl::OUString aPresentation;
134 : 0 : sal_Bool bIsFixed = false;
135 : 0 : sal_Int16 nFmt = text::FilenameDisplayFormat::FULL;
136 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
137 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_CURRENT_PRESENTATION) >>= aPresentation;
138 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_FILE_FORMAT) >>= nFmt;
139 : :
140 : 0 : SvxFileFormat eFmt = SVXFILEFORMAT_NAME_EXT;
141 [ # # # # ]: 0 : switch (nFmt)
142 : : {
143 : 0 : case text::FilenameDisplayFormat::FULL: eFmt = SVXFILEFORMAT_FULLPATH; break;
144 : 0 : case text::FilenameDisplayFormat::PATH: eFmt = SVXFILEFORMAT_PATH; break;
145 : 0 : case text::FilenameDisplayFormat::NAME: eFmt = SVXFILEFORMAT_NAME; break;
146 : : default:;
147 : : }
148 : :
149 : : // pass fixed attribute to constructor
150 : : return new SvxExtFileField(
151 [ # # ][ # # ]: 0 : aPresentation, bIsFixed ? SVXFILETYPE_FIX : SVXFILETYPE_VAR, eFmt);
152 : : }
153 : : case text::textfield::Type::AUTHOR:
154 : : {
155 : 0 : sal_Bool bIsFixed = false;
156 : 0 : sal_Bool bFullName = false;
157 : 0 : sal_Int16 nFmt = -1;
158 : 0 : rtl::OUString aPresentation, aContent, aFirstName, aLastName;
159 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
160 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_AUTHOR_FULLNAME) >>= bFullName;
161 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_CURRENT_PRESENTATION) >>= aPresentation;
162 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_AUTHOR_CONTENT) >>= aContent;
163 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_AUTHOR_FORMAT) >>= nFmt;
164 : :
165 : : // do we have CurrentPresentation given? Mimic behaviour of
166 : : // writer, which means: prefer CurrentPresentation over Content
167 : : // if both are given.
168 [ # # ]: 0 : if (!aPresentation.isEmpty())
169 : 0 : aContent = aPresentation;
170 : :
171 : 0 : sal_Int32 nPos = aContent.lastIndexOf(sal_Unicode(' '), 0);
172 [ # # ]: 0 : if (nPos > 0)
173 : : {
174 : 0 : aFirstName = aContent.copy(0, nPos);
175 : 0 : aLastName = aContent.copy(nPos + 1);
176 : : }
177 : : else
178 : : {
179 : 0 : aLastName = aContent;
180 : : }
181 : :
182 : : // #92009# pass fixed attribute to constructor
183 : : SvxAuthorField* pData = new SvxAuthorField(
184 [ # # ][ # # ]: 0 : aFirstName, aLastName, rtl::OUString(), bIsFixed ? SVXAUTHORTYPE_FIX : SVXAUTHORTYPE_VAR);
185 : :
186 [ # # ]: 0 : if (!bFullName)
187 : : {
188 : 0 : pData->SetFormat(SVXAUTHORFORMAT_SHORTNAME);
189 : : }
190 [ # # ][ # # ]: 0 : else if (nFmt >= SVXAUTHORFORMAT_FULLNAME || nFmt <= SVXAUTHORFORMAT_SHORTNAME)
191 : : {
192 : 0 : pData->SetFormat(static_cast<SvxAuthorFormat>(nFmt));
193 : : }
194 : :
195 : 0 : return pData;
196 : : }
197 : : case text::textfield::Type::MEASURE:
198 : : {
199 : 0 : SdrMeasureFieldKind eKind = SDRMEASUREFIELD_VALUE;
200 : 0 : sal_Int16 nTmp = -1;
201 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue(UNO_TC_PROP_MEASURE_KIND) >>= nTmp;
202 [ # # ][ # # ]: 0 : if (nTmp == static_cast<sal_Int16>(SDRMEASUREFIELD_UNIT) ||
203 : : nTmp == static_cast<sal_Int16>(SDRMEASUREFIELD_ROTA90BLANCS))
204 : 0 : eKind = static_cast<SdrMeasureFieldKind>(nTmp);
205 : :
206 [ # # ][ # # ]: 0 : return new SdrMeasureField(eKind);
207 : : }
208 : : case text::textfield::Type::PRESENTATION_HEADER:
209 [ + - ][ + - ]: 10 : return new SvxHeaderField();
210 : : case text::textfield::Type::PRESENTATION_FOOTER:
211 [ + - ][ + - ]: 15 : return new SvxFooterField();
212 : : case text::textfield::Type::PRESENTATION_DATE_TIME:
213 [ + - ][ + - ]: 15 : return new SvxDateTimeField();
214 : : default:
215 : : ;
216 : : };
217 : :
218 : 81 : return NULL;
219 : : }
220 : :
221 [ - + ][ - + ]: 90058 : TYPEINIT1( SvxFieldItem, SfxPoolItem );
222 : :
223 [ # # ][ # # ]: 11892 : SV_IMPL_PERSIST1( SvxFieldData, SvPersistBase );
[ # # ][ # # ]
[ # # ][ # # ]
[ - + ][ - + ]
224 : :
225 : : // -----------------------------------------------------------------------
226 : :
227 : 30235 : SvxFieldData::SvxFieldData()
228 : : {
229 : 30235 : }
230 : :
231 : : // -----------------------------------------------------------------------
232 : :
233 : 33594 : SvxFieldData::~SvxFieldData()
234 : : {
235 [ - + ]: 33732 : }
236 : :
237 : : // -----------------------------------------------------------------------
238 : :
239 : 138 : SvxFieldData* SvxFieldData::Clone() const
240 : : {
241 [ + - ]: 138 : return new SvxFieldData;
242 : : }
243 : :
244 : : // -----------------------------------------------------------------------
245 : :
246 : 0 : int SvxFieldData::operator==( const SvxFieldData& rFld ) const
247 : : {
248 : : DBG_ASSERT( Type() == rFld.Type(), "==: Different Types" );
249 : : (void)rFld;
250 : 0 : return sal_True; // Basic class is always the same.
251 : : }
252 : :
253 : : // -----------------------------------------------------------------------
254 : :
255 : 0 : void SvxFieldData::Load( SvPersistStream & /*rStm*/ )
256 : : {
257 : 0 : }
258 : :
259 : : // -----------------------------------------------------------------------
260 : :
261 : 0 : void SvxFieldData::Save( SvPersistStream & /*rStm*/ )
262 : : {
263 : 0 : }
264 : :
265 : :
266 : 0 : MetaAction* SvxFieldData::createBeginComment() const
267 : : {
268 [ # # ][ # # ]: 0 : return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
269 : : }
270 : :
271 : 0 : MetaAction* SvxFieldData::createEndComment() const
272 : : {
273 [ # # ][ # # ]: 0 : return new MetaCommentAction( "FIELD_SEQ_END" );
274 : : }
275 : :
276 : : // -----------------------------------------------------------------------
277 : :
278 : 0 : SvxFieldItem::SvxFieldItem( SvxFieldData* pFld, const sal_uInt16 nId ) :
279 : 0 : SfxPoolItem( nId )
280 : : {
281 : 0 : pField = pFld; // belongs directly to the item
282 : 0 : }
283 : :
284 : : // -----------------------------------------------------------------------
285 : :
286 : 5300 : SvxFieldItem::SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId ) :
287 : 5300 : SfxPoolItem( nId )
288 : : {
289 [ + - ]: 5300 : pField = rField.Clone();
290 : 5300 : }
291 : :
292 : : // -----------------------------------------------------------------------
293 : :
294 : 24166 : SvxFieldItem::SvxFieldItem( const SvxFieldItem& rItem ) :
295 : 24166 : SfxPoolItem ( rItem )
296 : : {
297 [ + - ][ + - ]: 24166 : pField = rItem.GetField() ? rItem.GetField()->Clone() : 0;
298 : 24166 : }
299 : :
300 : : // -----------------------------------------------------------------------
301 : :
302 : 28314 : SvxFieldItem::~SvxFieldItem()
303 : : {
304 [ + - ][ + - ]: 28314 : delete pField;
305 [ - + ]: 51546 : }
306 : :
307 : : // -----------------------------------------------------------------------
308 : :
309 : 23896 : SfxPoolItem* SvxFieldItem::Clone( SfxItemPool* ) const
310 : : {
311 [ + - ]: 23896 : return new SvxFieldItem(*this);
312 : : }
313 : :
314 : : // -----------------------------------------------------------------------
315 : :
316 : 0 : SfxPoolItem* SvxFieldItem::Create( SvStream& rStrm, sal_uInt16 ) const
317 : : {
318 : 0 : SvxFieldData* pData = 0;
319 [ # # ][ # # ]: 0 : SvPersistStream aPStrm( GetClassManager(), &rStrm );
320 [ # # ]: 0 : aPStrm >> pData;
321 : :
322 [ # # ]: 0 : if( aPStrm.IsEof() )
323 [ # # ]: 0 : aPStrm.SetError( SVSTREAM_GENERALERROR );
324 : :
325 [ # # ]: 0 : if ( aPStrm.GetError() == ERRCODE_IO_NOFACTORY )
326 [ # # ]: 0 : aPStrm.ResetError(); // Actually a code for that not all were read Attr ...
327 : :
328 [ # # ][ # # ]: 0 : return new SvxFieldItem( pData, Which() );
[ # # ]
329 : : }
330 : :
331 : : // -----------------------------------------------------------------------
332 : :
333 : 568 : SvStream& SvxFieldItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
334 : : {
335 : : DBG_ASSERT( pField, "SvxFieldItem::Store: Field?!" );
336 [ + - ][ + - ]: 568 : SvPersistStream aPStrm( GetClassManager(), &rStrm );
337 : : // The reset error in the above Create method did not exist in 3.1,
338 : : // therefore newer items can not be saved for 3.x-exports!
339 [ + - ][ + - ]: 1136 : if ( ( rStrm.GetVersion() <= SOFFICE_FILEFORMAT_31 ) && pField &&
[ - + ][ - + ]
340 [ + - ]: 568 : pField->GetClassId() == 50 /* SdrMeasureField */ )
341 : : {
342 : : // SvxFieldData not enough, because not registered on ClassMgr.
343 [ # # ]: 0 : SvxURLField aDummyData;
344 [ # # ][ # # ]: 0 : aPStrm << &aDummyData;
345 : : }
346 : : else
347 [ + - ]: 568 : aPStrm << pField;
348 : :
349 [ + - ]: 568 : return rStrm;
350 : : }
351 : :
352 : : // -----------------------------------------------------------------------
353 : :
354 : 18872 : int SvxFieldItem::operator==( const SfxPoolItem& rItem ) const
355 : : {
356 : : DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal which or type" );
357 : :
358 : 18872 : const SvxFieldData* pOtherFld = ((const SvxFieldItem&)rItem).GetField();
359 [ # # ][ - + ]: 18872 : if ( !pField && !pOtherFld )
360 : 0 : return sal_True;
361 : :
362 [ - + ][ # # ]: 18872 : if ( ( !pField && pOtherFld ) || ( pField && !pOtherFld ) )
[ + - ][ - + ]
363 : 0 : return sal_False;
364 : :
365 : 18872 : return ( ( pField->Type() == pOtherFld->Type() )
366 [ + + ][ + + ]: 18872 : && ( *pField == *pOtherFld ) );
367 : : }
368 : :
369 : : // =================================================================
370 : : // The following are the derivatives of SvxFieldData ...
371 : : // =================================================================
372 : :
373 [ # # ][ # # ]: 4536 : SV_IMPL_PERSIST1( SvxDateField, SvxFieldData );
[ # # ][ # # ]
[ # # ][ # # ]
[ - + ][ - + ]
374 : :
375 : : // -----------------------------------------------------------------------
376 : :
377 : 96 : SvxDateField::SvxDateField()
378 : : {
379 [ + - ]: 96 : nFixDate = Date( Date::SYSTEM ).GetDate();
380 : 96 : eType = SVXDATETYPE_VAR;
381 : 96 : eFormat = SVXDATEFORMAT_STDSMALL;
382 : 96 : }
383 : :
384 : : // -----------------------------------------------------------------------
385 : :
386 : 423 : SvxDateField::SvxDateField( const Date& rDate, SvxDateType eT, SvxDateFormat eF )
387 : : {
388 : 423 : nFixDate = rDate.GetDate();
389 : 423 : eType = eT;
390 : 423 : eFormat = eF;
391 : 423 : }
392 : :
393 : : // -----------------------------------------------------------------------
394 : :
395 : 3489 : SvxFieldData* SvxDateField::Clone() const
396 : : {
397 [ + - ]: 3489 : return new SvxDateField( *this );
398 : : }
399 : :
400 : : // -----------------------------------------------------------------------
401 : :
402 : 10 : int SvxDateField::operator==( const SvxFieldData& rOther ) const
403 : : {
404 [ - + ]: 10 : if ( rOther.Type() != Type() )
405 : 0 : return sal_False;
406 : :
407 : 10 : const SvxDateField& rOtherFld = (const SvxDateField&) rOther;
408 : : return ( ( nFixDate == rOtherFld.nFixDate ) &&
409 : : ( eType == rOtherFld.eType ) &&
410 [ + - ][ + - ]: 10 : ( eFormat == rOtherFld.eFormat ) );
[ + - ]
411 : : }
412 : :
413 : : // -----------------------------------------------------------------------
414 : :
415 : 0 : void SvxDateField::Load( SvPersistStream & rStm )
416 : : {
417 : : sal_uInt16 nType, nFormat;
418 : :
419 [ # # ]: 0 : rStm >> nFixDate;
420 [ # # ]: 0 : rStm >> nType;
421 [ # # ]: 0 : rStm >> nFormat;
422 : :
423 : 0 : eType = (SvxDateType)nType;
424 : 0 : eFormat= (SvxDateFormat)nFormat;
425 : 0 : }
426 : :
427 : : // -----------------------------------------------------------------------
428 : :
429 : 0 : void SvxDateField::Save( SvPersistStream & rStm )
430 : : {
431 : 0 : rStm << nFixDate;
432 : 0 : rStm << (sal_uInt16)eType;
433 : 0 : rStm << (sal_uInt16)eFormat;
434 : 0 : }
435 : :
436 : : // -----------------------------------------------------------------------
437 : :
438 : 12 : rtl::OUString SvxDateField::GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLang ) const
439 : : {
440 : 12 : Date aDate( Date::EMPTY );
441 [ - + ]: 12 : if ( eType == SVXDATETYPE_FIX )
442 : 0 : aDate.SetDate( nFixDate );
443 : : else
444 [ + - ]: 12 : aDate = Date( Date::SYSTEM ); // current date
445 : :
446 [ + - ]: 12 : return GetFormatted( aDate, eFormat, rFormatter, eLang );
447 : : }
448 : :
449 : 12 : rtl::OUString SvxDateField::GetFormatted( Date& aDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLang )
450 : : {
451 [ - + ]: 12 : if ( eFormat == SVXDATEFORMAT_SYSTEM )
452 : : {
453 : : OSL_FAIL( "SVXDATEFORMAT_SYSTEM not implemented!" );
454 : 0 : eFormat = SVXDATEFORMAT_STDSMALL;
455 : : }
456 [ - + ]: 12 : else if ( eFormat == SVXDATEFORMAT_APPDEFAULT )
457 : : {
458 : : OSL_FAIL( "SVXDATEFORMAT_APPDEFAULT: take them from where? ");
459 : 0 : eFormat = SVXDATEFORMAT_STDSMALL;
460 : : }
461 : :
462 : : sal_uLong nFormatKey;
463 : :
464 [ + - - - : 12 : switch( eFormat )
- - - -
- ]
465 : : {
466 : : case SVXDATEFORMAT_STDSMALL:
467 : : // short
468 [ + - ]: 12 : nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYSTEM_SHORT, eLang );
469 : 12 : break;
470 : : case SVXDATEFORMAT_STDBIG:
471 : : // long
472 [ # # ]: 0 : nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYSTEM_LONG, eLang );
473 : 0 : break;
474 : : case SVXDATEFORMAT_A:
475 : : // 13.02.96
476 [ # # ]: 0 : nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYY, eLang );
477 : 0 : break;
478 : : case SVXDATEFORMAT_B:
479 : : // 13.02.1996
480 [ # # ]: 0 : nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYYYY, eLang );
481 : 0 : break;
482 : : case SVXDATEFORMAT_C:
483 : : // 13. Feb 1996
484 [ # # ]: 0 : nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DMMMYYYY, eLang );
485 : 0 : break;
486 : : case SVXDATEFORMAT_D:
487 : : // 13. February 1996
488 [ # # ]: 0 : nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DMMMMYYYY, eLang );
489 : 0 : break;
490 : : case SVXDATEFORMAT_E:
491 : : // The, 13. February 1996
492 [ # # ]: 0 : nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_NNDMMMMYYYY, eLang );
493 : 0 : break;
494 : : case SVXDATEFORMAT_F:
495 : : // Tuesday, 13. February 1996
496 [ # # ]: 0 : nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_NNNNDMMMMYYYY, eLang );
497 : 0 : break;
498 : : default:
499 [ # # ]: 0 : nFormatKey = rFormatter.GetStandardFormat( NUMBERFORMAT_DATE, eLang );
500 : : }
501 : :
502 [ + - ][ + - ]: 12 : double fDiffDate = aDate - *(rFormatter.GetNullDate());
503 : 12 : rtl::OUString aStr;
504 : 12 : Color* pColor = NULL;
505 [ + - ]: 12 : rFormatter.GetOutputString( fDiffDate, nFormatKey, aStr, &pColor );
506 : 12 : return aStr;
507 : : }
508 : :
509 : 0 : MetaAction* SvxDateField::createBeginComment() const
510 : : {
511 [ # # ][ # # ]: 0 : return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
512 : : }
513 : :
514 [ # # ][ # # ]: 9066 : SV_IMPL_PERSIST1( SvxURLField, SvxFieldData );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
515 : :
516 : : // -----------------------------------------------------------------------
517 : :
518 : 0 : SvxURLField::SvxURLField()
519 : : {
520 : 0 : eFormat = SVXURLFORMAT_URL;
521 : 0 : }
522 : :
523 : : // -----------------------------------------------------------------------
524 : :
525 : 32 : SvxURLField::SvxURLField( const rtl::OUString& rURL, const rtl::OUString& rRepres, SvxURLFormat eFmt )
526 : 32 : : aURL( rURL ), aRepresentation( rRepres )
527 : : {
528 : 32 : eFormat = eFmt;
529 : 32 : }
530 : :
531 : : // -----------------------------------------------------------------------
532 : :
533 : 248 : SvxFieldData* SvxURLField::Clone() const
534 : : {
535 [ + - ]: 248 : return new SvxURLField( *this );
536 : : }
537 : :
538 : : // -----------------------------------------------------------------------
539 : :
540 : 2206 : int SvxURLField::operator==( const SvxFieldData& rOther ) const
541 : : {
542 [ - + ]: 2206 : if ( rOther.Type() != Type() )
543 : 0 : return sal_False;
544 : :
545 : 2206 : const SvxURLField& rOtherFld = (const SvxURLField&) rOther;
546 : : return ( ( eFormat == rOtherFld.eFormat ) &&
547 : 2206 : ( aURL == rOtherFld.aURL ) &&
548 : 546 : ( aRepresentation == rOtherFld.aRepresentation ) &&
549 [ + - + + : 4958 : ( aTargetFrame == rOtherFld.aTargetFrame ) );
+ + ][ + + ]
550 : : }
551 : :
552 : : // -----------------------------------------------------------------------
553 : :
554 : 0 : static void write_unicode( SvPersistStream & rStm, const rtl::OUString& rString )
555 : : {
556 : 0 : sal_uInt16 nL = sal::static_int_cast<sal_uInt16>(rString.getLength());
557 : 0 : rStm << nL;
558 : : //endian specific?, yipes!
559 : 0 : rStm.Write( rString.getStr(), nL*sizeof(sal_Unicode) );
560 : 0 : }
561 : :
562 : 0 : static rtl::OUString read_unicode( SvPersistStream & rStm )
563 : : {
564 : 0 : rtl_uString *pStr = NULL;
565 : 0 : sal_uInt16 nL = 0;
566 [ # # ]: 0 : rStm >> nL;
567 [ # # ]: 0 : if ( nL )
568 : : {
569 : : using comphelper::string::rtl_uString_alloc;
570 [ # # ]: 0 : pStr = rtl_uString_alloc(nL);
571 : : //endian specific?, yipes!
572 [ # # ]: 0 : rStm.Read(pStr->buffer, nL*sizeof(sal_Unicode));
573 : : }
574 : : //take ownership of buffer and return, otherwise return empty string
575 [ # # ]: 0 : return pStr ? rtl::OUString(pStr, SAL_NO_ACQUIRE) : rtl::OUString();
576 : : }
577 : :
578 : 0 : void SvxURLField::Load( SvPersistStream & rStm )
579 : : {
580 : 0 : sal_uInt16 nFormat = 0;
581 : :
582 [ # # ]: 0 : rStm >> nFormat;
583 : 0 : eFormat= (SvxURLFormat)nFormat;
584 : :
585 [ # # ]: 0 : aURL = read_unicode( rStm );
586 [ # # ]: 0 : aRepresentation = read_unicode( rStm );
587 [ # # ]: 0 : aTargetFrame = read_unicode( rStm );
588 : 0 : }
589 : :
590 : : // -----------------------------------------------------------------------
591 : :
592 : 0 : void SvxURLField::Save( SvPersistStream & rStm )
593 : : {
594 : 0 : rStm << (sal_uInt16)eFormat;
595 : :
596 : 0 : write_unicode( rStm, aURL );
597 : 0 : write_unicode( rStm, aRepresentation );
598 : 0 : write_unicode( rStm, aTargetFrame );
599 : 0 : }
600 : :
601 : 0 : MetaAction* SvxURLField::createBeginComment() const
602 : : {
603 : : // #i46618# Adding target URL to metafile comment
604 : : return new MetaCommentAction( "FIELD_SEQ_BEGIN",
605 : : 0,
606 : 0 : reinterpret_cast<const sal_uInt8*>(aURL.getStr()),
607 [ # # ][ # # ]: 0 : 2*aURL.getLength() );
608 : : }
609 : :
610 : : // =================================================================
611 : : // The fields that were removed from Calc:
612 : : // =================================================================
613 : :
614 [ # # ][ # # ]: 81248 : SV_IMPL_PERSIST1( SvxPageField, SvxFieldData );
[ # # ][ # # ]
[ # # ][ # # ]
[ + + ][ - + ]
615 : :
616 : 8772 : SvxPageField::SvxPageField() {}
617 : :
618 : 7462 : SvxFieldData* SvxPageField::Clone() const
619 : : {
620 [ + - ]: 7462 : return new SvxPageField; // empty
621 : : }
622 : :
623 : 820 : int SvxPageField::operator==( const SvxFieldData& rCmp ) const
624 : : {
625 : 820 : return ( rCmp.Type() == TYPE(SvxPageField) );
626 : : }
627 : :
628 : 0 : void SvxPageField::Load( SvPersistStream & /*rStm*/ )
629 : : {
630 : 0 : }
631 : :
632 : 274 : void SvxPageField::Save( SvPersistStream & /*rStm*/ )
633 : : {
634 : 274 : }
635 : :
636 : 0 : MetaAction* SvxPageField::createBeginComment() const
637 : : {
638 [ # # ][ # # ]: 0 : return new MetaCommentAction( "FIELD_SEQ_BEGIN;PageField" );
639 : : }
640 : :
641 : :
642 [ # # ][ # # ]: 17710 : SV_IMPL_PERSIST1( SvxPagesField, SvxFieldData );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
643 : :
644 : 3759 : SvxPagesField::SvxPagesField() {}
645 : :
646 : 3254 : SvxFieldData* SvxPagesField::Clone() const
647 : : {
648 [ + - ]: 3254 : return new SvxPagesField; // empty
649 : : }
650 : :
651 : 8 : int SvxPagesField::operator==( const SvxFieldData& rCmp ) const
652 : : {
653 : 8 : return ( rCmp.Type() == TYPE(SvxPagesField) );
654 : : }
655 : :
656 : 0 : void SvxPagesField::Load( SvPersistStream & /*rStm*/ )
657 : : {
658 : 0 : }
659 : :
660 : 0 : void SvxPagesField::Save( SvPersistStream & /*rStm*/ )
661 : : {
662 : 0 : }
663 : :
664 [ # # ][ # # ]: 3557 : SV_IMPL_PERSIST1( SvxTimeField, SvxFieldData );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
665 : :
666 : 3162 : SvxTimeField::SvxTimeField() {}
667 : :
668 : 2746 : SvxFieldData* SvxTimeField::Clone() const
669 : : {
670 [ + - ]: 2746 : return new SvxTimeField; // empty
671 : : }
672 : :
673 : 8 : int SvxTimeField::operator==( const SvxFieldData& rCmp ) const
674 : : {
675 : 8 : return ( rCmp.Type() == TYPE(SvxTimeField) );
676 : : }
677 : :
678 : 0 : void SvxTimeField::Load( SvPersistStream & /*rStm*/ )
679 : : {
680 : 0 : }
681 : :
682 : 0 : void SvxTimeField::Save( SvPersistStream & /*rStm*/ )
683 : : {
684 : 0 : }
685 : :
686 : 0 : MetaAction* SvxTimeField::createBeginComment() const
687 : : {
688 [ # # ][ # # ]: 0 : return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
689 : : }
690 : :
691 [ # # ][ # # ]: 4321 : SV_IMPL_PERSIST1( SvxFileField, SvxFieldData );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
692 : :
693 : 3852 : SvxFileField::SvxFileField() {}
694 : :
695 : 3347 : SvxFieldData* SvxFileField::Clone() const
696 : : {
697 [ + - ]: 3347 : return new SvxFileField; // empty
698 : : }
699 : :
700 : 8 : int SvxFileField::operator==( const SvxFieldData& rCmp ) const
701 : : {
702 : 8 : return ( rCmp.Type() == TYPE(SvxFileField) );
703 : : }
704 : :
705 : 0 : void SvxFileField::Load( SvPersistStream & /*rStm*/ )
706 : : {
707 : 0 : }
708 : :
709 : 0 : void SvxFileField::Save( SvPersistStream & /*rStm*/ )
710 : : {
711 : 0 : }
712 : :
713 [ # # ][ # # ]: 8738 : SV_IMPL_PERSIST1( SvxTableField, SvxFieldData );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
714 : :
715 : 1112 : SvxTableField::SvxTableField() : mnTab(0) {}
716 : :
717 : 7281 : SvxTableField::SvxTableField(int nTab) : mnTab(nTab) {}
718 : :
719 : 0 : void SvxTableField::SetTab(int nTab)
720 : : {
721 : 0 : mnTab = nTab;
722 : 0 : }
723 : :
724 : 0 : int SvxTableField::GetTab() const
725 : : {
726 : 0 : return mnTab;
727 : : }
728 : :
729 : 7281 : SvxFieldData* SvxTableField::Clone() const
730 : : {
731 [ + - ]: 7281 : return new SvxTableField(mnTab);
732 : : }
733 : :
734 : 655 : int SvxTableField::operator==( const SvxFieldData& rCmp ) const
735 : : {
736 [ - + ]: 655 : if (rCmp.Type() != TYPE(SvxTableField))
737 : 0 : return false;
738 : :
739 : 655 : return mnTab == static_cast<const SvxTableField&>(rCmp).mnTab;
740 : : }
741 : :
742 : 0 : void SvxTableField::Load( SvPersistStream & /*rStm*/ )
743 : : {
744 : 0 : }
745 : :
746 : 294 : void SvxTableField::Save( SvPersistStream & /*rStm*/ )
747 : : {
748 : 294 : }
749 : :
750 : : //----------------------------------------------------------------------------
751 : : // SvxExtTimeField
752 : : //----------------------------------------------------------------------------
753 : :
754 [ # # ][ # # ]: 744 : SV_IMPL_PERSIST1( SvxExtTimeField, SvxFieldData );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
755 : :
756 : : //----------------------------------------------------------------------------
757 : :
758 : 93 : SvxExtTimeField::SvxExtTimeField()
759 : : {
760 [ + - ]: 93 : nFixTime = Time( Time::SYSTEM ).GetTime();
761 : 93 : eType = SVXTIMETYPE_VAR;
762 : 93 : eFormat = SVXTIMEFORMAT_STANDARD;
763 : 93 : }
764 : :
765 : : //----------------------------------------------------------------------------
766 : :
767 : 3 : SvxExtTimeField::SvxExtTimeField( const Time& rTime, SvxTimeType eT, SvxTimeFormat eF )
768 : : {
769 : 3 : nFixTime = rTime.GetTime();
770 : 3 : eType = eT;
771 : 3 : eFormat = eF;
772 : 3 : }
773 : :
774 : : //----------------------------------------------------------------------------
775 : :
776 : 753 : SvxFieldData* SvxExtTimeField::Clone() const
777 : : {
778 [ + - ]: 753 : return new SvxExtTimeField( *this );
779 : : }
780 : :
781 : : //----------------------------------------------------------------------------
782 : :
783 : 0 : int SvxExtTimeField::operator==( const SvxFieldData& rOther ) const
784 : : {
785 [ # # ]: 0 : if ( rOther.Type() != Type() )
786 : 0 : return sal_False;
787 : :
788 : 0 : const SvxExtTimeField& rOtherFld = (const SvxExtTimeField&) rOther;
789 : : return ( ( nFixTime == rOtherFld.nFixTime ) &&
790 : : ( eType == rOtherFld.eType ) &&
791 [ # # ][ # # ]: 0 : ( eFormat == rOtherFld.eFormat ) );
[ # # ]
792 : : }
793 : :
794 : : //----------------------------------------------------------------------------
795 : :
796 : 0 : void SvxExtTimeField::Load( SvPersistStream & rStm )
797 : : {
798 : : sal_uInt16 nType, nFormat;
799 : :
800 [ # # ]: 0 : rStm >> nFixTime;
801 [ # # ]: 0 : rStm >> nType;
802 [ # # ]: 0 : rStm >> nFormat;
803 : :
804 : 0 : eType = (SvxTimeType) nType;
805 : 0 : eFormat= (SvxTimeFormat) nFormat;
806 : 0 : }
807 : :
808 : : //----------------------------------------------------------------------------
809 : :
810 : 0 : void SvxExtTimeField::Save( SvPersistStream & rStm )
811 : : {
812 : 0 : rStm << nFixTime;
813 : 0 : rStm << (sal_uInt16) eType;
814 : 0 : rStm << (sal_uInt16) eFormat;
815 : 0 : }
816 : :
817 : : //----------------------------------------------------------------------------
818 : :
819 : 0 : rtl::OUString SvxExtTimeField::GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLang ) const
820 : : {
821 : 0 : Time aTime( Time::EMPTY );
822 [ # # ]: 0 : if ( eType == SVXTIMETYPE_FIX )
823 : 0 : aTime.SetTime( nFixTime );
824 : : else
825 [ # # ][ # # ]: 0 : aTime = Time( Time::SYSTEM ); // current time
826 [ # # ]: 0 : return GetFormatted( aTime, eFormat, rFormatter, eLang );
827 : : }
828 : :
829 : 0 : rtl::OUString SvxExtTimeField::GetFormatted( Time& aTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLang )
830 : : {
831 [ # # # ]: 0 : switch( eFormat )
832 : : {
833 : : case SVXTIMEFORMAT_SYSTEM :
834 : : OSL_FAIL( "SVXTIMEFORMAT_SYSTEM: not implemented" );
835 : 0 : eFormat = SVXTIMEFORMAT_STANDARD;
836 : 0 : break;
837 : : case SVXTIMEFORMAT_APPDEFAULT :
838 : : OSL_FAIL( "SVXTIMEFORMAT_APPDEFAULT: not implemented" );
839 : 0 : eFormat = SVXTIMEFORMAT_STANDARD;
840 : 0 : break;
841 : : default: ;//prevent warning
842 : : }
843 : :
844 : : sal_uInt32 nFormatKey;
845 : :
846 [ # # # # : 0 : switch( eFormat )
# # # ]
847 : : {
848 : : case SVXTIMEFORMAT_12_HM:
849 [ # # ]: 0 : nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMAMPM, eLang );
850 : 0 : break;
851 : : case SVXTIMEFORMAT_12_HMSH:
852 : : { // no builtin format available, try to insert or reuse
853 [ # # ]: 0 : rtl::OUString aFormatCode( RTL_CONSTASCII_USTRINGPARAM( "HH:MM:SS.00 AM/PM" ) );
854 : : xub_StrLen nCheckPos;
855 : : short nType;
856 : : rFormatter.PutandConvertEntry( aFormatCode,
857 [ # # ]: 0 : nCheckPos, nType, nFormatKey, LANGUAGE_ENGLISH_US, eLang );
858 : : DBG_ASSERT( nCheckPos == 0, "SVXTIMEFORMAT_12_HMSH: could not insert format code" );
859 [ # # ]: 0 : if ( nCheckPos )
860 [ # # ]: 0 : nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HH_MMSS00, eLang );
861 : : }
862 : 0 : break;
863 : : case SVXTIMEFORMAT_24_HM:
864 [ # # ]: 0 : nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMM, eLang );
865 : 0 : break;
866 : : case SVXTIMEFORMAT_24_HMSH:
867 [ # # ]: 0 : nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HH_MMSS00, eLang );
868 : 0 : break;
869 : : case SVXTIMEFORMAT_12_HMS:
870 [ # # ]: 0 : nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMSSAMPM, eLang );
871 : 0 : break;
872 : : case SVXTIMEFORMAT_24_HMS:
873 [ # # ]: 0 : nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMSS, eLang );
874 : 0 : break;
875 : : case SVXTIMEFORMAT_STANDARD:
876 : : default:
877 [ # # ]: 0 : nFormatKey = rFormatter.GetStandardFormat( NUMBERFORMAT_TIME, eLang );
878 : : }
879 : :
880 [ # # ]: 0 : double fFracTime = aTime.GetTimeInDays();
881 : 0 : rtl::OUString aStr;
882 : 0 : Color* pColor = NULL;
883 [ # # ]: 0 : rFormatter.GetOutputString( fFracTime, nFormatKey, aStr, &pColor );
884 : 0 : return aStr;
885 : : }
886 : :
887 : 0 : MetaAction* SvxExtTimeField::createBeginComment() const
888 : : {
889 [ # # ][ # # ]: 0 : return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
890 : : }
891 : :
892 : : //----------------------------------------------------------------------------
893 : : // SvxExtFileField
894 : : //----------------------------------------------------------------------------
895 : :
896 [ # # ][ # # ]: 3 : SV_IMPL_PERSIST1( SvxExtFileField, SvxFieldData );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
897 : :
898 : : //----------------------------------------------------------------------------
899 : :
900 : 0 : SvxExtFileField::SvxExtFileField()
901 : : {
902 : 0 : eType = SVXFILETYPE_VAR;
903 : 0 : eFormat = SVXFILEFORMAT_FULLPATH;
904 : 0 : }
905 : :
906 : : //----------------------------------------------------------------------------
907 : :
908 : 3 : SvxExtFileField::SvxExtFileField( const rtl::OUString& rStr, SvxFileType eT, SvxFileFormat eF )
909 : : {
910 : 3 : aFile = rStr;
911 : 3 : eType = eT;
912 : 3 : eFormat = eF;
913 : 3 : }
914 : :
915 : : //----------------------------------------------------------------------------
916 : :
917 : 21 : SvxFieldData* SvxExtFileField::Clone() const
918 : : {
919 [ + - ]: 21 : return new SvxExtFileField( *this );
920 : : }
921 : :
922 : : //----------------------------------------------------------------------------
923 : :
924 : 0 : int SvxExtFileField::operator==( const SvxFieldData& rOther ) const
925 : : {
926 [ # # ]: 0 : if ( rOther.Type() != Type() )
927 : 0 : return sal_False;
928 : :
929 : 0 : const SvxExtFileField& rOtherFld = (const SvxExtFileField&) rOther;
930 : 0 : return ( ( aFile == rOtherFld.aFile ) &&
931 : : ( eType == rOtherFld.eType ) &&
932 [ # # ][ # # ]: 0 : ( eFormat == rOtherFld.eFormat ) );
[ # # ]
933 : : }
934 : :
935 : : //----------------------------------------------------------------------------
936 : :
937 : 0 : void SvxExtFileField::Load( SvPersistStream & rStm )
938 : : {
939 : : sal_uInt16 nType, nFormat;
940 : :
941 : : // UNICODE: rStm >> aFile;
942 [ # # ]: 0 : aFile = rStm.ReadUniOrByteString(rStm.GetStreamCharSet());
943 : :
944 [ # # ]: 0 : rStm >> nType;
945 [ # # ]: 0 : rStm >> nFormat;
946 : :
947 : 0 : eType = (SvxFileType) nType;
948 : 0 : eFormat= (SvxFileFormat) nFormat;
949 : 0 : }
950 : :
951 : : //----------------------------------------------------------------------------
952 : :
953 : 0 : void SvxExtFileField::Save( SvPersistStream & rStm )
954 : : {
955 : : // UNICODE: rStm << aFile;
956 : 0 : rStm.WriteUniOrByteString(aFile, rStm.GetStreamCharSet());
957 : :
958 : 0 : rStm << (sal_uInt16) eType;
959 : 0 : rStm << (sal_uInt16) eFormat;
960 : 0 : }
961 : :
962 : : //----------------------------------------------------------------------------
963 : :
964 : 0 : rtl::OUString SvxExtFileField::GetFormatted() const
965 : : {
966 : 0 : rtl::OUString aString;
967 : :
968 [ # # ]: 0 : INetURLObject aURLObj( aFile );
969 : :
970 [ # # ]: 0 : if( INET_PROT_NOT_VALID == aURLObj.GetProtocol() )
971 : : {
972 : : // invalid? try to interpret string as system file name
973 : 0 : rtl::OUString aURLStr;
974 : :
975 [ # # ]: 0 : ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aFile, aURLStr );
976 : :
977 [ # # ]: 0 : aURLObj.SetURL( aURLStr );
978 : : }
979 : :
980 : : // #92009# Be somewhat liberate when trying to
981 : : // get formatted content out of the FileField
982 [ # # ]: 0 : if( INET_PROT_NOT_VALID == aURLObj.GetProtocol() )
983 : : {
984 : : // still not valid? Then output as is
985 : 0 : aString = aFile;
986 : : }
987 [ # # ]: 0 : else if( INET_PROT_FILE == aURLObj.GetProtocol() )
988 : : {
989 [ # # # # : 0 : switch( eFormat )
# ]
990 : : {
991 : : case SVXFILEFORMAT_FULLPATH:
992 [ # # ]: 0 : aString = aURLObj.getFSysPath(INetURLObject::FSYS_DETECT);
993 : 0 : break;
994 : :
995 : : case SVXFILEFORMAT_PATH:
996 [ # # ]: 0 : aURLObj.removeSegment(INetURLObject::LAST_SEGMENT, false);
997 : : // #101742# Leave trailing slash at the pathname
998 [ # # ]: 0 : aURLObj.setFinalSlash();
999 [ # # ]: 0 : aString = aURLObj.getFSysPath(INetURLObject::FSYS_DETECT);
1000 : 0 : break;
1001 : :
1002 : : case SVXFILEFORMAT_NAME:
1003 [ # # ]: 0 : aString = aURLObj.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_UNAMBIGUOUS);
1004 : 0 : break;
1005 : :
1006 : : case SVXFILEFORMAT_NAME_EXT:
1007 [ # # ]: 0 : aString = aURLObj.getName(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_UNAMBIGUOUS);
1008 : 0 : break;
1009 : : }
1010 : : }
1011 : : else
1012 : : {
1013 [ # # # # : 0 : switch( eFormat )
# ]
1014 : : {
1015 : : case SVXFILEFORMAT_FULLPATH:
1016 [ # # ]: 0 : aString = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
1017 : 0 : break;
1018 : :
1019 : : case SVXFILEFORMAT_PATH:
1020 [ # # ]: 0 : aURLObj.removeSegment(INetURLObject::LAST_SEGMENT, false);
1021 : : // #101742# Leave trailing slash at the pathname
1022 [ # # ]: 0 : aURLObj.setFinalSlash();
1023 [ # # ]: 0 : aString = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
1024 : 0 : break;
1025 : :
1026 : : case SVXFILEFORMAT_NAME:
1027 [ # # ]: 0 : aString = aURLObj.getBase();
1028 : 0 : break;
1029 : :
1030 : : case SVXFILEFORMAT_NAME_EXT:
1031 [ # # ]: 0 : aString = aURLObj.getName();
1032 : 0 : break;
1033 : : }
1034 : : }
1035 : :
1036 [ # # ]: 0 : return aString;
1037 : : }
1038 : :
1039 : : //----------------------------------------------------------------------------
1040 : : // SvxAuthorField
1041 : : //----------------------------------------------------------------------------
1042 : :
1043 [ # # ][ # # ]: 12938 : SV_IMPL_PERSIST1( SvxAuthorField, SvxFieldData );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1044 : :
1045 : : //----------------------------------------------------------------------------
1046 : :
1047 : 0 : SvxAuthorField::SvxAuthorField()
1048 : : {
1049 : 0 : eType = SVXAUTHORTYPE_VAR;
1050 : 0 : eFormat = SVXAUTHORFORMAT_FULLNAME;
1051 : 0 : }
1052 : :
1053 : : //----------------------------------------------------------------------------
1054 : :
1055 : 0 : SvxAuthorField::SvxAuthorField( const rtl::OUString& rFirstName,
1056 : : const rtl::OUString& rLastName,
1057 : : const rtl::OUString& rShortName,
1058 : 0 : SvxAuthorType eT, SvxAuthorFormat eF )
1059 : : {
1060 : 0 : aName = rLastName;
1061 : 0 : aFirstName = rFirstName;
1062 : 0 : aShortName = rShortName;
1063 : 0 : eType = eT;
1064 : 0 : eFormat = eF;
1065 : 0 : }
1066 : :
1067 : : //----------------------------------------------------------------------------
1068 : :
1069 : 0 : SvxFieldData* SvxAuthorField::Clone() const
1070 : : {
1071 [ # # ]: 0 : return new SvxAuthorField( *this );
1072 : : }
1073 : :
1074 : : //----------------------------------------------------------------------------
1075 : :
1076 : 0 : int SvxAuthorField::operator==( const SvxFieldData& rOther ) const
1077 : : {
1078 [ # # ]: 0 : if ( rOther.Type() != Type() )
1079 : 0 : return sal_False;
1080 : :
1081 : 0 : const SvxAuthorField& rOtherFld = (const SvxAuthorField&) rOther;
1082 : 0 : return ( ( aName == rOtherFld.aName ) &&
1083 : 0 : ( aFirstName == rOtherFld.aFirstName ) &&
1084 : 0 : ( aShortName == rOtherFld.aShortName ) &&
1085 : : ( eType == rOtherFld.eType ) &&
1086 [ # # ][ # # ]: 0 : ( eFormat == rOtherFld.eFormat ) );
[ # # # #
# # ]
1087 : : }
1088 : :
1089 : : //----------------------------------------------------------------------------
1090 : :
1091 : 0 : void SvxAuthorField::Load( SvPersistStream & rStm )
1092 : : {
1093 : 0 : sal_uInt16 nType = 0, nFormat = 0;
1094 : :
1095 [ # # ]: 0 : aName = read_unicode( rStm );
1096 [ # # ]: 0 : aFirstName = read_unicode( rStm );
1097 [ # # ]: 0 : aShortName = read_unicode( rStm );
1098 : :
1099 [ # # ]: 0 : rStm >> nType;
1100 [ # # ]: 0 : rStm >> nFormat;
1101 : :
1102 : 0 : eType = (SvxAuthorType) nType;
1103 : 0 : eFormat= (SvxAuthorFormat) nFormat;
1104 : 0 : }
1105 : :
1106 : : //----------------------------------------------------------------------------
1107 : :
1108 : 0 : void SvxAuthorField::Save( SvPersistStream & rStm )
1109 : : {
1110 : 0 : write_unicode( rStm, aName );
1111 : 0 : write_unicode( rStm, aFirstName );
1112 : 0 : write_unicode( rStm, aShortName );
1113 : :
1114 : 0 : rStm << (sal_uInt16) eType;
1115 : 0 : rStm << (sal_uInt16) eFormat;
1116 : 0 : }
1117 : :
1118 : : //----------------------------------------------------------------------------
1119 : :
1120 : 0 : rtl::OUString SvxAuthorField::GetFormatted() const
1121 : : {
1122 : 0 : rtl::OUString aString;
1123 : :
1124 [ # # # # : 0 : switch( eFormat )
# ]
1125 : : {
1126 : : case SVXAUTHORFORMAT_FULLNAME:
1127 : : {
1128 [ # # ]: 0 : rtl::OUStringBuffer aBuf(aFirstName);
1129 [ # # ]: 0 : aBuf.append(sal_Unicode(' '));
1130 [ # # ]: 0 : aBuf.append(aName);
1131 [ # # ]: 0 : aString = aBuf.makeStringAndClear();
1132 : : }
1133 : 0 : break;
1134 : : case SVXAUTHORFORMAT_NAME:
1135 : 0 : aString = aName;
1136 : 0 : break;
1137 : :
1138 : : case SVXAUTHORFORMAT_FIRSTNAME:
1139 : 0 : aString = aFirstName;
1140 : 0 : break;
1141 : :
1142 : : case SVXAUTHORFORMAT_SHORTNAME:
1143 : 0 : aString = aShortName;
1144 : 0 : break;
1145 : : }
1146 : :
1147 : 0 : return aString;
1148 : : }
1149 : :
1150 : : static SvClassManager* pClassMgr=0;
1151 : :
1152 : 1159 : SvClassManager& SvxFieldItem::GetClassManager()
1153 : : {
1154 [ + + ]: 1159 : if ( !pClassMgr )
1155 : : {
1156 [ + - ]: 135 : pClassMgr = new SvClassManager;
1157 : 135 : pClassMgr->Register(SvxFieldData::StaticClassId(), SvxFieldData::CreateInstance);
1158 : 135 : pClassMgr->Register(SvxURLField::StaticClassId(), SvxURLField::CreateInstance);
1159 : 135 : pClassMgr->Register(SvxDateField::StaticClassId(), SvxDateField::CreateInstance);
1160 : 135 : pClassMgr->Register(SvxPageField::StaticClassId(), SvxPageField::CreateInstance);
1161 : 135 : pClassMgr->Register(SvxTimeField::StaticClassId(), SvxTimeField::CreateInstance);
1162 : 135 : pClassMgr->Register(SvxExtTimeField::StaticClassId(), SvxExtTimeField::CreateInstance);
1163 : 135 : pClassMgr->Register(SvxExtFileField::StaticClassId(), SvxExtFileField::CreateInstance);
1164 : 135 : pClassMgr->Register(SvxAuthorField::StaticClassId(), SvxAuthorField::CreateInstance);
1165 : : }
1166 : :
1167 : 1159 : return *pClassMgr;
1168 : : }
1169 : :
1170 : : ///////////////////////////////////////////////////////////////////////
1171 : :
1172 [ # # ][ # # ]: 69427 : SV_IMPL_PERSIST1( SvxHeaderField, SvxFieldData );
[ # # ][ # # ]
[ # # ][ # # ]
[ + + ][ - + ]
1173 : :
1174 : 342 : SvxHeaderField::SvxHeaderField() {}
1175 : :
1176 : 222 : SvxFieldData* SvxHeaderField::Clone() const
1177 : : {
1178 [ + - ]: 222 : return new SvxHeaderField; // empty
1179 : : }
1180 : :
1181 : 70 : int SvxHeaderField::operator==( const SvxFieldData& rCmp ) const
1182 : : {
1183 : 70 : return ( rCmp.Type() == TYPE(SvxHeaderField) );
1184 : : }
1185 : :
1186 : 0 : void SvxHeaderField::Load( SvPersistStream & /*rStm*/ )
1187 : : {
1188 : 0 : }
1189 : :
1190 : 0 : void SvxHeaderField::Save( SvPersistStream & /*rStm*/ )
1191 : : {
1192 : 0 : }
1193 : :
1194 : : ///////////////////////////////////////////////////////////////////////
1195 : :
1196 [ # # ][ # # ]: 73847 : SV_IMPL_PERSIST1( SvxFooterField, SvxFieldData );
[ # # ][ # # ]
[ # # ][ # # ]
[ + + ][ - + ]
1197 : 518 : SvxFooterField::SvxFooterField() {}
1198 : :
1199 : 332 : SvxFieldData* SvxFooterField::Clone() const
1200 : : {
1201 [ + - ]: 332 : return new SvxFooterField; // empty
1202 : : }
1203 : :
1204 : 136 : int SvxFooterField::operator==( const SvxFieldData& rCmp ) const
1205 : : {
1206 : 136 : return ( rCmp.Type() == TYPE(SvxFooterField) );
1207 : : }
1208 : :
1209 : 0 : void SvxFooterField::Load( SvPersistStream & /*rStm*/ )
1210 : : {
1211 : 0 : }
1212 : :
1213 : 0 : void SvxFooterField::Save( SvPersistStream & /*rStm*/ )
1214 : : {
1215 : 0 : }
1216 : :
1217 : : ///////////////////////////////////////////////////////////////////////
1218 : :
1219 [ # # ][ # # ]: 75127 : SV_IMPL_PERSIST1( SvxDateTimeField, SvxFieldData );
[ # # ][ # # ]
[ # # ][ # # ]
[ + + ][ - + ]
1220 : :
1221 : 329 : SvxFieldData* SvxDateTimeField::Clone() const
1222 : : {
1223 [ + - ]: 329 : return new SvxDateTimeField; // empty
1224 : : }
1225 : :
1226 : 133 : int SvxDateTimeField::operator==( const SvxFieldData& rCmp ) const
1227 : : {
1228 : 133 : return ( rCmp.Type() == TYPE(SvxDateTimeField) );
1229 : : }
1230 : :
1231 : 0 : void SvxDateTimeField::Load( SvPersistStream & /*rStm*/ )
1232 : : {
1233 : 0 : }
1234 : :
1235 : 0 : void SvxDateTimeField::Save( SvPersistStream & /*rStm*/ )
1236 : : {
1237 : 0 : }
1238 : :
1239 : 512 : SvxDateTimeField::SvxDateTimeField() {}
1240 : :
1241 : 0 : rtl::OUString SvxDateTimeField::GetFormatted(
1242 : : Date& rDate, Time& rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage )
1243 : : {
1244 : 0 : rtl::OUString aRet;
1245 : :
1246 : 0 : SvxDateFormat eDateFormat = (SvxDateFormat)(eFormat & 0x0f);
1247 : :
1248 [ # # ]: 0 : if(eDateFormat)
1249 : : {
1250 [ # # ]: 0 : aRet = SvxDateField::GetFormatted( rDate, eDateFormat, rFormatter, eLanguage );
1251 : : }
1252 : :
1253 : 0 : SvxTimeFormat eTimeFormat = (SvxTimeFormat)((eFormat >> 4) & 0x0f);
1254 : :
1255 [ # # ]: 0 : if(eTimeFormat)
1256 : : {
1257 [ # # ]: 0 : rtl::OUStringBuffer aBuf(aRet);
1258 : :
1259 [ # # ]: 0 : if (!aRet.isEmpty())
1260 [ # # ]: 0 : aBuf.append(sal_Unicode(' '));
1261 : :
1262 : : aBuf.append(
1263 [ # # ][ # # ]: 0 : SvxExtTimeField::GetFormatted(rTime, eTimeFormat, rFormatter, eLanguage));
1264 : :
1265 [ # # ]: 0 : aRet = aBuf.makeStringAndClear();
1266 : : }
1267 : :
1268 : 0 : return aRet;
1269 : : }
1270 : :
1271 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|