nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / uibase / sidebar / WriterInspectorTextPanel.cxx
blobe2c3c15d0e24e84bc854ec9948366fb11e11390a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "WriterInspectorTextPanel.hxx"
22 #include <doc.hxx>
23 #include <ndtxt.hxx>
24 #include <docsh.hxx>
25 #include <wrtsh.hxx>
26 #include <unoprnms.hxx>
27 #include <editeng/unoprnms.hxx>
28 #include <com/sun/star/text/XTextRange.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/beans/XPropertyState.hpp>
31 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
32 #include <com/sun/star/table/BorderLine2.hpp>
33 #include <com/sun/star/lang/IllegalArgumentException.hpp>
35 #include <unotextrange.hxx>
36 #include <comphelper/string.hxx>
37 #include <comphelper/processfactory.hxx>
38 #include <i18nlangtag/languagetag.hxx>
39 #include <vcl/settings.hxx>
40 #include <inspectorproperties.hrc>
41 #include <strings.hrc>
43 namespace sw::sidebar
45 static void UpdateTree(SwDocShell* pDocSh, std::vector<svx::sidebar::TreeNode>& aStore);
47 VclPtr<vcl::Window> WriterInspectorTextPanel::Create(vcl::Window* pParent,
48 const uno::Reference<frame::XFrame>& rxFrame)
50 if (pParent == nullptr)
51 throw lang::IllegalArgumentException(
52 "no parent Window given to WriterInspectorTextPanel::Create", nullptr, 0);
53 if (!rxFrame.is())
54 throw lang::IllegalArgumentException("no XFrame given to WriterInspectorTextPanel::Create",
55 nullptr, 1);
57 return VclPtr<WriterInspectorTextPanel>::Create(pParent, rxFrame);
60 WriterInspectorTextPanel::WriterInspectorTextPanel(vcl::Window* pParent,
61 const uno::Reference<frame::XFrame>& rxFrame)
62 : InspectorTextPanel(pParent, rxFrame)
64 SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current());
65 m_pShell = pDocSh->GetWrtShell();
66 if (m_pShell)
68 m_oldLink = m_pShell->GetChgLnk();
69 m_pShell->SetChgLnk(LINK(this, WriterInspectorTextPanel, AttrChangedNotify));
72 // Update panel on start
73 std::vector<svx::sidebar::TreeNode> aStore;
74 if (pDocSh->GetDoc()->GetEditShell()->GetCursor()->GetNode().GetTextNode())
75 UpdateTree(pDocSh, aStore);
76 updateEntries(aStore);
79 WriterInspectorTextPanel::~WriterInspectorTextPanel() { disposeOnce(); }
81 void WriterInspectorTextPanel::dispose()
83 m_pShell->SetChgLnk(m_oldLink);
85 InspectorTextPanel::dispose();
88 static OUString PropertyNametoRID(const OUString& rName)
90 static const std::map<OUString, const char*> aNameToRID = {
91 { "BorderDistance", RID_BORDER_DISTANCE },
92 { "BottomBorder", RID_BOTTOM_BORDER },
93 { "BottomBorderDistance", RID_BOTTOM_BORDER_DISTANCE },
94 { "BreakType", RID_BREAK_TYPE },
95 { "Category", RID_CATEGORY },
96 { "Cell", RID_CELL },
97 { "CharAutoEscapement", RID_CHAR_AUTO_ESCAPEMENT },
98 { "CharAutoKerning", RID_CHAR_AUTO_KERNING },
99 { "CharAutoStyleName", RID_CHAR_AUTO_STYLE_NAME },
100 { "CharBackColor", RID_CHAR_BACK_COLOR },
101 { "CharBackTransparent", RID_CHAR_BACK_TRANSPARENT },
102 { "CharBorderDistance", RID_CHAR_BORDER_DISTANCE },
103 { "CharBottomBorder", RID_CHAR_BOTTOM_BORDER },
104 { "CharBottomBorderDistance", RID_CHAR_BOTTOM_BORDER_DISTANCE },
105 { "CharCaseMap", RID_CHAR_CASE_MAP },
106 { "CharColor", RID_CHAR_COLOR },
107 { "CharCombineIsOn", RID_CHAR_COMBINE_IS_ON },
108 { "CharCombinePrefix", RID_CHAR_COMBINE_PREFIX },
109 { "CharCombineSuffix", RID_CHAR_COMBINE_SUFFIX },
110 { "CharContoured", RID_CHAR_CONTOURED },
111 { "CharCrossedOut", RID_CHAR_CROSSED_OUT },
112 { "CharDiffHeight", RID_CHAR_DIFF_HEIGHT },
113 { "CharDiffHeightAsian", RID_CHAR_DIFF_HEIGHT_ASIAN },
114 { "CharDiffHeightComplex", RID_CHAR_DIFF_HEIGHT_COMPLEX },
115 { "CharEmphasis", RID_CHAR_EMPHASIS },
116 { "CharEscapement", RID_CHAR_ESCAPEMENT },
117 { "CharEscapementHeight", RID_CHAR_ESCAPEMENT_HEIGHT },
118 { "CharFlash", RID_CHAR_FLASH },
119 { "CharFontCharSet", RID_CHAR_FONT_CHAR_SET },
120 { "CharFontCharSetAsian", RID_CHAR_FONT_CHAR_SET_ASIAN },
121 { "CharFontCharSetComplex", RID_CHAR_FONT_CHAR_SET_COMPLEX },
122 { "CharFontFamily", RID_CHAR_FONT_FAMILY },
123 { "CharFontFamilyAsian", RID_CHAR_FONT_FAMILY_ASIAN },
124 { "CharFontFamilyComplex", RID_CHAR_FONT_FAMILY_COMPLEX },
125 { "CharFontName", RID_CHAR_FONT_NAME },
126 { "CharFontNameAsian", RID_CHAR_FONT_NAME_ASIAN },
127 { "CharFontNameComplex", RID_CHAR_FONT_NAME_COMPLEX },
128 { "CharFontPitch", RID_CHAR_FONT_PITCH },
129 { "CharFontPitchAsian", RID_CHAR_FONT_PITCH_ASIAN },
130 { "CharFontPitchComplex", RID_CHAR_FONT_PITCH_COMPLEX },
131 { "CharFontStyleName", RID_CHAR_FONT_STYLE_NAME },
132 { "CharFontStyleNameAsian", RID_CHAR_FONT_STYLE_NAME_ASIAN },
133 { "CharFontStyleNameComplex", RID_CHAR_FONT_STYLE_NAME_COMPLEX },
134 { "CharHeight", RID_CHAR_HEIGHT },
135 { "CharHeightAsian", RID_CHAR_HEIGHT_ASIAN },
136 { "CharHeightComplex", RID_CHAR_HEIGHT_COMPLEX },
137 { "CharHidden", RID_CHAR_HIDDEN },
138 { "CharHighlight", RID_CHAR_HIGHLIGHT },
139 { "CharInteropGrabBag", RID_CHAR_INTEROP_GRAB_BAG },
140 { "CharKerning", RID_CHAR_KERNING },
141 { "CharLeftBorder", RID_CHAR_LEFT_BORDER },
142 { "CharLeftBorderDistance", RID_CHAR_LEFT_BORDER_DISTANCE },
143 { "CharLocale", RID_CHAR_LOCALE },
144 { "CharLocaleAsian", RID_CHAR_LOCALE_ASIAN },
145 { "CharLocaleComplex", RID_CHAR_LOCALE_COMPLEX },
146 { "CharNoHyphenation", RID_CHAR_NO_HYPHENATION },
147 { "CharOverline", RID_CHAR_OVERLINE },
148 { "CharOverlineColor", RID_CHAR_OVERLINE_COLOR },
149 { "CharOverlineHasColor", RID_CHAR_OVERLINE_HAS_COLOR },
150 { "CharPosture", RID_CHAR_POSTURE },
151 { "CharPostureAsian", RID_CHAR_POSTURE_ASIAN },
152 { "CharPostureComplex", RID_CHAR_POSTURE_COMPLEX },
153 { "CharPropHeight", RID_CHAR_PROP_HEIGHT },
154 { "CharPropHeightAsian", RID_CHAR_PROP_HEIGHT_ASIAN },
155 { "CharPropHeightComplex", RID_CHAR_PROP_HEIGHT_COMPLEX },
156 { "CharRelief", RID_CHAR_RELIEF },
157 { "CharRightBorder", RID_CHAR_RIGHT_BORDER },
158 { "CharRightBorderDistance", RID_CHAR_RIGHT_BORDER_DISTANCE },
159 { "CharRotation", RID_CHAR_ROTATION },
160 { "CharRotationIsFitToLine", RID_CHAR_ROTATION_IS_FIT_TO_LINE },
161 { "CharScaleWidth", RID_CHAR_SCALE_WIDTH },
162 { "CharShadingValue", RID_CHAR_SHADING_VALUE },
163 { "CharShadowFormat", RID_CHAR_SHADOW_FORMAT },
164 { "CharShadowed", RID_CHAR_SHADOWED },
165 { "CharStrikeout", RID_CHAR_STRIKEOUT },
166 { "CharStyleName", RID_CHAR_STYLE_NAME },
167 { "CharStyleNames", RID_CHAR_STYLE_NAMES },
168 { "CharTopBorder", RID_CHAR_TOP_BORDER },
169 { "CharTopBorderDistance", RID_CHAR_TOP_BORDER_DISTANCE },
170 { "CharTransparence", RID_CHAR_TRANSPARENCE },
171 { "CharUnderline", RID_CHAR_UNDERLINE },
172 { "CharUnderlineColor", RID_CHAR_UNDERLINE_COLOR },
173 { "CharUnderlineHasColor", RID_CHAR_UNDERLINE_HAS_COLOR },
174 { "CharWeight", RID_CHAR_WEIGHT },
175 { "CharWeightAsian", RID_CHAR_WEIGHT_ASIAN },
176 { "CharWeightComplex", RID_CHAR_WEIGHT_COMPLEX },
177 { "CharWordMode", RID_CHAR_WORD_MODE },
178 { "ContinueingPreviousSubTree", RID_CONTINUING_PREVIOUS_SUB_TREE },
179 { "DisplayName", RID_DISPLAY_NAME },
180 { "DocumentIndex", RID_DOCUMENT_INDEX },
181 { "DocumentIndexMark", RID_DOCUMENT_INDEX_MARK },
182 { "DropCapCharStyleName", RID_DROP_CAP_CHAR_STYLE_NAME },
183 { "DropCapFormat", RID_DROP_CAP_FORMAT },
184 { "DropCapWholeWord", RID_DROP_CAP_WHOLE_WORD },
185 { "Endnote", RID_ENDNOTE },
186 { "FillBackground", RID_FILL_BACKGROUND },
187 { "FillBitmap", RID_FILL_BITMAP },
188 { "FillBitmapLogicalSize", RID_FILL_BITMAP_LOGICAL_SIZE },
189 { "FillBitmapMode", RID_FILL_BITMAP_MODE },
190 { "FillBitmapName", RID_FILL_BITMAP_NAME },
191 { "FillBitmapOffsetX", RID_FILL_BITMAP_OFFSET_X },
192 { "FillBitmapOffsetY", RID_FILL_BITMAP_OFFSET_Y },
193 { "FillBitmapPositionOffsetX", RID_FILL_BITMAP_POSITION_OFFSET_X },
194 { "FillBitmapPositionOffsetY", RID_FILL_BITMAP_POSITION_OFFSET_Y },
195 { "FillBitmapRectanglePoint", RID_FILL_BITMAP_RECTANGLE_POINT },
196 { "FillBitmapSizeX", RID_FILL_BITMAP_SIZE_X },
197 { "FillBitmapSizeY", RID_FILL_BITMAP_SIZE_Y },
198 { "FillBitmapStretch", RID_FILL_BITMAP_STRETCH },
199 { "FillBitmapTile", RID_FILL_BITMAP_TILE },
200 { "FillBitmapURL", RID_FILL_BITMAP_URL },
201 { "FillColor", RID_FILL_COLOR },
202 { "FillColor2", RID_FILL_COLOR2 },
203 { "FillGradient", RID_FILL_GRADIENT },
204 { "FillGradientName", RID_FILL_GRADIENT_NAME },
205 { "FillGradientStepCount", RID_FILL_GRADIENT_STEP_COUNT },
206 { "FillHatch", RID_FILL_HATCH },
207 { "FillHatchName", RID_FILL_HATCH_NAME },
208 { "FillStyle", RID_FILL_STYLE },
209 { "FillTransparence", RID_FILL_TRANSPARENCE },
210 { "FillTransparenceGradient", RID_FILL_TRANSPARENCE_GRADIENT },
211 { "FillTransparenceGradientName", RID_FILL_TRANSPARENCE_GRADIENT_NAME },
212 { "FollowStyle", RID_FOLLOW_STYLE },
213 { "Footnote", RID_FOOTNOTE },
214 { "Hidden", RID_HIDDEN },
215 { "HyperLinkEvents", RID_HYPERLINK_EVENTS },
216 { "HyperLinkName", RID_HYPERLINK_NAME },
217 { "HyperLinkTarget", RID_HYPERLINK_TARGET },
218 { "HyperLinkURL", RID_HYPERLINK_URL },
219 { "IsAutoUpdate", RID_IS_AUTO_UPDATE },
220 { "IsPhysical", RID_IS_PHYSICAL },
221 { "LeftBorder", RID_LEFT_BORDER },
222 { "LeftBorderDistance", RID_LEFT_BORDER_DISTANCE },
223 { "ListAutoFormat", RID_LIST_AUTO_FORMAT },
224 { "ListId", RID_LIST_ID },
225 { "ListLabelString", RID_LIST_LABEL_STRING },
226 { "NestedTextContent", RID_NESTED_TEXT_CONTENT },
227 { "NumberingIsNumber", RID_NUMBERING_IS_NUMBER },
228 { "NumberingLevel", RID_NUMBERING_LEVEL },
229 { "NumberingRules", RID_NUMBERING_RULES },
230 { "NumberingStartValue", RID_NUMBERING_START_VALUE },
231 { "NumberingStyleName", RID_NUMBERING_STYLE_NAME },
232 { "OutlineContentVisible", RID_OUTLINE_CONTENT_VISIBLE },
233 { "OutlineLevel", RID_OUTLINE_LEVEL },
234 { "PageDescName", RID_PAGE_DESC_NAME },
235 { "PageNumberOffset", RID_PAGE_NUMBER_OFFSET },
236 { "PageStyleName", RID_PAGE_STYLE_NAME },
237 { "ParRsid", RID_PAR_RSID },
238 { "ParaAdjust", RID_PARA_ADJUST },
239 { "ParaAutoStyleName", RID_PARA_AUTO_STYLE_NAME },
240 { "ParaBackColor", RID_PARA_BACK_COLOR },
241 { "ParaBackGraphic", RID_PARA_BACK_GRAPHIC },
242 { "ParaBackGraphicFilter", RID_PARA_BACK_GRAPHIC_FILTER },
243 { "ParaBackGraphicLocation", RID_PARA_BACK_GRAPHIC_LOCATION },
244 { "ParaBackGraphicURL", RID_PARA_BACK_GRAPHIC_URL },
245 { "ParaBackTransparent", RID_PARA_BACK_TRANSPARENT },
246 { "ParaBottomMargin", RID_PARA_BOTTOM_MARGIN },
247 { "ParaBottomMarginRelative", RID_PARA_BOTTOM_MARGIN_RELATIVE },
248 { "ParaChapterNumberingLevel", RID_PARA_CHAPTER_NUMBERING_LEVEL },
249 { "ParaConditionalStyleName", RID_PARA_CONDITIONAL_STYLE_NAME },
250 { "ParaContextMargin", RID_PARA_CONTEXT_MARGIN },
251 { "ParaExpandSingleWord", RID_PARA_EXPAND_SINGLE_WORD },
252 { "ParaFirstLineIndent", RID_PARA_FIRST_LINE_INDENT },
253 { "ParaFirstLineIndentRelative", RID_PARA_FIRST_LINE_INDENT_RELATIVE },
254 { "ParaHyphenationMaxHyphens", RID_PARA_HYPHENATION_MAX_HYPHENS },
255 { "ParaHyphenationMaxLeadingChars", RID_PARA_HYPHENATION_MAX_LEADING_CHARS },
256 { "ParaHyphenationMaxTrailingChars", RID_PARA_HYPHENATION_MAX_TRAILING_CHARS },
257 { "ParaHyphenationNoCaps", RID_PARA_HYPHENATION_NO_CAPS },
258 { "ParaInteropGrabBag", RID_PARA_INTEROP_GRAB_BAG },
259 { "ParaIsAutoFirstLineIndent", RID_PARA_IS_AUTO_FIRST_LINE_INDENT },
260 { "ParaIsCharacterDistance", RID_PARA_IS_CHARACTER_DISTANCE },
261 { "ParaIsConnectBorder", RID_PARA_IS_CONNECT_BORDER },
262 { "ParaIsForbiddenRules", RID_PARA_IS_FORBIDDEN_RULES },
263 { "ParaIsHangingPunctuation", RID_PARA_IS_HANGING_PUNCTUATION },
264 { "ParaIsHyphenation", RID_PARA_IS_HYPHENATION },
265 { "ParaIsNumberingRestart", RID_PARA_IS_NUMBERING_RESTART },
266 { "ParaKeepTogether", RID_PARA_KEEP_TOGETHER },
267 { "ParaLastLineAdjust", RID_PARA_LAST_LINE_ADJUST },
268 { "ParaLeftMargin", RID_PARA_LEFT_MARGIN },
269 { "ParaLeftMarginRelative", RID_PARA_LEFT_MARGIN_RELATIVE },
270 { "ParaLineNumberCount", RID_PARA_LINE_NUMBER_COUNT },
271 { "ParaLineNumberStartValue", RID_PARA_LINE_NUMBER_START_VALUE },
272 { "ParaLineSpacing", RID_PARA_LINE_SPACING },
273 { "ParaOrphans", RID_PARA_ORPHANS },
274 { "ParaRegisterModeActive", RID_PARA_REGISTER_MODE_ACTIVE },
275 { "ParaRightMargin", RID_PARA_RIGHT_MARGIN },
276 { "ParaRightMarginRelative", RID_PARA_RIGHT_MARGIN_RELATIVE },
277 { "ParaShadowFormat", RID_PARA_SHADOW_FORMAT },
278 { "ParaSplit", RID_PARA_SPLIT },
279 { "ParaStyleName", RID_PARA_STYLE_NAME },
280 { "ParaTabStops", RID_PARA_TAB_STOPS },
281 { "ParaTopMargin", RID_PARA_TOP_MARGIN },
282 { "ParaTopMarginRelative", RID_PARA_TOP_MARGIN_RELATIVE },
283 { "ParaUserDefinedAttributes", RID_PARA_USER_DEFINED_ATTRIBUTES },
284 { "ParaVertAlignment", RID_PARA_VERT_ALIGNMENT },
285 { "ParaWidows", RID_PARA_WIDOWS },
286 { "ReferenceMark", RID_REFERENCE_MARK },
287 { "RightBorder", RID_RIGHT_BORDER },
288 { "RightBorderDistance", RID_RIGHT_BORDER_DISTANCE },
289 { "Rsid", RID_RSID },
290 { "RubyAdjust", RID_RUBY_ADJUST },
291 { "RubyCharStyleName", RID_RUBY_CHAR_STYLE_NAME },
292 { "RubyIsAbove", RID_RUBY_IS_ABOVE },
293 { "RubyPosition", RID_RUBY_POSITION },
294 { "RubyText", RID_RUBY_TEXT },
295 { "SnapToGrid", RID_SNAP_TO_GRID },
296 { "StyleInteropGrabBag", RID_STYLE_INTEROP_GRAB_BAG },
297 { "TextField", RID_TEXT_FIELD },
298 { "TextFrame", RID_TEXT_FRAME },
299 { "TextParagraph", RID_TEXT_PARAGRAPH },
300 { "TextSection", RID_TEXT_SECTION },
301 { "TextTable", RID_TEXT_TABLE },
302 { "TextUserDefinedAttributes", RID_TEXT_USER_DEFINED_ATTRIBUTES },
303 { "TopBorder", RID_TOP_BORDER },
304 { "TopBorderDistance", RID_TOP_BORDER_DISTANCE },
305 { "UnvisitedCharStyleName", RID_UNVISITED_CHAR_STYLE_NAME },
306 { "VisitedCharStyleName", RID_VISITED_CHAR_STYLE_NAME },
307 { "WritingMode", RID_WRITING_MODE },
308 { "BorderColor", RID_BORDER_COLOR },
309 { "BorderInnerLineWidth", RID_BORDER_INNER_LINE_WIDTH },
310 { "BorderLineDistance", RID_BORDER_LINE_DISTANCE },
311 { "BorderLineStyle", RID_BORDER_LINE_STYLE },
312 { "BorderLineWidth", RID_BORDER_LINE_WIDTH },
313 { "BorderOuterLineWidth", RID_BORDER_OUTER_LINE_WIDTH },
316 auto itr = aNameToRID.find(rName);
317 if (itr != aNameToRID.end())
318 return SwResId(itr->second);
319 return rName;
322 static svx::sidebar::TreeNode SimplePropToTreeNode(const OUString& rName, const css::uno::Any& rVal)
324 svx::sidebar::TreeNode aCurNode;
325 aCurNode.sNodeName = PropertyNametoRID(rName);
326 aCurNode.aValue = rVal;
328 return aCurNode;
331 static svx::sidebar::TreeNode BorderToTreeNode(const OUString& rName, const css::uno::Any& rVal)
333 table::BorderLine2 aBorder;
334 rVal >>= aBorder;
335 svx::sidebar::TreeNode aCurNode;
336 aCurNode.sNodeName = PropertyNametoRID(rName);
337 aCurNode.NodeType = svx::sidebar::TreeNode::ComplexProperty;
339 aCurNode.children.push_back(SimplePropToTreeNode("BorderColor", css::uno::Any(aBorder.Color)));
340 aCurNode.children.push_back(
341 SimplePropToTreeNode("BorderLineWidth", css::uno::Any(aBorder.LineWidth)));
342 aCurNode.children.push_back(
343 SimplePropToTreeNode("BorderLineStyle", css::uno::Any(aBorder.LineStyle)));
344 aCurNode.children.push_back(
345 SimplePropToTreeNode("BorderLineDistance", css::uno::Any(aBorder.LineDistance)));
346 aCurNode.children.push_back(
347 SimplePropToTreeNode("BorderInnerLineWidth", css::uno::Any(aBorder.InnerLineWidth)));
348 aCurNode.children.push_back(
349 SimplePropToTreeNode("BorderOuterLineWidth", css::uno::Any(aBorder.OuterLineWidth)));
351 return aCurNode;
354 static svx::sidebar::TreeNode LocaleToTreeNode(const OUString& rName, const css::uno::Any& rVal)
356 svx::sidebar::TreeNode aCurNode;
357 aCurNode.sNodeName = PropertyNametoRID(rName);
358 lang::Locale aLocale;
359 rVal >>= aLocale;
360 OUString aLocaleText(aLocale.Language + "-" + aLocale.Country);
361 if (!aLocale.Variant.isEmpty())
362 aLocaleText += " (" + aLocale.Variant + ")";
363 aCurNode.aValue <<= aLocaleText;
365 return aCurNode;
368 static svx::sidebar::TreeNode
369 PropertyToTreeNode(const css::beans::Property& rProperty,
370 const uno::Reference<beans::XPropertySet>& xPropertiesSet, const bool& rIsGrey)
372 const OUString& rPropName = rProperty.Name;
373 svx::sidebar::TreeNode aCurNode;
374 const uno::Any aAny = xPropertiesSet->getPropertyValue(rPropName);
375 aCurNode.sNodeName = PropertyNametoRID(rPropName);
377 // These properties are handled separately as they are stored in STRUCT and not in single data members
378 if (rPropName == "CharTopBorder" || rPropName == "CharBottomBorder"
379 || rPropName == "CharLeftBorder" || rPropName == "CharRightBorder"
380 || rPropName == "TopBorder" || rPropName == "BottomBorder" || rPropName == "LeftBorder"
381 || rPropName == "RightBorder")
383 aCurNode = BorderToTreeNode(rPropName, aAny);
385 else if (rPropName == "CharLocale")
387 aCurNode = LocaleToTreeNode(rPropName, aAny);
389 else
390 aCurNode = SimplePropToTreeNode(rPropName, aAny);
392 if (rIsGrey)
394 aCurNode.isGrey = true;
395 for (svx::sidebar::TreeNode& rChildNode : aCurNode.children)
396 rChildNode.isGrey = true; // grey out all the children nodes
399 return aCurNode;
402 static void InsertValues(const css::uno::Reference<css::uno::XInterface>& rSource,
403 std::unordered_map<OUString, bool>& rIsDefined,
404 svx::sidebar::TreeNode& rNode, const bool& isRoot,
405 const std::vector<OUString>& rHiddenProperty)
407 uno::Reference<beans::XPropertySet> xPropertiesSet(rSource, uno::UNO_QUERY_THROW);
408 uno::Reference<beans::XPropertyState> xPropertiesState(rSource, uno::UNO_QUERY_THROW);
409 const uno::Sequence<beans::Property> aProperties
410 = xPropertiesSet->getPropertySetInfo()->getProperties();
412 for (const beans::Property& rProperty : aProperties)
414 const OUString& rPropName = rProperty.Name;
415 if (std::find(rHiddenProperty.begin(), rHiddenProperty.end(), rPropName)
416 != rHiddenProperty.end())
417 continue;
419 if (isRoot
420 || xPropertiesState->getPropertyState(rPropName) == beans::PropertyState_DIRECT_VALUE)
422 svx::sidebar::TreeNode aCurNode
423 = PropertyToTreeNode(rProperty, xPropertiesSet, rIsDefined[rPropName]);
424 rIsDefined[rPropName] = true;
425 rNode.children.push_back(aCurNode);
429 const comphelper::string::NaturalStringSorter aSorter(
430 comphelper::getProcessComponentContext(),
431 Application::GetSettings().GetUILanguageTag().getLocale());
433 std::sort(
434 rNode.children.begin(), rNode.children.end(),
435 [&aSorter](svx::sidebar::TreeNode const& rEntry1, svx::sidebar::TreeNode const& rEntry2) {
436 return aSorter.compare(rEntry1.sNodeName, rEntry2.sNodeName) < 0;
440 static void UpdateTree(SwDocShell* pDocSh, std::vector<svx::sidebar::TreeNode>& aStore)
442 SwDoc* pDoc = pDocSh->GetDoc();
443 SwPaM* pCursor = pDoc->GetEditShell()->GetCursor();
444 svx::sidebar::TreeNode aCharDFNode;
445 svx::sidebar::TreeNode aCharNode;
446 svx::sidebar::TreeNode aParaNode;
447 svx::sidebar::TreeNode aParaDFNode;
449 aCharNode.sNodeName = SwResId(STR_CHARACTERSTYLEFAMILY);
450 aParaNode.sNodeName = SwResId(STR_PARAGRAPHSTYLEFAMILY);
451 aCharDFNode.sNodeName = SwResId(RID_CHAR_DIRECTFORMAT);
452 aParaDFNode.sNodeName = SwResId(RID_PARA_DIRECTFORMAT);
453 aCharDFNode.NodeType = svx::sidebar::TreeNode::Category;
454 aCharNode.NodeType = svx::sidebar::TreeNode::Category;
455 aParaNode.NodeType = svx::sidebar::TreeNode::Category;
456 aParaDFNode.NodeType = svx::sidebar::TreeNode::Category;
458 uno::Reference<text::XTextRange> xRange(
459 SwXTextRange::CreateXTextRange(*pDoc, *pCursor->GetPoint(), nullptr));
460 uno::Reference<beans::XPropertySet> xPropertiesSet(xRange, uno::UNO_QUERY_THROW);
461 std::unordered_map<OUString, bool> aIsDefined;
463 const std::vector<OUString> aHiddenProperties{ UNO_NAME_RSID,
464 UNO_NAME_PARA_IS_NUMBERING_RESTART,
465 UNO_NAME_PARA_STYLE_NAME,
466 UNO_NAME_PARA_CONDITIONAL_STYLE_NAME,
467 UNO_NAME_PAGE_STYLE_NAME,
468 UNO_NAME_NUMBERING_START_VALUE,
469 UNO_NAME_NUMBERING_IS_NUMBER,
470 UNO_NAME_PARA_CONTINUEING_PREVIOUS_SUB_TREE,
471 UNO_NAME_CHAR_STYLE_NAME,
472 UNO_NAME_NUMBERING_LEVEL,
473 UNO_NAME_PARRSID };
475 InsertValues(xRange, aIsDefined, aCharDFNode, false, aHiddenProperties);
477 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(pDocSh->GetBaseModel(),
478 uno::UNO_QUERY);
479 uno::Reference<container::XNameAccess> xStyleFamilies
480 = xStyleFamiliesSupplier->getStyleFamilies();
481 OUString sCurrentCharStyle, sCurrentParaStyle, sDisplayName;
483 uno::Reference<container::XNameAccess> xStyleFamily(
484 xStyleFamilies->getByName("CharacterStyles"), uno::UNO_QUERY_THROW);
485 xPropertiesSet->getPropertyValue("CharStyleName") >>= sCurrentCharStyle;
486 xPropertiesSet->getPropertyValue("ParaStyleName") >>= sCurrentParaStyle;
488 if (!sCurrentCharStyle.isEmpty())
490 xPropertiesSet.set(xStyleFamily->getByName(sCurrentCharStyle), css::uno::UNO_QUERY_THROW);
491 xPropertiesSet->getPropertyValue("DisplayName") >>= sDisplayName;
492 svx::sidebar::TreeNode aCurrentChild;
493 aCurrentChild.sNodeName = sDisplayName;
494 aCurrentChild.NodeType = svx::sidebar::TreeNode::ComplexProperty;
496 InsertValues(xPropertiesSet, aIsDefined, aCurrentChild, false, {});
498 aCharNode.children.push_back(aCurrentChild);
501 // Collect paragraph direct formatting
502 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xRange, uno::UNO_QUERY_THROW);
503 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
504 uno::Reference<text::XTextRange> xThisParagraphRange(xParaEnum->nextElement(), uno::UNO_QUERY);
505 if (xThisParagraphRange.is())
506 InsertValues(xThisParagraphRange, aIsDefined, aParaDFNode, false, aHiddenProperties);
508 xStyleFamily.set(xStyleFamilies->getByName("ParagraphStyles"), uno::UNO_QUERY_THROW);
510 while (!sCurrentParaStyle.isEmpty())
512 uno::Reference<style::XStyle> xPropertiesStyle(xStyleFamily->getByName(sCurrentParaStyle),
513 uno::UNO_QUERY_THROW);
514 xPropertiesSet.set(xPropertiesStyle, css::uno::UNO_QUERY_THROW);
515 xPropertiesSet->getPropertyValue("DisplayName") >>= sDisplayName;
516 OUString aParentParaStyle = xPropertiesStyle->getParentStyle();
517 svx::sidebar::TreeNode aCurrentChild;
518 aCurrentChild.sNodeName = sDisplayName;
519 aCurrentChild.NodeType = svx::sidebar::TreeNode::ComplexProperty;
521 InsertValues(xPropertiesSet, aIsDefined, aCurrentChild, aParentParaStyle.isEmpty(), {});
523 aParaNode.children.push_back(aCurrentChild);
524 sCurrentParaStyle = aParentParaStyle;
527 std::reverse(aParaNode.children.begin(),
528 aParaNode.children.end()); // Parent style should be first then children
531 Display Order :-
532 PARAGRAPH STYLE
533 PARAGRAPH DIRECT FORMATTING
534 CHARACTER STYLE
535 DIRECT FORMATTING
537 aStore.push_back(aParaNode);
538 aStore.push_back(aParaDFNode);
539 aStore.push_back(aCharNode);
540 aStore.push_back(aCharDFNode);
543 IMPL_LINK(WriterInspectorTextPanel, AttrChangedNotify, LinkParamNone*, pLink, void)
545 if (m_oldLink.IsSet())
546 m_oldLink.Call(pLink);
548 SwDocShell* pDocSh = m_pShell->GetDoc()->GetDocShell();
549 std::vector<svx::sidebar::TreeNode> aStore;
551 if (pDocSh && pDocSh->GetDoc()->GetEditShell()->GetCursor()->GetNode().GetTextNode())
552 UpdateTree(pDocSh, aStore);
554 updateEntries(aStore);
557 } // end of namespace svx::sidebar
559 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */