20#include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
21#include <com/sun/star/text/XTextSectionsSupplier.hpp>
22#include <com/sun/star/text/XDependentTextField.hpp>
23#include <com/sun/star/text/XDocumentIndex.hpp>
24#include <com/sun/star/text/ChapterFormat.hpp>
25#include <com/sun/star/text/XTextSection.hpp>
26#include <com/sun/star/beans/PropertyValues.hpp>
27#include <com/sun/star/ucb/XCommandEnvironment.hpp>
35#include <unoprnms.hxx>
52static void lcl_SetProp( uno::Reference< XPropertySetInfo >
const & xInfo,
53 uno::Reference< XPropertySet >
const & xProps,
54 OUString
const & aPropName,
const OUString& rValue)
60 xProps->setPropertyValue(
aPropName, aValue);
64static void lcl_SetProp( uno::Reference< XPropertySetInfo >
const & xInfo,
65 uno::Reference< XPropertySet >
const & xProps,
66 OUString
const & aPropName, sal_Int16 nValue )
72 xProps->setPropertyValue(
aPropName, aValue);
77 uno::Reference< beans::XPropertySetInfo >
const & xInfo,
78 uno::Reference< beans::XPropertySet >
const & xProps,
79 OUString
const & aPropName,
bool bValue )
91 uno::Reference< frame::XModel > &
xModel = m_xExampleFrame->GetModel();
92 auto pDoc = comphelper::getFromUnoTunnel<SwXTextDocument>(
xModel);
95 pDoc->GetDocShell()->LoadStyles_( *m_rWrtShell.GetView().GetDocShell(),
true );
97 uno::Reference< text::XTextSectionsSupplier > xSectionSupplier(
99 uno::Reference< container::XNameAccess > xSections =
100 xSectionSupplier->getTextSections();
102 for(
int i = 0;
i < 7; ++
i )
104 OUString sTmp =
"IndexSection_" + OUString::number(
i);
105 uno::Any aSection = xSections->getByName( sTmp );
106 aSection >>= m_vTypeData[
i].m_oIndexSections->xContainerSection;
108 uno::Reference< text::XDocumentIndexesSupplier > xIdxSupp(
xModel, uno::UNO_QUERY);
109 uno::Reference< container::XIndexAccess > xIdxs = xIdxSupp->getDocumentIndexes();
110 int n = xIdxs->getCount();
115 uno::Reference< text::XDocumentIndex > xIdx;
119 CreateOrUpdateExample(m_eCurrentTOXType.eType);
128 TOXTypes nTOXIndex, sal_uInt16 nPage, sal_uInt16 nCurrentLevel)
135 static const char* IndexServiceNames[] =
137 "com.sun.star.text.DocumentIndex",
138 "com.sun.star.text.UserIndex",
139 "com.sun.star.text.ContentIndex",
140 "com.sun.star.text.IllustrationsIndex",
141 "com.sun.star.text.ObjectIndex",
142 "com.sun.star.text.TableIndex",
143 "com.sun.star.text.Bibliography"
146 OSL_ENSURE(
m_vTypeData[nTOXIndex].m_oIndexSections &&
147 m_vTypeData[nTOXIndex].m_oIndexSections->xContainerSection.is(),
148 "Section not created");
150 bool bInitialCreate =
true;
151 if(!
m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex.is())
153 bInitialCreate =
true;
154 if(!
m_vTypeData[nTOXIndex].m_oIndexSections->xContainerSection.is())
155 throw uno::RuntimeException();
156 uno::Reference< text::XTextRange > xAnchor =
m_vTypeData[nTOXIndex].m_oIndexSections->xContainerSection->getAnchor();
157 xAnchor = xAnchor->getStart();
158 uno::Reference< text::XTextCursor > xCursor = xAnchor->getText()->createTextCursorByRange(xAnchor);
160 uno::Reference< lang::XMultiServiceFactory > xFact(
xModel, uno::UNO_QUERY);
162 OUString sIndexTypeName(OUString::createFromAscii( IndexServiceNames[
164 m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex.set(xFact->createInstance(sIndexTypeName), uno::UNO_QUERY);
165 uno::Reference< text::XTextContent > xContent =
m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex;
166 xCursor->getText()->insertTextContent(xCursor, xContent,
false);
170 uno::Reference< beans::XPropertySet > xSectPr(
m_vTypeData[
i].m_oIndexSections->xContainerSection, uno::UNO_QUERY);
177 uno::Reference< beans::XPropertySet > xIdxProps(
m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex, uno::UNO_QUERY);
178 uno::Reference< beans::XPropertySetInfo > xInfo = xIdxProps->getPropertySetInfo();
193 uno::Reference< container::XIndexReplace > xAcc;
194 aStyleNames >>= xAcc;
201 const sal_Int32 nStyles =
203 uno::Sequence<OUString> aStyles(nStyles);
204 OUString* pArr = aStyles.getArray();
206 for(sal_Int32 nStyle = 0; nStyle < nStyles; ++nStyle)
209 xAcc->replaceByIndex(
i, aAny);
240 sal_Int16 nSet = text::ChapterFormat::NAME_NUMBER;
261 const bool bUseCurrent = nCurrentLevel < pForm->
GetFormMax();
262 const sal_uInt16 nStartLevel = bUseCurrent ? nCurrentLevel : 0;
263 const sal_uInt16 nEndLevel = bUseCurrent ? nCurrentLevel : pForm->
GetFormMax() - 1;
266 for(sal_uInt16 nCurrLevel = nStartLevel; nCurrLevel <= nEndLevel; nCurrLevel++)
269 uno::Sequence< beans::PropertyValues> aSequPropVals(10);
276 for(
const auto& aToken : aPattern)
278 if( aSequPropVals.getLength() <= nTokenIndex)
279 aSequPropVals.realloc(nTokenIndex + 10);
281 switch(aToken.eTokenType)
284 sTokenType =
"TokenEntryNumber";
289 sTokenType =
"TokenEntryText";
293 sTokenType =
"TokenTabStop";
296 sTokenType =
"TokenText";
300 sTokenType =
"TokenPageNumber";
303 sTokenType =
"TokenChapterInfo";
306 sTokenType =
"TokenHyperlinkStart";
309 sTokenType =
"TokenHyperlinkEnd";
313 sTokenType =
"TokenBibliographyDataField";
318 beans::PropertyValues aPropVals(nParamCount);
319 beans::PropertyValue* pPropValArr = aPropVals.getArray();
320 pPropValArr[0].Name =
"TokenType";
321 pPropValArr[0].Value <<= sTokenType;
322 pPropValArr[1].Name =
"CharacterStyleName";
323 pPropValArr[1].Value <<= aToken.sCharStyleName;
326 pPropValArr[2].Name =
"TabStopRightAligned";
327 pPropValArr[2].Value <<= SvxTabAdjust::End == aToken.eTabAlign;
328 pPropValArr[3].Name =
"TabStopFillCharacter";
329 pPropValArr[3].Value <<= OUString(aToken.cTabFillChar);
330 pPropValArr[4].Name =
"TabStopPosition";
331 SwTwips nTempPos = aToken.nTabStopPosition >= 0 ?
332 aToken.nTabStopPosition : 0;
334 pPropValArr[4].Value <<=
static_cast<sal_Int32
>(nTempPos);
338 pPropValArr[2].Name =
"Text";
339 pPropValArr[2].Value <<= aToken.sText;
341 beans::PropertyValues*
pValues = aSequPropVals.getArray();
342 pValues[nTokenIndex] = aPropVals;
345 aSequPropVals.realloc(nTokenIndex);
349 "wrong property type");
351 uno::Reference< container::XIndexReplace > xFormatAccess;
352 aFormatAccess >>= xFormatAccess;
354 xFormatAccess->replaceByIndex(nCurrLevel, aLevelProp);
361 sal_uInt16 nOffset = 0;
362 sal_uInt16 nEndLevel = 2;
377 for(sal_uInt16
i = 1;
i < nEndLevel;
i++)
381 "ParaStyleLevel" + OUString::number(
i ),
385 m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex->update();
const PropertyValue * pValues
constexpr auto convertTwipToMm100(N n)
std::vector< TypeData > m_vTypeData
void CreateOrUpdateExample(TOXTypes nTOXIndex, sal_uInt16 nPage=0, sal_uInt16 nCurLevel=USHRT_MAX)
std::unique_ptr< SwOneExampleFrame > m_xExampleFrame
SwTOXDescription & GetTOXDescription(CurTOXType eTOXTypes)
CurTOXType m_eCurrentTOXType
SwForm * GetForm(CurTOXType eType)
static SW_DLLPUBLIC const OUString & GetSpecialExtraProgName(const OUString &rExtraUIName)
SwTOXElement GetContentOptions() const
bool IsFromChapter() const
sal_uInt8 GetLevel() const
bool IsCreateFromObjectNames() const
SwTOIOptions GetIndexOptions() const
SwCaptionDisplay GetCaptionDisplay() const
const OUString & GetSequenceName() const
const OUString & GetStyleNames(sal_uInt16 nLvl) const
std::optional< OUString > const & GetTitle() const
SwTOOElements GetOLEOptions() const
IMPL_LINK_NOARG(SwMultiTOXTabDialog, CreateExample_Hdl, SwOneExampleFrame &, void)
static void lcl_SetBOOLProp(uno::Reference< beans::XPropertySetInfo > const &xInfo, uno::Reference< beans::XPropertySet > const &xProps, OUString const &aPropName, bool bValue)
static void lcl_SetProp(uno::Reference< XPropertySetInfo > const &xInfo, uno::Reference< XPropertySet > const &xProps, OUString const &aPropName, const OUString &rValue)
#define TOOLS_WARN_EXCEPTION(area, stream)
sal_Int32 getTokenCount(std::string_view rIn, char cTok)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Reference< XModel > xModel
constexpr sal_uInt8 MAXLEVEL
#define TOX_STYLE_DELIMITER
std::vector< SwFormToken > SwFormTokens
Vector of tokens.
constexpr OUStringLiteral UNO_NAME_CREATE_FROM_CHAPTER
constexpr OUStringLiteral UNO_NAME_LEVEL
constexpr OUStringLiteral UNO_NAME_CREATE_FROM_STAR_MATH
constexpr OUStringLiteral UNO_NAME_CREATE_FROM_TEXT_FRAMES
constexpr OUStringLiteral UNO_NAME_CREATE_FROM_OUTLINE
constexpr OUStringLiteral UNO_NAME_CREATE_FROM_MARKS
constexpr OUStringLiteral UNO_NAME_HIDE_TAB_LEADER_AND_PAGE_NUMBERS
constexpr OUStringLiteral UNO_NAME_CREATE_FROM_STAR_CHART
constexpr OUStringLiteral UNO_NAME_USE_DASH
constexpr OUStringLiteral UNO_NAME_IS_CASE_SENSITIVE
constexpr OUStringLiteral UNO_NAME_CREATE_FROM_TABLES
constexpr OUStringLiteral UNO_NAME_USE_P_P
constexpr OUStringLiteral UNO_NAME_LEVEL_PARAGRAPH_STYLES
constexpr OUStringLiteral UNO_NAME_CREATE_FROM_EMBEDDED_OBJECTS
constexpr OUStringLiteral UNO_NAME_CREATE_FROM_STAR_CALC
constexpr OUStringLiteral UNO_NAME_IS_COMMA_SEPARATED
constexpr OUStringLiteral UNO_NAME_CREATE_FROM_STAR_DRAW
constexpr OUStringLiteral UNO_NAME_LABEL_DISPLAY_TYPE
constexpr OUStringLiteral UNO_NAME_USE_KEY_AS_ENTRY
constexpr OUStringLiteral UNO_NAME_IS_PROTECTED
constexpr OUStringLiteral UNO_NAME_USE_COMBINED_ENTRIES
constexpr OUStringLiteral UNO_NAME_CREATE_FROM_OTHER_EMBEDDED_OBJECTS
constexpr OUStringLiteral UNO_NAME_TOC_NEWLINE
constexpr OUStringLiteral UNO_NAME_USE_ALPHABETICAL_SEPARATORS
constexpr OUStringLiteral UNO_NAME_CREATE_FROM_LABELS
constexpr OUStringLiteral UNO_NAME_TAB_IN_TOC
constexpr OUStringLiteral UNO_NAME_USE_UPPER_CASE
constexpr OUStringLiteral UNO_NAME_TOC_PARAGRAPH_OUTLINE_LEVEL
constexpr OUStringLiteral UNO_NAME_LABEL_CATEGORY
constexpr OUStringLiteral UNO_NAME_IS_VISIBLE
constexpr OUStringLiteral UNO_NAME_TITLE
constexpr OUStringLiteral UNO_NAME_CREATE_FROM_GRAPHIC_OBJECTS
constexpr OUStringLiteral UNO_NAME_LEVEL_FORMAT