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