/* -*- 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 .
*/
if(rTmp==pShellRes->aTOXUserName)
{
rTmp = cUserDefined;
} // if the version is not English but the alternative index's name is // "User-Defined" a " (user)" is appended elseif(rTmp == cUserDefined)
{
rTmp += cUserSuffix;
}
}
staticvoid
lcl_ConvertTOUNameToUserName(OUString& rTmp)
{
ShellResource* pShellRes = SwViewShell::GetShellRes(); if (rTmp == cUserDefined)
{
rTmp = pShellRes->aTOXUserName;
} elseif (pShellRes->aTOXUserName != cUserDefined &&
USER_AND_SUFFIXLEN == rTmp.getLength())
{ //make sure that in non-English versions the " (user)" suffix is removed if (rTmp.startsWith(cUserDefined) &&
rTmp.match(cUserSuffix, USER_LEN))
{
rTmp = cUserDefined;
}
}
}
SwTOXElement nCreate = rTOXBase.GetCreateType();
SwTOOElements nOLEOptions = rTOXBase.GetOLEOptions(); const TOXTypes eTxBaseType = rTOXBase.GetTOXType()->GetType();
SwTOIOptions nTOIOptions = (eTxBaseType == TOX_INDEX)
? rTOXBase.GetOptions() : SwTOIOptions::NONE;
SwForm aForm(rTOXBase.GetTOXForm()); bool bForm = false; switch (pEntry->nWID)
{ case WID_IDX_TITLE:
{
OUString sNewName; if (!(rValue >>= sNewName))
{ throw lang::IllegalArgumentException();
}
rTOXBase.SetTitle(sNewName);
} break; case WID_IDX_NAME:
{
OUString sNewName; if (!(rValue >>= sNewName))
{ throw lang::IllegalArgumentException();
}
rTOXBase.SetTOXName(UIName(sNewName));
} break; case WID_USER_IDX_NAME:
{
OUString sNewName; if (!(rValue >>= sNewName))
{ throw lang::IllegalArgumentException();
}
lcl_ConvertTOUNameToUserName(sNewName);
OSL_ENSURE(TOX_USER == eTxBaseType, "tox type name can only be changed for user indexes"); if (pSectionFormat)
{ if (rTOXBase.GetTOXType()->GetTypeName() != sNewName)
{
lcl_ReAssignTOXType(pSectionFormat->GetDoc(),
rTOXBase, sNewName);
}
} else
{
m_pImpl->m_oProps->SetTypeName(sNewName);
}
} break; case WID_IDX_LOCALE:
{
lang::Locale aLocale; if (!(rValue>>= aLocale))
{ throw lang::IllegalArgumentException();
}
rTOXBase.SetLanguage( LanguageTag::convertToLanguageType(aLocale));
} break; case WID_IDX_SORT_ALGORITHM:
{
OUString sTmp; if (!(rValue >>= sTmp))
{ throw lang::IllegalArgumentException();
}
rTOXBase.SetSortAlgorithm(sTmp);
} break; case WID_LEVEL:
{
rTOXBase.SetLevel(lcl_AnyToType<sal_Int16>(rValue));
} break; case WID_TOC_BOOKMARK:
{
rTOXBase.SetBookmarkName(lcl_AnyToType<OUString>(rValue));
nCreate = SwTOXElement::Bookmark;
rTOXBase.SetCreate(nCreate);
} break; case WID_CREATE_FROM_MARKS:
lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Mark); break; case WID_CREATE_FROM_OUTLINE:
lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::OutlineLevel); break; case WID_TOC_PARAGRAPH_OUTLINE_LEVEL:
lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::ParagraphOutlineLevel); break; case WID_TAB_IN_TOC:
lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::TableInToc); break; case WID_TOC_NEWLINE:
lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Newline); break; // case WID_PARAGRAPH_STYLE_NAMES :OSL_FAIL("not implemented") // break; case WID_HIDE_TABLEADER_PAGENUMBERS:
lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::TableLeader); break ; case WID_CREATE_FROM_CHAPTER:
rTOXBase.SetFromChapter(lcl_AnyToType<bool>(rValue)); break; case WID_CREATE_FROM_LABELS:
rTOXBase.SetFromObjectNames(! lcl_AnyToType<bool>(rValue)); break; case WID_PROTECTED:
{ bool bSet = lcl_AnyToType<bool>(rValue);
rTOXBase.SetProtected(bSet); if (pSectionFormat)
{ static_cast<SwTOXBaseSection &>(rTOXBase).SetProtect(bSet);
}
} break; case WID_USE_ALPHABETICAL_SEPARATORS:
lcl_AnyToBitMask(rValue, nTOIOptions,
SwTOIOptions::AlphaDelimiter); break; case WID_USE_KEY_AS_ENTRY:
lcl_AnyToBitMask(rValue, nTOIOptions,
SwTOIOptions::KeyAsEntry); break; case WID_USE_COMBINED_ENTRIES:
lcl_AnyToBitMask(rValue, nTOIOptions,
SwTOIOptions::SameEntry); break; case WID_IS_CASE_SENSITIVE:
lcl_AnyToBitMask(rValue, nTOIOptions,
SwTOIOptions::CaseSensitive); break; case WID_USE_P_P:
lcl_AnyToBitMask(rValue, nTOIOptions, SwTOIOptions::FF); break; case WID_USE_DASH:
lcl_AnyToBitMask(rValue, nTOIOptions, SwTOIOptions::Dash); break; case WID_USE_UPPER_CASE:
lcl_AnyToBitMask(rValue, nTOIOptions,
SwTOIOptions::InitialCaps); break; case WID_IS_COMMA_SEPARATED:
bForm = true;
aForm.SetCommaSeparated(lcl_AnyToType<bool>(rValue)); break; case WID_LABEL_CATEGORY:
{ // convert file-format/API/external programmatic english name // to internal UI name before usage
rTOXBase.SetSequenceName( SwStyleNameMapper::GetSpecialExtraUIName(
ProgName(lcl_AnyToType<OUString>(rValue) )) );
} break; case WID_LABEL_DISPLAY_TYPE:
{ const sal_Int16 nVal = lcl_AnyToType<sal_Int16>(rValue);
sal_uInt16 nSet = CAPTION_COMPLETE; switch (nVal)
{ case text::ReferenceFieldPart::TEXT:
nSet = CAPTION_COMPLETE; break; case text::ReferenceFieldPart::CATEGORY_AND_NUMBER:
nSet = CAPTION_NUMBER; break; case text::ReferenceFieldPart::ONLY_CAPTION:
nSet = CAPTION_TEXT; break; default: throw lang::IllegalArgumentException();
}
rTOXBase.SetCaptionDisplay(static_cast<SwCaptionDisplay>(nSet));
} break; case WID_USE_LEVEL_FROM_SOURCE:
rTOXBase.SetLevelFromChapter(lcl_AnyToType<bool>(rValue)); break; case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME:
{
UIName aString;
SwStyleNameMapper::FillUIName(ProgName(lcl_AnyToType<OUString>(rValue)),
aString, SwGetPoolIdFromName::ChrFmt);
rTOXBase.SetMainEntryCharStyle( aString );
} break; case WID_CREATE_FROM_TABLES:
lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Table); break; case WID_CREATE_FROM_TEXT_FRAMES:
lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Frame); break; case WID_CREATE_FROM_GRAPHIC_OBJECTS:
lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Graphic); break; case WID_CREATE_FROM_EMBEDDED_OBJECTS:
lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Ole); break; case WID_CREATE_FROM_STAR_MATH:
lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Math); break; case WID_CREATE_FROM_STAR_CHART:
lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Chart); break; case WID_CREATE_FROM_STAR_CALC:
lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Calc); break; case WID_CREATE_FROM_STAR_DRAW:
lcl_AnyToBitMask(rValue, nOLEOptions,
SwTOOElements::DrawImpress); break; case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS:
lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Other); break; case WID_PARA_HEAD:
{
UIName aString;
SwStyleNameMapper::FillUIName( ProgName(lcl_AnyToType<OUString>(rValue)),
aString, SwGetPoolIdFromName::TxtColl);
bForm = true; // Header is on Pos 0
aForm.SetTemplate( 0, aString );
} break; case WID_IS_RELATIVE_TABSTOPS:
bForm = true;
aForm.SetRelTabPos(lcl_AnyToType<bool>(rValue)); break; case WID_PARA_SEP:
{
UIName aString;
bForm = true;
SwStyleNameMapper::FillUIName( ProgName(lcl_AnyToType<OUString>(rValue)),
aString, SwGetPoolIdFromName::TxtColl);
aForm.SetTemplate( 1, aString );
} break; case WID_CREATE_FROM_PARAGRAPH_STYLES:
lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Template); break; case WID_CREATE_FROM_PARAGRAPH_STYLE:
{
OUString style; if (rValue >>= style)
{ if (style.indexOf(TOX_STYLE_DELIMITER) != -1)
{ throw lang::IllegalArgumentException();
}
lcl_AnyToBitMask(uno::Any(true), nCreate, SwTOXElement::Template);
UIName uiStyle;
SwStyleNameMapper::FillUIName(ProgName(style), uiStyle, SwGetPoolIdFromName::TxtColl);
rTOXBase.SetStyleNames(uiStyle, 0);
} elseif (!rValue.hasValue())
{
lcl_AnyToBitMask(uno::Any(false), nCreate, SwTOXElement::Template);
} else
{ throw lang::IllegalArgumentException();
}
} break;
case WID_PARA_LEV1: case WID_PARA_LEV2: case WID_PARA_LEV3: case WID_PARA_LEV4: case WID_PARA_LEV5: case WID_PARA_LEV6: case WID_PARA_LEV7: case WID_PARA_LEV8: case WID_PARA_LEV9: case WID_PARA_LEV10:
{
bForm = true; // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1 const sal_uInt16 nLPos = rTOXBase.GetType() == TOX_INDEX ? 2 : 1;
UIName aString;
SwStyleNameMapper::FillUIName( ProgName(lcl_AnyToType<OUString>(rValue)),
aString, SwGetPoolIdFromName::TxtColl);
aForm.SetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1, aString );
} break; default: //this is for items only if (WID_PRIMARY_KEY > pEntry->nWID)
{ const SwAttrSet& rSet =
SwDoc::GetTOXBaseAttrSet(rTOXBase);
SfxItemSet aAttrSet(rSet);
m_pImpl->m_rPropSet.setPropertyValue(
rPropertyName, rValue, aAttrSet);
const SwSectionFormats& rSects = m_pImpl->m_pDoc->GetSections(); for (size_t i = 0; i < rSects.size(); ++i)
{ const SwSectionFormat* pTmpFormat = rSects[ i ]; if (pTmpFormat == pSectionFormat)
{
SwSectionData tmpData( static_cast<SwTOXBaseSection&>(rTOXBase));
m_pImpl->m_pDoc->UpdateSection(i, tmpData, & aAttrSet); break;
}
}
}
}
rTOXBase.SetCreate(nCreate);
rTOXBase.SetOLEOptions(nOLEOptions); if (rTOXBase.GetTOXType()->GetType() == TOX_INDEX)
{
rTOXBase.SetOptions(nTOIOptions);
} if (bForm)
{
rTOXBase.SetTOXForm(aForm);
}
}
uno::Any aRet;
SfxItemPropertyMapEntry const*const pEntry =
m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName); if (!pEntry)
{ throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName,
getXWeak());
} // TODO: is this the best approach to tell API clients about the change? if (pEntry->nWID == RES_BACKGROUND && pEntry->nMemberId == MID_GRAPHIC_URL)
{ throw uno::RuntimeException(u"Getting GraphicURL property is not supported"_ustr);
}
SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
SwTOXBase* pTOXBase = nullptr; if (pSectionFormat)
{
pTOXBase = static_cast<SwTOXBaseSection*>(pSectionFormat->GetSection());
} elseif (m_pImpl->m_bIsDescriptor)
{
pTOXBase = &m_pImpl->m_oProps->GetTOXBase();
} if(pTOXBase)
{ const SwTOXElement nCreate = pTOXBase->GetCreateType(); const SwTOOElements nOLEOptions = pTOXBase->GetOLEOptions(); const SwTOIOptions nTOIOptions =
(pTOXBase->GetTOXType()->GetType() == TOX_INDEX)
? pTOXBase->GetOptions()
: SwTOIOptions::NONE; const SwForm& rForm = pTOXBase->GetTOXForm(); switch(pEntry->nWID)
{ case WID_IDX_CONTENT_SECTION: case WID_IDX_HEADER_SECTION : if(WID_IDX_CONTENT_SECTION == pEntry->nWID)
{ const rtl::Reference<SwXTextSection> xContentSect =
SwXTextSection::CreateXTextSection( pSectionFormat );
aRet <<= uno::Reference <text::XTextSection>(xContentSect);
} elseif (pSectionFormat)
{
SwSections aSectArr;
pSectionFormat->GetChildSections(aSectArr,
SectionSort::Not, false); for(SwSection* pSect : aSectArr)
{ if(pSect->GetType() == SectionType::ToxHeader)
{ const rtl::Reference<SwXTextSection> xHeader =
SwXTextSection::CreateXTextSection(
pSect->GetFormat() );
aRet <<= uno::Reference <text::XTextSection>(xHeader); break;
}
}
} break; case WID_IDX_TITLE :
{
aRet <<= pTOXBase->GetTitle(); break;
} case WID_IDX_NAME:
aRet <<= pTOXBase->GetTOXName().toString(); break; case WID_USER_IDX_NAME:
{
OUString sTmp((!m_pImpl->m_bIsDescriptor)
? pTOXBase->GetTOXType()->GetTypeName()
: m_pImpl->m_oProps->GetTypeName()); //I18N
lcl_ConvertTOUNameToProgrammaticName(sTmp);
aRet <<= sTmp;
} break; case WID_IDX_LOCALE:
aRet <<= LanguageTag(pTOXBase->GetLanguage()).getLocale(); break; case WID_IDX_SORT_ALGORITHM:
aRet <<= pTOXBase->GetSortAlgorithm(); break; case WID_LEVEL :
aRet <<= static_cast<sal_Int16>(pTOXBase->GetLevel()); break; case WID_TOC_BOOKMARK :
aRet <<= pTOXBase->GetBookmarkName(); break; case WID_CREATE_FROM_MARKS:
lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Mark); break; case WID_CREATE_FROM_OUTLINE:
lcl_BitMaskToAny(aRet, nCreate,
SwTOXElement::OutlineLevel); break; case WID_CREATE_FROM_CHAPTER:
{ constbool bRet = pTOXBase->IsFromChapter();
aRet <<= bRet;
} break; case WID_CREATE_FROM_LABELS:
{ constbool bRet = ! pTOXBase->IsFromObjectNames();
aRet <<= bRet;
} break; case WID_PROTECTED:
{ constbool bRet = pTOXBase->IsProtected();
aRet <<= bRet;
} break; case WID_USE_ALPHABETICAL_SEPARATORS:
lcl_BitMaskToAny(aRet, nTOIOptions,
SwTOIOptions::AlphaDelimiter); break; case WID_USE_KEY_AS_ENTRY:
lcl_BitMaskToAny(aRet, nTOIOptions,
SwTOIOptions::KeyAsEntry); break; case WID_USE_COMBINED_ENTRIES:
lcl_BitMaskToAny(aRet, nTOIOptions,
SwTOIOptions::SameEntry); break; case WID_IS_CASE_SENSITIVE:
lcl_BitMaskToAny(aRet, nTOIOptions,
SwTOIOptions::CaseSensitive); break; case WID_USE_P_P:
lcl_BitMaskToAny(aRet, nTOIOptions, SwTOIOptions::FF); break; case WID_USE_DASH:
lcl_BitMaskToAny(aRet, nTOIOptions, SwTOIOptions::Dash); break; case WID_USE_UPPER_CASE:
lcl_BitMaskToAny(aRet, nTOIOptions,
SwTOIOptions::InitialCaps); break; case WID_IS_COMMA_SEPARATED:
{ constbool bRet = rForm.IsCommaSeparated();
aRet <<= bRet;
} break; case WID_LABEL_CATEGORY:
{ // convert internal UI name to // file-format/API/external programmatic english name // before usage
aRet <<= SwStyleNameMapper::GetSpecialExtraProgName(
pTOXBase->GetSequenceName() ).toString();
} break; case WID_LABEL_DISPLAY_TYPE:
{
sal_Int16 nSet = text::ReferenceFieldPart::TEXT; switch (pTOXBase->GetCaptionDisplay())
{ case CAPTION_COMPLETE:
nSet = text::ReferenceFieldPart::TEXT; break; case CAPTION_NUMBER:
nSet = text::ReferenceFieldPart::CATEGORY_AND_NUMBER; break; case CAPTION_TEXT:
nSet = text::ReferenceFieldPart::ONLY_CAPTION; break;
}
aRet <<= nSet;
} break; case WID_USE_LEVEL_FROM_SOURCE:
{ constbool bRet = pTOXBase->IsLevelFromChapter();
aRet <<= bRet;
} break; case WID_LEVEL_FORMAT:
{
rtl::Reference< TokenAccess_Impl > xTokenAccess(
m_pImpl->m_wTokenAccess.get()); if (!xTokenAccess.is())
{
xTokenAccess = new TokenAccess_Impl(*this);
m_pImpl->m_wTokenAccess = xTokenAccess.get();
}
aRet <<= uno::Reference< container::XIndexReplace >(xTokenAccess);
} break; case WID_LEVEL_PARAGRAPH_STYLES:
{
rtl::Reference< StyleAccess_Impl > xStyleAccess(
m_pImpl->m_wStyleAccess.get()); if (!xStyleAccess.is())
{
xStyleAccess = new StyleAccess_Impl(*this);
m_pImpl->m_wStyleAccess = xStyleAccess.get();
}
aRet <<= uno::Reference< container::XIndexReplace >(xStyleAccess);
} break; case WID_MAIN_ENTRY_CHARACTER_STYLE_NAME:
{
ProgName aString;
SwStyleNameMapper::FillProgName(
pTOXBase->GetMainEntryCharStyle(),
aString,
SwGetPoolIdFromName::ChrFmt);
aRet <<= aString.toString();
} break; case WID_CREATE_FROM_TABLES:
lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Table); break; case WID_CREATE_FROM_TEXT_FRAMES:
lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Frame); break; case WID_CREATE_FROM_GRAPHIC_OBJECTS:
lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Graphic); break; case WID_CREATE_FROM_EMBEDDED_OBJECTS:
lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Ole); break; case WID_CREATE_FROM_STAR_MATH:
lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Math); break; case WID_CREATE_FROM_STAR_CHART:
lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Chart); break; case WID_CREATE_FROM_STAR_CALC:
lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Calc); break; case WID_CREATE_FROM_STAR_DRAW:
lcl_BitMaskToAny(aRet, nOLEOptions,
SwTOOElements::DrawImpress); break; case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS:
lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Other); break; case WID_CREATE_FROM_PARAGRAPH_STYLES:
lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Template); break; case WID_CREATE_FROM_PARAGRAPH_STYLE:
{ if (nCreate & SwTOXElement::Template)
{ // there is only one style, at top level
UIName const& rStyle(pTOXBase->GetStyleNames(0)); if (!rStyle.isEmpty())
{
assert(rStyle.toString().indexOf(TOX_STYLE_DELIMITER) == -1);
ProgName ret;
SwStyleNameMapper::FillProgName(rStyle, ret,
SwGetPoolIdFromName::TxtColl);
aRet <<= ret.toString();
}
}
} break;
case WID_PARA_HEAD:
{ //Header is at position 0
ProgName aString;
SwStyleNameMapper::FillProgName(rForm.GetTemplate( 0 ), aString,
SwGetPoolIdFromName::TxtColl );
aRet <<= aString.toString();
} break; case WID_PARA_SEP:
{
ProgName aString;
SwStyleNameMapper::FillProgName(
rForm.GetTemplate( 1 ),
aString,
SwGetPoolIdFromName::TxtColl);
aRet <<= aString.toString();
} break; case WID_PARA_LEV1: case WID_PARA_LEV2: case WID_PARA_LEV3: case WID_PARA_LEV4: case WID_PARA_LEV5: case WID_PARA_LEV6: case WID_PARA_LEV7: case WID_PARA_LEV8: case WID_PARA_LEV9: case WID_PARA_LEV10:
{ // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1 const sal_uInt16 nLPos = pTOXBase->GetType() == TOX_INDEX ? 2 : 1;
ProgName aString;
SwStyleNameMapper::FillProgName(
rForm.GetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1),
aString,
SwGetPoolIdFromName::TxtColl);
aRet <<= aString.toString();
} break; case WID_IS_RELATIVE_TABSTOPS:
{ constbool bRet = rForm.IsRelTabPos();
aRet <<= bRet;
} break; case WID_INDEX_MARKS:
{
SwTOXMarks aMarks; const SwTOXType* pType = pTOXBase->GetTOXType();
pType->CollectTextMarks(aMarks);
uno::Sequence< uno::Reference<text::XDocumentIndexMark> > aXMarks(aMarks.size());
uno::Reference<text::XDocumentIndexMark>* pxMarks = aXMarks.getArray(); for(size_t i = 0; i < aMarks.size(); ++i)
{
SwTOXMark* pMark = aMarks[i];
pxMarks[i] = SwXDocumentIndexMark::CreateXDocumentIndexMark(
*m_pImpl->m_pDoc, pMark);
}
aRet <<= aXMarks;
} break; default: //this is for items only if(WID_PRIMARY_KEY > pEntry->nWID)
{ const SwAttrSet& rSet =
SwDoc::GetTOXBaseAttrSet(*pTOXBase);
aRet = m_pImpl->m_rPropSet.getPropertyValue(
rPropertyName, rSet);
}
}
} return aRet;
}
void SAL_CALL SwXDocumentIndex::addRefreshListener( const uno::Reference<util::XRefreshListener>& xListener)
{ // no need to lock here as m_pImpl is const and container threadsafe
std::unique_lock g(m_pImpl->m_Mutex);
m_pImpl->m_RefreshListeners.addInterface(g, xListener);
}
void SAL_CALL SwXDocumentIndex::removeRefreshListener( const uno::Reference<util::XRefreshListener>& xListener)
{ // no need to lock here as m_pImpl is const and container threadsafe
std::unique_lock g(m_pImpl->m_Mutex);
m_pImpl->m_RefreshListeners.removeInterface(g, xListener);
}
void SAL_CALL
SwXDocumentIndex::addEventListener( const uno::Reference< lang::XEventListener > & xListener)
{ // no need to lock here as m_pImpl is const and container threadsafe
std::unique_lock g(m_pImpl->m_Mutex);
m_pImpl->m_EventListeners.addInterface(g, xListener);
}
void SAL_CALL
SwXDocumentIndex::removeEventListener( const uno::Reference< lang::XEventListener > & xListener)
{ // no need to lock here as m_pImpl is const and container threadsafe
std::unique_lock g(m_pImpl->m_Mutex);
m_pImpl->m_EventListeners.removeInterface(g, xListener);
}
void SwXDocumentIndexMark::Impl::Invalidate()
{ if (!m_bInReplaceMark) // #i109983# only dispose on delete, not on replace!
{
rtl::Reference<SwXDocumentIndexMark> const xThis(m_wThis); // fdo#72695: if UNO object is already dead, don't revive it with event if (xThis.is())
{
lang::EventObject const ev(xThis->getXWeak());
std::unique_lock aGuard(m_Mutex);
m_EventListeners.disposeAndClear(aGuard, ev);
}
}
EndListeningAll();
m_pDoc = nullptr;
m_pTOXMark = nullptr;
m_pTOXType = nullptr;
}
// called when the associated SwTOXMark is deleted void SwXDocumentIndexMark::OnSwTOXMarkDeleted()
{
m_pImpl->Invalidate();
}
rtl::Reference<SwXDocumentIndexMark>
SwXDocumentIndexMark::CreateXDocumentIndexMark(
SwDoc & rDoc, SwTOXMark *const pMark, TOXTypes const eType)
{ // re-use existing SwXDocumentIndexMark // NB: xmloff depends on this caching to generate ID from the address! // #i105557#: do not iterate over the registered clients: race condition
rtl::Reference<SwXDocumentIndexMark> xTOXMark; if (pMark)
{
xTOXMark = pMark->GetXTOXMark();
} if (!xTOXMark.is())
{ if (pMark)
{
xTOXMark = new SwXDocumentIndexMark(rDoc,
*const_cast<SwTOXType*>(pMark->GetTOXType()), *pMark);
pMark->SetXTOXMark(xTOXMark);
} else
xTOXMark = new SwXDocumentIndexMark(eType);
// need a permanent Reference to initialize m_wThis
xTOXMark->m_pImpl->m_wThis = xTOXMark.get();
} return xTOXMark;
}
const SwTOXType* pTOXType = nullptr; switch (m_pImpl->m_eTOXType)
{ case TOX_INDEX: case TOX_CONTENT: case TOX_CITATION:
pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 ); break; case TOX_USER:
{ if (m_pImpl->m_sUserIndexName.isEmpty())
{
pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 );
} else
{ const sal_uInt16 nCount =
pDoc->GetTOXTypeCount(m_pImpl->m_eTOXType); for (sal_uInt16 i = 0; i < nCount; i++)
{
SwTOXType const*const pTemp =
pDoc->GetTOXType( m_pImpl->m_eTOXType, i ); if (m_pImpl->m_sUserIndexName == pTemp->GetTypeName())
{
pTOXType = pTemp; break;
}
} if (!pTOXType)
{
SwTOXType aUserType(*pDoc, TOX_USER, m_pImpl->m_sUserIndexName);
pTOXType = pDoc->InsertTOXType(aUserType);
}
}
} break;
default: break;
} if (!pTOXType)
{ throw lang::IllegalArgumentException();
}
SwUnoInternalPaM aPam(*pDoc); // this now needs to return TRUE
::sw::XTextRangeToSwPaM(aPam, xTextRange);
SwTOXMark aMark (pTOXType); if (!m_pImpl->m_sAltText.isEmpty())
{
aMark.SetAlternativeText(m_pImpl->m_sAltText);
} switch (m_pImpl->m_eTOXType)
{ case TOX_INDEX: if (!m_pImpl->m_sPrimaryKey.isEmpty())
{
aMark.SetPrimaryKey(m_pImpl->m_sPrimaryKey);
} if (!m_pImpl->m_sSecondaryKey.isEmpty())
{
aMark.SetSecondaryKey(m_pImpl->m_sSecondaryKey);
} if (!m_pImpl->m_sTextReading.isEmpty())
{
aMark.SetTextReading(m_pImpl->m_sTextReading);
} if (!m_pImpl->m_sPrimaryKeyReading.isEmpty())
{
aMark.SetPrimaryKeyReading(m_pImpl->m_sPrimaryKeyReading);
} if (!m_pImpl->m_sSecondaryKeyReading.isEmpty())
{
aMark.SetSecondaryKeyReading(m_pImpl->m_sSecondaryKeyReading);
}
aMark.SetMainEntry(m_pImpl->m_bMainEntry); break; case TOX_CITATION:
aMark.SetMainEntry(m_pImpl->m_bMainEntry); break; case TOX_USER: case TOX_CONTENT: if (USHRT_MAX != m_pImpl->m_nLevel)
{
aMark.SetLevel(m_pImpl->m_nLevel+1);
} break;
void SwXDocumentIndexMark::Impl::InsertTOXMark( const SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam,
SwXTextCursor const*const pTextCursor)
{
SwDoc& rDoc(rPam.GetDoc());
UnoActionContext aAction(&rDoc); bool bMark = *rPam.GetPoint() != *rPam.GetMark(); // n.b.: toxmarks must have either alternative text or an extent if (bMark && !rMark.GetAlternativeText().isEmpty())
{
rPam.Normalize();
rPam.DeleteMark();
bMark = false;
} // Marks without alternative text and without selected text cannot be inserted, // thus use a space - is this really the ideal solution? if (!bMark && rMark.GetAlternativeText().isEmpty())
{
rMark.SetAlternativeText( u" "_ustr );
}
// rMark gets copied into the document pool; // pNewTextAttr comes back with the real format
SwTextAttr *pNewTextAttr = nullptr;
rDoc.getIDocumentContentOperations().InsertPoolItem(rPam, rMark, nInsertFlags, /*pLayout*/nullptr, &pNewTextAttr); if (bMark && *rPam.GetPoint() > *rPam.GetMark())
{
rPam.Exchange();
}
SwTOXType *const pType = m_pImpl->GetTOXType(); if (pType && m_pImpl->m_pTOXMark)
{
m_pImpl->DeleteTOXMark(); // call Invalidate() via modify!
}
}
void SAL_CALL
SwXDocumentIndexMark::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
SwXDocumentIndexMark::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);
}
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.