LibreOffice Module editeng (master) 1
flditem.cxx
Go to the documentation of this file.
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 <osl/file.hxx>
21#include <utility>
22#include <vcl/metaact.hxx>
23#include <svl/numformat.hxx>
24#include <svl/zforlist.hxx>
25#include <tools/urlobj.hxx>
26
27#include <editeng/flditem.hxx>
29#include <editeng/measfld.hxx>
30#include <editeng/unonames.hxx>
31
32#include <tools/debug.hxx>
33
34#include <com/sun/star/beans/XPropertySet.hpp>
35#include <com/sun/star/text/XTextContent.hpp>
36#include <com/sun/star/text/FilenameDisplayFormat.hpp>
37#include <com/sun/star/util/DateTime.hpp>
38
39using namespace com::sun::star;
40
41SvxFieldData* SvxFieldData::Create(const uno::Reference<text::XTextContent>& xTextContent)
42{
43 uno::Reference<beans::XPropertySet> xPropSet(xTextContent, uno::UNO_QUERY);
44 if (!xPropSet.is())
45 return nullptr;
46
47 // we do not support these fields from Writer, so make sure we do not throw
48 // here - see fdo#63436 how to possibly extend Writer to make use of this
49 uno::Any aAny;
50 try {
51 aAny = xPropSet->getPropertyValue(UNO_TC_PROP_TEXTFIELD_TYPE);
52 if ( !aAny.has<sal_Int32>() )
53 return nullptr;
54
55 sal_Int32 nFieldType = aAny.get<sal_Int32>();
56
57 switch (nFieldType)
58 {
59 case text::textfield::Type::TIME:
60 case text::textfield::Type::EXTENDED_TIME:
61 case text::textfield::Type::DATE:
62 {
63 bool bIsDate = false;
64 xPropSet->getPropertyValue(UNO_TC_PROP_IS_DATE) >>= bIsDate;
65
66 if (bIsDate)
67 {
68 util::DateTime aDateTime = xPropSet->getPropertyValue(UNO_TC_PROP_DATE_TIME).get<util::DateTime>();
69 Date aDate(aDateTime.Day, aDateTime.Month, aDateTime.Year);
70 bool bIsFixed = false;
71 xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
72
74 sal_Int32 nNumFmt = -1;
75 xPropSet->getPropertyValue(UNO_TC_PROP_NUMFORMAT) >>= nNumFmt;
76 if (static_cast<SvxDateFormat>(nNumFmt) >= SvxDateFormat::AppDefault &&
77 static_cast<SvxDateFormat>(nNumFmt) <= SvxDateFormat::F)
78 pData->SetFormat(static_cast<SvxDateFormat>(nNumFmt));
79
80 return pData;
81 }
82
83 if (nFieldType != text::textfield::Type::TIME)
84 {
85 util::DateTime aDateTime = xPropSet->getPropertyValue(UNO_TC_PROP_DATE_TIME).get<util::DateTime>();
86 tools::Time aTime(aDateTime);
87
88 bool bIsFixed = false;
89 xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
90
92
93 sal_Int32 nNumFmt = -1;
94 xPropSet->getPropertyValue(UNO_TC_PROP_NUMFORMAT) >>= nNumFmt;
95 if (static_cast<SvxTimeFormat>(nNumFmt) >= SvxTimeFormat::AppDefault &&
96 static_cast<SvxTimeFormat>(nNumFmt) <= SvxTimeFormat::HH12_MM_SS_00_AMPM)
97 pData->SetFormat(static_cast<SvxTimeFormat>(nNumFmt));
98
99 return pData;
100 }
101
102 return new SvxTimeField();
103 }
104 case text::textfield::Type::URL:
105 {
106 OUString aRep, aTarget, aURL;
107 sal_Int16 nFmt = -1;
108 xPropSet->getPropertyValue(UNO_TC_PROP_URL_REPRESENTATION) >>= aRep;
109 xPropSet->getPropertyValue(UNO_TC_PROP_URL_TARGET) >>= aTarget;
110 xPropSet->getPropertyValue(UNO_TC_PROP_URL) >>= aURL;
111 xPropSet->getPropertyValue(UNO_TC_PROP_URL_FORMAT) >>= nFmt;
112 SvxURLField* pData = new SvxURLField(aURL, aRep, aRep.isEmpty() ? SvxURLFormat::Url : SvxURLFormat::Repr);
113 pData->SetTargetFrame(aTarget);
114 if (static_cast<SvxURLFormat>(nFmt) >= SvxURLFormat::AppDefault &&
115 static_cast<SvxURLFormat>(nFmt) <= SvxURLFormat::Repr)
116 pData->SetFormat(static_cast<SvxURLFormat>(nFmt));
117
118 return pData;
119 }
120 case text::textfield::Type::PAGE:
121 return new SvxPageField();
122 case text::textfield::Type::PAGES:
123 return new SvxPagesField();
124 case text::textfield::Type::PAGE_NAME:
125 return new SvxPageTitleField();
126 case text::textfield::Type::DOCINFO_TITLE:
127 return new SvxFileField();
128 case text::textfield::Type::TABLE:
129 {
130 sal_Int32 nTab = 0;
131 xPropSet->getPropertyValue(UNO_TC_PROP_TABLE_POSITION) >>= nTab;
132 return new SvxTableField(nTab);
133 }
134 case text::textfield::Type::EXTENDED_FILE:
135 {
136 OUString aPresentation;
137 bool bIsFixed = false;
138 sal_Int16 nFmt = text::FilenameDisplayFormat::FULL;
139 xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
140 xPropSet->getPropertyValue(UNO_TC_PROP_CURRENT_PRESENTATION) >>= aPresentation;
141 xPropSet->getPropertyValue(UNO_TC_PROP_FILE_FORMAT) >>= nFmt;
142
144 switch (nFmt)
145 {
146 case text::FilenameDisplayFormat::FULL: eFmt = SvxFileFormat::PathFull; break;
147 case text::FilenameDisplayFormat::PATH: eFmt = SvxFileFormat::PathOnly; break;
149 default:;
150 }
151
152 // pass fixed attribute to constructor
153 return new SvxExtFileField(
154 aPresentation, bIsFixed ? SvxFileType::Fix : SvxFileType::Var, eFmt);
155 }
156 case text::textfield::Type::AUTHOR:
157 {
158 bool bIsFixed = false;
159 bool bFullName = false;
160 sal_Int16 nFmt = -1;
161 OUString aPresentation, aContent, aFirstName, aLastName;
162 xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
163 xPropSet->getPropertyValue(UNO_TC_PROP_AUTHOR_FULLNAME) >>= bFullName;
164 xPropSet->getPropertyValue(UNO_TC_PROP_CURRENT_PRESENTATION) >>= aPresentation;
165 xPropSet->getPropertyValue(UNO_TC_PROP_AUTHOR_CONTENT) >>= aContent;
166 xPropSet->getPropertyValue(UNO_TC_PROP_AUTHOR_FORMAT) >>= nFmt;
167
168 // do we have CurrentPresentation given? Mimic behaviour of
169 // writer, which means: prefer CurrentPresentation over Content
170 // if both are given.
171 if (!aPresentation.isEmpty())
172 aContent = aPresentation;
173
174 sal_Int32 nPos = aContent.lastIndexOf(' ', 0);
175 if (nPos > 0)
176 {
177 aFirstName = aContent.copy(0, nPos);
178 aLastName = aContent.copy(nPos + 1);
179 }
180 else
181 {
182 aLastName = aContent;
183 }
184
185 // #92009# pass fixed attribute to constructor
187 aFirstName, aLastName, OUString(), bIsFixed ? SvxAuthorType::Fix : SvxAuthorType::Var);
188
189 if (!bIsFixed)
190 {
191 if (!bFullName)
192 {
194 }
195 else if (static_cast<SvxAuthorFormat>(nFmt) >= SvxAuthorFormat::FullName &&
196 static_cast<SvxAuthorFormat>(nFmt) <= SvxAuthorFormat::ShortName)
197 {
198 pData->SetFormat(static_cast<SvxAuthorFormat>(nFmt));
199 }
200 }
201
202 return pData;
203 }
204 case text::textfield::Type::MEASURE:
205 {
207 sal_Int16 nTmp = -1;
208 xPropSet->getPropertyValue(UNO_TC_PROP_MEASURE_KIND) >>= nTmp;
209 if (nTmp == static_cast<sal_Int16>(SdrMeasureFieldKind::Unit) ||
210 nTmp == static_cast<sal_Int16>(SdrMeasureFieldKind::Rotate90Blanks))
211 eKind = static_cast<SdrMeasureFieldKind>(nTmp);
212
213 return new SdrMeasureField(eKind);
214 }
215 case text::textfield::Type::PRESENTATION_HEADER:
216 return new SvxHeaderField();
217 case text::textfield::Type::PRESENTATION_FOOTER:
218 return new SvxFooterField();
219 case text::textfield::Type::PRESENTATION_DATE_TIME:
220 return new SvxDateTimeField();
221 case text::textfield::Type::DOCINFO_CUSTOM:
222 {
223 OUString sName;
224 xPropSet->getPropertyValue(UNO_TC_PROP_NAME) >>= sName;
225
226 OUString sCurrentPresentation;
227 xPropSet->getPropertyValue(UNO_TC_PROP_CURRENT_PRESENTATION) >>= sCurrentPresentation;
228
229 return new editeng::CustomPropertyField(sName, sCurrentPresentation);
230 }
231 default:
232 ;
233 };
234 } catch ( const beans::UnknownPropertyException& )
235 {
236 return nullptr;
237 }
238
239 return nullptr;
240}
241
242
244{
245}
246
247
249{
250}
251
252
253std::unique_ptr<SvxFieldData> SvxFieldData::Clone() const
254{
255 return std::make_unique<SvxFieldData>();
256}
257
258
259bool SvxFieldData::operator==( const SvxFieldData& rFld ) const
260{
261 DBG_ASSERT( typeid(*this) == typeid(rFld), "==: Different Types" );
262 (void)rFld;
263 return true; // Basic class is always the same.
264}
265
266
268{
269 return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
270}
271
273{
274 return new MetaCommentAction( "FIELD_SEQ_END" );
275}
276
277
278SvxFieldItem::SvxFieldItem( std::unique_ptr<SvxFieldData> pField, const sal_uInt16 nId ) :
280 , mpField( std::move(pField) )
281{
282}
283
284SvxFieldItem::SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId ) :
286 , mpField( rField.Clone() )
287{
288}
289
290
292 SfxPoolItem ( rItem )
293 , mpField( rItem.mpField ? rItem.mpField->Clone() : nullptr )
294{
295}
296
298{
299}
300
302{
303 return new SvxFieldItem(*this);
304}
305
306bool SvxFieldItem::operator==( const SfxPoolItem& rItem ) const
307{
308 assert(SfxPoolItem::operator==(rItem));
309
310 const SvxFieldData* pOtherFld = static_cast<const SvxFieldItem&>(rItem).GetField();
311 if( mpField.get() == pOtherFld )
312 return true;
313 if( mpField == nullptr || pOtherFld == nullptr )
314 return false;
315 return ( typeid(*mpField) == typeid(*pOtherFld) )
316 && ( *mpField == *pOtherFld );
317}
318
319
320// The following are the derivatives of SvxFieldData ...
321
322
324{
328}
329
330
332{
333 nFixDate = rDate.GetDate();
334 eType = eT;
335 eFormat = eF;
336}
337
338
339std::unique_ptr<SvxFieldData> SvxDateField::Clone() const
340{
341 return std::make_unique<SvxDateField>( *this );
342}
343
344
345bool SvxDateField::operator==( const SvxFieldData& rOther ) const
346{
347 if ( typeid(rOther) != typeid(*this) )
348 return false;
349
350 const SvxDateField& rOtherFld = static_cast<const SvxDateField&>(rOther);
351 return ( ( nFixDate == rOtherFld.nFixDate ) &&
352 ( eType == rOtherFld.eType ) &&
353 ( eFormat == rOtherFld.eFormat ) );
354}
355
356
357
359{
360 Date aDate( Date::EMPTY );
361 if ( eType == SvxDateType::Fix )
362 aDate.SetDate( nFixDate );
363 else
364 aDate = Date( Date::SYSTEM ); // current date
365
366 return GetFormatted( aDate, eFormat, rFormatter, eLang );
367}
368
369OUString SvxDateField::GetFormatted( Date const & aDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLang )
370{
372 {
373 OSL_FAIL( "SvxDateFormat::System not implemented!" );
375 }
377 {
378 OSL_FAIL( "SvxDateFormat::AppDefault: take them from where? ");
380 }
381
382 sal_uInt32 nFormatKey;
383
384 switch( eFormat )
385 {
387 // short
388 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYSTEM_SHORT, eLang );
389 break;
391 // long
392 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYSTEM_LONG, eLang );
393 break;
394 case SvxDateFormat::A:
395 // 13.02.96
396 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYY, eLang );
397 break;
398 case SvxDateFormat::B:
399 // 13.02.1996
400 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYYYY, eLang );
401 break;
402 case SvxDateFormat::C:
403 // 13. Feb 1996
404 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DMMMYYYY, eLang );
405 break;
406 case SvxDateFormat::D:
407 // 13. February 1996
408 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DMMMMYYYY, eLang );
409 break;
410 case SvxDateFormat::E:
411 // The, 13. February 1996
412 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_NNDMMMMYYYY, eLang );
413 break;
414 case SvxDateFormat::F:
415 // Tuesday, 13. February 1996
416 nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_NNNNDMMMMYYYY, eLang );
417 break;
418 default:
419 nFormatKey = rFormatter.GetStandardFormat( SvNumFormatType::DATE, eLang );
420 }
421
422 double fDiffDate = aDate - rFormatter.GetNullDate();
423 OUString aStr;
424 const Color* pColor = nullptr;
425 rFormatter.GetOutputString( fDiffDate, nFormatKey, aStr, &pColor );
426 return aStr;
427}
428
430{
431 return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
432}
433
435{
437}
438
439
440SvxURLField::SvxURLField( OUString _aURL, OUString aRepres, SvxURLFormat eFmt )
441 : aURL(std::move( _aURL )), aRepresentation(std::move( aRepres ))
442{
443 eFormat = eFmt;
444}
445
446
447std::unique_ptr<SvxFieldData> SvxURLField::Clone() const
448{
449 return std::make_unique<SvxURLField>( *this );
450}
451
452
453bool SvxURLField::operator==( const SvxFieldData& rOther ) const
454{
455 if ( typeid(rOther) != typeid(*this) )
456 return false;
457
458 const SvxURLField& rOtherFld = static_cast<const SvxURLField&>(rOther);
459 return ( ( eFormat == rOtherFld.eFormat ) &&
460 ( aURL == rOtherFld.aURL ) &&
461 ( aRepresentation == rOtherFld.aRepresentation ) &&
462 ( aTargetFrame == rOtherFld.aTargetFrame ) );
463}
464
465
467{
468 // #i46618# Adding target URL to metafile comment
469 return new MetaCommentAction( "FIELD_SEQ_BEGIN",
470 0,
471 reinterpret_cast<const sal_uInt8*>(aURL.getStr()),
472 2*aURL.getLength() );
473}
474
475//
476// SvxPageTitleField methods
477//
478
480
481std::unique_ptr<SvxFieldData> SvxPageTitleField::Clone() const
482{
483 return std::make_unique<SvxPageTitleField>();
484}
485
487{
488 return ( dynamic_cast< const SvxPageTitleField *>(&rCmp) != nullptr );
489}
490
492{
493 return new MetaCommentAction( "FIELD_SEQ_BEGIN;PageTitleField" );
494}
495
496//
497// SvxPagesField
498//
499// The fields that were removed from Calc:
500
501
503
504std::unique_ptr<SvxFieldData> SvxPageField::Clone() const
505{
506 return std::make_unique<SvxPageField>(); // empty
507}
508
509bool SvxPageField::operator==( const SvxFieldData& rCmp ) const
510{
511 return ( dynamic_cast< const SvxPageField *>(&rCmp) != nullptr );
512}
513
515{
516 return new MetaCommentAction( "FIELD_SEQ_BEGIN;PageField" );
517}
518
519
521
522std::unique_ptr<SvxFieldData> SvxPagesField::Clone() const
523{
524 return std::make_unique<SvxPagesField>(); // empty
525}
526
528{
529 return ( dynamic_cast< const SvxPagesField *>(&rCmp) != nullptr);
530}
531
533
534std::unique_ptr<SvxFieldData> SvxTimeField::Clone() const
535{
536 return std::make_unique<SvxTimeField>(); // empty
537}
538
539bool SvxTimeField::operator==( const SvxFieldData& rCmp ) const
540{
541 return ( dynamic_cast< const SvxTimeField *>(&rCmp) != nullptr);
542}
543
545{
546 return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
547}
548
550
551std::unique_ptr<SvxFieldData> SvxFileField::Clone() const
552{
553 return std::make_unique<SvxFileField>(); // empty
554}
555
556bool SvxFileField::operator==( const SvxFieldData& rCmp ) const
557{
558 return ( dynamic_cast< const SvxFileField *>(&rCmp) != nullptr );
559}
560
562
563SvxTableField::SvxTableField(int nTab) : mnTab(nTab) {}
564
566{
567 mnTab = nTab;
568}
569
570
571std::unique_ptr<SvxFieldData> SvxTableField::Clone() const
572{
573 return std::make_unique<SvxTableField>(mnTab);
574}
575
577{
578 if (dynamic_cast<const SvxTableField *>(&rCmp) == nullptr)
579 return false;
580
581 return mnTab == static_cast<const SvxTableField&>(rCmp).mnTab;
582}
583
584// SvxExtTimeField
585
586
588 : m_nFixTime( tools::Time(tools::Time::SYSTEM).GetTime() )
589{
592}
593
594
596 : m_nFixTime( rTime.GetTime() )
597{
598 eType = eT;
599 eFormat = eF;
600}
601
602
603std::unique_ptr<SvxFieldData> SvxExtTimeField::Clone() const
604{
605 return std::make_unique<SvxExtTimeField>( *this );
606}
607
608
609bool SvxExtTimeField::operator==( const SvxFieldData& rOther ) const
610{
611 if ( typeid(rOther) != typeid(*this) )
612 return false;
613
614 const SvxExtTimeField& rOtherFld = static_cast<const SvxExtTimeField&>(rOther);
615 return ((m_nFixTime == rOtherFld.m_nFixTime) &&
616 ( eType == rOtherFld.eType ) &&
617 ( eFormat == rOtherFld.eFormat ) );
618}
619
620
622{
624 if ( eType == SvxTimeType::Fix )
625 aTime.SetTime(m_nFixTime);
626 else
627 aTime = tools::Time( tools::Time::SYSTEM ); // current time
628 return GetFormatted( aTime, eFormat, rFormatter, eLang );
629}
630
631OUString SvxExtTimeField::GetFormatted( tools::Time const & aTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLang )
632{
633 switch( eFormat )
634 {
636 OSL_FAIL( "SvxTimeFormat::System: not implemented" );
638 break;
640 OSL_FAIL( "SvxTimeFormat::AppDefault: not implemented" );
642 break;
643 default: ;//prevent warning
644 }
645
646 sal_uInt32 nFormatKey;
647
648 switch( eFormat )
649 {
651 nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMAMPM, eLang );
652 break;
654 {
655 // no builtin format available, try to insert or reuse
656 OUString aFormatCode( "HH:MM:SS.00 AM/PM" );
657 sal_Int32 nCheckPos;
659 rFormatter.PutandConvertEntry( aFormatCode, nCheckPos, nType,
660 nFormatKey, LANGUAGE_ENGLISH_US, eLang, true);
661 DBG_ASSERT( nCheckPos == 0, "SvxTimeFormat::HH12_MM_SS_00: could not insert format code" );
662 if ( nCheckPos )
663 {
664 nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HH_MMSS00, eLang );
665 }
666 break;
667 }
669 nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMM, eLang );
670 break;
672 nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HH_MMSS00, eLang );
673 break;
675 nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMSSAMPM, eLang );
676 break;
678 nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMSS, eLang );
679 break;
681 default:
682 nFormatKey = rFormatter.GetStandardFormat( SvNumFormatType::TIME, eLang );
683 }
684
685 double fFracTime = aTime.GetTimeInDays();
686 OUString aStr;
687 const Color* pColor = nullptr;
688 rFormatter.GetOutputString( fFracTime, nFormatKey, aStr, &pColor );
689 return aStr;
690}
691
693{
694 return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
695}
696
697
698// SvxExtFileField
699
700
702{
705}
706
707
709{
710 aFile = rStr;
711 eType = eT;
712 eFormat = eF;
713}
714
715
716std::unique_ptr<SvxFieldData> SvxExtFileField::Clone() const
717{
718 return std::make_unique<SvxExtFileField>( *this );
719}
720
721
722bool SvxExtFileField::operator==( const SvxFieldData& rOther ) const
723{
724 if ( typeid(rOther) != typeid(*this) )
725 return false;
726
727 const SvxExtFileField& rOtherFld = static_cast<const SvxExtFileField&>(rOther);
728 return ( ( aFile == rOtherFld.aFile ) &&
729 ( eType == rOtherFld.eType ) &&
730 ( eFormat == rOtherFld.eFormat ) );
731}
732
733
735{
736 OUString aString;
737
738 INetURLObject aURLObj( aFile );
739
740 if( INetProtocol::NotValid == aURLObj.GetProtocol() )
741 {
742 // invalid? try to interpret string as system file name
743 OUString aURLStr;
744
745 osl::FileBase::getFileURLFromSystemPath( aFile, aURLStr );
746
747 aURLObj.SetURL( aURLStr );
748 }
749
750 // #92009# Be somewhat liberate when trying to
751 // get formatted content out of the FileField
752 if( INetProtocol::NotValid == aURLObj.GetProtocol() )
753 {
754 // still not valid? Then output as is
755 aString = aFile;
756 }
757 else if( INetProtocol::File == aURLObj.GetProtocol() )
758 {
759 switch( eFormat )
760 {
762 aString = aURLObj.getFSysPath(FSysStyle::Detect);
763 break;
764
767 // #101742# Leave trailing slash at the pathname
768 aURLObj.setFinalSlash();
769 aString = aURLObj.getFSysPath(FSysStyle::Detect);
770 break;
771
774 break;
775
778 break;
779 }
780 }
781 else
782 {
783 switch( eFormat )
784 {
787 break;
788
791 // #101742# Leave trailing slash at the pathname
792 aURLObj.setFinalSlash();
794 break;
795
797 aString = aURLObj.getBase();
798 break;
799
801 aString = aURLObj.getName();
802 break;
803 }
804 }
805
806 return aString;
807}
808
809
810// SvxAuthorField
811
812
813SvxAuthorField::SvxAuthorField( const OUString& rFirstName,
814 const OUString& rLastName,
815 const OUString& rShortName,
817{
818 aName = rLastName;
819 aFirstName = rFirstName;
820 aShortName = rShortName;
821 eType = eT;
822 eFormat = eF;
823}
824
825
826std::unique_ptr<SvxFieldData> SvxAuthorField::Clone() const
827{
828 return std::make_unique<SvxAuthorField>( *this );
829}
830
831
832bool SvxAuthorField::operator==( const SvxFieldData& rOther ) const
833{
834 if ( typeid(rOther) != typeid(*this) )
835 return false;
836
837 const SvxAuthorField& rOtherFld = static_cast<const SvxAuthorField&>(rOther);
838 return ( ( aName == rOtherFld.aName ) &&
839 ( aFirstName == rOtherFld.aFirstName ) &&
840 ( aShortName == rOtherFld.aShortName ) &&
841 ( eType == rOtherFld.eType ) &&
842 ( eFormat == rOtherFld.eFormat ) );
843}
844
845
847{
848 OUString aString;
849
850 switch( eFormat )
851 {
853 aString = aFirstName + " " + aName;
854 break;
856 aString = aName;
857 break;
858
860 aString = aFirstName;
861 break;
862
864 aString = aShortName;
865 break;
866 }
867
868 return aString;
869}
870
872
873std::unique_ptr<SvxFieldData> SvxHeaderField::Clone() const
874{
875 return std::make_unique<SvxHeaderField>(); // empty
876}
877
879{
880 return ( dynamic_cast< const SvxHeaderField *>(&rCmp) != nullptr );
881}
882
884
885std::unique_ptr<SvxFieldData> SvxFooterField::Clone() const
886{
887 return std::make_unique<SvxFooterField>(); // empty
888}
889
891{
892 return ( dynamic_cast< const SvxFooterField *>(&rCmp) != nullptr );
893}
894
895std::unique_ptr<SvxFieldData> SvxDateTimeField::Clone() const
896{
897 return std::make_unique<SvxDateTimeField>(); // empty
898}
899
901{
902 return ( dynamic_cast< const SvxDateTimeField *>(&rCmp) != nullptr );
903}
904
906
908 Date const & rDate, tools::Time const & rTime,
909 SvxDateFormat eDateFormat, SvxTimeFormat eTimeFormat,
910 SvNumberFormatter& rFormatter, LanguageType eLanguage )
911{
912 OUString aRet;
913
914 if(eDateFormat != SvxDateFormat::AppDefault)
915 {
916 aRet = SvxDateField::GetFormatted( rDate, eDateFormat, rFormatter, eLanguage );
917 }
918
919 if(eTimeFormat != SvxTimeFormat::AppDefault)
920 {
921 OUStringBuffer aBuf(aRet);
922
923 if (!aRet.isEmpty())
924 aBuf.append(' ');
925
926 aBuf.append(
927 SvxExtTimeField::GetFormatted(rTime, eTimeFormat, rFormatter, eLanguage));
928
929 aRet = aBuf.makeStringAndClear();
930 }
931
932 return aRet;
933}
934
935/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 GetDate() const
void SetDate(sal_Int32 nNewDate)
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
bool setFinalSlash()
OUString getBase(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
INetProtocol GetProtocol() const
OUString getFSysPath(FSysStyle eStyle, sal_Unicode *pDelimiter=nullptr) const
bool SetURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
void GetOutputString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &sOutString, const Color **ppColor, bool bUseStarFormat=false)
bool PutandConvertEntry(OUString &rString, sal_Int32 &nCheckPos, SvNumFormatType &nType, sal_uInt32 &nKey, LanguageType eLnge, LanguageType eNewLnge, bool bConvertDateOrder, bool bReplaceBooleanEquivalent=true)
const Date & GetNullDate() const
sal_uInt32 GetFormatIndex(NfIndexTableOffset, LanguageType eLnge=LANGUAGE_DONTKNOW)
SvxAuthorType eType
Definition: flditem.hxx:368
OUString GetFormatted() const
Definition: flditem.cxx:846
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:832
OUString aName
Definition: flditem.hxx:365
OUString aFirstName
Definition: flditem.hxx:366
SvxAuthorFormat eFormat
Definition: flditem.hxx:369
OUString aShortName
Definition: flditem.hxx:367
SvxAuthorField(const OUString &rFirstName, const OUString &rLastName, const OUString &rShortName, SvxAuthorType eType=SvxAuthorType::Var, SvxAuthorFormat eFormat=SvxAuthorFormat::FullName)
Definition: flditem.cxx:813
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:826
OUString GetFormatted(SvNumberFormatter &rFormatter, LanguageType eLanguage) const
Definition: flditem.cxx:358
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:339
SvxDateType eType
Definition: flditem.hxx:105
sal_Int32 nFixDate
Definition: flditem.hxx:104
virtual MetaAction * createBeginComment() const override
Definition: flditem.cxx:429
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:345
SvxDateFormat eFormat
Definition: flditem.hxx:106
this field is used as a placeholder for a header&footer in impress.
Definition: flditem.hxx:421
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:895
static OUString GetFormatted(Date const &rDate, tools::Time const &rTime, SvxDateFormat eDateFormat, SvxTimeFormat eTimeFormat, SvNumberFormatter &rFormatter, LanguageType eLanguage)
Definition: flditem.cxx:907
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:900
SvxFileType eType
Definition: flditem.hxx:325
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:722
SvxFileFormat eFormat
Definition: flditem.hxx:326
OUString GetFormatted() const
Definition: flditem.cxx:734
OUString aFile
Definition: flditem.hxx:324
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:716
sal_Int64 m_nFixTime
Definition: flditem.hxx:276
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:603
SvxTimeFormat eFormat
Definition: flditem.hxx:278
OUString GetFormatted(SvNumberFormatter &rFormatter, LanguageType eLanguage) const
Definition: flditem.cxx:621
SvxTimeType eType
Definition: flditem.hxx:277
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:609
virtual MetaAction * createBeginComment() const override
Definition: flditem.cxx:692
static SvxFieldData * Create(const css::uno::Reference< css::text::XTextContent > &xContent)
Definition: flditem.cxx:41
virtual std::unique_ptr< SvxFieldData > Clone() const
Definition: flditem.cxx:253
virtual bool operator==(const SvxFieldData &) const
Definition: flditem.cxx:259
virtual ~SvxFieldData()
Definition: flditem.cxx:248
static MetaAction * createEndComment()
Definition: flditem.cxx:272
virtual MetaAction * createBeginComment() const
Definition: flditem.cxx:267
This item stores a field (SvxFieldData).
Definition: flditem.hxx:70
virtual ~SvxFieldItem() override
Definition: flditem.cxx:297
virtual bool operator==(const SfxPoolItem &) const override
Definition: flditem.cxx:306
SvxFieldItem(std::unique_ptr< SvxFieldData > pField, const sal_uInt16 nId)
Definition: flditem.cxx:278
std::unique_ptr< SvxFieldData > mpField
Definition: flditem.hxx:71
virtual SvxFieldItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: flditem.cxx:301
const SvxFieldData * GetField() const
Definition: flditem.hxx:81
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:556
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:551
this field is used as a placeholder for a header&footer in impress.
Definition: flditem.hxx:409
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:885
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:890
this field is used as a placeholder for a header&footer in impress.
Definition: flditem.hxx:396
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:873
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:878
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:504
virtual MetaAction * createBeginComment() const override
Definition: flditem.cxx:514
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:509
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:481
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:486
virtual MetaAction * createBeginComment() const override
Definition: flditem.cxx:491
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:522
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:527
void SetTab(int nTab)
Definition: flditem.cxx:565
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:571
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:576
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:534
virtual MetaAction * createBeginComment() const override
Definition: flditem.cxx:544
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:539
OUString aTargetFrame
Definition: flditem.hxx:150
OUString aURL
Definition: flditem.hxx:148
SvxURLFormat eFormat
Definition: flditem.hxx:147
virtual bool operator==(const SvxFieldData &) const override
Definition: flditem.cxx:453
virtual MetaAction * createBeginComment() const override
Definition: flditem.cxx:466
virtual std::unique_ptr< SvxFieldData > Clone() const override
Definition: flditem.cxx:447
OUString aRepresentation
Definition: flditem.hxx:149
void SetTime(sal_Int64 nNewTime)
double GetTimeInDays() const
#define DBG_ASSERT(sCon, aError)
URL aURL
SvxAuthorFormat
Definition: flditem.hxx:355
SvxFileType
Definition: flditem.hxx:309
SvxURLFormat
Definition: flditem.hxx:138
SvxFileFormat
Definition: flditem.hxx:313
SvxTimeFormat
Definition: flditem.hxx:258
SvxAuthorType
Definition: flditem.hxx:352
SvxTimeType
Definition: flditem.hxx:254
SvxDateType
Definition: flditem.hxx:88
SvxDateFormat
Definition: flditem.hxx:89
OUString sName
#define LANGUAGE_ENGLISH_US
sal_uInt16 nPos
SdrMeasureFieldKind
Definition: measfld.hxx:27
aStr
aBuf
std::unique_ptr< sal_Int32[]> pData
Any GetTime(const OUString &val)
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
sal_Int16 nId
QPRO_FUNC_TYPE nType
unsigned char sal_uInt8
constexpr OUStringLiteral UNO_TC_PROP_NUMFORMAT
Definition: unonames.hxx:22
constexpr OUStringLiteral UNO_TC_PROP_AUTHOR_CONTENT
Definition: unonames.hxx:41
constexpr OUStringLiteral UNO_TC_PROP_DATE_TIME
Definition: unonames.hxx:26
constexpr OUStringLiteral UNO_TC_PROP_AUTHOR_FORMAT
Definition: unonames.hxx:42
constexpr OUStringLiteral UNO_TC_PROP_URL
Definition: unonames.hxx:32
constexpr OUStringLiteral UNO_TC_PROP_FILE_FORMAT
Definition: unonames.hxx:38
constexpr OUStringLiteral UNO_TC_PROP_IS_DATE
Definition: unonames.hxx:25
constexpr OUStringLiteral UNO_TC_PROP_TABLE_POSITION
Definition: unonames.hxx:35
constexpr OUStringLiteral UNO_TC_PROP_IS_FIXED
Definition: unonames.hxx:18
constexpr OUStringLiteral UNO_TC_PROP_URL_REPRESENTATION
Definition: unonames.hxx:30
constexpr OUStringLiteral UNO_TC_PROP_TEXTFIELD_TYPE
Definition: unonames.hxx:17
constexpr OUStringLiteral UNO_TC_PROP_URL_FORMAT
Definition: unonames.hxx:29
constexpr OUStringLiteral UNO_TC_PROP_CURRENT_PRESENTATION
Definition: unonames.hxx:19
constexpr OUStringLiteral UNO_TC_PROP_AUTHOR_FULLNAME
Definition: unonames.hxx:43
constexpr OUStringLiteral UNO_TC_PROP_NAME
Definition: unonames.hxx:20
constexpr OUStringLiteral UNO_TC_PROP_MEASURE_KIND
Definition: unonames.hxx:46
constexpr OUStringLiteral UNO_TC_PROP_URL_TARGET
Definition: unonames.hxx:31
SvNumFormatType
NF_DATE_SYSTEM_SHORT
NF_TIME_HHMMSSAMPM
NF_TIME_HHMMAMPM
NF_DATE_SYS_DMMMMYYYY
NF_TIME_HH_MMSS00
NF_DATE_SYS_NNNNDMMMMYYYY
NF_DATE_SYS_DDMMYY
NF_TIME_HHMM
NF_DATE_SYS_DMMMYYYY
NF_TIME_HHMMSS
NF_DATE_SYS_NNDMMMMYYYY
NF_DATE_SYS_DDMMYYYY
NF_DATE_SYSTEM_LONG