LibreOffice Module sw (master)  1
uiregionsw.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <hintids.hxx>
21 #include <regionsw.hxx>
22 #include <svl/urihelper.hxx>
23 #include <svl/PasswordHelper.hxx>
24 #include <vcl/svapp.hxx>
25 #include <vcl/weld.hxx>
26 #include <svl/stritem.hxx>
27 #include <svl/eitem.hxx>
28 #include <sfx2/passwd.hxx>
29 #include <sfx2/docfilt.hxx>
30 #include <sfx2/request.hxx>
31 #include <sfx2/docfile.hxx>
32 #include <sfx2/linkmgr.hxx>
33 #include <sfx2/docinsert.hxx>
34 #include <sfx2/filedlghelper.hxx>
35 #include <editeng/sizeitem.hxx>
36 #include <svtools/htmlcfg.hxx>
37 
38 #include <uitool.hxx>
39 #include <IMark.hxx>
40 #include <section.hxx>
41 #include <docary.hxx>
42 #include <doc.hxx>
43 #include <wdocsh.hxx>
44 #include <view.hxx>
45 #include <wrtsh.hxx>
46 #include <column.hxx>
47 #include <fmtclbl.hxx>
48 #include <fmtfsize.hxx>
49 #include <frmatr.hxx>
50 #include <shellio.hxx>
51 
52 #include <cmdid.h>
53 #include <strings.hrc>
54 #include <bitmaps.hlst>
55 #include <sfx2/bindings.hxx>
56 #include <sfx2/sfxdlg.hxx>
57 #include <sfx2/viewfrm.hxx>
58 #include <svx/dialogs.hrc>
59 #include <svx/flagsdef.hxx>
60 #include <memory>
61 #include <string_view>
62 
63 using namespace ::com::sun::star;
64 
65 namespace {
66 
67 OUString BuildBitmap(bool bProtect, bool bHidden)
68 {
69  if (bProtect)
70  return bHidden ? OUString(RID_BMP_PROT_HIDE) : OUString(RID_BMP_PROT_NO_HIDE);
71  return bHidden ? OUString(RID_BMP_HIDE) : OUString(RID_BMP_NO_HIDE);
72 }
73 
74 }
75 
76 static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox );
77 
78 static void lcl_FillList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames, const SwSectionFormat* pNewFormat )
79 {
80  if( !pNewFormat )
81  {
82  const size_t nCount = rSh.GetSectionFormatCount();
83  for (size_t i = 0; i<nCount; i++)
84  {
85  SectionType eTmpType;
86  const SwSectionFormat* pFormat = &rSh.GetSectionFormat(i);
87  if( !pFormat->GetParent() &&
88  pFormat->IsInNodesArr() &&
89  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
90  && SectionType::ToxHeader != eTmpType )
91  {
92  const OUString sString(pFormat->GetSection()->GetSectionName());
93  if (pAvailNames)
94  pAvailNames->append_text(sString);
95  rSubRegions.append_text(sString);
96  lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
97  }
98  }
99  }
100  else
101  {
102  SwSections aTmpArr;
103  pNewFormat->GetChildSections(aTmpArr, SectionSort::Pos);
104  if( !aTmpArr.empty() )
105  {
106  SectionType eTmpType;
107  for( const auto pSect : aTmpArr )
108  {
109  const SwSectionFormat* pFormat = pSect->GetFormat();
110  if( pFormat->IsInNodesArr()&&
111  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
112  && SectionType::ToxHeader != eTmpType )
113  {
114  const OUString sString(pFormat->GetSection()->GetSectionName());
115  if (pAvailNames)
116  pAvailNames->append_text(sString);
117  rSubRegions.append_text(sString);
118  lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
119  }
120  }
121  }
122  }
123 }
124 
125 static void lcl_FillSubRegionList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames )
126 {
127  rSubRegions.clear();
128  lcl_FillList( rSh, rSubRegions, pAvailNames, nullptr );
129  IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
130  for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin();
131  ppMark != pMarkAccess->getBookmarksEnd();
132  ++ppMark)
133  {
134  const ::sw::mark::IMark* pBkmk = *ppMark;
135  if( pBkmk->IsExpanded() )
136  rSubRegions.append_text( pBkmk->GetName() );
137  }
138 }
139 
140 // user data class for region information
141 class SectRepr
142 {
143 private:
146  std::unique_ptr<SvxBrushItem> m_Brush;
150  std::shared_ptr<SvxFrameDirectionItem> m_FrameDirItem;
151  std::shared_ptr<SvxLRSpaceItem> m_LRSpaceItem;
152  const size_t m_nArrPos;
153  // shows, if maybe textcontent is in the region
154  bool m_bContent : 1;
155  // for multiselection, mark at first, then work with TreeListBox!
156  bool m_bSelected : 1;
157  uno::Sequence<sal_Int8> m_TempPasswd;
158 
159 public:
160  SectRepr(size_t nPos, SwSection& rSect);
161 
163  SwFormatCol& GetCol() { return m_Col; }
164  std::unique_ptr<SvxBrushItem>& GetBackground() { return m_Brush; }
168  std::shared_ptr<SvxFrameDirectionItem>& GetFrameDir() { return m_FrameDirItem; }
169  std::shared_ptr<SvxLRSpaceItem>& GetLRSpace() { return m_LRSpaceItem; }
170 
171  size_t GetArrPos() const { return m_nArrPos; }
172  OUString GetFile() const;
173  OUString GetSubRegion() const;
174  void SetFile(OUString const& rFile);
175  void SetFilter(std::u16string_view rFilter);
176  void SetSubRegion(std::u16string_view rSubRegion);
177 
178  bool IsContent() const { return m_bContent; }
179  void SetContent(bool const bValue) { m_bContent = bValue; }
180 
181  void SetSelected() { m_bSelected = true; }
182  bool IsSelected() const { return m_bSelected; }
183 
184  uno::Sequence<sal_Int8> & GetTempPasswd() { return m_TempPasswd; }
185  void SetTempPasswd(const uno::Sequence<sal_Int8> & rPasswd)
186  { m_TempPasswd = rPasswd; }
187 };
188 
189 SectRepr::SectRepr( size_t nPos, SwSection& rSect )
190  : m_SectionData( rSect )
191  , m_Brush(std::make_unique<SvxBrushItem>(RES_BACKGROUND))
193  , m_LRSpaceItem(std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE))
194  , m_nArrPos(nPos)
195  , m_bContent(m_SectionData.GetLinkFileName().isEmpty())
196  , m_bSelected(false)
197 {
198  SwSectionFormat *pFormat = rSect.GetFormat();
199  if( pFormat )
200  {
201  m_Col = pFormat->GetCol();
202  m_Brush = pFormat->makeBackgroundBrushItem();
204  m_EndNtAtEnd = pFormat->GetEndAtTextEnd();
206  m_FrameDirItem.reset(pFormat->GetFrameDir().Clone());
207  m_LRSpaceItem.reset(pFormat->GetLRSpace().Clone());
208  }
209 }
210 
211 void SectRepr::SetFile( const OUString& rFile )
212 {
213  OUString sNewFile( INetURLObject::decode( rFile,
215  const OUString sOldFileName( m_SectionData.GetLinkFileName() );
216  const OUString sSub( sOldFileName.getToken( 2, sfx2::cTokenSeparator ) );
217 
218  if( !rFile.isEmpty() || !sSub.isEmpty() )
219  {
220  sNewFile += OUStringChar(sfx2::cTokenSeparator);
221  if( !rFile.isEmpty() ) // Filter only with FileName
222  sNewFile += sOldFileName.getToken( 1, sfx2::cTokenSeparator );
223 
224  sNewFile += OUStringChar(sfx2::cTokenSeparator) + sSub;
225  }
226 
227  m_SectionData.SetLinkFileName( sNewFile );
228 
229  if( !rFile.isEmpty() || !sSub.isEmpty() )
230  {
232  }
233  else
234  {
236  }
237 }
238 
239 void SectRepr::SetFilter( std::u16string_view rFilter )
240 {
241  OUString sNewFile;
242  const OUString sOldFileName( m_SectionData.GetLinkFileName() );
243  sal_Int32 nIdx{ 0 };
244  const OUString sFile( sOldFileName.getToken( 0, sfx2::cTokenSeparator, nIdx ) ); // token 0
245  const OUString sSub( sOldFileName.getToken( 1, sfx2::cTokenSeparator, nIdx ) ); // token 2
246 
247  if( !sFile.isEmpty() )
248  sNewFile = sFile + OUStringChar(sfx2::cTokenSeparator) +
249  rFilter + OUStringChar(sfx2::cTokenSeparator) + sSub;
250  else if( !sSub.isEmpty() )
251  sNewFile = OUStringChar(sfx2::cTokenSeparator) + OUStringChar(sfx2::cTokenSeparator) + sSub;
252 
253  m_SectionData.SetLinkFileName( sNewFile );
254 
255  if( !sNewFile.isEmpty() )
256  {
258  }
259 }
260 
261 void SectRepr::SetSubRegion(std::u16string_view rSubRegion)
262 {
263  OUString sNewFile;
264  sal_Int32 n(0);
265  const OUString sLinkFileName(m_SectionData.GetLinkFileName());
266  const OUString sOldFileName( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
267  const OUString sFilter( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
268 
269  if( !rSubRegion.empty() || !sOldFileName.isEmpty() )
270  sNewFile = sOldFileName + OUStringChar(sfx2::cTokenSeparator) +
271  sFilter + OUStringChar(sfx2::cTokenSeparator) + rSubRegion;
272 
273  m_SectionData.SetLinkFileName( sNewFile );
274 
275  if( !rSubRegion.empty() || !sOldFileName.isEmpty() )
276  {
278  }
279  else
280  {
282  }
283 }
284 
285 OUString SectRepr::GetFile() const
286 {
287  const OUString sLinkFile( m_SectionData.GetLinkFileName() );
288 
289  if( sLinkFile.isEmpty() )
290  {
291  return sLinkFile;
292  }
294  {
295  sal_Int32 n = 0;
296  return sLinkFile.replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n )
297  .replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n );
298  }
299  return INetURLObject::decode( sLinkFile.getToken( 0, sfx2::cTokenSeparator ),
301 }
302 
303 OUString SectRepr::GetSubRegion() const
304 {
305  const OUString sLinkFile( m_SectionData.GetLinkFileName() );
306  if( !sLinkFile.isEmpty() )
307  return sLinkFile.getToken( 2, sfx2::cTokenSeparator );
308  return sLinkFile;
309 }
310 
311 // dialog edit regions
313  : SfxDialogController(pParent, "modules/swriter/ui/editsectiondialog.ui",
314  "EditSectionDialog")
315  , m_bSubRegionsFilled(false)
316  , rSh(rWrtSh)
317  , bDontCheckPasswd(true)
318  , m_xCurName(m_xBuilder->weld_entry("curname"))
319  , m_xTree(m_xBuilder->weld_tree_view("tree"))
320  , m_xFileCB(m_xBuilder->weld_check_button("link"))
321  , m_xDDECB(m_xBuilder->weld_check_button("dde"))
322  , m_xDDEFrame(m_xBuilder->weld_widget("ddedepend"))
323  , m_xFileNameFT(m_xBuilder->weld_label("filenameft"))
324  , m_xDDECommandFT(m_xBuilder->weld_label("ddeft"))
325  , m_xFileNameED(m_xBuilder->weld_entry("filename"))
326  , m_xFilePB(m_xBuilder->weld_button("file"))
327  , m_xSubRegionFT(m_xBuilder->weld_label("sectionft"))
328  , m_xSubRegionED(m_xBuilder->weld_combo_box("section"))
329  , m_xProtectCB(m_xBuilder->weld_check_button("protect"))
330  , m_xPasswdCB(m_xBuilder->weld_check_button("withpassword"))
331  , m_xPasswdPB(m_xBuilder->weld_button("password"))
332  , m_xHideCB(m_xBuilder->weld_check_button("hide"))
333  , m_xConditionFT(m_xBuilder->weld_label("conditionft"))
334  , m_xConditionED(new ConditionEdit(m_xBuilder->weld_entry("condition")))
335  , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editinro"))
336  , m_xOK(m_xBuilder->weld_button("ok"))
337  , m_xOptionsPB(m_xBuilder->weld_button("options"))
338  , m_xDismiss(m_xBuilder->weld_button("remove"))
339  , m_xHideFrame(m_xBuilder->weld_widget("hideframe"))
340 {
341  m_xTree->set_size_request(-1, m_xTree->get_height_rows(16));
342  m_xFileCB->set_state(TRISTATE_FALSE);
343  m_xSubRegionED->make_sorted();
344  m_xProtectCB->set_state(TRISTATE_FALSE);
345  m_xHideCB->set_state(TRISTATE_FALSE);
346  // edit in readonly sections
348 
349  bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr;
350 
351  m_xTree->connect_changed(LINK(this, SwEditRegionDlg, GetFirstEntryHdl));
352  m_xCurName->connect_changed(LINK(this, SwEditRegionDlg, NameEditHdl));
353  m_xConditionED->connect_changed( LINK( this, SwEditRegionDlg, ConditionEditHdl));
354  m_xOK->connect_clicked( LINK( this, SwEditRegionDlg, OkHdl));
355  m_xPasswdCB->connect_toggled(LINK(this, SwEditRegionDlg, TogglePasswdHdl));
356  m_xPasswdPB->connect_clicked(LINK(this, SwEditRegionDlg, ChangePasswdHdl));
357  m_xHideCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeHideHdl));
358  // edit in readonly sections
359  m_xEditInReadonlyCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeEditInReadonlyHdl));
360 
361  m_xOptionsPB->connect_clicked(LINK(this, SwEditRegionDlg, OptionsHdl));
362  m_xProtectCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeProtectHdl));
363  m_xDismiss->connect_clicked( LINK( this, SwEditRegionDlg, ChangeDismissHdl));
364  m_xFileCB->connect_toggled(LINK(this, SwEditRegionDlg, UseFileHdl));
365  m_xFilePB->connect_clicked(LINK(this, SwEditRegionDlg, FileSearchHdl));
366  m_xFileNameED->connect_changed(LINK(this, SwEditRegionDlg, FileNameEntryHdl));
367  m_xSubRegionED->connect_changed(LINK(this, SwEditRegionDlg, FileNameComboBoxHdl));
368  m_xSubRegionED->connect_popup_toggled(LINK(this, SwEditRegionDlg, SubRegionEventHdl));
369  m_xSubRegionED->set_entry_completion(true, true);
370 
371  m_xTree->set_selection_mode(SelectionMode::Multiple);
372 
373  if (bWeb)
374  {
375  m_xDDECB->hide();
376  m_xHideFrame->hide();
377  m_xPasswdCB->hide();
378  }
379 
380  m_xDDECB->connect_toggled(LINK(this, SwEditRegionDlg, DDEHdl));
381 
383  RecurseList( nullptr, nullptr );
384 
385  // if the cursor is not in a region the first one will always be selected
386  if (!m_xTree->get_selected(nullptr))
387  {
388  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
389  if (m_xTree->get_iter_first(*xIter))
390  {
391  m_xTree->select(*xIter);
392  GetFirstEntryHdl(*m_xTree);
393  }
394  }
395 
396  m_xTree->show();
397  bDontCheckPasswd = false;
398 }
399 
401 {
402  if (bDontCheckPasswd)
403  return true;
404  bool bRet = true;
405 
406  m_xTree->selected_foreach([this, &bRet](weld::TreeIter& rEntry){
407  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
408  if (!pRepr->GetTempPasswd().hasElements()
409  && pRepr->GetSectionData().GetPassword().hasElements())
410  {
411  SfxPasswordDialog aPasswdDlg(m_xDialog.get());
412  bRet = false;
413  if (aPasswdDlg.run())
414  {
415  const OUString sNewPasswd(aPasswdDlg.GetPassword());
416  css::uno::Sequence <sal_Int8 > aNewPasswd;
417  SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
419  pRepr->GetSectionData().GetPassword(), sNewPasswd))
420  {
421  pRepr->SetTempPasswd(aNewPasswd);
422  bRet = true;
423  }
424  else
425  {
426  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
427  VclMessageType::Info, VclButtonsType::Ok,
428  SwResId(STR_WRONG_PASSWORD)));
429  xInfoBox->run();
430  }
431  }
432  }
433  return false;
434  });
435  if (!bRet && pBox)
436  {
437  //reset old button state
438  if (pBox->get_state() != TRISTATE_INDET)
439  pBox->set_active(!pBox->get_active());
440  }
441 
442  return bRet;
443 }
444 
445 // recursively look for child-sections
447 {
448  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
449  if (!pFormat)
450  {
451  const size_t nCount=rSh.GetSectionFormatCount();
452  for ( size_t n = 0; n < nCount; n++ )
453  {
454  SectionType eTmpType;
455  if( !( pFormat = &rSh.GetSectionFormat(n))->GetParent() &&
456  pFormat->IsInNodesArr() &&
457  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
458  && SectionType::ToxHeader != eTmpType )
459  {
460  SwSection *pSect = pFormat->GetSection();
461  SectRepr* pSectRepr = new SectRepr( n, *pSect );
462 
463  OUString sText(pSect->GetSectionName());
464  OUString sImage(BuildBitmap(pSect->IsProtect(),pSect->IsHidden()));
465  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr)));
466  m_xTree->insert(nullptr, -1, &sText, &sId, nullptr, nullptr, false, xIter.get());
467  m_xTree->set_image(*xIter, sImage);
468 
469  RecurseList(pFormat, xIter.get());
470  if (m_xTree->iter_has_child(*xIter))
471  m_xTree->expand_row(*xIter);
472  if (pCurrSect==pSect)
473  {
474  m_xTree->select(*xIter);
475  m_xTree->scroll_to_row(*xIter);
476  GetFirstEntryHdl(*m_xTree);
477  }
478  }
479  }
480  }
481  else
482  {
483  SwSections aTmpArr;
484  pFormat->GetChildSections(aTmpArr, SectionSort::Pos);
485  for( const auto pSect : aTmpArr )
486  {
487  SectionType eTmpType;
488  pFormat = pSect->GetFormat();
489  if( pFormat->IsInNodesArr() &&
490  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
491  && SectionType::ToxHeader != eTmpType )
492  {
493  SectRepr* pSectRepr=new SectRepr(
494  FindArrPos( pSect->GetFormat() ), *pSect );
495 
496  OUString sText(pSect->GetSectionName());
497  OUString sImage = BuildBitmap(pSect->IsProtect(), pSect->IsHidden());
498  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr)));
499  m_xTree->insert(pEntry, -1, &sText, &sId, nullptr, nullptr, false, xIter.get());
500  m_xTree->set_image(*xIter, sImage);
501 
502  RecurseList(pSect->GetFormat(), xIter.get());
503  if (m_xTree->iter_has_child(*xIter))
504  m_xTree->expand_row(*xIter);
505  if (pCurrSect==pSect)
506  {
507  m_xTree->select(*xIter);
508  m_xTree->scroll_to_row(*xIter);
509  GetFirstEntryHdl(*m_xTree);
510  }
511  }
512  }
513  }
514 }
515 
517 {
518  const size_t nCount=rSh.GetSectionFormatCount();
519  for ( size_t i = 0; i < nCount; i++ )
520  if ( pFormat == &rSh.GetSectionFormat(i) )
521  return i;
522 
523  OSL_FAIL("SectionFormat not on the list" );
524  return SIZE_MAX;
525 }
526 
528 {
529  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
530  if (m_xTree->get_iter_first(*xIter))
531  {
532  do
533  {
534  delete reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
535  } while (m_xTree->iter_next(*xIter));
536  }
537 }
538 
539 void SwEditRegionDlg::SelectSection(std::u16string_view rSectionName)
540 {
541  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
542  if (!m_xTree->get_iter_first(*xIter))
543  return;
544 
545  do
546  {
547  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
548  if (pRepr->GetSectionData().GetSectionName() == rSectionName)
549  {
550  m_xTree->unselect_all();
551  m_xTree->select(*xIter);
552  m_xTree->scroll_to_row(*xIter);
553  GetFirstEntryHdl(*m_xTree);
554  break;
555  }
556  } while (m_xTree->iter_next(*xIter));
557 }
558 
559 // selected entry in TreeListBox is showed in Edit window in case of
560 // multiselection some controls are disabled
561 IMPL_LINK(SwEditRegionDlg, GetFirstEntryHdl, weld::TreeView&, rBox, void)
562 {
563  bDontCheckPasswd = true;
564  std::unique_ptr<weld::TreeIter> xIter(rBox.make_iterator());
565  bool bEntry = rBox.get_selected(xIter.get());
566  m_xHideCB->set_sensitive(true);
567  // edit in readonly sections
568  m_xEditInReadonlyCB->set_sensitive(true);
569 
570  m_xProtectCB->set_sensitive(true);
571  m_xFileCB->set_sensitive(true);
572  css::uno::Sequence <sal_Int8> aCurPasswd;
573  if (1 < rBox.count_selected_rows())
574  {
575  m_xHideCB->set_state(TRISTATE_INDET);
576  m_xProtectCB->set_state(TRISTATE_INDET);
577  // edit in readonly sections
578  m_xEditInReadonlyCB->set_state(TRISTATE_INDET);
579  m_xFileCB->set_state(TRISTATE_INDET);
580 
581  bool bHiddenValid = true;
582  bool bProtectValid = true;
583  bool bConditionValid = true;
584  // edit in readonly sections
585  bool bEditInReadonlyValid = true;
586  bool bEditInReadonly = true;
587 
588  bool bHidden = true;
589  bool bProtect = true;
590  OUString sCondition;
591  bool bFirst = true;
592  bool bFileValid = true;
593  bool bFile = true;
594  bool bPasswdValid = true;
595 
596  m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
597  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
598  SwSectionData const& rData( pRepr->GetSectionData() );
599  if(bFirst)
600  {
601  sCondition = rData.GetCondition();
602  bHidden = rData.IsHidden();
603  bProtect = rData.IsProtectFlag();
604  // edit in readonly sections
605  bEditInReadonly = rData.IsEditInReadonlyFlag();
606 
607  bFile = (rData.GetType() != SectionType::Content);
608  aCurPasswd = rData.GetPassword();
609  }
610  else
611  {
612  if(sCondition != rData.GetCondition())
613  bConditionValid = false;
614  bHiddenValid = (bHidden == rData.IsHidden());
615  bProtectValid = (bProtect == rData.IsProtectFlag());
616  // edit in readonly sections
617  bEditInReadonlyValid =
618  (bEditInReadonly == rData.IsEditInReadonlyFlag());
619 
620  bFileValid = (bFile ==
621  (rData.GetType() != SectionType::Content));
622  bPasswdValid = (aCurPasswd == rData.GetPassword());
623  }
624  bFirst = false;
625  return false;
626  });
627 
628  m_xHideCB->set_state(!bHiddenValid ? TRISTATE_INDET :
629  bHidden ? TRISTATE_TRUE : TRISTATE_FALSE);
630  m_xProtectCB->set_state(!bProtectValid ? TRISTATE_INDET :
631  bProtect ? TRISTATE_TRUE : TRISTATE_FALSE);
632  // edit in readonly sections
633  m_xEditInReadonlyCB->set_state(!bEditInReadonlyValid ? TRISTATE_INDET :
634  bEditInReadonly ? TRISTATE_TRUE : TRISTATE_FALSE);
635 
636  m_xFileCB->set_state(!bFileValid ? TRISTATE_INDET :
637  bFile ? TRISTATE_TRUE : TRISTATE_FALSE);
638 
639  if (bConditionValid)
640  m_xConditionED->set_text(sCondition);
641  else
642  {
643  m_xConditionFT->set_sensitive(false);
644  m_xConditionED->set_sensitive(false);
645  }
646 
647  m_xCurName->set_sensitive(false);
648  m_xDDECB->set_sensitive(false);
649  m_xDDEFrame->set_sensitive(false);
650  m_xOptionsPB->set_sensitive(false);
651  bool bPasswdEnabled = m_xProtectCB->get_state() == TRISTATE_TRUE;
652  m_xPasswdCB->set_sensitive(bPasswdEnabled);
653  m_xPasswdPB->set_sensitive(bPasswdEnabled);
654  if(!bPasswdValid)
655  {
656  rBox.get_selected(xIter.get());
657  rBox.unselect_all();
658  rBox.select(*xIter);
659  GetFirstEntryHdl(rBox);
660  return;
661  }
662  else
663  m_xPasswdCB->set_active(aCurPasswd.hasElements());
664  }
665  else if (bEntry )
666  {
667  m_xCurName->set_sensitive(true);
668  m_xOptionsPB->set_sensitive(true);
669  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
670  SwSectionData const& rData( pRepr->GetSectionData() );
671  m_xConditionED->set_text(rData.GetCondition());
672  m_xHideCB->set_sensitive(true);
673  m_xHideCB->set_state((rData.IsHidden()) ? TRISTATE_TRUE : TRISTATE_FALSE);
674  bool bHide = TRISTATE_TRUE == m_xHideCB->get_state();
675  m_xConditionED->set_sensitive(bHide);
676  m_xConditionFT->set_sensitive(bHide);
677  m_xPasswdCB->set_active(rData.GetPassword().hasElements());
678 
679  m_xOK->set_sensitive(true);
680  m_xPasswdCB->set_sensitive(true);
681  m_xCurName->set_text(rBox.get_text(*xIter));
682  m_xCurName->set_sensitive(true);
683  m_xDismiss->set_sensitive(true);
684  const OUString aFile = pRepr->GetFile();
685  const OUString sSub = pRepr->GetSubRegion();
686  m_xSubRegionED->clear();
687  m_xSubRegionED->append_text(""); // put in a dummy entry, which is replaced when m_bSubRegionsFilled is set
688  m_bSubRegionsFilled = false;
689  if( !aFile.isEmpty() || !sSub.isEmpty() )
690  {
691  m_xFileCB->set_active(true);
692  m_xFileNameED->set_text(aFile);
693  m_xSubRegionED->set_entry_text(sSub);
694  m_xDDECB->set_active(rData.GetType() == SectionType::DdeLink);
695  }
696  else
697  {
698  m_xFileCB->set_active(false);
699  m_xFileNameED->set_text(aFile);
700  m_xDDECB->set_sensitive(false);
701  m_xDDECB->set_active(false);
702  }
703  UseFileHdl(*m_xFileCB);
704  DDEHdl(*m_xDDECB);
705  m_xProtectCB->set_state((rData.IsProtectFlag())
706  ? TRISTATE_TRUE : TRISTATE_FALSE);
707  m_xProtectCB->set_sensitive(true);
708 
709  // edit in readonly sections
710  m_xEditInReadonlyCB->set_state((rData.IsEditInReadonlyFlag())
711  ? TRISTATE_TRUE : TRISTATE_FALSE);
712  m_xEditInReadonlyCB->set_sensitive(true);
713 
714  bool bPasswdEnabled = m_xProtectCB->get_active();
715  m_xPasswdCB->set_sensitive(bPasswdEnabled);
716  m_xPasswdPB->set_sensitive(bPasswdEnabled);
717  }
718  bDontCheckPasswd = false;
719 }
720 
721 // in OkHdl the modified settings are being applied and reversed regions are deleted
723 {
724  // temp. Array because during changing of a region the position
725  // inside of the "Core-Arrays" can be shifted:
726  // - at linked regions, when they have more SubRegions or get
727  // new ones.
728  // StartUndo must certainly also happen not before the formats
729  // are copied (ClearRedo!)
730 
731  const SwSectionFormats& rDocFormats = rSh.GetDoc()->GetSections();
732  SwSectionFormats aOrigArray(rDocFormats);
733 
734  rSh.StartAllAction();
735  rSh.StartUndo();
736  rSh.ResetSelect( nullptr,false );
737 
738  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
739  if (m_xTree->get_iter_first(*xIter))
740  {
741  do
742  {
743  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
744  SwSectionFormat* pFormat = aOrigArray[ pRepr->GetArrPos() ];
745  if (!pRepr->GetSectionData().IsProtectFlag())
746  {
747  pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
748  }
749  size_t nNewPos = rDocFormats.GetPos(pFormat);
750  if ( SIZE_MAX != nNewPos )
751  {
752  std::unique_ptr<SfxItemSet> pSet(pFormat->GetAttrSet().Clone( false ));
753  if( pFormat->GetCol() != pRepr->GetCol() )
754  pSet->Put( pRepr->GetCol() );
755 
756  std::unique_ptr<SvxBrushItem> aBrush(pFormat->makeBackgroundBrushItem(false));
757  if( aBrush && pRepr->GetBackground() && *aBrush != *pRepr->GetBackground() )
758  pSet->Put( *pRepr->GetBackground() );
759 
760  if( pFormat->GetFootnoteAtTextEnd(false) != pRepr->GetFootnoteNtAtEnd() )
761  pSet->Put( pRepr->GetFootnoteNtAtEnd() );
762 
763  if( pFormat->GetEndAtTextEnd(false) != pRepr->GetEndNtAtEnd() )
764  pSet->Put( pRepr->GetEndNtAtEnd() );
765 
766  if( pFormat->GetBalancedColumns() != pRepr->GetBalance() )
767  pSet->Put( pRepr->GetBalance() );
768 
769  if( pFormat->GetFrameDir() != *pRepr->GetFrameDir() )
770  pSet->Put( *pRepr->GetFrameDir() );
771 
772  if( pFormat->GetLRSpace() != *pRepr->GetLRSpace())
773  pSet->Put( *pRepr->GetLRSpace());
774 
775  rSh.UpdateSection( nNewPos, pRepr->GetSectionData(),
776  pSet->Count() ? pSet.get() : nullptr );
777  }
778  } while (m_xTree->iter_next(*xIter));
779  }
780 
781  for (SectReprs_t::reverse_iterator it = m_SectReprs.rbegin(), aEnd = m_SectReprs.rend(); it != aEnd; ++it)
782  {
783  assert(it->first == it->second->GetArrPos());
784  SwSectionFormat* pFormat = aOrigArray[ it->second->GetArrPos() ];
785  const size_t nNewPos = rDocFormats.GetPos( pFormat );
786  if( SIZE_MAX != nNewPos )
787  rSh.DelSectionFormat( nNewPos );
788  }
789 
790  aOrigArray.clear();
791 
792  // response must be called ahead of EndAction's end,
793  // otherwise ScrollError can occur.
794  m_xDialog->response(RET_OK);
795 
796  rSh.EndUndo();
797  rSh.EndAllAction();
798 }
799 
800 // Toggle protect
801 IMPL_LINK(SwEditRegionDlg, ChangeProtectHdl, weld::ToggleButton&, rButton, void)
802 {
803  if (!CheckPasswd(&rButton))
804  return;
805  bool bCheck = TRISTATE_TRUE == rButton.get_state();
806  m_xTree->selected_foreach([this, bCheck](weld::TreeIter& rEntry){
807  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
808  pRepr->GetSectionData().SetProtectFlag(bCheck);
809  OUString aImage = BuildBitmap(bCheck, TRISTATE_TRUE == m_xHideCB->get_state());
810  m_xTree->set_image(rEntry, aImage);
811  return false;
812  });
813  m_xPasswdCB->set_sensitive(bCheck);
814  m_xPasswdPB->set_sensitive(bCheck);
815 }
816 
817 // Toggle hide
818 IMPL_LINK( SwEditRegionDlg, ChangeHideHdl, weld::ToggleButton&, rButton, void)
819 {
820  if (!CheckPasswd(&rButton))
821  return;
822  m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){
823  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
824  pRepr->GetSectionData().SetHidden(TRISTATE_TRUE == rButton.get_state());
825  OUString aImage = BuildBitmap(TRISTATE_TRUE == m_xProtectCB->get_state(),
826  TRISTATE_TRUE == rButton.get_state());
827  m_xTree->set_image(rEntry, aImage);
828  return false;
829  });
830  bool bHide = TRISTATE_TRUE == rButton.get_state();
831  m_xConditionED->set_sensitive(bHide);
832  m_xConditionFT->set_sensitive(bHide);
833 }
834 
835 // Toggle edit in readonly
836 IMPL_LINK(SwEditRegionDlg, ChangeEditInReadonlyHdl, weld::ToggleButton&, rButton, void)
837 {
838  if (!CheckPasswd(&rButton))
839  return;
840  m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){
841  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
843  TRISTATE_TRUE == rButton.get_state());
844  return false;
845  });
846 }
847 
848 // clear selected region
849 IMPL_LINK_NOARG(SwEditRegionDlg, ChangeDismissHdl, weld::Button&, void)
850 {
851  if(!CheckPasswd())
852  return;
853  // at first mark all selected
854  m_xTree->selected_foreach([this](weld::TreeIter& rEntry){
855  SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
856  pSectRepr->SetSelected();
857  return false;
858  });
859 
860  std::unique_ptr<weld::TreeIter> xEntry(m_xTree->make_iterator());
861  bool bEntry(m_xTree->get_selected(xEntry.get()));
862  // then delete
863  while (bEntry)
864  {
865  SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xEntry).toInt64());
866  std::unique_ptr<weld::TreeIter> xRemove;
867  bool bRestart = false;
868  if (pSectRepr->IsSelected())
869  {
870  m_SectReprs.insert(std::make_pair(pSectRepr->GetArrPos(),
871  std::unique_ptr<SectRepr>(pSectRepr)));
872  if (m_xTree->iter_has_child(*xEntry))
873  {
874  std::unique_ptr<weld::TreeIter> xChild(m_xTree->make_iterator(xEntry.get()));
875  (void)m_xTree->iter_children(*xChild);
876  std::unique_ptr<weld::TreeIter> xParent(m_xTree->make_iterator(xEntry.get()));
877  if (!m_xTree->iter_parent(*xParent))
878  xParent.reset();
879  bool bChild = true;
880  do
881  {
882  // because of the repositioning we have to start at the beginning again
883  bRestart = true;
884  std::unique_ptr<weld::TreeIter> xMove(m_xTree->make_iterator(xChild.get()));
885  bChild = m_xTree->iter_next_sibling(*xChild);
886  m_xTree->move_subtree(*xMove, xParent.get(), m_xTree->get_iter_index_in_parent(*xEntry));
887  } while (bChild);
888  }
889  xRemove = m_xTree->make_iterator(xEntry.get());
890  }
891  if (bRestart)
892  bEntry = m_xTree->get_iter_first(*xEntry);
893  else
894  bEntry = m_xTree->iter_next(*xEntry);
895  if (xRemove)
896  m_xTree->remove(*xRemove);
897  }
898 
899  if (m_xTree->get_selected(nullptr))
900  return;
901 
902  m_xConditionFT->set_sensitive(false);
903  m_xConditionED->set_sensitive(false);
904  m_xDismiss->set_sensitive(false);
905  m_xCurName->set_sensitive(false);
906  m_xProtectCB->set_sensitive(false);
907  m_xPasswdCB->set_sensitive(false);
908  m_xHideCB->set_sensitive(false);
909  // edit in readonly sections
910  m_xEditInReadonlyCB->set_sensitive(false);
911  m_xEditInReadonlyCB->set_state(TRISTATE_FALSE);
912  m_xProtectCB->set_state(TRISTATE_FALSE);
913  m_xPasswdCB->set_active(false);
914  m_xHideCB->set_state(TRISTATE_FALSE);
915  m_xFileCB->set_active(false);
916  // otherwise the focus would be on HelpButton
917  m_xOK->grab_focus();
918  UseFileHdl(*m_xFileCB);
919 }
920 
921 // link CheckBox to file?
922 IMPL_LINK(SwEditRegionDlg, UseFileHdl, weld::ToggleButton&, rButton, void)
923 {
924  if (!CheckPasswd(&rButton))
925  return;
926  bool bMulti = 1 < m_xTree->count_selected_rows();
927  bool bFile = rButton.get_active();
928  if (m_xTree->get_selected(nullptr))
929  {
930  m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
931  SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
932  bool bContent = pSectRepr->IsContent();
933  if( rButton.get_active() && bContent && rSh.HasSelection() )
934  {
935  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
936  VclMessageType::Question, VclButtonsType::YesNo,
937  SwResId(STR_QUERY_CONNECT)));
938  if (RET_NO == xQueryBox->run())
939  rButton.set_active( false );
940  }
941  if( bFile )
942  pSectRepr->SetContent(false);
943  else
944  {
945  pSectRepr->SetFile(OUString());
946  pSectRepr->SetSubRegion(std::u16string_view());
947  pSectRepr->GetSectionData().SetLinkFilePassword(OUString());
948  }
949  return false;
950  });
951  m_xDDECB->set_sensitive(bFile && !bMulti);
952  m_xDDEFrame->set_sensitive(bFile && !bMulti);
953  if( bFile )
954  {
955  m_xProtectCB->set_state(TRISTATE_TRUE);
956  ChangeProtectHdl(*m_xProtectCB);
957  m_xFileNameED->grab_focus();
958 
959  }
960  else
961  {
962  m_xDDECB->set_active(false);
963  m_xSubRegionED->set_entry_text(OUString());
964  }
965  DDEHdl(*m_xDDECB);
966  }
967  else
968  {
969  rButton.set_active(false);
970  rButton.set_sensitive(false);
971  m_xDDECB->set_active(false);
972  m_xDDECB->set_sensitive(false);
973  m_xDDEFrame->set_sensitive(false);
974  }
975 }
976 
977 // call dialog paste file
979 {
980  if(!CheckPasswd())
981  return;
982  m_pDocInserter.reset(new ::sfx2::DocumentInserter(m_xDialog.get(), "swriter"));
983  m_pDocInserter->StartExecuteModal( LINK( this, SwEditRegionDlg, DlgClosedHdl ) );
984 }
985 
987 {
988  if(!CheckPasswd())
989  return;
990  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
991  if (!pSectRepr)
992  return;
993 
994  SfxItemSet aSet(
995  rSh.GetView().GetPool(),
996  svl::Items<
1000  RES_COL, RES_COL,
1003  SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE>{});
1004 
1005  aSet.Put( pSectRepr->GetCol() );
1006  aSet.Put( *pSectRepr->GetBackground() );
1007  aSet.Put( pSectRepr->GetFootnoteNtAtEnd() );
1008  aSet.Put( pSectRepr->GetEndNtAtEnd() );
1009  aSet.Put( pSectRepr->GetBalance() );
1010  aSet.Put( *pSectRepr->GetFrameDir() );
1011  aSet.Put( *pSectRepr->GetLRSpace() );
1012 
1013  const SwSectionFormats& rDocFormats = rSh.GetDoc()->GetSections();
1014  SwSectionFormats aOrigArray(rDocFormats);
1015 
1016  SwSectionFormat* pFormat = aOrigArray[pSectRepr->GetArrPos()];
1017  tools::Long nWidth = rSh.GetSectionWidth(*pFormat);
1018  aOrigArray.clear();
1019  if (!nWidth)
1020  nWidth = USHRT_MAX;
1021 
1022  aSet.Put(SwFormatFrameSize(SwFrameSize::Variable, nWidth));
1023  aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
1024 
1025  SwSectionPropertyTabDialog aTabDlg(m_xDialog.get(), aSet, rSh);
1026  if (RET_OK != aTabDlg.run())
1027  return;
1028 
1029  const SfxItemSet* pOutSet = aTabDlg.GetOutputItemSet();
1030  if( !(pOutSet && pOutSet->Count()) )
1031  return;
1032 
1033  const SfxPoolItem *pColItem, *pBrushItem,
1034  *pFootnoteItem, *pEndItem, *pBalanceItem,
1035  *pFrameDirItem, *pLRSpaceItem;
1036  SfxItemState eColState = pOutSet->GetItemState(
1037  RES_COL, false, &pColItem );
1038  SfxItemState eBrushState = pOutSet->GetItemState(
1039  RES_BACKGROUND, false, &pBrushItem );
1040  SfxItemState eFootnoteState = pOutSet->GetItemState(
1041  RES_FTN_AT_TXTEND, false, &pFootnoteItem );
1042  SfxItemState eEndState = pOutSet->GetItemState(
1043  RES_END_AT_TXTEND, false, &pEndItem );
1044  SfxItemState eBalanceState = pOutSet->GetItemState(
1045  RES_COLUMNBALANCE, false, &pBalanceItem );
1046  SfxItemState eFrameDirState = pOutSet->GetItemState(
1047  RES_FRAMEDIR, false, &pFrameDirItem );
1048  SfxItemState eLRState = pOutSet->GetItemState(
1049  RES_LR_SPACE, false, &pLRSpaceItem);
1050 
1051  if( !(SfxItemState::SET == eColState ||
1052  SfxItemState::SET == eBrushState ||
1053  SfxItemState::SET == eFootnoteState ||
1054  SfxItemState::SET == eEndState ||
1055  SfxItemState::SET == eBalanceState||
1056  SfxItemState::SET == eFrameDirState||
1057  SfxItemState::SET == eLRState))
1058  return;
1059 
1060  m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
1061  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
1062  if( SfxItemState::SET == eColState )
1063  pRepr->GetCol() = *static_cast<const SwFormatCol*>(pColItem);
1064  if( SfxItemState::SET == eBrushState )
1065  pRepr->GetBackground().reset(static_cast<SvxBrushItem*>(pBrushItem->Clone()));
1066  if( SfxItemState::SET == eFootnoteState )
1067  pRepr->GetFootnoteNtAtEnd() = *static_cast<const SwFormatFootnoteAtTextEnd*>(pFootnoteItem);
1068  if( SfxItemState::SET == eEndState )
1069  pRepr->GetEndNtAtEnd() = *static_cast<const SwFormatEndAtTextEnd*>(pEndItem);
1070  if( SfxItemState::SET == eBalanceState )
1071  pRepr->GetBalance().SetValue(static_cast<const SwFormatNoBalancedColumns*>(pBalanceItem)->GetValue());
1072  if( SfxItemState::SET == eFrameDirState )
1073  pRepr->GetFrameDir()->SetValue(static_cast<const SvxFrameDirectionItem*>(pFrameDirItem)->GetValue());
1074  if( SfxItemState::SET == eLRState )
1075  pRepr->GetLRSpace().reset(static_cast<SvxLRSpaceItem*>(pLRSpaceItem->Clone()));
1076  return false;
1077  });
1078 }
1079 
1080 IMPL_LINK(SwEditRegionDlg, FileNameComboBoxHdl, weld::ComboBox&, rEdit, void)
1081 {
1082  int nStartPos, nEndPos;
1083  rEdit.get_entry_selection_bounds(nStartPos, nEndPos);
1084  if (!CheckPasswd())
1085  return;
1086  rEdit.select_entry_region(nStartPos, nEndPos);
1087  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1088  pSectRepr->SetSubRegion( rEdit.get_active_text() );
1089 }
1090 
1091 // Applying of the filename or the linked region
1092 IMPL_LINK(SwEditRegionDlg, FileNameEntryHdl, weld::Entry&, rEdit, void)
1093 {
1094  int nStartPos, nEndPos;
1095  rEdit.get_selection_bounds(nStartPos, nEndPos);
1096  if (!CheckPasswd())
1097  return;
1098  rEdit.select_region(nStartPos, nEndPos);
1099  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1100  m_xSubRegionED->clear();
1101  m_xSubRegionED->append_text(""); // put in a dummy entry, which is replaced when m_bSubRegionsFilled is set
1102  m_bSubRegionsFilled = false;
1103  if (m_xDDECB->get_active())
1104  {
1105  OUString sLink( SwSectionData::CollapseWhiteSpaces(rEdit.get_text()) );
1106  sal_Int32 nPos = 0;
1107  sLink = sLink.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1108  if (nPos>=0)
1109  {
1110  sLink = sLink.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1111  }
1112 
1113  pSectRepr->GetSectionData().SetLinkFileName( sLink );
1115  }
1116  else
1117  {
1118  OUString sTmp(rEdit.get_text());
1119  if(!sTmp.isEmpty())
1120  {
1121  SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
1122  INetURLObject aAbs;
1123  if( pMedium )
1124  aAbs = pMedium->GetURLObject();
1125  sTmp = URIHelper::SmartRel2Abs(
1126  aAbs, sTmp, URIHelper::GetMaybeFileHdl() );
1127  }
1128  pSectRepr->SetFile( sTmp );
1129  pSectRepr->GetSectionData().SetLinkFilePassword(OUString());
1130  }
1131 }
1132 
1134 {
1135  if (!CheckPasswd(&rButton))
1136  return;
1137  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1138  if (!pSectRepr)
1139  return;
1140 
1141  bool bFile = m_xFileCB->get_active();
1142  SwSectionData & rData( pSectRepr->GetSectionData() );
1143  bool bDDE = rButton.get_active();
1144  if(bDDE)
1145  {
1146  m_xFileNameFT->hide();
1147  m_xDDECommandFT->set_sensitive(true);
1148  m_xDDECommandFT->show();
1149  m_xSubRegionFT->hide();
1150  m_xSubRegionED->hide();
1151  if (SectionType::FileLink == rData.GetType())
1152  {
1153  pSectRepr->SetFile(OUString());
1154  m_xFileNameED->set_text(OUString());
1155  rData.SetLinkFilePassword(OUString());
1156  }
1157  rData.SetType(SectionType::DdeLink);
1158  }
1159  else
1160  {
1161  m_xDDECommandFT->hide();
1162  m_xFileNameFT->set_sensitive(bFile);
1163  m_xFileNameFT->show();
1164  m_xSubRegionED->show();
1165  m_xSubRegionFT->show();
1166  m_xSubRegionED->set_sensitive(bFile);
1167  m_xSubRegionFT->set_sensitive(bFile);
1168  m_xSubRegionED->set_sensitive(bFile);
1169  if (SectionType::DdeLink == rData.GetType())
1170  {
1171  rData.SetType(SectionType::FileLink);
1172  pSectRepr->SetFile(OUString());
1173  rData.SetLinkFilePassword(OUString());
1174  m_xFileNameED->set_text(OUString());
1175  }
1176  }
1177  m_xFilePB->set_sensitive(bFile && !bDDE);
1178 }
1179 
1181 {
1182  if (!CheckPasswd())
1183  {
1184  if (!bChange)
1185  m_xPasswdCB->set_active(!m_xPasswdCB->get_active());
1186  return;
1187  }
1188 
1189  bool bSet = bChange ? bChange : m_xPasswdCB->get_active();
1190 
1191  m_xTree->selected_foreach([this, bChange, bSet](weld::TreeIter& rEntry){
1192  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
1193  if(bSet)
1194  {
1195  if(!pRepr->GetTempPasswd().hasElements() || bChange)
1196  {
1197  SfxPasswordDialog aPasswdDlg(m_xDialog.get());
1198  aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
1199  if (RET_OK == aPasswdDlg.run())
1200  {
1201  const OUString sNewPasswd(aPasswdDlg.GetPassword());
1202  if (aPasswdDlg.GetConfirm() == sNewPasswd)
1203  {
1204  SvPasswordHelper::GetHashPassword( pRepr->GetTempPasswd(), sNewPasswd );
1205  }
1206  else
1207  {
1208  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
1209  VclMessageType::Info, VclButtonsType::Ok,
1210  SwResId(STR_WRONG_PASSWD_REPEAT)));
1211  xInfoBox->run();
1212  ChangePasswd(bChange);
1213  return true;
1214  }
1215  }
1216  else
1217  {
1218  if(!bChange)
1219  m_xPasswdCB->set_active(false);
1220  return true;
1221  }
1222  }
1223  pRepr->GetSectionData().SetPassword(pRepr->GetTempPasswd());
1224  }
1225  else
1226  {
1227  pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
1228  }
1229  return false;
1230  });
1231 }
1232 
1234 {
1235  ChangePasswd(false);
1236 }
1237 
1239 {
1240  ChangePasswd(true);
1241 }
1242 
1243 // the current region name is being added to the TreeListBox immediately during
1244 // editing, with empty string no Ok()
1246 {
1247  if(!CheckPasswd())
1248  return;
1249  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
1250  if (m_xTree->get_selected(xIter.get()))
1251  {
1252  const OUString aName = m_xCurName->get_text();
1253  m_xTree->set_text(*xIter, aName);
1254  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
1255  pRepr->GetSectionData().SetSectionName(aName);
1256 
1257  m_xOK->set_sensitive(!aName.isEmpty());
1258  }
1259 }
1260 
1261 IMPL_LINK( SwEditRegionDlg, ConditionEditHdl, weld::Entry&, rEdit, void )
1262 {
1263  int nStartPos, nEndPos;
1264  rEdit.get_selection_bounds(nStartPos, nEndPos);
1265  if(!CheckPasswd())
1266  return;
1267  rEdit.select_region(nStartPos, nEndPos);
1268 
1269  m_xTree->selected_foreach([this, &rEdit](weld::TreeIter& rEntry){
1270  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
1272  return false;
1273  });
1274 }
1275 
1276 IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void )
1277 {
1278  OUString sFileName, sFilterName, sPassword;
1279  if ( _pFileDlg->GetError() == ERRCODE_NONE )
1280  {
1281  std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium("sglobal"));
1282  if ( pMedium )
1283  {
1284  sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE );
1285  sFilterName = pMedium->GetFilter()->GetFilterName();
1286  const SfxPoolItem* pItem;
1287  if ( SfxItemState::SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) )
1288  sPassword = static_cast<const SfxStringItem*>(pItem )->GetValue();
1289  ::lcl_ReadSections(*pMedium, *m_xSubRegionED);
1290  }
1291  }
1292 
1293  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1294  if (pSectRepr)
1295  {
1296  pSectRepr->SetFile( sFileName );
1297  pSectRepr->SetFilter( sFilterName );
1298  pSectRepr->GetSectionData().SetLinkFilePassword(sPassword);
1299  m_xFileNameED->set_text(pSectRepr->GetFile());
1300  }
1301 }
1302 
1304 {
1305  if (m_bSubRegionsFilled)
1306  return;
1307 
1308  //if necessary fill the names bookmarks/sections/tables now
1309 
1310  OUString sFileName = m_xFileNameED->get_text();
1311  if(!sFileName.isEmpty())
1312  {
1313  SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
1314  INetURLObject aAbs;
1315  if( pMedium )
1316  aAbs = pMedium->GetURLObject();
1317  sFileName = URIHelper::SmartRel2Abs(
1318  aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
1319 
1320  //load file and set the shell
1321  SfxMedium aMedium( sFileName, StreamMode::STD_READ );
1323  ::lcl_ReadSections(aMedium, *m_xSubRegionED);
1324  }
1325  else
1326  lcl_FillSubRegionList(rSh, *m_xSubRegionED, nullptr);
1327  m_bSubRegionsFilled = true;
1328 }
1329 
1330 // helper function - read section names from medium
1331 static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox )
1332 {
1333  rBox.clear();
1334  uno::Reference < embed::XStorage > xStg;
1335  if( !(rMedium.IsStorage() && (xStg = rMedium.GetStorage()).is()) )
1336  return;
1337 
1338  std::vector<OUString> aArr;
1340  if ( nFormat == SotClipboardFormatId::STARWRITER_60 || nFormat == SotClipboardFormatId::STARWRITERGLOB_60 ||
1341  nFormat == SotClipboardFormatId::STARWRITER_8 || nFormat == SotClipboardFormatId::STARWRITERGLOB_8)
1342  SwGetReaderXML()->GetSectionList( rMedium, aArr );
1343 
1344  for (auto const& it : aArr)
1345  {
1346  rBox.append_text(it);
1347  }
1348 }
1349 
1351  weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
1352  : SfxTabDialogController(pParent, "modules/swriter/ui/insertsectiondialog.ui",
1353  "InsertSectionDialog",&rSet)
1354  , rWrtSh(rSh)
1355 {
1357  AddTabPage("section", SwInsertSectionTabPage::Create, nullptr);
1358  AddTabPage("columns", SwColumnPage::Create, nullptr);
1359  AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
1361  AddTabPage("indents", SwSectionIndentTabPage::Create, nullptr);
1362 
1363  SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
1364  tools::Long nHtmlMode = rHtmlOpt.GetExportMode();
1365 
1366  bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ;
1367  if(bWeb)
1368  {
1369  RemoveTabPage("notes");
1370  RemoveTabPage("indents");
1371  if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
1372  RemoveTabPage("columns");
1373  }
1374  SetCurPageId("section");
1375 }
1376 
1378 {
1379 }
1380 
1381 void SwInsertSectionTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
1382 {
1383  if (rId == "section")
1384  static_cast<SwInsertSectionTabPage&>(rPage).SetWrtShell(rWrtSh);
1385  else if (rId == "background")
1386  {
1387  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1388  aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
1389  rPage.PageCreated(aSet);
1390  }
1391  else if (rId == "columns")
1392  {
1394  static_cast<SwColumnPage&>(rPage).SetPageWidth(rSize.GetWidth());
1395  static_cast<SwColumnPage&>(rPage).ShowBalance(true);
1396  static_cast<SwColumnPage&>(rPage).SetInSection(true);
1397  }
1398  else if (rId == "indents")
1399  static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh);
1400 }
1401 
1403 {
1404  m_pSectionData.reset( new SwSectionData(rSect) );
1405 }
1406 
1408 {
1409  short nRet = SfxTabDialogController::Ok();
1410  OSL_ENSURE(m_pSectionData, "SwInsertSectionTabDialog: no SectionData?");
1411  const SfxItemSet* pOutputItemSet = GetOutputItemSet();
1412  rWrtSh.InsertSection(*m_pSectionData, pOutputItemSet);
1413  SfxViewFrame* pViewFrame = rWrtSh.GetView().GetViewFrame();
1414  uno::Reference< frame::XDispatchRecorder > xRecorder =
1415  pViewFrame->GetBindings().GetRecorder();
1416  if ( xRecorder.is() )
1417  {
1418  SfxRequest aRequest( pViewFrame, FN_INSERT_REGION);
1419  const SfxPoolItem* pCol;
1420  if(SfxItemState::SET == pOutputItemSet->GetItemState(RES_COL, false, &pCol))
1421  {
1422  aRequest.AppendItem(SfxUInt16Item(SID_ATTR_COLUMNS,
1423  static_cast<const SwFormatCol*>(pCol)->GetColumns().size()));
1424  }
1426  m_pSectionData->GetSectionName()));
1428  m_pSectionData->GetCondition()));
1430  m_pSectionData->IsHidden()));
1432  m_pSectionData->IsProtectFlag()));
1433  // edit in readonly sections
1435  m_pSectionData->IsEditInReadonlyFlag()));
1436 
1437  const OUString sLinkFileName( m_pSectionData->GetLinkFileName() );
1438  sal_Int32 n = 0;
1439  aRequest.AppendItem(SfxStringItem( FN_PARAM_1, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1440  aRequest.AppendItem(SfxStringItem( FN_PARAM_2, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1441  aRequest.AppendItem(SfxStringItem( FN_PARAM_3, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1442  aRequest.Done();
1443  }
1444  return nRet;
1445 }
1446 
1448  : SfxTabPage(pPage, pController, "modules/swriter/ui/sectionpage.ui", "SectionPage", &rAttrSet)
1449  , m_pWrtSh(nullptr)
1450  , m_xCurName(m_xBuilder->weld_entry_tree_view("sectionnames", "sectionnames-entry",
1451  "sectionnames-list"))
1452  , m_xFileCB(m_xBuilder->weld_check_button("link"))
1453  , m_xDDECB(m_xBuilder->weld_check_button("dde"))
1454  , m_xDDECommandFT(m_xBuilder->weld_label("ddelabel"))
1455  , m_xFileNameFT(m_xBuilder->weld_label("filelabel"))
1456  , m_xFileNameED(m_xBuilder->weld_entry("filename"))
1457  , m_xFilePB(m_xBuilder->weld_button("selectfile"))
1458  , m_xSubRegionFT(m_xBuilder->weld_label("sectionlabel"))
1459  , m_xSubRegionED(m_xBuilder->weld_combo_box("sectionname"))
1460  , m_xProtectCB(m_xBuilder->weld_check_button("protect"))
1461  , m_xPasswdCB(m_xBuilder->weld_check_button("withpassword"))
1462  , m_xPasswdPB(m_xBuilder->weld_button("selectpassword"))
1463  , m_xHideCB(m_xBuilder->weld_check_button("hide"))
1464  , m_xConditionFT(m_xBuilder->weld_label("condlabel"))
1465  , m_xConditionED(new ConditionEdit(m_xBuilder->weld_entry("withcond")))
1466  // edit in readonly sections
1467  , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editable"))
1468 {
1469  m_xCurName->make_sorted();
1470  m_xCurName->set_height_request_by_rows(12);
1471  m_xSubRegionED->make_sorted();
1472 
1473  m_xProtectCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeProtectHdl));
1474  m_xPasswdCB->connect_toggled( LINK( this, SwInsertSectionTabPage, TogglePasswdHdl));
1475  m_xPasswdPB->connect_clicked( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
1476  m_xHideCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeHideHdl));
1477  m_xFileCB->connect_toggled( LINK( this, SwInsertSectionTabPage, UseFileHdl ));
1478  m_xFilePB->connect_clicked( LINK( this, SwInsertSectionTabPage, FileSearchHdl ));
1479  m_xCurName->connect_changed( LINK( this, SwInsertSectionTabPage, NameEditHdl));
1480  m_xDDECB->connect_toggled( LINK( this, SwInsertSectionTabPage, DDEHdl ));
1481  ChangeProtectHdl(*m_xProtectCB);
1482  m_xSubRegionED->set_entry_completion(true, true);
1483 }
1484 
1486 {
1487 }
1488 
1490 {
1491  m_pWrtSh = &rSh;
1492 
1493  bool bWeb = dynamic_cast<SwWebDocShell*>( m_pWrtSh->GetView().GetDocShell() )!= nullptr;
1494  if(bWeb)
1495  {
1496  m_xHideCB->hide();
1497  m_xConditionED->hide();
1498  m_xConditionFT->hide();
1499  m_xDDECB->hide();
1500  m_xDDECommandFT->hide();
1501  }
1502 
1504 
1505  SwSectionData *const pSectionData =
1507  ->GetSectionData();
1508  if (pSectionData) // something set?
1509  {
1510  const OUString sSectionName(pSectionData->GetSectionName());
1511  m_xCurName->set_entry_text(rSh.GetUniqueSectionName(&sSectionName));
1512  m_xProtectCB->set_active( pSectionData->IsProtectFlag() );
1513  ChangeProtectHdl(*m_xProtectCB);
1514  m_sFileName = pSectionData->GetLinkFileName();
1515  m_sFilePasswd = pSectionData->GetLinkFilePassword();
1516  m_xFileCB->set_active( !m_sFileName.isEmpty() );
1517  m_xFileNameED->set_text( m_sFileName );
1518  UseFileHdl(*m_xFileCB);
1519  }
1520  else
1521  {
1522  m_xCurName->set_entry_text(rSh.GetUniqueSectionName());
1523  }
1524 }
1525 
1527 {
1528  SwSectionData aSection(SectionType::Content, m_xCurName->get_active_text());
1529  aSection.SetCondition(m_xConditionED->get_text());
1530  bool bProtected = m_xProtectCB->get_active();
1531  aSection.SetProtectFlag(bProtected);
1532  aSection.SetHidden(m_xHideCB->get_active());
1533  // edit in readonly sections
1534  aSection.SetEditInReadonlyFlag(m_xEditInReadonlyCB->get_active());
1535 
1536  if(bProtected)
1537  {
1538  aSection.SetPassword(m_aNewPasswd);
1539  }
1540  const OUString sFileName = m_xFileNameED->get_text();
1541  const OUString sSubRegion = m_xSubRegionED->get_active_text();
1542  bool bDDe = m_xDDECB->get_active();
1543  if (m_xFileCB->get_active() && (!sFileName.isEmpty() || !sSubRegion.isEmpty() || bDDe))
1544  {
1545  OUString aLinkFile;
1546  if( bDDe )
1547  {
1548  aLinkFile = SwSectionData::CollapseWhiteSpaces(sFileName);
1549  sal_Int32 nPos = 0;
1550  aLinkFile = aLinkFile.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1551  if (nPos>=0)
1552  {
1553  aLinkFile = aLinkFile.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1554  }
1555  }
1556  else
1557  {
1558  if(!sFileName.isEmpty())
1559  {
1560  SfxMedium* pMedium = m_pWrtSh->GetView().GetDocShell()->GetMedium();
1561  INetURLObject aAbs;
1562  if( pMedium )
1563  aAbs = pMedium->GetURLObject();
1564  aLinkFile = URIHelper::SmartRel2Abs(
1565  aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
1566  aSection.SetLinkFilePassword( m_sFilePasswd );
1567  }
1568 
1569  aLinkFile += OUStringChar(sfx2::cTokenSeparator) + m_sFilterName
1570  + OUStringChar(sfx2::cTokenSeparator) + sSubRegion;
1571  }
1572 
1573  aSection.SetLinkFileName(aLinkFile);
1574  if (!aLinkFile.isEmpty())
1575  {
1576  aSection.SetType( m_xDDECB->get_active() ?
1579  }
1580  }
1581  static_cast<SwInsertSectionTabDialog*>(GetDialogController())->SetSectionData(aSection);
1582  return true;
1583 }
1584 
1586 {
1587 }
1588 
1589 std::unique_ptr<SfxTabPage> SwInsertSectionTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
1590  const SfxItemSet* rAttrSet)
1591 {
1592  return std::make_unique<SwInsertSectionTabPage>(pPage, pController, *rAttrSet);
1593 }
1594 
1596 {
1597  bool bHide = rBox.get_active();
1598  m_xConditionED->set_sensitive(bHide);
1599  m_xConditionFT->set_sensitive(bHide);
1600 }
1601 
1602 IMPL_LINK(SwInsertSectionTabPage, ChangeProtectHdl, weld::ToggleButton&, rBox, void)
1603 {
1604  bool bCheck = rBox.get_active();
1605  m_xPasswdCB->set_sensitive(bCheck);
1606  m_xPasswdPB->set_sensitive(bCheck);
1607 }
1608 
1610 {
1611  bool bSet = bChange ? bChange : m_xPasswdCB->get_active();
1612  if (bSet)
1613  {
1614  if(!m_aNewPasswd.hasElements() || bChange)
1615  {
1616  SfxPasswordDialog aPasswdDlg(GetFrameWeld());
1617  aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
1618  if (RET_OK == aPasswdDlg.run())
1619  {
1620  const OUString sNewPasswd(aPasswdDlg.GetPassword());
1621  if (aPasswdDlg.GetConfirm() == sNewPasswd)
1622  {
1624  }
1625  else
1626  {
1627  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
1628  VclMessageType::Info, VclButtonsType::Ok,
1629  SwResId(STR_WRONG_PASSWD_REPEAT)));
1630  xInfoBox->run();
1631  }
1632  }
1633  else if(!bChange)
1634  m_xPasswdCB->set_active(false);
1635  }
1636  }
1637  else
1638  m_aNewPasswd.realloc(0);
1639 }
1640 
1642 {
1643  ChangePasswd(false);
1644 }
1645 
1647 {
1648  ChangePasswd(true);
1649 }
1650 
1651 
1653 {
1654  const OUString aName = m_xCurName->get_active_text();
1655  GetDialogController()->GetOKButton().set_sensitive(!aName.isEmpty() &&
1656  m_xCurName->find_text(aName) == -1);
1657 }
1658 
1660 {
1661  if (rButton.get_active())
1662  {
1663  if (m_pWrtSh->HasSelection())
1664  {
1665  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
1666  VclMessageType::Question, VclButtonsType::YesNo,
1667  SwResId(STR_QUERY_CONNECT)));
1668  if (RET_NO == xQueryBox->run())
1669  rButton.set_active(false);
1670  }
1671  }
1672 
1673  bool bFile = rButton.get_active();
1674  m_xFileNameFT->set_sensitive(bFile);
1675  m_xFileNameED->set_sensitive(bFile);
1676  m_xFilePB->set_sensitive(bFile);
1677  m_xSubRegionFT->set_sensitive(bFile);
1678  m_xSubRegionED->set_sensitive(bFile);
1679  m_xDDECommandFT->set_sensitive(bFile);
1680  m_xDDECB->set_sensitive(bFile);
1681  if (bFile)
1682  {
1683  m_xFileNameED->grab_focus();
1684  m_xProtectCB->set_active(true);
1685  ChangeProtectHdl(*m_xProtectCB);
1686  }
1687  else
1688  {
1689  m_xDDECB->set_active(false);
1690  DDEHdl(*m_xDDECB);
1691  }
1692 }
1693 
1695 {
1696  m_pDocInserter.reset(new ::sfx2::DocumentInserter(GetFrameWeld(), "swriter"));
1697  m_pDocInserter->StartExecuteModal( LINK( this, SwInsertSectionTabPage, DlgClosedHdl ) );
1698 }
1699 
1701 {
1702  bool bDDE = rButton.get_active();
1703  bool bFile = m_xFileCB->get_active();
1704  m_xFilePB->set_sensitive(!bDDE && bFile);
1705  if (bDDE)
1706  {
1707  m_xFileNameFT->hide();
1708  m_xDDECommandFT->set_sensitive(bDDE);
1709  m_xDDECommandFT->show();
1710  m_xSubRegionFT->hide();
1711  m_xSubRegionED->hide();
1712  m_xFileNameED->set_accessible_name(m_xDDECommandFT->get_label());
1713  }
1714  else
1715  {
1716  m_xDDECommandFT->hide();
1717  m_xFileNameFT->set_sensitive(bFile);
1718  m_xFileNameFT->show();
1719  m_xSubRegionFT->show();
1720  m_xSubRegionED->show();
1721  m_xSubRegionED->set_sensitive(bFile);
1722  m_xFileNameED->set_accessible_name(m_xFileNameFT->get_label());
1723  }
1724 }
1725 
1726 IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void )
1727 {
1728  if ( _pFileDlg->GetError() == ERRCODE_NONE )
1729  {
1730  std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium("sglobal"));
1731  if ( pMedium )
1732  {
1733  m_sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE );
1734  m_sFilterName = pMedium->GetFilter()->GetFilterName();
1735  const SfxPoolItem* pItem;
1736  if ( SfxItemState::SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) )
1737  m_sFilePasswd = static_cast<const SfxStringItem*>(pItem)->GetValue();
1738  m_xFileNameED->set_text( INetURLObject::decode(
1740  ::lcl_ReadSections(*pMedium, *m_xSubRegionED);
1741  }
1742  }
1743  else
1744  {
1745  m_sFilterName.clear();
1746  m_sFilePasswd.clear();
1747  }
1748 }
1749 
1751  : SfxTabPage(pPage, pController, "modules/swriter/ui/footnotesendnotestabpage.ui", "FootnotesEndnotesTabPage", &rAttrSet)
1752  , m_xFootnoteNtAtTextEndCB(m_xBuilder->weld_check_button("ftnntattextend"))
1753  , m_xFootnoteNtNumCB(m_xBuilder->weld_check_button("ftnntnum"))
1754  , m_xFootnoteOffsetLbl(m_xBuilder->weld_label("ftnoffset_label"))
1755  , m_xFootnoteOffsetField(m_xBuilder->weld_spin_button("ftnoffset"))
1756  , m_xFootnoteNtNumFormatCB(m_xBuilder->weld_check_button("ftnntnumfmt"))
1757  , m_xFootnotePrefixFT(m_xBuilder->weld_label("ftnprefix_label"))
1758  , m_xFootnotePrefixED(m_xBuilder->weld_entry("ftnprefix"))
1759  , m_xFootnoteNumViewBox(new SwNumberingTypeListBox(m_xBuilder->weld_combo_box("ftnnumviewbox")))
1760  , m_xFootnoteSuffixFT(m_xBuilder->weld_label("ftnsuffix_label"))
1761  , m_xFootnoteSuffixED(m_xBuilder->weld_entry("ftnsuffix"))
1762  , m_xEndNtAtTextEndCB(m_xBuilder->weld_check_button("endntattextend"))
1763  , m_xEndNtNumCB(m_xBuilder->weld_check_button("endntnum"))
1764  , m_xEndOffsetLbl(m_xBuilder->weld_label("endoffset_label"))
1765  , m_xEndOffsetField(m_xBuilder->weld_spin_button("endoffset"))
1766  , m_xEndNtNumFormatCB(m_xBuilder->weld_check_button("endntnumfmt"))
1767  , m_xEndPrefixFT(m_xBuilder->weld_label("endprefix_label"))
1768  , m_xEndPrefixED(m_xBuilder->weld_entry("endprefix"))
1769  , m_xEndNumViewBox(new SwNumberingTypeListBox(m_xBuilder->weld_combo_box("endnumviewbox")))
1770  , m_xEndSuffixFT(m_xBuilder->weld_label("endsuffix_label"))
1771  , m_xEndSuffixED(m_xBuilder->weld_entry("endsuffix"))
1772 {
1775 
1777  m_xFootnoteNtAtTextEndCB->connect_toggled( aLk );
1778  m_xFootnoteNtNumCB->connect_toggled( aLk );
1779  m_xEndNtAtTextEndCB->connect_toggled( aLk );
1780  m_xEndNtNumCB->connect_toggled( aLk );
1781  m_xFootnoteNtNumFormatCB->connect_toggled( aLk );
1782  m_xEndNtNumFormatCB->connect_toggled( aLk );
1783 }
1784 
1786 {
1787 }
1788 
1790 {
1791  SwFormatFootnoteAtTextEnd aFootnote( m_xFootnoteNtAtTextEndCB->get_active()
1792  ? ( m_xFootnoteNtNumCB->get_active()
1793  ? ( m_xFootnoteNtNumFormatCB->get_active()
1796  : FTNEND_ATTXTEND )
1797  : FTNEND_ATPGORDOCEND );
1798 
1799  switch( aFootnote.GetValue() )
1800  {
1802  aFootnote.SetNumType( m_xFootnoteNumViewBox->GetSelectedNumberingType() );
1803  aFootnote.SetPrefix( m_xFootnotePrefixED->get_text().replaceAll("\\t", "\t") ); // fdo#65666
1804  aFootnote.SetSuffix( m_xFootnoteSuffixED->get_text().replaceAll("\\t", "\t") );
1805  [[fallthrough]];
1806 
1808  aFootnote.SetOffset( static_cast< sal_uInt16 >( m_xFootnoteOffsetField->get_value()-1 ) );
1809  break;
1810  default: break;
1811  }
1812 
1813  SwFormatEndAtTextEnd aEnd( m_xEndNtAtTextEndCB->get_active()
1814  ? ( m_xEndNtNumCB->get_active()
1815  ? ( m_xEndNtNumFormatCB->get_active()
1818  : FTNEND_ATTXTEND )
1819  : FTNEND_ATPGORDOCEND );
1820 
1821  switch( aEnd.GetValue() )
1822  {
1824  aEnd.SetNumType( m_xEndNumViewBox->GetSelectedNumberingType() );
1825  aEnd.SetPrefix( m_xEndPrefixED->get_text().replaceAll("\\t", "\t") );
1826  aEnd.SetSuffix( m_xEndSuffixED->get_text().replaceAll("\\t", "\t") );
1827  [[fallthrough]];
1828 
1830  aEnd.SetOffset( static_cast< sal_uInt16 >( m_xEndOffsetField->get_value()-1 ) );
1831  break;
1832  default: break;
1833  }
1834 
1835  rSet->Put( aFootnote );
1836  rSet->Put( aEnd );
1837 
1838  return true;
1839 }
1840 
1842  const SwFormatFootnoteEndAtTextEnd& rAttr )
1843 {
1844  weld::CheckButton *pNtAtTextEndCB, *pNtNumCB, *pNtNumFormatCB;
1845  weld::Label *pPrefixFT, *pSuffixFT;
1846  weld::Entry *pPrefixED, *pSuffixED;
1847  SwNumberingTypeListBox *pNumViewBox;
1848  weld::Label *pOffsetText;
1849  weld::SpinButton *pOffsetField;
1850 
1851  if( bFootnote )
1852  {
1853  pNtAtTextEndCB = m_xFootnoteNtAtTextEndCB.get();
1854  pNtNumCB = m_xFootnoteNtNumCB.get();
1855  pNtNumFormatCB = m_xFootnoteNtNumFormatCB.get();
1856  pPrefixFT = m_xFootnotePrefixFT.get();
1857  pPrefixED = m_xFootnotePrefixED.get();
1858  pSuffixFT = m_xFootnoteSuffixFT.get();
1859  pSuffixED = m_xFootnoteSuffixED.get();
1860  pNumViewBox = m_xFootnoteNumViewBox.get();
1861  pOffsetText = m_xFootnoteOffsetLbl.get();
1862  pOffsetField = m_xFootnoteOffsetField.get();
1863  }
1864  else
1865  {
1866  pNtAtTextEndCB = m_xEndNtAtTextEndCB.get();
1867  pNtNumCB = m_xEndNtNumCB.get();
1868  pNtNumFormatCB = m_xEndNtNumFormatCB.get();
1869  pPrefixFT = m_xEndPrefixFT.get();
1870  pPrefixED = m_xEndPrefixED.get();
1871  pSuffixFT = m_xEndSuffixFT.get();
1872  pSuffixED = m_xEndSuffixED.get();
1873  pNumViewBox = m_xEndNumViewBox.get();
1874  pOffsetText = m_xEndOffsetLbl.get();
1875  pOffsetField = m_xEndOffsetField.get();
1876  }
1877 
1878  const sal_uInt16 eState = rAttr.GetValue();
1879  switch( eState )
1880  {
1882  pNtNumFormatCB->set_state( TRISTATE_TRUE );
1883  [[fallthrough]];
1884 
1886  pNtNumCB->set_state( TRISTATE_TRUE );
1887  [[fallthrough]];
1888 
1889  case FTNEND_ATTXTEND:
1890  pNtAtTextEndCB->set_state( TRISTATE_TRUE );
1891  // no break;
1892  }
1893 
1894  pNumViewBox->SelectNumberingType( rAttr.GetNumType() );
1895  pOffsetField->set_value( rAttr.GetOffset() + 1 );
1896  pPrefixED->set_text( rAttr.GetPrefix().replaceAll("\t", "\\t") );
1897  pSuffixED->set_text( rAttr.GetSuffix().replaceAll("\t", "\\t") );
1898 
1899  switch( eState )
1900  {
1901  case FTNEND_ATPGORDOCEND:
1902  pNtNumCB->set_sensitive( false );
1903  [[fallthrough]];
1904 
1905  case FTNEND_ATTXTEND:
1906  pNtNumFormatCB->set_sensitive( false );
1907  pOffsetField->set_sensitive( false );
1908  pOffsetText->set_sensitive( false );
1909  [[fallthrough]];
1910 
1912  pNumViewBox->set_sensitive( false );
1913  pPrefixFT->set_sensitive( false );
1914  pPrefixED->set_sensitive( false );
1915  pSuffixFT->set_sensitive( false );
1916  pSuffixED->set_sensitive( false );
1917  // no break;
1918  }
1919 }
1920 
1922 {
1923  ResetState( true, rSet->Get( RES_FTN_AT_TXTEND, false ));
1924  ResetState( false, rSet->Get( RES_END_AT_TXTEND, false ));
1925 }
1926 
1927 std::unique_ptr<SfxTabPage> SwSectionFootnoteEndTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
1928  const SfxItemSet* rAttrSet)
1929 {
1930  return std::make_unique<SwSectionFootnoteEndTabPage>(pPage, pController, *rAttrSet);
1931 }
1932 
1934 {
1935  bool bFoot = m_xFootnoteNtAtTextEndCB.get() == &rBox || m_xFootnoteNtNumCB.get() == &rBox ||
1936  m_xFootnoteNtNumFormatCB.get() == &rBox ;
1937 
1938  weld::CheckButton *pNumBox, *pNumFormatBox, *pEndBox;
1939  SwNumberingTypeListBox* pNumViewBox;
1940  weld::Label *pOffsetText;
1941  weld::SpinButton *pOffsetField;
1942  weld::Label *pPrefixFT, *pSuffixFT;
1943  weld::Entry *pPrefixED, *pSuffixED;
1944 
1945  if( bFoot )
1946  {
1947  pEndBox = m_xFootnoteNtAtTextEndCB.get();
1948  pNumBox = m_xFootnoteNtNumCB.get();
1949  pNumFormatBox = m_xFootnoteNtNumFormatCB.get();
1950  pNumViewBox = m_xFootnoteNumViewBox.get();
1951  pOffsetText = m_xFootnoteOffsetLbl.get();
1952  pOffsetField = m_xFootnoteOffsetField.get();
1953  pPrefixFT = m_xFootnotePrefixFT.get();
1954  pSuffixFT = m_xFootnoteSuffixFT.get();
1955  pPrefixED = m_xFootnotePrefixED.get();
1956  pSuffixED = m_xFootnoteSuffixED.get();
1957  }
1958  else
1959  {
1960  pEndBox = m_xEndNtAtTextEndCB.get();
1961  pNumBox = m_xEndNtNumCB.get();
1962  pNumFormatBox = m_xEndNtNumFormatCB.get();
1963  pNumViewBox = m_xEndNumViewBox.get();
1964  pOffsetText = m_xEndOffsetLbl.get();
1965  pOffsetField = m_xEndOffsetField.get();
1966  pPrefixFT = m_xEndPrefixFT.get();
1967  pSuffixFT = m_xEndSuffixFT.get();
1968  pPrefixED = m_xEndPrefixED.get();
1969  pSuffixED = m_xEndSuffixED.get();
1970  }
1971 
1972  bool bEnableAtEnd = TRISTATE_TRUE == pEndBox->get_state();
1973  bool bEnableNum = bEnableAtEnd && TRISTATE_TRUE == pNumBox->get_state();
1974  bool bEnableNumFormat = bEnableNum && TRISTATE_TRUE == pNumFormatBox->get_state();
1975 
1976  pNumBox->set_sensitive( bEnableAtEnd );
1977  pOffsetText->set_sensitive( bEnableNum );
1978  pOffsetField->set_sensitive( bEnableNum );
1979  pNumFormatBox->set_sensitive( bEnableNum );
1980  pNumViewBox->set_sensitive( bEnableNumFormat );
1981  pPrefixED->set_sensitive( bEnableNumFormat );
1982  pSuffixED->set_sensitive( bEnableNumFormat );
1983  pPrefixFT->set_sensitive( bEnableNumFormat );
1984  pSuffixFT->set_sensitive( bEnableNumFormat );
1985 }
1986 
1988  weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
1989  : SfxTabDialogController(pParent, "modules/swriter/ui/formatsectiondialog.ui",
1990  "FormatSectionDialog", &rSet)
1991  , rWrtSh(rSh)
1992 {
1994  AddTabPage("columns", SwColumnPage::Create, nullptr);
1995  AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
1997  AddTabPage("indents", SwSectionIndentTabPage::Create, nullptr);
1998 
1999  SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
2000  tools::Long nHtmlMode = rHtmlOpt.GetExportMode();
2001  bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ;
2002  if(bWeb)
2003  {
2004  RemoveTabPage("notes");
2005  RemoveTabPage("indents");
2006  if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
2007  RemoveTabPage("columns");
2008  }
2009 }
2010 
2012 {
2013 }
2014 
2015 void SwSectionPropertyTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
2016 {
2017  if (rId == "background")
2018  {
2019  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
2020  aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
2021  rPage.PageCreated(aSet);
2022  }
2023  else if (rId == "columns")
2024  {
2025  static_cast<SwColumnPage&>(rPage).ShowBalance(true);
2026  static_cast<SwColumnPage&>(rPage).SetInSection(true);
2027  }
2028  else if (rId == "indents")
2029  static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh);
2030 }
2031 
2033  : SfxTabPage(pPage, pController, "modules/swriter/ui/indentpage.ui", "IndentPage", &rAttrSet)
2034  , m_xBeforeMF(m_xBuilder->weld_metric_spin_button("before", FieldUnit::CM))
2035  , m_xAfterMF(m_xBuilder->weld_metric_spin_button("after", FieldUnit::CM))
2036  , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin))
2037 {
2038  Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwSectionIndentTabPage, IndentModifyHdl);
2039  m_xBeforeMF->connect_value_changed(aLk);
2040  m_xAfterMF->connect_value_changed(aLk);
2041 }
2042 
2044 {
2045 }
2046 
2048 {
2049  if (m_xBeforeMF->get_value_changed_from_saved() || m_xAfterMF->get_value_changed_from_saved())
2050  {
2051  SvxLRSpaceItem aLRSpace(
2052  m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)) ,
2053  m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)), 0, 0, RES_LR_SPACE);
2054  rSet->Put(aLRSpace);
2055  }
2056  return true;
2057 }
2058 
2060 {
2061  //this page doesn't show up in HTML mode
2062  FieldUnit aMetric = ::GetDfltMetric(false);
2063  SetFieldUnit(*m_xBeforeMF, aMetric);
2064  SetFieldUnit(*m_xAfterMF , aMetric);
2065 
2066  SfxItemState eItemState = rSet->GetItemState( RES_LR_SPACE );
2067  if ( eItemState >= SfxItemState::DEFAULT )
2068  {
2069  const SvxLRSpaceItem& rSpace =
2070  rSet->Get( RES_LR_SPACE );
2071 
2072  m_xBeforeMF->set_value(m_xBeforeMF->normalize(rSpace.GetLeft()), FieldUnit::TWIP);
2073  m_xAfterMF->set_value(m_xAfterMF->normalize(rSpace.GetRight()), FieldUnit::TWIP);
2074  }
2075  else
2076  {
2077  m_xBeforeMF->set_text("");
2078  m_xAfterMF->set_text("");
2079  }
2080  m_xBeforeMF->save_value();
2081  m_xAfterMF->save_value();
2082  IndentModifyHdl(*m_xBeforeMF);
2083 }
2084 
2085 std::unique_ptr<SfxTabPage> SwSectionIndentTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
2086 {
2087  return std::make_unique<SwSectionIndentTabPage>(pPage, pController, *rAttrSet);
2088 }
2089 
2091 {
2092  //set sensible values at the preview
2093  m_aPreviewWin.SetAdjust(SvxAdjust::Block);
2094  m_aPreviewWin.SetLastLine(SvxAdjust::Block);
2095  const SwRect& rPageRect = rSh.GetAnyCurRect( CurRectType::Page );
2096  Size aPageSize(rPageRect.Width(), rPageRect.Height());
2097  m_aPreviewWin.SetSize(aPageSize);
2098 }
2099 
2101 {
2102  m_aPreviewWin.SetLeftMargin(m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)));
2103  m_aPreviewWin.SetRightMargin(m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)));
2104  m_aPreviewWin.Invalidate();
2105 }
2106 
2107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~SwEditRegionDlg() override
Definition: uiregionsw.cxx:527
SfxViewFrame * GetViewFrame() const
bool GetValue() const
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
tools::Long GetWidth() const
constexpr TypedWhichId< SwFormatEndAtTextEnd > RES_END_AT_TXTEND(118)
std::unique_ptr< weld::Label > m_xDDECommandFT
Definition: regionsw.hxx:131
static void lcl_FillSubRegionList(SwWrtShell &rSh, weld::ComboBox &rSubRegions, weld::ComboBox *pAvailNames)
Definition: uiregionsw.cxx:125
SwFormatFootnoteAtTextEnd & GetFootnoteNtAtEnd()
Definition: uiregionsw.cxx:165
OUString GetConfirm() const
void SetAdjust(SvxAdjust eNew)
std::vector< SwSection * > SwSections
Definition: section.hxx:41
void RecurseList(const SwSectionFormat *pFormat, const weld::TreeIter *pIter)
Definition: uiregionsw.cxx:446
FieldUnit
#define FN_PARAM_REGION_EDIT_IN_READONLY
Definition: cmdid.h:776
virtual void Reset(const SfxItemSet *) override
css::uno::Sequence< sal_Int8 > const & GetPassword() const
Definition: section.hxx:125
std::unique_ptr< weld::CheckButton > m_xFootnoteNtNumCB
Definition: regionsw.hxx:174
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:168
const size_t m_nArrPos
Definition: uiregionsw.cxx:152
std::unique_ptr< weld::CheckButton > m_xFootnoteNtNumFormatCB
Definition: regionsw.hxx:177
void SetType(SectionType const eNew)
Definition: section.hxx:95
void SetHidden(bool const bFlag)
Definition: section.hxx:98
SAL_DLLPRIVATE void SetProtectFlag(bool const bFlag)
Definition: section.hxx:105
virtual void PageCreated(const SfxAllItemSet &aSet)
static SfxAbstractDialogFactory * Create()
void SetLinkFileName(OUString const &rNew)
Definition: section.hxx:117
bool IsContent() const
Definition: uiregionsw.cxx:178
std::unique_ptr< SvxBrushItem > m_Brush
Definition: uiregionsw.cxx:146
virtual ~SwInsertSectionTabPage() override
virtual bool FillItemSet(SfxItemSet *) override
std::string GetValue
constexpr TypedWhichId< SwFormatCol > RES_COL(109)
const SfxItemSet * GetOutputItemSet() const
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
css::uno::Sequence< sal_Int8 > m_aNewPasswd
Definition: regionsw.hxx:124
IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl, weld::Button &, void)
Definition: uiregionsw.cxx:722
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
const SwRect & GetAnyCurRect(CurRectType eType, const Point *pPt=nullptr, const css::uno::Reference< css::embed::XEmbeddedObject > &=css::uno::Reference< css::embed::XEmbeddedObject >()) const
Definition: fews.cxx:89
void SetSize(Size aNew)
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
void SetTempPasswd(const uno::Sequence< sal_Int8 > &rPasswd)
Definition: uiregionsw.cxx:185
SwEditRegionDlg(weld::Window *pParent, SwWrtShell &rWrtSh)
Definition: uiregionsw.cxx:312
std::shared_ptr< SvxLRSpaceItem > m_LRSpaceItem
Definition: uiregionsw.cxx:151
SwSectionIndentTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rAttrSet)
std::unique_ptr< weld::Label > m_xFootnoteOffsetLbl
Definition: regionsw.hxx:175
-""- and with own numberformat
Definition: fmtftntx.hxx:33
long Long
tools::Long GetRight() const
std::unique_ptr< ConditionEdit > m_xConditionED
Definition: regionsw.hxx:142
void set_sensitive(bool bEnable)
const sal_Unicode cTokenSeparator
const SvxFrameDirectionItem & GetFrameDir(bool=true) const
Definition: frmatr.hxx:94
const OUString & GetSuffix() const
Definition: fmtftntx.hxx:80
#define FN_INSERT_REGION
Definition: cmdid.h:281
sal_Int64 n
Provides access to the marks of a document.
SwSection const * InsertSection(SwSectionData &rNewData, SfxItemSet const *const =nullptr)
Definition: edsect.cxx:35
If text in multi-column sections should be evenly distributed.
Definition: fmtclbl.hxx:28
size_t FindArrPos(const SwSectionFormat *pFormat)
Definition: uiregionsw.cxx:516
static SVL_DLLPUBLIC void GetHashPassword(css::uno::Sequence< sal_Int8 > &rPassHash, const char *pPass, sal_uInt32 nLen)
void RemoveTabPage(const OString &rName)
std::unique_ptr< weld::SpinButton > m_xEndOffsetField
Definition: regionsw.hxx:186
SwFormatEndAtTextEnd & GetEndNtAtEnd()
Definition: uiregionsw.cxx:166
const ContentProperties & rData
size_t GetArrPos() const
Definition: uiregionsw.cxx:171
std::unique_ptr< weld::EntryTreeView > m_xCurName
Definition: regionsw.hxx:128
void SetSectionData(SwSectionData const &rSect)
std::unique_ptr< weld::Label > m_xEndPrefixFT
Definition: regionsw.hxx:188
void ChangePasswd(bool bChange)
void Done(bool bRemove=false)
SvxFrameDirection
SwSectionFormat * GetFormat()
Definition: section.hxx:336
SfxItemSet * GetInputSetImpl()
std::unique_ptr< weld::Entry > m_xFileNameED
Definition: regionsw.hxx:133
virtual short run() override
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
std::shared_ptr< T > make_shared(Args &&...args)
sal_uInt16 GetOffset() const
Definition: fmtftntx.hxx:74
std::unique_ptr< weld::Entry > m_xFileNameED
Definition: regionsw.hxx:64
void ResetState(bool bFootnote, const SwFormatFootnoteEndAtTextEnd &)
virtual void set_text(const OUString &rText)=0
TRISTATE_TRUE
void SetFile(OUString const &rFile)
Definition: uiregionsw.cxx:211
virtual bool get_active() const =0
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::Entry > m_xFootnotePrefixED
Definition: regionsw.hxx:179
std::unique_ptr< weld::CheckButton > m_xFileCB
Definition: regionsw.hxx:129
static bool bFootnote
Definition: insfnote.cxx:33
size_t GetPos(const SwFormat *p) const
Definition: docary.hxx:158
std::unique_ptr< ConditionEdit > m_xConditionED
Definition: regionsw.hxx:73
virtual ~SwSectionIndentTabPage() override
const SwSection * GetCurrSection() const
Definition: edsect.cxx:71
OUString GetFile() const
Definition: uiregionsw.cxx:285
Array of Undo-history.
Definition: docary.hxx:197
std::unique_ptr< weld::CheckButton > m_xPasswdCB
Definition: regionsw.hxx:69
Used by the UI to modify the document model.
Definition: wrtsh.hxx:91
RET_NO
void SetWrtShell(SwWrtShell const &rSh)
virtual short Ok()
IMPL_LINK(SwEditRegionDlg, GetFirstEntryHdl, weld::TreeView &, rBox, void)
Definition: uiregionsw.cxx:561
bool IsStorage()
std::unique_ptr< SwNumberingTypeListBox > m_xEndNumViewBox
Definition: regionsw.hxx:190
std::unique_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:734
const SwView & GetView() const
Definition: wrtsh.hxx:429
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
const SwFormatNoBalancedColumns & GetBalancedColumns(bool=true) const
Definition: fmtclbl.hxx:42
std::unique_ptr< weld::Button > m_xFilePB
Definition: regionsw.hxx:65
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
bool m_bContent
Definition: uiregionsw.cxx:154
std::unique_ptr< weld::TreeView > m_xTree
Definition: regionsw.hxx:58
SwFormatCol m_Col
Definition: uiregionsw.cxx:145
std::unique_ptr< weld::ComboBox > m_xSubRegionED
Definition: regionsw.hxx:136
int nCount
at page or document end
Definition: fmtftntx.hxx:30
virtual SvxFrameDirectionItem * Clone(SfxItemPool *pPool=nullptr) const override
bool bDontCheckPasswd
Definition: regionsw.hxx:55
std::unique_ptr< weld::CheckButton > m_xEditInReadonlyCB
Definition: regionsw.hxx:144
void Width(tools::Long nNew)
Definition: swrect.hxx:187
const SwFormatFootnoteAtTextEnd & GetFootnoteAtTextEnd(bool=true) const
Definition: fmtftntx.hxx:111
std::unique_ptr< weld::MetricSpinButton > m_xAfterMF
Definition: regionsw.hxx:212
std::unique_ptr< weld::SpinButton > m_xFootnoteOffsetField
Definition: regionsw.hxx:176
const IDocumentMarkAccess * getIDocumentMarkAccess() const
Provides access to the document bookmark interface.
Definition: viewsh.cxx:2671
SotClipboardFormatId
const OUString & GetSectionName() const
Definition: section.hxx:92
virtual void Reset(const SfxItemSet *) override
std::unique_ptr< weld::CheckButton > m_xHideCB
Definition: regionsw.hxx:71
#define HTML_CFG_WRITER
virtual std::unique_ptr< SfxItemSet > Clone(bool bItems=true, SfxItemPool *pToPool=nullptr) const override
Definition: swatrset.cxx:150
TRISTATE_INDET
const SwSectionFormat & GetSectionFormat(size_t nFormat) const
Definition: edsect.cxx:142
static SotClipboardFormatId GetFormatID(css::uno::Reference< css::embed::XStorage > const &xStorage)
std::unique_ptr< weld::CheckButton > m_xFootnoteNtAtTextEndCB
Definition: regionsw.hxx:173
virtual void set_active(bool active)=0
#define FN_PARAM_REGION_PROTECT
Definition: cmdid.h:775
virtual bool FillItemSet(SfxItemSet *) override
SwInsertSectionTabDialog(weld::Window *pParent, const SfxItemSet &rSet, SwWrtShell &rSh)
SwFormatNoBalancedColumns m_Balance
Definition: uiregionsw.cxx:149
static SvxHtmlOptions & Get()
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
SwFormatFootnoteAtTextEnd m_FootnoteNtAtEnd
Definition: uiregionsw.cxx:147
virtual const_iterator_t getBookmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of IBookmarks.
const SwSection * pCurrSect
Definition: regionsw.hxx:52
virtual bool get_selection_bounds(int &rStartPos, int &rEndPos)=0
std::unique_ptr< weld::CheckButton > m_xProtectCB
Definition: regionsw.hxx:137
std::unique_ptr< weld::Button > m_xOptionsPB
Definition: regionsw.hxx:77
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SW_DLLPUBLIC FieldUnit GetDfltMetric(bool bWeb)
Definition: uitool.cxx:695
int i
const OUString & GetSectionName() const
Definition: section.hxx:168
std::unique_ptr< weld::ComboBox > m_xSubRegionED
Definition: regionsw.hxx:67
std::unique_ptr< weld::Label > m_xFootnoteSuffixFT
Definition: regionsw.hxx:181
std::unique_ptr< weld::Entry > m_xEndPrefixED
Definition: regionsw.hxx:189
bool IsProtect() const
Definition: section.cxx:348
void SelectSection(std::u16string_view rSectionName)
Definition: uiregionsw.cxx:539
uno::Sequence< sal_Int8 > & GetTempPasswd()
Definition: uiregionsw.cxx:184
std::unique_ptr< weld::Label > m_xEndOffsetLbl
Definition: regionsw.hxx:185
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
bool IsHidden() const
Definition: section.hxx:178
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
SectRepr(size_t nPos, SwSection &rSect)
Definition: uiregionsw.cxx:189
std::unique_ptr< weld::Entry > m_xCurName
Definition: regionsw.hxx:57
std::unique_ptr< SvxBrushItem > & GetBackground()
Definition: uiregionsw.cxx:164
SfxBindings & GetBindings()
std::unique_ptr< weld::CheckButton > m_xProtectCB
Definition: regionsw.hxx:68
std::shared_ptr< SvxFrameDirectionItem > m_FrameDirItem
Definition: uiregionsw.cxx:150
TRISTATE_FALSE
sal_uInt16 Count() const
SwFormatEndAtTextEnd m_EndNtAtEnd
Definition: uiregionsw.cxx:148
const SvxPageUsage aArr[]
bool IsProtectFlag() const
Definition: section.hxx:103
tools::Long GetLeft() const
std::unique_ptr< weld::CheckButton > m_xEndNtNumFormatCB
Definition: regionsw.hxx:187
virtual void select_region(int nStartPos, int nEndPos)=0
void ShowExtras(SfxShowExtras nExtras)
bool IsSelected() const
Definition: uiregionsw.cxx:182
constexpr sal_uInt16 XATTR_FILL_FIRST(XATTRSET_LINE+1)
std::unique_ptr< weld::CheckButton > m_xFileCB
Definition: regionsw.hxx:59
std::unique_ptr< weld::Widget > m_xHideFrame
Definition: regionsw.hxx:79
std::unique_ptr< weld::Label > m_xFootnotePrefixFT
Definition: regionsw.hxx:178
std::shared_ptr< SvxLRSpaceItem > & GetLRSpace()
Definition: uiregionsw.cxx:169
size
bool SelectNumberingType(SvxNumType nType)
bool CheckPasswd(weld::ToggleButton *pBox=nullptr)
Definition: uiregionsw.cxx:400
std::unique_ptr< weld::Button > m_xDismiss
Definition: regionsw.hxx:78
SvxNumType GetNumType() const
Definition: fmtftntx.hxx:69
OUString SwResId(const char *pId)
Definition: swmodule.cxx:166
SectionType
Definition: section.hxx:45
virtual void Reset(const SfxItemSet *) override
virtual void clear()=0
const SwFormatEndAtTextEnd & GetEndAtTextEnd(bool=true) const
Definition: fmtftntx.hxx:113
std::unique_ptr< weld::Entry > m_xEndSuffixED
Definition: regionsw.hxx:192
std::unique_ptr< weld::Button > m_xFilePB
Definition: regionsw.hxx:134
virtual short Ok() override
Reader * SwGetReaderXML()
Definition: fltini.cxx:89
void SetCondition(OUString const &rNew)
Definition: section.hxx:114
void SetValue(bool const bTheValue)
SwDocShell * GetDocShell()
Definition: view.cxx:1110
virtual OUString get_text() const =0
void SetSubRegion(std::u16string_view rSubRegion)
Definition: uiregionsw.cxx:261
at end of the current text end
Definition: fmtftntx.hxx:31
SwSectionFormat * GetParent() const
Definition: section.hxx:355
const OUString & GetPrefix() const
Definition: fmtftntx.hxx:77
uno::Sequence< sal_Int8 > m_TempPasswd
Definition: uiregionsw.cxx:157
std::unique_ptr< weld::MetricSpinButton > m_xBeforeMF
Definition: regionsw.hxx:211
Rect of current page.
void SetContent(bool const bValue)
Definition: uiregionsw.cxx:179
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::Label > m_xConditionFT
Definition: regionsw.hxx:141
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
static void lcl_FillList(SwWrtShell &rSh, weld::ComboBox &rSubRegions, weld::ComboBox *pAvailNames, const SwSectionFormat *pNewFormat)
Definition: uiregionsw.cxx:78
std::unique_ptr< weld::Button > m_xPasswdPB
Definition: regionsw.hxx:139
SvxParaPrevWindow m_aPreviewWin
Definition: regionsw.hxx:210
size_t GetSectionFormatCount() const
Definition: edsect.cxx:114
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const OUString & GetLinkFileName() const
Definition: section.hxx:116
std::unique_ptr< weld::CheckButton > m_xEditInReadonlyCB
Definition: regionsw.hxx:75
std::unique_ptr< weld::CheckButton > m_xHideCB
Definition: regionsw.hxx:140
std::unique_ptr< weld::Label > m_xEndSuffixFT
Definition: regionsw.hxx:191
weld::Window * GetFrameWeld() const
const css::uno::Reference< css::frame::XDispatchRecorder > & GetRecorder() const
void SetLinkFilePassword(OUString const &rS)
Definition: section.hxx:123
virtual void set_value(int value)=0
#define FN_PARAM_REGION_CONDITION
Definition: cmdid.h:773
SfxItemState
weld::Entry & rEdit
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual ~SwSectionPropertyTabDialog() override
SwWrtShell * m_pWrtSh
Definition: regionsw.hxx:125
OUString GetUniqueSectionName(const OUString *pChkStr=nullptr) const
Definition: edsect.cxx:166
#define ERRCODE_NONE
std::unique_ptr< weld::Button > m_xPasswdPB
Definition: regionsw.hxx:70
SwSectionPropertyTabDialog(weld::Window *pParent, const SfxItemSet &rSet, SwWrtShell &rSh)
std::unique_ptr< weld::CheckButton > m_xDDECB
Definition: regionsw.hxx:60
void ChangePasswd(bool bChange)
SwWrtShell & rSh
Definition: regionsw.hxx:50
constexpr TypedWhichId< SwFormatNoBalancedColumns > RES_COLUMNBALANCE(119)
#define HTML_CFG_NS40
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
void SetEditInReadonlyFlag(bool const bFlag)
Definition: section.hxx:107
virtual const_iterator_t getBookmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
TriState get_state() const
OUString aName
RET_OK
std::unique_ptr< SwNumberingTypeListBox > m_xFootnoteNumViewBox
Definition: regionsw.hxx:180
SwFormatCol & GetCol()
Definition: uiregionsw.cxx:163
SwSectionData m_SectionData
Definition: uiregionsw.cxx:144
virtual SvxLRSpaceItem * Clone(SfxItemPool *pPool=nullptr) const override
std::unique_ptr< weld::CheckButton > m_xEndNtNumCB
Definition: regionsw.hxx:184
virtual ~SwSectionFootnoteEndTabPage() override
#define FN_PARAM_REGION_NAME
Definition: cmdid.h:772
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
Reference< XExecutableDialog > m_xDialog
SwSectionFootnoteEndTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rAttrSet)
const INetURLObject & GetURLObject() const
OUString GetPassword() const
void SetSelected()
Definition: uiregionsw.cxx:181
SfxOkDialogController * GetDialogController() const
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
std::unique_ptr< weld::Button > m_xOK
Definition: regionsw.hxx:76
SectionType GetType() const
Definition: section.hxx:94
std::unique_ptr< SwSectionData > m_pSectionData
Definition: regionsw.hxx:231
std::shared_ptr< SvxFrameDirectionItem > & GetFrameDir()
Definition: uiregionsw.cxx:168
void SetLastLine(SvxAdjust eNew)
void SetFilter(std::u16string_view rFilter)
Definition: uiregionsw.cxx:239
static void lcl_ReadSections(SfxMedium &rMedium, weld::ComboBox &rBox)
-""- and with own number sequence
Definition: fmtftntx.hxx:32
std::unique_ptr< weld::CheckButton > m_xEndNtAtTextEndCB
Definition: regionsw.hxx:183
SwSectionData & GetSectionData()
Definition: uiregionsw.cxx:162
virtual size_t GetSectionList(SfxMedium &rMedium, std::vector< OUString > &rStrings) const
Definition: shellio.cxx:637
OUString sId
static SVL_DLLPUBLIC bool CompareHashPassword(const css::uno::Sequence< sal_Int8 > &rOldPassHash, const OUString &sNewPass)
void AppendItem(const SfxPoolItem &)
sal_uInt16 GetExportMode() const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: column.cxx:591
void append_text(const OUString &rStr)
std::unique_ptr< weld::CheckButton > m_xDDECB
Definition: regionsw.hxx:130
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLBACKGROUND)
bool m_bSelected
Definition: uiregionsw.cxx:156
void set_state(TriState eState)
SectionType GetType() const
Definition: section.hxx:170
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:120
virtual ~SwInsertSectionTabDialog() override
std::unique_ptr< weld::CheckButton > m_xPasswdCB
Definition: regionsw.hxx:138
Frame is variable in Var-direction.
SwSection * GetSection() const
Definition: section.cxx:674
OUString GetSubRegion() const
Definition: uiregionsw.cxx:303
SwFormatNoBalancedColumns & GetBalance()
Definition: uiregionsw.cxx:167
void GetChildSections(SwSections &rArr, SectionSort eSort=SectionSort::Not, bool bAllSections=true) const
Definition: section.cxx:884
static OUString CollapseWhiteSpaces(const OUString &sName)
Definition: section.cxx:179
void SetWrtShell(SwWrtShell &rSh)
void Height(tools::Long nNew)
Definition: swrect.hxx:191
SwInsertSectionTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rAttrSet)
constexpr TypedWhichId< SwFormatFootnoteAtTextEnd > RES_FTN_AT_TXTEND(117)
std::unique_ptr< weld::Entry > m_xFootnoteSuffixED
Definition: regionsw.hxx:182
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
sal_uInt16 nPos
virtual void set_sensitive(bool sensitive)=0
#define FN_PARAM_REGION_HIDDEN
Definition: cmdid.h:774
void SetCurPageId(const OString &rName)
virtual bool FillItemSet(SfxItemSet *) override
void SetPassword(css::uno::Sequence< sal_Int8 > const &rNew)
Definition: section.hxx:127
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
void SetSectionName(OUString const &rName)
Definition: section.hxx:93
bool IsInNodesArr() const
Definition: section.cxx:916
const SvxLRSpaceItem & GetLRSpace(bool=true) const
Definition: frmatr.hxx:74
EnumT GetValue() const
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
SfxMedium * GetMedium() const
static OUString decode(OUString const &rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)