LibreOffice Module sw (master) 1
fmtatr2.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 <libxml/xmlwriter.h>
21#include <hintids.hxx>
22#include <poolfmt.hxx>
23#include <unomid.h>
24
25#include <o3tl/any.hxx>
26#include <svl/macitem.hxx>
27#include <svl/stylepool.hxx>
28#include <fmtautofmt.hxx>
29#include <fchrfmt.hxx>
30#include <fmtinfmt.hxx>
31#include <txtatr.hxx>
32#include <fmtruby.hxx>
33#include <charfmt.hxx>
34#include <unoevent.hxx>
35#include <com/sun/star/text/RubyAdjust.hpp>
36#include <com/sun/star/text/RubyPosition.hpp>
37#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
38#include <com/sun/star/util/XCloneable.hpp>
39#include <com/sun/star/frame/XModel.hpp>
40
41#include <com/sun/star/uno/Any.h>
42#include <SwStyleNameMapper.hxx>
44
45#include <fmtmeta.hxx>
46#include <ndtxt.hxx>
47#include <doc.hxx>
48#include <unometa.hxx>
49#include <docsh.hxx>
50#include <osl/diagnose.h>
51
52#include <algorithm>
53#include <utility>
54
55using namespace ::com::sun::star;
56
57
59
62 SwClient(pFormat),
63 m_pTextAttribute( nullptr )
64{
65}
66
69 SwClient( rAttr.GetCharFormat() ),
70 m_pTextAttribute( nullptr )
71{
72}
73
75
77{
78 assert(SfxPoolItem::operator==(rAttr));
79 return GetCharFormat() == static_cast<const SwFormatCharFormat&>(rAttr).GetCharFormat();
80}
81
83{
84 return new SwFormatCharFormat( *this );
85}
86
87// forward to the TextAttribute
89{
90 if (rHint.GetId() != SfxHintId::SwLegacyModify)
91 return;
92 auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
95}
96
97// forward to the TextAttribute
99{
100 return m_pTextAttribute && m_pTextAttribute->GetInfo( rInfo );
101}
103{
104 OUString sCharFormatName;
105 if(GetCharFormat())
107 rVal <<= sCharFormatName;
108 return true;
109}
111{
112 OSL_FAIL("format cannot be set with PutValue!");
113 return false;
114}
115
117 : SfxPoolItem( nInitWhich )
118{
119}
120
122{
123 assert(SfxPoolItem::operator==(rAttr));
124 return mpHandle == static_cast<const SwFormatAutoFormat&>(rAttr).mpHandle;
125}
126
128{
129 return new SwFormatAutoFormat( *this );
130}
131
133{
134 rVal <<= StylePool::nameOf( mpHandle );
135 return true;
136}
137
139{
140 //the format is not renameable via API
141 return false;
142}
143
145{
146 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwFormatAutoFormat"));
147 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
148 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
149 if (mpHandle) // pool default doesn't have one
150 {
151 mpHandle->dumpAsXml(pWriter);
152 }
153 (void)xmlTextWriterEndElement(pWriter);
154}
155
158 , msURL()
159 , msTargetFrame()
160 , msINetFormatName()
161 , msVisitedFormatName()
162 , msHyperlinkName()
163 , mpTextAttr( nullptr )
164 , mnINetFormatId( 0 )
165 , mnVisitedFormatId( 0 )
166{}
167
168SwFormatINetFormat::SwFormatINetFormat( OUString aURL, OUString aTarget )
170 , msURL( std::move(aURL) )
171 , msTargetFrame( std::move(aTarget) )
172 , msINetFormatName()
173 , msVisitedFormatName()
174 , msHyperlinkName()
175 , mpTextAttr( nullptr )
176 , mnINetFormatId( RES_POOLCHR_INET_NORMAL )
177 , mnVisitedFormatId( RES_POOLCHR_INET_VISIT )
178{
181}
182
185 , sw::BroadcasterMixin()
186 , msURL( rAttr.GetValue() )
187 , msTargetFrame( rAttr.msTargetFrame )
188 , msINetFormatName( rAttr.msINetFormatName )
189 , msVisitedFormatName( rAttr.msVisitedFormatName )
190 , msHyperlinkName( rAttr.msHyperlinkName )
191 , mpTextAttr( nullptr )
192 , mnINetFormatId( rAttr.mnINetFormatId )
193 , mnVisitedFormatId( rAttr.mnVisitedFormatId )
194{
195 if ( rAttr.GetMacroTable() )
196 mpMacroTable.reset( new SvxMacroTableDtor( *rAttr.GetMacroTable() ) );
197}
198
200{
201}
202
204{
205 assert(SfxPoolItem::operator==(rAttr));
206 bool bRet = SfxPoolItem::operator==( rAttr )
207 && msURL == static_cast<const SwFormatINetFormat&>(rAttr).msURL
208 && msHyperlinkName == static_cast<const SwFormatINetFormat&>(rAttr).msHyperlinkName
209 && msTargetFrame == static_cast<const SwFormatINetFormat&>(rAttr).msTargetFrame
210 && msINetFormatName == static_cast<const SwFormatINetFormat&>(rAttr).msINetFormatName
211 && msVisitedFormatName == static_cast<const SwFormatINetFormat&>(rAttr).msVisitedFormatName
212 && mnINetFormatId == static_cast<const SwFormatINetFormat&>(rAttr).mnINetFormatId
213 && mnVisitedFormatId == static_cast<const SwFormatINetFormat&>(rAttr).mnVisitedFormatId;
214
215 if( !bRet )
216 return false;
217
218 const SvxMacroTableDtor* pOther = static_cast<const SwFormatINetFormat&>(rAttr).mpMacroTable.get();
219 if( !mpMacroTable )
220 return ( !pOther || pOther->empty() );
221 if( !pOther )
222 return mpMacroTable->empty();
223
224 const SvxMacroTableDtor& rOwn = *mpMacroTable;
225 const SvxMacroTableDtor& rOther = *pOther;
226
227 return rOwn == rOther;
228}
229
231{
232 return new SwFormatINetFormat( *this );
233}
234
236{
237 if( pNewTable )
238 {
239 if( mpMacroTable )
240 *mpMacroTable = *pNewTable;
241 else
242 mpMacroTable.reset( new SvxMacroTableDtor( *pNewTable ) );
243 }
244 else
245 {
246 mpMacroTable.reset();
247 }
248}
249
251{
252 if( !mpMacroTable )
253 mpMacroTable.reset( new SvxMacroTableDtor );
254
255 mpMacroTable->Insert( nEvent, rMacro );
256}
257
259{
260 const SvxMacro* pRet = nullptr;
261 if( mpMacroTable && mpMacroTable->IsKeyValid( nEvent ) )
262 pRet = mpMacroTable->Get( nEvent );
263 return pRet;
264}
265
267{
268 nMemberId &= ~CONVERT_TWIPS;
269 switch(nMemberId)
270 {
271 case MID_URL_URL:
272 rVal <<= msURL;
273 break;
274 case MID_URL_TARGET:
275 rVal <<= msTargetFrame;
276 break;
278 rVal <<= msHyperlinkName;
279 break;
281 {
282 OUString sVal = msVisitedFormatName;
283 if (sVal.isEmpty() && mnVisitedFormatId != 0)
285 if (!sVal.isEmpty())
288 rVal <<= sVal;
289 }
290 break;
292 {
293 OUString sVal = msINetFormatName;
294 if (sVal.isEmpty() && mnINetFormatId != 0)
296 if (!sVal.isEmpty())
299 rVal <<= sVal;
300 }
301 break;
303 {
304 // create (and return) event descriptor
307 pEvents->copyMacrosFromINetFormat(*this);
308
309 // all others return a string; so we just set rVal here and exit
310 rVal <<= uno::Reference<container::XNameReplace>(pEvents);
311 }
312 break;
313 default:
314 rVal <<= OUString();
315 break;
316 }
317 return true;
318}
319bool SwFormatINetFormat::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
320{
321 bool bRet = true;
322 nMemberId &= ~CONVERT_TWIPS;
323
324 // all properties except HyperlinkEvents are of type string, hence
325 // we treat HyperlinkEvents specially
326 if (MID_URL_HYPERLINKEVENTS == nMemberId)
327 {
328 uno::Reference<container::XNameReplace> xReplace;
329 rVal >>= xReplace;
330 if (xReplace.is())
331 {
332 // Create hyperlink event descriptor. Then copy events
333 // from argument into descriptor. Then copy events from
334 // the descriptor into the format.
336 pEvents->copyMacrosFromNameReplace(xReplace);
337 pEvents->copyMacrosIntoINetFormat(*this);
338 }
339 else
340 {
341 // wrong type!
342 bRet = false;
343 }
344 }
345 else
346 {
347 // all string properties:
348 if(rVal.getValueType() != ::cppu::UnoType<OUString>::get())
349 return false;
350
351 switch(nMemberId)
352 {
353 case MID_URL_URL:
354 rVal >>= msURL;
355 break;
356 case MID_URL_TARGET:
357 rVal >>= msTargetFrame;
358 break;
360 rVal >>= msHyperlinkName;
361 break;
363 {
364 OUString sVal;
365 rVal >>= sVal;
366 OUString aString;
368 msVisitedFormatName = aString;
371 }
372 break;
374 {
375 OUString sVal;
376 rVal >>= sVal;
377 OUString aString;
379 msINetFormatName = aString;
381 }
382 break;
383 default:
384 bRet = false;
385 }
386 }
387 return bRet;
388}
389
390SwFormatRuby::SwFormatRuby( OUString aRubyText )
392 m_sRubyText( std::move(aRubyText) ),
393 m_pTextAttr( nullptr ),
394 m_nCharFormatId( 0 ),
395 m_nPosition( 0 ),
396 m_eAdjustment( css::text::RubyAdjust_LEFT )
397{
398}
399
402 m_sRubyText( rAttr.m_sRubyText ),
403 m_sCharFormatName( rAttr.m_sCharFormatName ),
404 m_pTextAttr( nullptr ),
405 m_nCharFormatId( rAttr.m_nCharFormatId),
406 m_nPosition( rAttr.m_nPosition ),
407 m_eAdjustment( rAttr.m_eAdjustment )
408{
409}
410
412{
413}
414
416{
417 if(this == &rAttr)
418 return *this;
419
420 m_sRubyText = rAttr.m_sRubyText;
423 m_nPosition = rAttr.m_nPosition;
425 m_pTextAttr = nullptr;
426 return *this;
427}
428
429bool SwFormatRuby::operator==( const SfxPoolItem& rAttr ) const
430{
431 assert(SfxPoolItem::operator==(rAttr));
432 return m_sRubyText == static_cast<const SwFormatRuby&>(rAttr).m_sRubyText &&
433 m_sCharFormatName == static_cast<const SwFormatRuby&>(rAttr).m_sCharFormatName &&
434 m_nCharFormatId == static_cast<const SwFormatRuby&>(rAttr).m_nCharFormatId &&
435 m_nPosition == static_cast<const SwFormatRuby&>(rAttr).m_nPosition &&
436 m_eAdjustment == static_cast<const SwFormatRuby&>(rAttr).m_eAdjustment;
437}
438
440{
441 return new SwFormatRuby( *this );
442}
443
445 sal_uInt8 nMemberId ) const
446{
447 bool bRet = true;
448 nMemberId &= ~CONVERT_TWIPS;
449 switch( nMemberId )
450 {
451 case MID_RUBY_TEXT: rVal <<= m_sRubyText; break;
452 case MID_RUBY_ADJUST: rVal <<= static_cast<sal_Int16>(m_eAdjustment); break;
454 {
455 OUString aString;
457 rVal <<= aString;
458 }
459 break;
460 case MID_RUBY_ABOVE:
461 {
462 rVal <<= static_cast<bool>(!m_nPosition);
463 }
464 break;
466 {
467 rVal <<= m_nPosition;
468 }
469 break;
470 default:
471 bRet = false;
472 }
473 return bRet;
474}
476 sal_uInt8 nMemberId )
477{
478 bool bRet = true;
479 nMemberId &= ~CONVERT_TWIPS;
480 switch( nMemberId )
481 {
482 case MID_RUBY_TEXT:
483 bRet = rVal >>= m_sRubyText;
484 break;
485 case MID_RUBY_ADJUST:
486 {
487 sal_Int16 nSet = 0;
488 rVal >>= nSet;
489 if(nSet >= sal_Int16(text::RubyAdjust_LEFT) && nSet <= sal_Int16(text::RubyAdjust_INDENT_BLOCK))
490 m_eAdjustment = static_cast<text::RubyAdjust>(nSet);
491 else
492 bRet = false;
493 }
494 break;
495 case MID_RUBY_ABOVE:
496 {
497 const uno::Type& rType = cppu::UnoType<bool>::get();
498 if(rVal.hasValue() && rVal.getValueType() == rType)
499 {
500 bool bAbove = *o3tl::doAccess<bool>(rVal);
501 m_nPosition = bAbove ? 0 : 1;
502 }
503 }
504 break;
506 {
507 sal_Int16 nSet = 0;
508 rVal >>= nSet;
509 if(nSet >= sal_Int16(text::RubyPosition::ABOVE) && nSet <= sal_Int16(text::RubyPosition::INTER_CHARACTER))
510 m_nPosition = nSet;
511 else
512 bRet = false;
513 }
514 break;
516 {
517 OUString sTmp;
518 bRet = rVal >>= sTmp;
519 if(bRet)
521 }
522 break;
523 default:
524 bRet = false;
525 }
526 return bRet;
527}
528
530{
531 return new SwFormatMeta(i_nWhich);
532}
533
534SwFormatMeta::SwFormatMeta(const sal_uInt16 i_nWhich)
535 : SfxPoolItem( i_nWhich )
536 , m_pMeta()
537 , m_pTextAttr( nullptr )
538{
539 OSL_ENSURE((RES_TXTATR_META == i_nWhich) || (RES_TXTATR_METAFIELD == i_nWhich),
540 "ERROR: SwFormatMeta: invalid which id!");
541}
542
543SwFormatMeta::SwFormatMeta( std::shared_ptr< ::sw::Meta > i_pMeta,
544 const sal_uInt16 i_nWhich )
545 : SfxPoolItem( i_nWhich )
546 , m_pMeta( std::move(i_pMeta) )
547 , m_pTextAttr( nullptr )
548{
549 OSL_ENSURE((RES_TXTATR_META == i_nWhich) || (RES_TXTATR_METAFIELD == i_nWhich),
550 "ERROR: SwFormatMeta: invalid which id!");
551 OSL_ENSURE(m_pMeta, "SwFormatMeta: no Meta ?");
552 // DO NOT call m_pMeta->SetFormatMeta(this) here; only from SetTextAttr!
553}
554
556{
557 if (m_pMeta && (m_pMeta->GetFormatMeta() == this))
558 {
559 NotifyChangeTextNode(nullptr);
560 m_pMeta->SetFormatMeta(nullptr);
561 }
562}
563
564bool SwFormatMeta::operator==( const SfxPoolItem & i_rOther ) const
565{
566 return SfxPoolItem::operator==( i_rOther )
567 && m_pMeta == static_cast<SwFormatMeta const &>( i_rOther ).m_pMeta;
568}
569
571{
572 // if this is indeed a copy, then DoCopy must be called later!
573 return m_pMeta // #i105148# pool default may be cloned also!
574 ? new SwFormatMeta( m_pMeta, Which() ) : new SwFormatMeta( Which() );
575}
576
577void SwFormatMeta::SetTextAttr(SwTextMeta * const i_pTextAttr)
578{
579 OSL_ENSURE(!(m_pTextAttr && i_pTextAttr),
580 "SwFormatMeta::SetTextAttr: already has text attribute?");
581 OSL_ENSURE( m_pTextAttr || i_pTextAttr ,
582 "SwFormatMeta::SetTextAttr: no attribute to remove?");
583 m_pTextAttr = i_pTextAttr;
584 OSL_ENSURE(m_pMeta, "inserted SwFormatMeta has no sw::Meta?");
585 // the sw::Meta must be able to find the current text attribute!
586 if (m_pMeta)
587 {
588 if (i_pTextAttr)
589 {
590 m_pMeta->SetFormatMeta(this);
591 }
592 else if (m_pMeta->GetFormatMeta() == this)
593 { // text attribute gone => de-register from text node!
594 NotifyChangeTextNode(nullptr);
595 m_pMeta->SetFormatMeta(nullptr);
596 }
597 }
598}
599
601{
602 // N.B.: do not reset m_pTextAttr here: see call in nodes.cxx,
603 // where the hint is not deleted!
604 OSL_ENSURE(m_pMeta, "SwFormatMeta::NotifyChangeTextNode: no Meta?");
605 if (m_pMeta && (m_pMeta->GetFormatMeta() == this))
606 { // do not call Modify, that would call SwXMeta::SwClientNotify
607 m_pMeta->NotifyChangeTextNode(pTextNode);
608 }
609}
610
611// this SwFormatMeta has been cloned and points at the same sw::Meta as the source
612// this method copies the sw::Meta
614 SwTextNode & i_rTargetTextNode)
615{
616 OSL_ENSURE(m_pMeta, "DoCopy called for SwFormatMeta with no sw::Meta?");
617 if (!m_pMeta)
618 return;
619
620 const std::shared_ptr< ::sw::Meta> pOriginal( m_pMeta );
621 if (RES_TXTATR_META == Which())
622 {
623 m_pMeta = std::make_shared<::sw::Meta>(this);
624 }
625 else
626 {
627 ::sw::MetaField *const pMetaField(
628 static_cast< ::sw::MetaField* >(pOriginal.get()));
629 m_pMeta = i_rTargetDocManager.makeMetaField( this,
630 pMetaField->m_nNumberFormat, pMetaField->IsFixedLanguage() );
631 }
632 // Meta must have a text node before calling RegisterAsCopyOf
633 m_pMeta->NotifyChangeTextNode(& i_rTargetTextNode);
634 // this cannot be done in Clone: a Clone is not necessarily a copy!
635 m_pMeta->RegisterAsCopyOf(*pOriginal);
636}
637
638namespace sw {
639
640Meta::Meta(SwFormatMeta * const i_pFormat)
641 : ::sfx2::Metadatable()
642 , sw::BroadcastingModify()
643 , m_pFormat(i_pFormat)
644 , m_pTextNode(nullptr)
645{
646}
647
649{
650}
651
653{
654 return m_pFormat ? m_pFormat->GetTextAttr() : nullptr;
655}
656
658{ m_wXMeta = xMeta.get(); }
659
661{
662 m_pTextNode = pTextNode;
663 if (m_pTextNode && (GetRegisteredIn() != m_pTextNode))
664 {
665 m_pTextNode->Add(this);
666 }
667 else if (!m_pTextNode)
668 {
669 EndListeningAll();
670 }
671 if (!pTextNode) // text node gone? invalidate UNO object!
672 {
673 GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing));
674 }
675}
676
677void Meta::SwClientNotify(const SwModify&, const SfxHint& rHint)
678{
679 if (rHint.GetId() != SfxHintId::SwLegacyModify)
680 return;
681 auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
682 CallSwClientNotify(rHint);
683 GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged));
684 if(RES_REMOVE_UNO_OBJECT == pLegacy->GetWhich())
685 { // invalidate cached uno object
686 SetXMeta(nullptr);
687 GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing));
688 }
689}
690
691// sfx2::Metadatable
693{
694 SwTextNode * const pTextNode( GetTextNode() );
695 // GetRegistry may only be called on a meta that is actually in the
696 // document, which means it has a pointer to its text node
697 OSL_ENSURE(pTextNode, "ERROR: GetRegistry: no text node?");
698 if (!pTextNode)
699 throw uno::RuntimeException();
700 return pTextNode->GetRegistry();
701}
702
704{
705 const SwTextNode * const pTextNode( GetTextNode() );
706// no text node: in UNDO OSL_ENSURE(pTextNode, "IsInClipboard: no text node?");
707 return pTextNode && pTextNode->IsInClipboard();
708}
709
710bool Meta::IsInUndo() const
711{
712 const SwTextNode * const pTextNode( GetTextNode() );
713// no text node: in UNDO OSL_ENSURE(pTextNode, "IsInUndo: no text node?");
714 return pTextNode == nullptr || pTextNode->IsInUndo();
715}
716
718{
719 const SwTextNode * const pTextNode( GetTextNode() );
720 OSL_ENSURE(pTextNode, "IsInContent: no text node?");
721 return pTextNode == nullptr || pTextNode->IsInContent();
722}
723
724css::uno::Reference< css::rdf::XMetadatable > Meta::MakeUnoObject()
725{
726 return SwXMeta::CreateXMeta(*this);
727}
728
730 const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage)
731 : Meta(i_pFormat)
732 , m_nNumberFormat( nNumberFormat )
733 , m_bIsFixedLanguage( bIsFixedLanguage )
734{
735}
736
738 OUString *const o_pPrefix, OUString *const o_pSuffix, OUString *const o_pShadowsColor)
739{
740 try
741 {
742 const uno::Reference<rdf::XMetadatable> xMetaField( MakeUnoObject() );
743 assert(dynamic_cast<SwXMetaField*>(xMetaField.get()) && "GetPrefixAndSuffix: no SwXMetaField?");
744 if (xMetaField.is())
745 {
746 SwTextNode * const pTextNode( GetTextNode() );
747 SwDocShell const * const pShell(pTextNode->GetDoc().GetDocShell());
748 const uno::Reference<frame::XModel> xModel(
749 pShell ? pShell->GetModel() : nullptr, uno::UNO_SET_THROW);
750 getPrefixAndSuffix(xModel, xMetaField, o_pPrefix, o_pSuffix, o_pShadowsColor);
751 }
752 }
753 catch (const uno::Exception&)
754 {
755 TOOLS_WARN_EXCEPTION( "sw", "");
756 }
757}
758
759sal_uInt32 MetaField::GetNumberFormat(std::u16string_view aContent) const
760{
761 //TODO: this probably lacks treatment for some special cases
762 sal_uInt32 nNumberFormat( m_nNumberFormat );
763 SwTextNode * const pTextNode( GetTextNode() );
764 if (pTextNode)
765 {
766 double number;
767 (void) pTextNode->GetDoc().IsNumberFormat( aContent, nNumberFormat, number );
768 }
769 return nNumberFormat;
770}
771
772void MetaField::SetNumberFormat(sal_uInt32 nNumberFormat)
773{
774 // effectively, the member is only a default:
775 // GetNumberFormat checks if the text actually conforms
776 m_nNumberFormat = nNumberFormat;
777}
778
780{
781}
782
783std::shared_ptr<MetaField>
785 const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage)
786{
787 const std::shared_ptr<MetaField> pMetaField(
788 new MetaField(i_pFormat, nNumberFormat, bIsFixedLanguage) );
789 m_MetaFields.push_back(pMetaField);
790 return pMetaField;
791}
792
793namespace {
794
795struct IsInUndo
796{
797 bool operator()(std::weak_ptr<MetaField> const & pMetaField) {
798 return pMetaField.lock()->IsInUndo();
799 }
800};
801
802struct MakeUnoObject
803{
804 uno::Reference<text::XTextField>
805 operator()(std::weak_ptr<MetaField> const & pMetaField) {
806 return uno::Reference<text::XTextField>(
807 pMetaField.lock()->MakeUnoObject(), uno::UNO_QUERY);
808 }
809};
810
811}
812
813std::vector< uno::Reference<text::XTextField> >
815{
816 // erase deleted fields
817 const MetaFieldList_t::iterator iter(
818 std::remove_if(m_MetaFields.begin(), m_MetaFields.end(),
819 [] (std::weak_ptr<MetaField> const& rField) { return rField.expired(); }));
820 m_MetaFields.erase(iter, m_MetaFields.end());
821 // filter out fields in UNDO
822 MetaFieldList_t filtered(m_MetaFields.size());
823 const MetaFieldList_t::iterator iter2(
824 std::remove_copy_if(m_MetaFields.begin(), m_MetaFields.end(),
825 filtered.begin(), IsInUndo()));
826 filtered.erase(iter2, filtered.end());
827 // create uno objects
828 std::vector< uno::Reference<text::XTextField> > ret(filtered.size());
829 std::transform(filtered.begin(), filtered.end(), ret.begin(),
830 MakeUnoObject());
831 return ret;
832}
833
835{
836 const SwDocShell* pDocShell = rSource.GetDocShell();
837 if (!pDocShell)
838 return;
839
840 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(pDocShell->GetModel(), uno::UNO_QUERY);
841 uno::Reference<util::XCloneable> xCloneable(xDocumentPropertiesSupplier->getDocumentProperties(), uno::UNO_QUERY);
842 m_xDocumentProperties.set(xCloneable->createClone(), uno::UNO_QUERY);
843}
844
845const uno::Reference<document::XDocumentProperties>& MetaFieldManager::getDocumentProperties() const
846{
848}
849
850} // namespace sw
851
852/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
sal_Int32 m_nPosition
SfxHintId GetId() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
sal_uInt16 Which() const
virtual bool operator==(const SfxPoolItem &) const=0
static OUString nameOf(const std::shared_ptr< SfxItemSet > &pSet)
bool empty() const
Represents the style of a text portion.
Definition: charfmt.hxx:27
Definition: doc.hxx:194
bool IsNumberFormat(std::u16string_view aString, sal_uInt32 &F_Index, double &fOutNumber)
Definition: ndtbl.cxx:4010
SwDocShell * GetDocShell()
Definition: doc.hxx:1359
std::shared_ptr< SfxItemSet > mpHandle
Definition: fmtautofmt.hxx:28
virtual bool operator==(const SfxPoolItem &) const override
"pure virtual methods" of SfxPoolItem
Definition: fmtatr2.cxx:121
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: fmtatr2.cxx:132
SwFormatAutoFormat(sal_uInt16 nWhich=RES_TXTATR_AUTOFMT)
Definition: fmtatr2.cxx:116
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: fmtatr2.cxx:138
virtual SwFormatAutoFormat * Clone(SfxItemPool *pPool=nullptr) const override
Definition: fmtatr2.cxx:127
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: fmtatr2.cxx:144
virtual bool operator==(const SfxPoolItem &) const override
"pure virtual methods" of SfxPoolItem
Definition: fmtatr2.cxx:76
virtual bool GetInfo(SfxPoolItem &rInfo) const override
Definition: fmtatr2.cxx:98
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: fmtatr2.cxx:88
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: fmtatr2.cxx:102
SwCharFormat * GetCharFormat() const
Definition: fchrfmt.hxx:70
virtual ~SwFormatCharFormat() override
Definition: fmtatr2.cxx:74
SwFormatCharFormat(SwCharFormat *pFormat)
single argument ctors shall be explicit.
Definition: fmtatr2.cxx:60
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: fmtatr2.cxx:110
virtual SwFormatCharFormat * Clone(SfxItemPool *pPool=nullptr) const override
Definition: fmtatr2.cxx:82
SwTextCharFormat * m_pTextAttribute
My text attribute.
Definition: fchrfmt.hxx:33
void SetMacroTable(const SvxMacroTableDtor *pTable)
Set a new MacroTable or clear the current one.
Definition: fmtatr2.cxx:235
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: fmtatr2.cxx:319
static SfxPoolItem * CreateDefault()
Definition: fmtatr2.cxx:58
const SvxMacroTableDtor * GetMacroTable() const
Definition: fmtinfmt.hxx:132
virtual SwFormatINetFormat * Clone(SfxItemPool *pPool=nullptr) const override
Definition: fmtatr2.cxx:230
sal_uInt16 mnINetFormatId
Definition: fmtinfmt.hxx:48
std::unique_ptr< SvxMacroTableDtor > mpMacroTable
Definition: fmtinfmt.hxx:46
OUString msTargetFrame
Target frame for URL.
Definition: fmtinfmt.hxx:42
OUString msURL
URL.
Definition: fmtinfmt.hxx:41
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: fmtatr2.cxx:266
OUString msINetFormatName
Definition: fmtinfmt.hxx:43
OUString msHyperlinkName
Name of the link.
Definition: fmtinfmt.hxx:45
const SvxMacro * GetMacro(SvMacroItemId nEvent) const
Definition: fmtatr2.cxx:258
virtual bool operator==(const SfxPoolItem &) const override
"Pure virtual methods" of SfxPoolItem.
Definition: fmtatr2.cxx:203
OUString msVisitedFormatName
Definition: fmtinfmt.hxx:44
SwFormatINetFormat()
For TypeInfo.
Definition: fmtatr2.cxx:156
sal_uInt16 mnVisitedFormatId
Definition: fmtinfmt.hxx:49
void SetMacro(SvMacroItemId nEvent, const SvxMacro &rMacro)
Macro getter and setter.
Definition: fmtatr2.cxx:250
virtual ~SwFormatINetFormat() override
Definition: fmtatr2.cxx:199
SwTextMeta * GetTextAttr()
Definition: fmtmeta.hxx:100
std::shared_ptr< ::sw::Meta > m_pMeta
Definition: fmtmeta.hxx:97
SwTextMeta * m_pTextAttr
Definition: fmtmeta.hxx:98
static SwFormatMeta * CreatePoolDefault(const sal_uInt16 i_nWhich)
Definition: fmtatr2.cxx:529
void NotifyChangeTextNode(SwTextNode *const pTextNode)
notify clients registered at m_pMeta that this meta is being (re-)moved
Definition: fmtatr2.cxx:600
void DoCopy(::sw::MetaFieldManager &i_rTargetDocManager, SwTextNode &i_rTargetTextNode)
this method must be called when the hint is actually copied
Definition: fmtatr2.cxx:613
SwFormatMeta(const sal_uInt16 i_nWhich)
Definition: fmtatr2.cxx:534
virtual bool operator==(const SfxPoolItem &) const override
SfxPoolItem.
Definition: fmtatr2.cxx:564
virtual SwFormatMeta * Clone(SfxItemPool *pPool=nullptr) const override
Definition: fmtatr2.cxx:570
void SetTextAttr(SwTextMeta *const i_pTextAttr)
Definition: fmtatr2.cxx:577
virtual ~SwFormatMeta() override
Definition: fmtatr2.cxx:555
SwFormatRuby & operator=(const SwFormatRuby &rAttr)
Definition: fmtatr2.cxx:415
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: fmtatr2.cxx:444
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: fmtatr2.cxx:475
virtual ~SwFormatRuby() override
Definition: fmtatr2.cxx:411
SwFormatRuby(OUString aRubyText)
Definition: fmtatr2.cxx:390
sal_uInt16 m_nCharFormatId
PoolId of the charformat.
Definition: fmtruby.hxx:35
OUString m_sRubyText
The ruby text.
Definition: fmtruby.hxx:32
virtual SwFormatRuby * Clone(SfxItemPool *pPool=nullptr) const override
Definition: fmtatr2.cxx:439
virtual bool operator==(const SfxPoolItem &) const override
Definition: fmtatr2.cxx:429
OUString m_sCharFormatName
Name of the charformat.
Definition: fmtruby.hxx:33
sal_uInt16 m_nPosition
Position of the Ruby-character.
Definition: fmtruby.hxx:36
css::text::RubyAdjust m_eAdjustment
Specific adjustment of the Ruby-ch.
Definition: fmtruby.hxx:37
SwTextRuby * m_pTextAttr
The TextAttribute.
Definition: fmtruby.hxx:34
SwDoc & GetDoc()
Definition: node.hxx:233
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
static void FillProgName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
static void FillUIName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
bool GetInfo(SfxPoolItem const &rInfo) const
Definition: txtatr2.cxx:71
void TriggerNodeUpdate(const sw::LegacyModifyHint &)
Definition: txtatr2.cxx:52
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:111
virtual bool IsInUndo() const override
Is this node in the undo array?
Definition: ndtxt.cxx:5388
virtual bool IsInClipboard() const override
Definition: ndtxt.cxx:5383
virtual ::sfx2::IXmlIdRegistry & GetRegistry() override
sfx2::Metadatable
Definition: ndtxt.cxx:5378
virtual bool IsInContent() const override
Definition: ndtxt.cxx:5393
static rtl::Reference< SwXMeta > CreateXMeta(::sw::Meta &rMeta, css::uno::Reference< css::text::XText > const &xParentText=nullptr, std::unique_ptr< TextRangeList_t const > &&pPortions=std::unique_ptr< TextRangeList_t const >())
css::uno::Type const & get()
knows all meta-fields in the document.
Definition: fmtmeta.hxx:195
std::shared_ptr< MetaField > makeMetaField(SwFormatMeta *const i_pFormat=nullptr, const sal_uInt32 nNumberFormat=SAL_MAX_UINT32, const bool bIsFixedLanguage=false)
Definition: fmtatr2.cxx:784
MetaFieldList_t m_MetaFields
Definition: fmtmeta.hxx:198
std::vector< css::uno::Reference< css::text::XTextField > > getMetaFields()
get all meta fields
Definition: fmtatr2.cxx:814
css::uno::Reference< css::document::XDocumentProperties > m_xDocumentProperties
Document properties of a clipboard document, empty for non-clipboard documents.
Definition: fmtmeta.hxx:200
const css::uno::Reference< css::document::XDocumentProperties > & getDocumentProperties() const
Definition: fmtatr2.cxx:845
std::vector< std::weak_ptr< MetaField > > MetaFieldList_t
Definition: fmtmeta.hxx:197
void copyDocumentProperties(const SwDoc &rSource)
Copy document properties from rSource to m_xDocumentProperties.
Definition: fmtatr2.cxx:834
sal_uInt32 GetNumberFormat(std::u16string_view aContent) const
Definition: fmtatr2.cxx:759
sal_uInt32 m_nNumberFormat
Definition: fmtmeta.hxx:175
MetaField(SwFormatMeta *const i_pFormat, const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage)
Definition: fmtatr2.cxx:729
void GetPrefixAndSuffix(OUString *const o_pPrefix, OUString *const o_pSuffix, OUString *const o_pShadingColor)
get prefix/suffix from the RDF repository.
Definition: fmtatr2.cxx:737
bool IsFixedLanguage() const
Definition: fmtmeta.hxx:180
void SetNumberFormat(sal_uInt32 nNumberFormat)
Definition: fmtatr2.cxx:772
SwTextNode * GetTextNode() const
Definition: fmtmeta.hxx:142
SwTextMeta * GetTextAttr() const
Definition: fmtatr2.cxx:652
virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override
Definition: fmtatr2.cxx:724
Meta(SwFormatMeta *const i_pFormat)
Definition: fmtatr2.cxx:640
virtual ~Meta() override
Definition: fmtatr2.cxx:648
void SetXMeta(rtl::Reference< SwXMeta > const &xMeta)
Definition: fmtatr2.cxx:657
virtual ::sfx2::IXmlIdRegistry & GetRegistry() override
sfx2::Metadatable
Definition: fmtatr2.cxx:692
virtual bool IsInUndo() const override
Definition: fmtatr2.cxx:710
virtual bool IsInClipboard() const override
Definition: fmtatr2.cxx:703
unotools::WeakReference< SwXMeta > m_wXMeta
Definition: fmtmeta.hxx:134
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: fmtatr2.cxx:677
SwTextNode * m_pTextNode
Definition: fmtmeta.hxx:137
SwFormatMeta * m_pFormat
Definition: fmtmeta.hxx:136
virtual bool IsInContent() const override
Definition: fmtatr2.cxx:717
void NotifyChangeTextNode(SwTextNode *const pTextNode)
Definition: fmtatr2.cxx:660
#define TOOLS_WARN_EXCEPTION(area, stream)
URL aURL
virtual OUString GetName() const override
SvMacroItemId
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(181)
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_METAFIELD(49)
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_META(48)
constexpr TypedWhichId< SwFormatRuby > RES_TXTATR_CJK_RUBY(53)
def text(shape, orig_st)
Dialog to specify the properties of date form field.
const char GetValue[]
@ RES_POOLCHR_INET_VISIT
Internet visited.
Definition: poolfmt.hxx:121
@ RES_POOLCHR_INET_NORMAL
Internet normal.
Definition: poolfmt.hxx:120
bool hasValue()
Reference< XModel > xModel
OUString m_sRubyText
unsigned char sal_uInt8
void getPrefixAndSuffix(const css::uno::Reference< css::frame::XModel > &xModel, const css::uno::Reference< css::rdf::XMetadatable > &xMetaField, OUString *const o_pPrefix, OUString *const o_pSuffix, OUString *const o_pShadowColor)
get prefix/suffix from the RDF repository.
#define MID_URL_URL
Definition: unomid.h:50
#define MID_RUBY_POSITION
Definition: unomid.h:117
#define MID_RUBY_ABOVE
Definition: unomid.h:116
#define MID_URL_TARGET
Definition: unomid.h:51
#define MID_RUBY_TEXT
Definition: unomid.h:113
#define MID_RUBY_ADJUST
Definition: unomid.h:114
#define MID_URL_UNVISITED_FMT
Definition: unomid.h:53
#define MID_URL_HYPERLINKEVENTS
Definition: unomid.h:54
#define MID_URL_HYPERLINKNAME
Definition: unomid.h:47
#define MID_URL_VISITED_FMT
Definition: unomid.h:52
#define MID_RUBY_CHARSTYLE
Definition: unomid.h:115