/* -*- 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 .
*/
// the following applies only to bookmarks (not to fieldmarks)
Bookmark* pBookmark = dynamic_cast<Bookmark*>(m_pRegisteredBookmark); if (pBookmark)
{
m_bHidden = pBookmark->IsHidden();
m_HideCondition = pBookmark->GetHideCondition();
}
EndListeningAll();
}
m_pRegisteredBookmark = pBkmk; // need a permanent Reference to initialize m_wThis
m_wThis = xBookmark.get();
}
m_pImpl->m_pDoc = pDoc;
SwUnoInternalPaM aPam(*m_pImpl->m_pDoc);
::sw::XTextRangeToSwPaM(aPam, xTextRange);
UnoActionContext aCont(m_pImpl->m_pDoc); if (m_pImpl->m_sMarkName.isEmpty())
{
m_pImpl->m_sMarkName = SwMarkName("Bookmark");
} if ((eType == IDocumentMarkAccess::MarkType::BOOKMARK) &&
::sw::mark::CrossRefNumItemBookmark::IsLegalName(m_pImpl->m_sMarkName))
{
eType = IDocumentMarkAccess::MarkType::CROSSREF_NUMITEM_BOOKMARK;
} elseif ((eType == IDocumentMarkAccess::MarkType::BOOKMARK) &&
::sw::mark::CrossRefHeadingBookmark::IsLegalName(m_pImpl->m_sMarkName) &&
IDocumentMarkAccess::IsLegalPaMForCrossRefHeadingBookmark( aPam ) )
{
eType = IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK;
}
m_pImpl->registerInMark(*this,
m_pImpl->m_pDoc->getIDocumentMarkAccess()->makeMark(
aPam, m_pImpl->m_sMarkName, eType, ::sw::mark::InsertMode::New, // note: aPam will be moved fwd by inserting start char, so sep // will be directly following start
isFieldmarkSeparatorAtStart ? aPam.Start() : nullptr)); // #i81002# // Check, if bookmark has been created. // E.g., the creation of a cross-reference bookmark is suppress, // if the PaM isn't a valid one for cross-reference bookmarks. if (!m_pImpl->m_pRegisteredBookmark)
{
OSL_FAIL("" " - could not create Mark."); throw lang::IllegalArgumentException();
}
}
void SAL_CALL SwXBookmark::addEventListener( const uno::Reference< lang::XEventListener > & xListener)
{ // no need to lock here as m_pImpl is const and container threadsafe
std::unique_lock aGuard(m_pImpl->m_Mutex);
m_pImpl->m_EventListeners.addInterface(aGuard, xListener);
}
void SAL_CALL SwXBookmark::removeEventListener( const uno::Reference< lang::XEventListener > & xListener)
{ // no need to lock here as m_pImpl is const and container threadsafe
std::unique_lock aGuard(m_pImpl->m_Mutex);
m_pImpl->m_EventListeners.removeInterface(aGuard, xListener);
}
if (PropertyName == UNO_NAME_BOOKMARK_HIDDEN)
{ bool bNewValue = false; if (!(rValue >>= bNewValue)) throw lang::IllegalArgumentException(u"Property BookmarkHidden requires value of type boolean"_ustr, nullptr, 0);
Bookmark* pBookmark = dynamic_cast<Bookmark*>(m_pImpl->m_pRegisteredBookmark); if (pBookmark)
{
pBookmark->Hide(bNewValue);
} else
{
m_pImpl->m_bHidden = bNewValue;
} return;
} elseif (PropertyName == UNO_NAME_BOOKMARK_CONDITION)
{
OUString newValue; if (!(rValue >>= newValue)) throw lang::IllegalArgumentException(u"Property BookmarkCondition requires value of type string"_ustr, nullptr, 0);
::sw::mark::CheckboxFieldmark*
SwXFieldmark::getCheckboxFieldmark()
{
::sw::mark::CheckboxFieldmark* pCheckboxFm = nullptr; if ( getFieldType() == ODF_FORMCHECKBOX )
{
pCheckboxFm = dynamic_cast< ::sw::mark::CheckboxFieldmark* >( GetBookmark());
assert( GetBookmark() == nullptr || pCheckboxFm != nullptr ); // unclear to me whether GetBookmark() can be null here
} return pCheckboxFm;
}
// support 'hidden' "Checked" property ( note: this property is just for convenience to support // docx import filter thus not published via PropertySet info )
void SAL_CALL
SwXFieldmark::setPropertyValue(const OUString& PropertyName, const uno::Any& rValue)
{
SolarMutexGuard g; if ( PropertyName == "Checked" )
{
::sw::mark::CheckboxFieldmark* pCheckboxFm = getCheckboxFieldmark(); bool bChecked( false ); if ( !(pCheckboxFm && ( rValue >>= bChecked )) ) throw uno::RuntimeException(
u"SwXFieldmark::setPropertyValue(): either Mark is empty or property value is not assignable to bool"_ustr);
pCheckboxFm->SetChecked( bChecked );
} elseif (PropertyName == "PrivateSeparatorAtStart")
{ bool isFieldmarkSeparatorAtStart{}; if (rValue >>= isFieldmarkSeparatorAtStart)
{
m_isFieldmarkSeparatorAtStart = isFieldmarkSeparatorAtStart;
}
} // this doesn't support any SwXBookmark property
}
// support 'hidden' "Checked" property ( note: this property is just for convenience to support // docx import filter thus not published via PropertySet info )
uno::Any SAL_CALL SwXFieldmark::getPropertyValue(const OUString& rPropertyName)
{
SolarMutexGuard g; if ( rPropertyName == "Checked" )
{
::sw::mark::CheckboxFieldmark* pCheckboxFm = getCheckboxFieldmark(); if ( !pCheckboxFm ) throw uno::RuntimeException(
u"SwXFieldmark::getPropertyValue(): Mark is empty"_ustr);
return uno::Any( pCheckboxFm->IsChecked() );
} return uno::Any(); // this doesn't support any SwXBookmark property
}
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.