/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
bool SwFormatINetFormat::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
{
nMemberId &= ~CONVERT_TWIPS; switch(nMemberId)
{ case MID_URL_URL:
rVal <<= msURL; break; case MID_URL_TARGET:
rVal <<= msTargetFrame; break; case MID_URL_HYPERLINKNAME:
rVal <<= msHyperlinkName; break; case MID_URL_VISITED_FMT:
{
UIName sVal = msVisitedFormatName; if (sVal.isEmpty() && mnVisitedFormatId != 0)
SwStyleNameMapper::FillUIName(mnVisitedFormatId, sVal);
ProgName aRet; if (!sVal.isEmpty())
SwStyleNameMapper::FillProgName(sVal, aRet,
SwGetPoolIdFromName::ChrFmt);
rVal <<= aRet.toString();
} break; case MID_URL_UNVISITED_FMT:
{
UIName sVal = msINetFormatName; if (sVal.isEmpty() && mnINetFormatId != 0)
SwStyleNameMapper::FillUIName(mnINetFormatId, sVal);
ProgName aRet; if (!sVal.isEmpty())
SwStyleNameMapper::FillProgName(sVal, aRet,
SwGetPoolIdFromName::ChrFmt);
rVal <<= aRet.toString();
} break; case MID_URL_HYPERLINKEVENTS:
{ // create (and return) event descriptor
rtl::Reference<SwHyperlinkEventDescriptor> pEvents = new SwHyperlinkEventDescriptor();
pEvents->copyMacrosFromINetFormat(*this);
// all others return a string; so we just set rVal here and exit
rVal <<= uno::Reference<container::XNameReplace>(pEvents);
} break; default:
rVal <<= OUString(); break;
} returntrue;
} bool SwFormatINetFormat::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
{ bool bRet = true;
nMemberId &= ~CONVERT_TWIPS;
// all properties except HyperlinkEvents are of type string, hence // we treat HyperlinkEvents specially if (MID_URL_HYPERLINKEVENTS == nMemberId)
{
uno::Reference<container::XNameReplace> xReplace;
rVal >>= xReplace; if (xReplace.is())
{ // Create hyperlink event descriptor. Then copy events // from argument into descriptor. Then copy events from // the descriptor into the format.
rtl::Reference<SwHyperlinkEventDescriptor> pEvents = new SwHyperlinkEventDescriptor();
pEvents->copyMacrosFromNameReplace(xReplace);
pEvents->copyMacrosIntoINetFormat(*this);
} else
{ // wrong type!
bRet = false;
}
} else
{ // all string properties: if(rVal.getValueType() != ::cppu::UnoType<OUString>::get()) returnfalse;
SwFormatRuby& SwFormatRuby::operator=( const SwFormatRuby& rAttr )
{ // SwFormatRuby is not shareable, so ptr compare is OK if (areSfxPoolItemPtrsEqual(this, &rAttr)) return *this;
SwFormatMeta::SwFormatMeta( std::shared_ptr< ::sw::Meta > i_pMeta, const sal_uInt16 i_nWhich )
: SfxPoolItem( i_nWhich )
, m_pMeta( std::move(i_pMeta) )
, m_pTextAttr( nullptr )
{
setNonShareable();
OSL_ENSURE((RES_TXTATR_META == i_nWhich) || (RES_TXTATR_METAFIELD == i_nWhich), "ERROR: SwFormatMeta: invalid which id!");
OSL_ENSURE(m_pMeta, "SwFormatMeta: no Meta ?"); // DO NOT call m_pMeta->SetFormatMeta(this) here; only from SetTextAttr!
}
SwFormatMeta::~SwFormatMeta()
{ // SwFormatMeta is not shareable, so ptr compare is OK if (m_pMeta && areSfxPoolItemPtrsEqual(m_pMeta->GetFormatMeta(), this))
{
NotifyChangeTextNode(nullptr);
m_pMeta->SetFormatMeta(nullptr);
}
}
SwFormatMeta* SwFormatMeta::Clone( SfxItemPool * /*pPool*/ ) const
{ // if this is indeed a copy, then DoCopy must be called later! return m_pMeta // #i105148# pool default may be cloned also!
? new SwFormatMeta( m_pMeta, Which() ) : new SwFormatMeta( Which() );
}
void SwFormatMeta::SetTextAttr(SwTextMeta * const i_pTextAttr)
{
OSL_ENSURE(!(m_pTextAttr && i_pTextAttr), "SwFormatMeta::SetTextAttr: already has text attribute?");
OSL_ENSURE( m_pTextAttr || i_pTextAttr , "SwFormatMeta::SetTextAttr: no attribute to remove?");
m_pTextAttr = i_pTextAttr;
OSL_ENSURE(m_pMeta, "inserted SwFormatMeta has no sw::Meta?"); // the sw::Meta must be able to find the current text attribute! if (m_pMeta)
{ if (i_pTextAttr)
{
m_pMeta->SetFormatMeta(this);
} // SwFormatMeta is not shareable, so ptr compare is OK elseif (areSfxPoolItemPtrsEqual(m_pMeta->GetFormatMeta(), this))
{ // text attribute gone => de-register from text node!
NotifyChangeTextNode(nullptr);
m_pMeta->SetFormatMeta(nullptr);
}
}
}
void SwFormatMeta::NotifyChangeTextNode(SwTextNode *const pTextNode)
{ // N.B.: do not reset m_pTextAttr here: see call in nodes.cxx, // where the hint is not deleted!
OSL_ENSURE(m_pMeta, "SwFormatMeta::NotifyChangeTextNode: no Meta?"); // SwFormatMeta is not shareable, so ptr compare is OK if (m_pMeta && areSfxPoolItemPtrsEqual(m_pMeta->GetFormatMeta(), this))
{ // do not call Modify, that would call SwXMeta::SwClientNotify
m_pMeta->NotifyChangeTextNode(pTextNode);
}
}
// this SwFormatMeta has been cloned and points at the same sw::Meta as the source // this method copies the sw::Meta void SwFormatMeta::DoCopy(::sw::MetaFieldManager & i_rTargetDocManager,
SwTextNode & i_rTargetTextNode)
{
OSL_ENSURE(m_pMeta, "DoCopy called for SwFormatMeta with no sw::Meta?"); if (!m_pMeta) return;
const std::shared_ptr< ::sw::Meta> pOriginal( m_pMeta ); if (RES_TXTATR_META == Which())
{
m_pMeta = std::make_shared<::sw::Meta>(this);
} else
{
::sw::MetaField *const pMetaField( static_cast< ::sw::MetaField* >(pOriginal.get()));
m_pMeta = i_rTargetDocManager.makeMetaField( this,
pMetaField->m_nNumberFormat, pMetaField->IsFixedLanguage() );
} // Meta must have a text node before calling RegisterAsCopyOf
m_pMeta->NotifyChangeTextNode(& i_rTargetTextNode); // this cannot be done in Clone: a Clone is not necessarily a copy!
m_pMeta->RegisterAsCopyOf(*pOriginal);
}
// sfx2::Metadatable
::sfx2::IXmlIdRegistry& Meta::GetRegistry()
{
SwTextNode * const pTextNode( GetTextNode() ); // GetRegistry may only be called on a meta that is actually in the // document, which means it has a pointer to its text node
OSL_ENSURE(pTextNode, "ERROR: GetRegistry: no text node?"); if (!pTextNode) throw uno::RuntimeException(); return pTextNode->GetRegistry();
}
bool Meta::IsInClipboard() const
{ const SwTextNode * const pTextNode( GetTextNode() ); // no text node: in UNDO OSL_ENSURE(pTextNode, "IsInClipboard: no text node?"); return pTextNode && pTextNode->IsInClipboard();
}
bool Meta::IsInUndo() const
{ const SwTextNode * const pTextNode( GetTextNode() ); // no text node: in UNDO OSL_ENSURE(pTextNode, "IsInUndo: no text node?"); return pTextNode == nullptr || pTextNode->IsInUndo();
}
sal_uInt32 MetaField::GetNumberFormat(const OUString& aContent) const
{ //TODO: this probably lacks treatment for some special cases
sal_uInt32 nNumberFormat( m_nNumberFormat );
SwTextNode * const pTextNode( GetTextNode() ); if (pTextNode)
{ double number;
(void) pTextNode->GetDoc().IsNumberFormat( aContent, nNumberFormat, number );
} return nNumberFormat;
}
void MetaField::SetNumberFormat(sal_uInt32 nNumberFormat)
{ // effectively, the member is only a default: // GetNumberFormat checks if the text actually conforms
m_nNumberFormat = nNumberFormat;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.