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 #include <osl/diagnose.h>
38 
39 #include <uitool.hxx>
40 #include <IMark.hxx>
41 #include <section.hxx>
42 #include <docary.hxx>
43 #include <doc.hxx>
44 #include <wdocsh.hxx>
45 #include <view.hxx>
46 #include <wrtsh.hxx>
47 #include <column.hxx>
48 #include <fmtclbl.hxx>
49 #include <fmtfsize.hxx>
50 #include <frmatr.hxx>
51 #include <shellio.hxx>
52 
53 #include <cmdid.h>
54 #include <strings.hrc>
55 #include <bitmaps.hlst>
56 #include <sfx2/bindings.hxx>
57 #include <sfx2/sfxdlg.hxx>
58 #include <sfx2/viewfrm.hxx>
59 #include <svx/dialogs.hrc>
60 #include <svx/flagsdef.hxx>
61 #include <memory>
62 #include <string_view>
63 
64 using namespace ::com::sun::star;
65 
66 namespace {
67 
68 OUString BuildBitmap(bool bProtect, bool bHidden)
69 {
70  if (bProtect)
71  return bHidden ? OUString(RID_BMP_PROT_HIDE) : OUString(RID_BMP_PROT_NO_HIDE);
72  return bHidden ? OUString(RID_BMP_HIDE) : OUString(RID_BMP_NO_HIDE);
73 }
74 
75 }
76 
77 static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox );
78 
79 static void lcl_FillList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames, const SwSectionFormat* pNewFormat )
80 {
81  if( !pNewFormat )
82  {
83  const size_t nCount = rSh.GetSectionFormatCount();
84  for (size_t i = 0; i<nCount; i++)
85  {
86  SectionType eTmpType;
87  const SwSectionFormat* pFormat = &rSh.GetSectionFormat(i);
88  if( !pFormat->GetParent() &&
89  pFormat->IsInNodesArr() &&
90  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
91  && SectionType::ToxHeader != eTmpType )
92  {
93  const OUString sString(pFormat->GetSection()->GetSectionName());
94  if (pAvailNames)
95  pAvailNames->append_text(sString);
96  rSubRegions.append_text(sString);
97  lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
98  }
99  }
100  }
101  else
102  {
103  SwSections aTmpArr;
104  pNewFormat->GetChildSections(aTmpArr, SectionSort::Pos);
105  if( !aTmpArr.empty() )
106  {
107  SectionType eTmpType;
108  for( const auto pSect : aTmpArr )
109  {
110  const SwSectionFormat* pFormat = pSect->GetFormat();
111  if( pFormat->IsInNodesArr()&&
112  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
113  && SectionType::ToxHeader != eTmpType )
114  {
115  const OUString sString(pFormat->GetSection()->GetSectionName());
116  if (pAvailNames)
117  pAvailNames->append_text(sString);
118  rSubRegions.append_text(sString);
119  lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
120  }
121  }
122  }
123  }
124 }
125 
126 static void lcl_FillSubRegionList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames )
127 {
128  rSubRegions.clear();
129  lcl_FillList( rSh, rSubRegions, pAvailNames, nullptr );
130  IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
131  for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin();
132  ppMark != pMarkAccess->getBookmarksEnd();
133  ++ppMark)
134  {
135  const ::sw::mark::IMark* pBkmk = *ppMark;
136  if( pBkmk->IsExpanded() )
137  rSubRegions.append_text( pBkmk->GetName() );
138  }
139 }
140 
141 // user data class for region information
142 class SectRepr
143 {
144 private:
147  std::unique_ptr<SvxBrushItem> m_Brush;
151  std::shared_ptr<SvxFrameDirectionItem> m_FrameDirItem;
152  std::shared_ptr<SvxLRSpaceItem> m_LRSpaceItem;
153  const size_t m_nArrPos;
154  // shows, if maybe textcontent is in the region
155  bool m_bContent : 1;
156  // for multiselection, mark at first, then work with TreeListBox!
157  bool m_bSelected : 1;
158  uno::Sequence<sal_Int8> m_TempPasswd;
159 
160 public:
161  SectRepr(size_t nPos, SwSection& rSect);
162 
164  SwFormatCol& GetCol() { return m_Col; }
165  std::unique_ptr<SvxBrushItem>& GetBackground() { return m_Brush; }
169  std::shared_ptr<SvxFrameDirectionItem>& GetFrameDir() { return m_FrameDirItem; }
170  std::shared_ptr<SvxLRSpaceItem>& GetLRSpace() { return m_LRSpaceItem; }
171 
172  size_t GetArrPos() const { return m_nArrPos; }
173  OUString GetFile() const;
174  OUString GetSubRegion() const;
175  void SetFile(std::u16string_view rFile);
176  void SetFilter(std::u16string_view rFilter);
177  void SetSubRegion(std::u16string_view rSubRegion);
178 
179  bool IsContent() const { return m_bContent; }
180  void SetContent(bool const bValue) { m_bContent = bValue; }
181 
182  void SetSelected() { m_bSelected = true; }
183  bool IsSelected() const { return m_bSelected; }
184 
185  uno::Sequence<sal_Int8> & GetTempPasswd() { return m_TempPasswd; }
186  void SetTempPasswd(const uno::Sequence<sal_Int8> & rPasswd)
187  { m_TempPasswd = rPasswd; }
188 };
189 
190 SectRepr::SectRepr( size_t nPos, SwSection& rSect )
191  : m_SectionData( rSect )
192  , m_Brush(std::make_unique<SvxBrushItem>(RES_BACKGROUND))
194  , m_LRSpaceItem(std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE))
195  , m_nArrPos(nPos)
196  , m_bContent(m_SectionData.GetLinkFileName().isEmpty())
197  , m_bSelected(false)
198 {
199  SwSectionFormat *pFormat = rSect.GetFormat();
200  if( pFormat )
201  {
202  m_Col = pFormat->GetCol();
203  m_Brush = pFormat->makeBackgroundBrushItem();
205  m_EndNtAtEnd = pFormat->GetEndAtTextEnd();
207  m_FrameDirItem.reset(pFormat->GetFrameDir().Clone());
208  m_LRSpaceItem.reset(pFormat->GetLRSpace().Clone());
209  }
210 }
211 
212 void SectRepr::SetFile( std::u16string_view rFile )
213 {
214  OUString sNewFile( INetURLObject::decode( rFile,
216  const OUString sOldFileName( m_SectionData.GetLinkFileName() );
217  const OUString sSub( sOldFileName.getToken( 2, sfx2::cTokenSeparator ) );
218 
219  if( !rFile.empty() || !sSub.isEmpty() )
220  {
221  sNewFile += OUStringChar(sfx2::cTokenSeparator);
222  if( !rFile.empty() ) // Filter only with FileName
223  sNewFile += sOldFileName.getToken( 1, sfx2::cTokenSeparator );
224 
225  sNewFile += OUStringChar(sfx2::cTokenSeparator) + sSub;
226  }
227 
228  m_SectionData.SetLinkFileName( sNewFile );
229 
230  if( !rFile.empty() || !sSub.isEmpty() )
231  {
233  }
234  else
235  {
237  }
238 }
239 
240 void SectRepr::SetFilter( std::u16string_view rFilter )
241 {
242  OUString sNewFile;
243  const OUString sOldFileName( m_SectionData.GetLinkFileName() );
244  sal_Int32 nIdx{ 0 };
245  const OUString sFile( sOldFileName.getToken( 0, sfx2::cTokenSeparator, nIdx ) ); // token 0
246  const OUString sSub( sOldFileName.getToken( 1, sfx2::cTokenSeparator, nIdx ) ); // token 2
247 
248  if( !sFile.isEmpty() )
249  sNewFile = sFile + OUStringChar(sfx2::cTokenSeparator) +
250  rFilter + OUStringChar(sfx2::cTokenSeparator) + sSub;
251  else if( !sSub.isEmpty() )
252  sNewFile = OUStringChar(sfx2::cTokenSeparator) + OUStringChar(sfx2::cTokenSeparator) + sSub;
253 
254  m_SectionData.SetLinkFileName( sNewFile );
255 
256  if( !sNewFile.isEmpty() )
257  {
259  }
260 }
261 
262 void SectRepr::SetSubRegion(std::u16string_view rSubRegion)
263 {
264  OUString sNewFile;
265  sal_Int32 n(0);
266  const OUString sLinkFileName(m_SectionData.GetLinkFileName());
267  const OUString sOldFileName( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
268  const OUString sFilter( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
269 
270  if( !rSubRegion.empty() || !sOldFileName.isEmpty() )
271  sNewFile = sOldFileName + OUStringChar(sfx2::cTokenSeparator) +
272  sFilter + OUStringChar(sfx2::cTokenSeparator) + rSubRegion;
273 
274  m_SectionData.SetLinkFileName( sNewFile );
275 
276  if( !rSubRegion.empty() || !sOldFileName.isEmpty() )
277  {
279  }
280  else
281  {
283  }
284 }
285 
286 OUString SectRepr::GetFile() const
287 {
288  const OUString sLinkFile( m_SectionData.GetLinkFileName() );
289 
290  if( sLinkFile.isEmpty() )
291  {
292  return sLinkFile;
293  }
295  {
296  sal_Int32 n = 0;
297  return sLinkFile.replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n )
298  .replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n );
299  }
300  return INetURLObject::decode( sLinkFile.getToken( 0, sfx2::cTokenSeparator ),
302 }
303 
304 OUString SectRepr::GetSubRegion() const
305 {
306  const OUString sLinkFile( m_SectionData.GetLinkFileName() );
307  if( !sLinkFile.isEmpty() )
308  return sLinkFile.getToken( 2, sfx2::cTokenSeparator );
309  return sLinkFile;
310 }
311 
312 // dialog edit regions
314  : SfxDialogController(pParent, "modules/swriter/ui/editsectiondialog.ui",
315  "EditSectionDialog")
316  , m_bSubRegionsFilled(false)
317  , rSh(rWrtSh)
318  , bDontCheckPasswd(true)
319  , m_xCurName(m_xBuilder->weld_entry("curname"))
320  , m_xTree(m_xBuilder->weld_tree_view("tree"))
321  , m_xFileCB(m_xBuilder->weld_check_button("link"))
322  , m_xDDECB(m_xBuilder->weld_check_button("dde"))
323  , m_xDDEFrame(m_xBuilder->weld_widget("ddedepend"))
324  , m_xFileNameFT(m_xBuilder->weld_label("filenameft"))
325  , m_xDDECommandFT(m_xBuilder->weld_label("ddeft"))
326  , m_xFileNameED(m_xBuilder->weld_entry("filename"))
327  , m_xFilePB(m_xBuilder->weld_button("file"))
328  , m_xSubRegionFT(m_xBuilder->weld_label("sectionft"))
329  , m_xSubRegionED(m_xBuilder->weld_combo_box("section"))
330  , m_xProtectCB(m_xBuilder->weld_check_button("protect"))
331  , m_xPasswdCB(m_xBuilder->weld_check_button("withpassword"))
332  , m_xPasswdPB(m_xBuilder->weld_button("password"))
333  , m_xHideCB(m_xBuilder->weld_check_button("hide"))
334  , m_xConditionFT(m_xBuilder->weld_label("conditionft"))
335  , m_xConditionED(new ConditionEdit(m_xBuilder->weld_entry("condition")))
336  , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editinro"))
337  , m_xOK(m_xBuilder->weld_button("ok"))
338  , m_xOptionsPB(m_xBuilder->weld_button("options"))
339  , m_xDismiss(m_xBuilder->weld_button("remove"))
340  , m_xHideFrame(m_xBuilder->weld_widget("hideframe"))
341 {
342  m_xTree->set_size_request(-1, m_xTree->get_height_rows(16));
343  m_xFileCB->set_state(TRISTATE_FALSE);
344  m_xSubRegionED->make_sorted();
345  m_xProtectCB->set_state(TRISTATE_FALSE);
346  m_xHideCB->set_state(TRISTATE_FALSE);
347  // edit in readonly sections
349 
350  bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr;
351 
352  m_xTree->connect_changed(LINK(this, SwEditRegionDlg, GetFirstEntryHdl));
353  m_xCurName->connect_changed(LINK(this, SwEditRegionDlg, NameEditHdl));
354  m_xConditionED->connect_changed( LINK( this, SwEditRegionDlg, ConditionEditHdl));
355  m_xOK->connect_clicked( LINK( this, SwEditRegionDlg, OkHdl));
356  m_xPasswdCB->connect_toggled(LINK(this, SwEditRegionDlg, TogglePasswdHdl));
357  m_xPasswdPB->connect_clicked(LINK(this, SwEditRegionDlg, ChangePasswdHdl));
358  m_xHideCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeHideHdl));
359  // edit in readonly sections
360  m_xEditInReadonlyCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeEditInReadonlyHdl));
361 
362  m_xOptionsPB->connect_clicked(LINK(this, SwEditRegionDlg, OptionsHdl));
363  m_xProtectCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeProtectHdl));
364  m_xDismiss->connect_clicked( LINK( this, SwEditRegionDlg, ChangeDismissHdl));
365  m_xFileCB->connect_toggled(LINK(this, SwEditRegionDlg, UseFileHdl));
366  m_xFilePB->connect_clicked(LINK(this, SwEditRegionDlg, FileSearchHdl));
367  m_xFileNameED->connect_changed(LINK(this, SwEditRegionDlg, FileNameEntryHdl));
368  m_xSubRegionED->connect_changed(LINK(this, SwEditRegionDlg, FileNameComboBoxHdl));
369  m_xSubRegionED->connect_popup_toggled(LINK(this, SwEditRegionDlg, SubRegionEventHdl));
370  m_xSubRegionED->set_entry_completion(true, true);
371 
372  m_xTree->set_selection_mode(SelectionMode::Multiple);
373 
374  if (bWeb)
375  {
376  m_xDDECB->hide();
377  m_xHideFrame->hide();
378  m_xPasswdCB->hide();
379  }
380 
381  m_xDDECB->connect_toggled(LINK(this, SwEditRegionDlg, DDEHdl));
382 
384  RecurseList( nullptr, nullptr );
385 
386  // if the cursor is not in a region the first one will always be selected
387  if (!m_xTree->get_selected(nullptr))
388  {
389  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
390  if (m_xTree->get_iter_first(*xIter))
391  {
392  m_xTree->select(*xIter);
393  GetFirstEntryHdl(*m_xTree);
394  }
395  }
396 
397  m_xTree->show();
398  bDontCheckPasswd = false;
399 }
400 
402 {
403  if (bDontCheckPasswd)
404  return true;
405  bool bRet = true;
406 
407  m_xTree->selected_foreach([this, &bRet](weld::TreeIter& rEntry){
408  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
409  if (!pRepr->GetTempPasswd().hasElements()
410  && pRepr->GetSectionData().GetPassword().hasElements())
411  {
412  SfxPasswordDialog aPasswdDlg(m_xDialog.get());
413  bRet = false;
414  if (aPasswdDlg.run())
415  {
416  const OUString sNewPasswd(aPasswdDlg.GetPassword());
417  css::uno::Sequence <sal_Int8 > aNewPasswd;
418  SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
420  pRepr->GetSectionData().GetPassword(), sNewPasswd))
421  {
422  pRepr->SetTempPasswd(aNewPasswd);
423  bRet = true;
424  }
425  else
426  {
427  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
428  VclMessageType::Info, VclButtonsType::Ok,
429  SwResId(STR_WRONG_PASSWORD)));
430  xInfoBox->run();
431  }
432  }
433  }
434  return false;
435  });
436  if (!bRet && pBox)
437  {
438  //reset old button state
439  if (pBox->get_state() != TRISTATE_INDET)
440  pBox->set_active(!pBox->get_active());
441  }
442 
443  return bRet;
444 }
445 
446 // recursively look for child-sections
448 {
449  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
450  if (!pFormat)
451  {
452  const size_t nCount=rSh.GetSectionFormatCount();
453  for ( size_t n = 0; n < nCount; n++ )
454  {
455  SectionType eTmpType;
456  if( !( pFormat = &rSh.GetSectionFormat(n))->GetParent() &&
457  pFormat->IsInNodesArr() &&
458  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
459  && SectionType::ToxHeader != eTmpType )
460  {
461  SwSection *pSect = pFormat->GetSection();
462  SectRepr* pSectRepr = new SectRepr( n, *pSect );
463 
464  OUString sText(pSect->GetSectionName());
465  OUString sImage(BuildBitmap(pSect->IsProtect(),pSect->IsHidden()));
466  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr)));
467  m_xTree->insert(nullptr, -1, &sText, &sId, nullptr, nullptr, false, xIter.get());
468  m_xTree->set_image(*xIter, sImage);
469 
470  RecurseList(pFormat, xIter.get());
471  if (m_xTree->iter_has_child(*xIter))
472  m_xTree->expand_row(*xIter);
473  if (pCurrSect==pSect)
474  {
475  m_xTree->select(*xIter);
476  m_xTree->scroll_to_row(*xIter);
477  GetFirstEntryHdl(*m_xTree);
478  }
479  }
480  }
481  }
482  else
483  {
484  SwSections aTmpArr;
485  pFormat->GetChildSections(aTmpArr, SectionSort::Pos);
486  for( const auto pSect : aTmpArr )
487  {
488  SectionType eTmpType;
489  pFormat = pSect->GetFormat();
490  if( pFormat->IsInNodesArr() &&
491  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
492  && SectionType::ToxHeader != eTmpType )
493  {
494  SectRepr* pSectRepr=new SectRepr(
495  FindArrPos( pSect->GetFormat() ), *pSect );
496 
497  OUString sText(pSect->GetSectionName());
498  OUString sImage = BuildBitmap(pSect->IsProtect(), pSect->IsHidden());
499  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr)));
500  m_xTree->insert(pEntry, -1, &sText, &sId, nullptr, nullptr, false, xIter.get());
501  m_xTree->set_image(*xIter, sImage);
502 
503  RecurseList(pSect->GetFormat(), xIter.get());
504  if (m_xTree->iter_has_child(*xIter))
505  m_xTree->expand_row(*xIter);
506  if (pCurrSect==pSect)
507  {
508  m_xTree->select(*xIter);
509  m_xTree->scroll_to_row(*xIter);
510  GetFirstEntryHdl(*m_xTree);
511  }
512  }
513  }
514  }
515 }
516 
518 {
519  const size_t nCount=rSh.GetSectionFormatCount();
520  for ( size_t i = 0; i < nCount; i++ )
521  if ( pFormat == &rSh.GetSectionFormat(i) )
522  return i;
523 
524  OSL_FAIL("SectionFormat not on the list" );
525  return SIZE_MAX;
526 }
527 
529 {
530  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
531  if (m_xTree->get_iter_first(*xIter))
532  {
533  do
534  {
535  delete reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
536  } while (m_xTree->iter_next(*xIter));
537  }
538 }
539 
540 void SwEditRegionDlg::SelectSection(std::u16string_view rSectionName)
541 {
542  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
543  if (!m_xTree->get_iter_first(*xIter))
544  return;
545 
546  do
547  {
548  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
549  if (pRepr->GetSectionData().GetSectionName() == rSectionName)
550  {
551  m_xTree->unselect_all();
552  m_xTree->select(*xIter);
553  m_xTree->scroll_to_row(*xIter);
554  GetFirstEntryHdl(*m_xTree);
555  break;
556  }
557  } while (m_xTree->iter_next(*xIter));
558 }
559 
560 // selected entry in TreeListBox is showed in Edit window in case of
561 // multiselection some controls are disabled
562 IMPL_LINK(SwEditRegionDlg, GetFirstEntryHdl, weld::TreeView&, rBox, void)
563 {
564  bDontCheckPasswd = true;
565  std::unique_ptr<weld::TreeIter> xIter(rBox.make_iterator());
566  bool bEntry = rBox.get_selected(xIter.get());
567  m_xHideCB->set_sensitive(true);
568  // edit in readonly sections
569  m_xEditInReadonlyCB->set_sensitive(true);
570 
571  m_xProtectCB->set_sensitive(true);
572  m_xFileCB->set_sensitive(true);
573  css::uno::Sequence <sal_Int8> aCurPasswd;
574  if (1 < rBox.count_selected_rows())
575  {
576  m_xHideCB->set_state(TRISTATE_INDET);
577  m_xProtectCB->set_state(TRISTATE_INDET);
578  // edit in readonly sections
579  m_xEditInReadonlyCB->set_state(TRISTATE_INDET);
580  m_xFileCB->set_state(TRISTATE_INDET);
581 
582  bool bHiddenValid = true;
583  bool bProtectValid = true;
584  bool bConditionValid = true;
585  // edit in readonly sections
586  bool bEditInReadonlyValid = true;
587  bool bEditInReadonly = true;
588 
589  bool bHidden = true;
590  bool bProtect = true;
591  OUString sCondition;
592  bool bFirst = true;
593  bool bFileValid = true;
594  bool bFile = true;
595  bool bPasswdValid = true;
596 
597  m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
598  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
599  SwSectionData const& rData( pRepr->GetSectionData() );
600  if(bFirst)
601  {
602  sCondition = rData.GetCondition();
603  bHidden = rData.IsHidden();
604  bProtect = rData.IsProtectFlag();
605  // edit in readonly sections
606  bEditInReadonly = rData.IsEditInReadonlyFlag();
607 
608  bFile = (rData.GetType() != SectionType::Content);
609  aCurPasswd = rData.GetPassword();
610  }
611  else
612  {
613  if(sCondition != rData.GetCondition())
614  bConditionValid = false;
615  bHiddenValid = (bHidden == rData.IsHidden());
616  bProtectValid = (bProtect == rData.IsProtectFlag());
617  // edit in readonly sections
618  bEditInReadonlyValid =
619  (bEditInReadonly == rData.IsEditInReadonlyFlag());
620 
621  bFileValid = (bFile ==
622  (rData.GetType() != SectionType::Content));
623  bPasswdValid = (aCurPasswd == rData.GetPassword());
624  }
625  bFirst = false;
626  return false;
627  });
628 
629  m_xHideCB->set_state(!bHiddenValid ? TRISTATE_INDET :
630  bHidden ? TRISTATE_TRUE : TRISTATE_FALSE);
631  m_xProtectCB->set_state(!bProtectValid ? TRISTATE_INDET :
632  bProtect ? TRISTATE_TRUE : TRISTATE_FALSE);
633  // edit in readonly sections
634  m_xEditInReadonlyCB->set_state(!bEditInReadonlyValid ? TRISTATE_INDET :
635  bEditInReadonly ? TRISTATE_TRUE : TRISTATE_FALSE);
636 
637  m_xFileCB->set_state(!bFileValid ? TRISTATE_INDET :
638  bFile ? TRISTATE_TRUE : TRISTATE_FALSE);
639 
640  if (bConditionValid)
641  m_xConditionED->set_text(sCondition);
642  else
643  {
644  m_xConditionFT->set_sensitive(false);
645  m_xConditionED->set_sensitive(false);
646  }
647 
648  m_xCurName->set_sensitive(false);
649  m_xDDECB->set_sensitive(false);
650  m_xDDEFrame->set_sensitive(false);
651  m_xOptionsPB->set_sensitive(false);
652  bool bPasswdEnabled = m_xProtectCB->get_state() == TRISTATE_TRUE;
653  m_xPasswdCB->set_sensitive(bPasswdEnabled);
654  m_xPasswdPB->set_sensitive(bPasswdEnabled);
655  if(!bPasswdValid)
656  {
657  rBox.get_selected(xIter.get());
658  rBox.unselect_all();
659  rBox.select(*xIter);
660  GetFirstEntryHdl(rBox);
661  return;
662  }
663  else
664  m_xPasswdCB->set_active(aCurPasswd.hasElements());
665  }
666  else if (bEntry )
667  {
668  m_xCurName->set_sensitive(true);
669  m_xOptionsPB->set_sensitive(true);
670  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
671  SwSectionData const& rData( pRepr->GetSectionData() );
672  m_xConditionED->set_text(rData.GetCondition());
673  m_xHideCB->set_sensitive(true);
674  m_xHideCB->set_state((rData.IsHidden()) ? TRISTATE_TRUE : TRISTATE_FALSE);
675  bool bHide = TRISTATE_TRUE == m_xHideCB->get_state();
676  m_xConditionED->set_sensitive(bHide);
677  m_xConditionFT->set_sensitive(bHide);
678  m_xPasswdCB->set_active(rData.GetPassword().hasElements());
679 
680  m_xOK->set_sensitive(true);
681  m_xPasswdCB->set_sensitive(true);
682  m_xCurName->set_text(rBox.get_text(*xIter));
683  m_xCurName->set_sensitive(true);
684  m_xDismiss->set_sensitive(true);
685  const OUString aFile = pRepr->GetFile();
686  const OUString sSub = pRepr->GetSubRegion();
687  m_xSubRegionED->clear();
688  m_xSubRegionED->append_text(""); // put in a dummy entry, which is replaced when m_bSubRegionsFilled is set
689  m_bSubRegionsFilled = false;
690  if( !aFile.isEmpty() || !sSub.isEmpty() )
691  {
692  m_xFileCB->set_active(true);
693  m_xFileNameED->set_text(aFile);
694  m_xSubRegionED->set_entry_text(sSub);
695  m_xDDECB->set_active(rData.GetType() == SectionType::DdeLink);
696  }
697  else
698  {
699  m_xFileCB->set_active(false);
700  m_xFileNameED->set_text(aFile);
701  m_xDDECB->set_sensitive(false);
702  m_xDDECB->set_active(false);
703  }
704  UseFileHdl(*m_xFileCB);
705  DDEHdl(*m_xDDECB);
706  m_xProtectCB->set_state((rData.IsProtectFlag())
707  ? TRISTATE_TRUE : TRISTATE_FALSE);
708  m_xProtectCB->set_sensitive(true);
709 
710  // edit in readonly sections
711  m_xEditInReadonlyCB->set_state((rData.IsEditInReadonlyFlag())
712  ? TRISTATE_TRUE : TRISTATE_FALSE);
713  m_xEditInReadonlyCB->set_sensitive(true);
714 
715  bool bPasswdEnabled = m_xProtectCB->get_active();
716  m_xPasswdCB->set_sensitive(bPasswdEnabled);
717  m_xPasswdPB->set_sensitive(bPasswdEnabled);
718  }
719  bDontCheckPasswd = false;
720 }
721 
722 // in OkHdl the modified settings are being applied and reversed regions are deleted
724 {
725  // temp. Array because during changing of a region the position
726  // inside of the "Core-Arrays" can be shifted:
727  // - at linked regions, when they have more SubRegions or get
728  // new ones.
729  // StartUndo must certainly also happen not before the formats
730  // are copied (ClearRedo!)
731 
732  const SwSectionFormats& rDocFormats = rSh.GetDoc()->GetSections();
733  SwSectionFormats aOrigArray(rDocFormats);
734 
735  rSh.StartAllAction();
736  rSh.StartUndo();
737  rSh.ResetSelect( nullptr,false );
738 
739  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
740  if (m_xTree->get_iter_first(*xIter))
741  {
742  do
743  {
744  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
745  SwSectionFormat* pFormat = aOrigArray[ pRepr->GetArrPos() ];
746  if (!pRepr->GetSectionData().IsProtectFlag())
747  {
748  pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
749  }
750  size_t nNewPos = rDocFormats.GetPos(pFormat);
751  if ( SIZE_MAX != nNewPos )
752  {
753  std::unique_ptr<SfxItemSet> pSet(pFormat->GetAttrSet().Clone( false ));
754  if( pFormat->GetCol() != pRepr->GetCol() )
755  pSet->Put( pRepr->GetCol() );
756 
757  std::unique_ptr<SvxBrushItem> aBrush(pFormat->makeBackgroundBrushItem(false));
758  if( aBrush && pRepr->GetBackground() && *aBrush != *pRepr->GetBackground() )
759  pSet->Put( *pRepr->GetBackground() );
760 
761  if( pFormat->GetFootnoteAtTextEnd(false) != pRepr->GetFootnoteNtAtEnd() )
762  pSet->Put( pRepr->GetFootnoteNtAtEnd() );
763 
764  if( pFormat->GetEndAtTextEnd(false) != pRepr->GetEndNtAtEnd() )
765  pSet->Put( pRepr->GetEndNtAtEnd() );
766 
767  if( pFormat->GetBalancedColumns() != pRepr->GetBalance() )
768  pSet->Put( pRepr->GetBalance() );
769 
770  if( pFormat->GetFrameDir() != *pRepr->GetFrameDir() )
771  pSet->Put( *pRepr->GetFrameDir() );
772 
773  if( pFormat->GetLRSpace() != *pRepr->GetLRSpace())
774  pSet->Put( *pRepr->GetLRSpace());
775 
776  rSh.UpdateSection( nNewPos, pRepr->GetSectionData(),
777  pSet->Count() ? pSet.get() : nullptr );
778  }
779  } while (m_xTree->iter_next(*xIter));
780  }
781 
782  for (SectReprs_t::reverse_iterator it = m_SectReprs.rbegin(), aEnd = m_SectReprs.rend(); it != aEnd; ++it)
783  {
784  assert(it->first == it->second->GetArrPos());
785  SwSectionFormat* pFormat = aOrigArray[ it->second->GetArrPos() ];
786  const size_t nNewPos = rDocFormats.GetPos( pFormat );
787  if( SIZE_MAX != nNewPos )
788  rSh.DelSectionFormat( nNewPos );
789  }
790 
791  aOrigArray.clear();
792 
793  // response must be called ahead of EndAction's end,
794  // otherwise ScrollError can occur.
795  m_xDialog->response(RET_OK);
796 
797  rSh.EndUndo();
798  rSh.EndAllAction();
799 }
800 
801 // Toggle protect
802 IMPL_LINK(SwEditRegionDlg, ChangeProtectHdl, weld::Toggleable&, rButton, void)
803 {
804  if (!CheckPasswd(&rButton))
805  return;
806  bool bCheck = TRISTATE_TRUE == rButton.get_state();
807  m_xTree->selected_foreach([this, bCheck](weld::TreeIter& rEntry){
808  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
809  pRepr->GetSectionData().SetProtectFlag(bCheck);
810  OUString aImage = BuildBitmap(bCheck, TRISTATE_TRUE == m_xHideCB->get_state());
811  m_xTree->set_image(rEntry, aImage);
812  return false;
813  });
814  m_xPasswdCB->set_sensitive(bCheck);
815  m_xPasswdPB->set_sensitive(bCheck);
816 }
817 
818 // Toggle hide
819 IMPL_LINK( SwEditRegionDlg, ChangeHideHdl, weld::Toggleable&, rButton, void)
820 {
821  if (!CheckPasswd(&rButton))
822  return;
823  m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){
824  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
825  pRepr->GetSectionData().SetHidden(TRISTATE_TRUE == rButton.get_state());
826  OUString aImage = BuildBitmap(TRISTATE_TRUE == m_xProtectCB->get_state(),
827  TRISTATE_TRUE == rButton.get_state());
828  m_xTree->set_image(rEntry, aImage);
829  return false;
830  });
831  bool bHide = TRISTATE_TRUE == rButton.get_state();
832  m_xConditionED->set_sensitive(bHide);
833  m_xConditionFT->set_sensitive(bHide);
834 }
835 
836 // Toggle edit in readonly
837 IMPL_LINK(SwEditRegionDlg, ChangeEditInReadonlyHdl, weld::Toggleable&, rButton, void)
838 {
839  if (!CheckPasswd(&rButton))
840  return;
841  m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){
842  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
844  TRISTATE_TRUE == rButton.get_state());
845  return false;
846  });
847 }
848 
849 // clear selected region
850 IMPL_LINK_NOARG(SwEditRegionDlg, ChangeDismissHdl, weld::Button&, void)
851 {
852  if(!CheckPasswd())
853  return;
854  // at first mark all selected
855  m_xTree->selected_foreach([this](weld::TreeIter& rEntry){
856  SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
857  pSectRepr->SetSelected();
858  return false;
859  });
860 
861  std::unique_ptr<weld::TreeIter> xEntry(m_xTree->make_iterator());
862  bool bEntry(m_xTree->get_selected(xEntry.get()));
863  // then delete
864  while (bEntry)
865  {
866  SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xEntry).toInt64());
867  std::unique_ptr<weld::TreeIter> xRemove;
868  bool bRestart = false;
869  if (pSectRepr->IsSelected())
870  {
871  m_SectReprs.insert(std::make_pair(pSectRepr->GetArrPos(),
872  std::unique_ptr<SectRepr>(pSectRepr)));
873  if (m_xTree->iter_has_child(*xEntry))
874  {
875  std::unique_ptr<weld::TreeIter> xChild(m_xTree->make_iterator(xEntry.get()));
876  (void)m_xTree->iter_children(*xChild);
877  std::unique_ptr<weld::TreeIter> xParent(m_xTree->make_iterator(xEntry.get()));
878  if (!m_xTree->iter_parent(*xParent))
879  xParent.reset();
880  bool bChild = true;
881  do
882  {
883  // because of the repositioning we have to start at the beginning again
884  bRestart = true;
885  std::unique_ptr<weld::TreeIter> xMove(m_xTree->make_iterator(xChild.get()));
886  bChild = m_xTree->iter_next_sibling(*xChild);
887  m_xTree->move_subtree(*xMove, xParent.get(), m_xTree->get_iter_index_in_parent(*xEntry));
888  } while (bChild);
889  }
890  xRemove = m_xTree->make_iterator(xEntry.get());
891  }
892  if (bRestart)
893  bEntry = m_xTree->get_iter_first(*xEntry);
894  else
895  bEntry = m_xTree->iter_next(*xEntry);
896  if (xRemove)
897  m_xTree->remove(*xRemove);
898  }
899 
900  if (m_xTree->get_selected(nullptr))
901  return;
902 
903  m_xConditionFT->set_sensitive(false);
904  m_xConditionED->set_sensitive(false);
905  m_xDismiss->set_sensitive(false);
906  m_xCurName->set_sensitive(false);
907  m_xProtectCB->set_sensitive(false);
908  m_xPasswdCB->set_sensitive(false);
909  m_xHideCB->set_sensitive(false);
910  // edit in readonly sections
911  m_xEditInReadonlyCB->set_sensitive(false);
912  m_xEditInReadonlyCB->set_state(TRISTATE_FALSE);
913  m_xProtectCB->set_state(TRISTATE_FALSE);
914  m_xPasswdCB->set_active(false);
915  m_xHideCB->set_state(TRISTATE_FALSE);
916  m_xFileCB->set_active(false);
917  // otherwise the focus would be on HelpButton
918  m_xOK->grab_focus();
919  UseFileHdl(*m_xFileCB);
920 }
921 
922 // link CheckBox to file?
923 IMPL_LINK(SwEditRegionDlg, UseFileHdl, weld::Toggleable&, rButton, void)
924 {
925  if (!CheckPasswd(&rButton))
926  return;
927  bool bMulti = 1 < m_xTree->count_selected_rows();
928  bool bFile = rButton.get_active();
929  if (m_xTree->get_selected(nullptr))
930  {
931  m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
932  SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
933  bool bContent = pSectRepr->IsContent();
934  if( rButton.get_active() && bContent && rSh.HasSelection() )
935  {
936  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
937  VclMessageType::Question, VclButtonsType::YesNo,
938  SwResId(STR_QUERY_CONNECT)));
939  if (RET_NO == xQueryBox->run())
940  rButton.set_active( false );
941  }
942  if( bFile )
943  pSectRepr->SetContent(false);
944  else
945  {
946  pSectRepr->SetFile(u"");
947  pSectRepr->SetSubRegion(std::u16string_view());
948  pSectRepr->GetSectionData().SetLinkFilePassword(OUString());
949  }
950  return false;
951  });
952  m_xDDECB->set_sensitive(bFile && !bMulti);
953  m_xDDEFrame->set_sensitive(bFile && !bMulti);
954  if( bFile )
955  {
956  m_xProtectCB->set_state(TRISTATE_TRUE);
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 
1133 IMPL_LINK(SwEditRegionDlg, DDEHdl, weld::Toggleable&, rButton, void)
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(u"");
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(u"");
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 
1364 
1365  bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ;
1366  if(bWeb)
1367  {
1368  RemoveTabPage("notes");
1369  RemoveTabPage("indents");
1370  if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
1371  RemoveTabPage("columns");
1372  }
1373  SetCurPageId("section");
1374 }
1375 
1377 {
1378 }
1379 
1380 void SwInsertSectionTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
1381 {
1382  if (rId == "section")
1383  static_cast<SwInsertSectionTabPage&>(rPage).SetWrtShell(rWrtSh);
1384  else if (rId == "background")
1385  {
1386  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1387  aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
1388  rPage.PageCreated(aSet);
1389  }
1390  else if (rId == "columns")
1391  {
1393  static_cast<SwColumnPage&>(rPage).SetPageWidth(rSize.GetWidth());
1394  static_cast<SwColumnPage&>(rPage).ShowBalance(true);
1395  static_cast<SwColumnPage&>(rPage).SetInSection(true);
1396  }
1397  else if (rId == "indents")
1398  static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh);
1399 }
1400 
1402 {
1403  m_pSectionData.reset( new SwSectionData(rSect) );
1404 }
1405 
1407 {
1408  short nRet = SfxTabDialogController::Ok();
1409  OSL_ENSURE(m_pSectionData, "SwInsertSectionTabDialog: no SectionData?");
1410  const SfxItemSet* pOutputItemSet = GetOutputItemSet();
1411  rWrtSh.InsertSection(*m_pSectionData, pOutputItemSet);
1412  SfxViewFrame* pViewFrame = rWrtSh.GetView().GetViewFrame();
1413  uno::Reference< frame::XDispatchRecorder > xRecorder =
1414  pViewFrame->GetBindings().GetRecorder();
1415  if ( xRecorder.is() )
1416  {
1417  SfxRequest aRequest( pViewFrame, FN_INSERT_REGION);
1418  const SfxPoolItem* pCol;
1419  if(SfxItemState::SET == pOutputItemSet->GetItemState(RES_COL, false, &pCol))
1420  {
1421  aRequest.AppendItem(SfxUInt16Item(SID_ATTR_COLUMNS,
1422  static_cast<const SwFormatCol*>(pCol)->GetColumns().size()));
1423  }
1425  m_pSectionData->GetSectionName()));
1427  m_pSectionData->GetCondition()));
1429  m_pSectionData->IsHidden()));
1431  m_pSectionData->IsProtectFlag()));
1432  // edit in readonly sections
1434  m_pSectionData->IsEditInReadonlyFlag()));
1435 
1436  const OUString sLinkFileName( m_pSectionData->GetLinkFileName() );
1437  sal_Int32 n = 0;
1438  aRequest.AppendItem(SfxStringItem( FN_PARAM_1, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1439  aRequest.AppendItem(SfxStringItem( FN_PARAM_2, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1440  aRequest.AppendItem(SfxStringItem( FN_PARAM_3, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
1441  aRequest.Done();
1442  }
1443  return nRet;
1444 }
1445 
1447  : SfxTabPage(pPage, pController, "modules/swriter/ui/sectionpage.ui", "SectionPage", &rAttrSet)
1448  , m_pWrtSh(nullptr)
1449  , m_xCurName(m_xBuilder->weld_entry_tree_view("sectionnames", "sectionnames-entry",
1450  "sectionnames-list"))
1451  , m_xFileCB(m_xBuilder->weld_check_button("link"))
1452  , m_xDDECB(m_xBuilder->weld_check_button("dde"))
1453  , m_xDDECommandFT(m_xBuilder->weld_label("ddelabel"))
1454  , m_xFileNameFT(m_xBuilder->weld_label("filelabel"))
1455  , m_xFileNameED(m_xBuilder->weld_entry("filename"))
1456  , m_xFilePB(m_xBuilder->weld_button("selectfile"))
1457  , m_xSubRegionFT(m_xBuilder->weld_label("sectionlabel"))
1458  , m_xSubRegionED(m_xBuilder->weld_combo_box("sectionname"))
1459  , m_xProtectCB(m_xBuilder->weld_check_button("protect"))
1460  , m_xPasswdCB(m_xBuilder->weld_check_button("withpassword"))
1461  , m_xPasswdPB(m_xBuilder->weld_button("selectpassword"))
1462  , m_xHideCB(m_xBuilder->weld_check_button("hide"))
1463  , m_xConditionFT(m_xBuilder->weld_label("condlabel"))
1464  , m_xConditionED(new ConditionEdit(m_xBuilder->weld_entry("withcond")))
1465  // edit in readonly sections
1466  , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editable"))
1467 {
1468  m_xCurName->make_sorted();
1469  m_xCurName->set_height_request_by_rows(12);
1470  m_xSubRegionED->make_sorted();
1471 
1472  m_xProtectCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeProtectHdl));
1473  m_xPasswdCB->connect_toggled( LINK( this, SwInsertSectionTabPage, TogglePasswdHdl));
1474  m_xPasswdPB->connect_clicked( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
1475  m_xHideCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeHideHdl));
1476  m_xFileCB->connect_toggled( LINK( this, SwInsertSectionTabPage, UseFileHdl ));
1477  m_xFilePB->connect_clicked( LINK( this, SwInsertSectionTabPage, FileSearchHdl ));
1478  m_xCurName->connect_changed( LINK( this, SwInsertSectionTabPage, NameEditHdl));
1479  m_xDDECB->connect_toggled( LINK( this, SwInsertSectionTabPage, DDEHdl ));
1480  ChangeProtectHdl(*m_xProtectCB);
1481  m_xSubRegionED->set_entry_completion(true, true);
1482 }
1483 
1485 {
1486 }
1487 
1489 {
1490  m_pWrtSh = &rSh;
1491 
1492  bool bWeb = dynamic_cast<SwWebDocShell*>( m_pWrtSh->GetView().GetDocShell() )!= nullptr;
1493  if(bWeb)
1494  {
1495  m_xHideCB->hide();
1496  m_xConditionED->hide();
1497  m_xConditionFT->hide();
1498  m_xDDECB->hide();
1499  m_xDDECommandFT->hide();
1500  }
1501 
1503 
1504  SwSectionData *const pSectionData =
1506  ->GetSectionData();
1507  if (pSectionData) // something set?
1508  {
1509  const OUString sSectionName(pSectionData->GetSectionName());
1510  m_xCurName->set_entry_text(rSh.GetUniqueSectionName(&sSectionName));
1511  m_xProtectCB->set_active( pSectionData->IsProtectFlag() );
1512  ChangeProtectHdl(*m_xProtectCB);
1513  m_sFileName = pSectionData->GetLinkFileName();
1514  m_sFilePasswd = pSectionData->GetLinkFilePassword();
1515  m_xFileCB->set_active( !m_sFileName.isEmpty() );
1516  m_xFileNameED->set_text( m_sFileName );
1517  UseFileHdl(*m_xFileCB);
1518  }
1519  else
1520  {
1521  m_xCurName->set_entry_text(rSh.GetUniqueSectionName());
1522  }
1523 }
1524 
1526 {
1527  SwSectionData aSection(SectionType::Content, m_xCurName->get_active_text());
1528  aSection.SetCondition(m_xConditionED->get_text());
1529  bool bProtected = m_xProtectCB->get_active();
1530  aSection.SetProtectFlag(bProtected);
1531  aSection.SetHidden(m_xHideCB->get_active());
1532  // edit in readonly sections
1533  aSection.SetEditInReadonlyFlag(m_xEditInReadonlyCB->get_active());
1534 
1535  if(bProtected)
1536  {
1537  aSection.SetPassword(m_aNewPasswd);
1538  }
1539  const OUString sFileName = m_xFileNameED->get_text();
1540  const OUString sSubRegion = m_xSubRegionED->get_active_text();
1541  bool bDDe = m_xDDECB->get_active();
1542  if (m_xFileCB->get_active() && (!sFileName.isEmpty() || !sSubRegion.isEmpty() || bDDe))
1543  {
1544  OUString aLinkFile;
1545  if( bDDe )
1546  {
1547  aLinkFile = SwSectionData::CollapseWhiteSpaces(sFileName);
1548  sal_Int32 nPos = 0;
1549  aLinkFile = aLinkFile.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1550  if (nPos>=0)
1551  {
1552  aLinkFile = aLinkFile.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1553  }
1554  }
1555  else
1556  {
1557  if(!sFileName.isEmpty())
1558  {
1559  SfxMedium* pMedium = m_pWrtSh->GetView().GetDocShell()->GetMedium();
1560  INetURLObject aAbs;
1561  if( pMedium )
1562  aAbs = pMedium->GetURLObject();
1563  aLinkFile = URIHelper::SmartRel2Abs(
1564  aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
1565  aSection.SetLinkFilePassword( m_sFilePasswd );
1566  }
1567 
1568  aLinkFile += OUStringChar(sfx2::cTokenSeparator) + m_sFilterName
1569  + OUStringChar(sfx2::cTokenSeparator) + sSubRegion;
1570  }
1571 
1572  aSection.SetLinkFileName(aLinkFile);
1573  if (!aLinkFile.isEmpty())
1574  {
1575  aSection.SetType( m_xDDECB->get_active() ?
1578  }
1579  }
1580  static_cast<SwInsertSectionTabDialog*>(GetDialogController())->SetSectionData(aSection);
1581  return true;
1582 }
1583 
1585 {
1586 }
1587 
1588 std::unique_ptr<SfxTabPage> SwInsertSectionTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
1589  const SfxItemSet* rAttrSet)
1590 {
1591  return std::make_unique<SwInsertSectionTabPage>(pPage, pController, *rAttrSet);
1592 }
1593 
1595 {
1596  bool bHide = rBox.get_active();
1597  m_xConditionED->set_sensitive(bHide);
1598  m_xConditionFT->set_sensitive(bHide);
1599 }
1600 
1601 IMPL_LINK(SwInsertSectionTabPage, ChangeProtectHdl, weld::Toggleable&, rBox, void)
1602 {
1603  bool bCheck = rBox.get_active();
1604  m_xPasswdCB->set_sensitive(bCheck);
1605  m_xPasswdPB->set_sensitive(bCheck);
1606 }
1607 
1609 {
1610  bool bSet = bChange ? bChange : m_xPasswdCB->get_active();
1611  if (bSet)
1612  {
1613  if(!m_aNewPasswd.hasElements() || bChange)
1614  {
1615  SfxPasswordDialog aPasswdDlg(GetFrameWeld());
1616  aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
1617  if (RET_OK == aPasswdDlg.run())
1618  {
1619  const OUString sNewPasswd(aPasswdDlg.GetPassword());
1620  if (aPasswdDlg.GetConfirm() == sNewPasswd)
1621  {
1623  }
1624  else
1625  {
1626  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
1627  VclMessageType::Info, VclButtonsType::Ok,
1628  SwResId(STR_WRONG_PASSWD_REPEAT)));
1629  xInfoBox->run();
1630  }
1631  }
1632  else if(!bChange)
1633  m_xPasswdCB->set_active(false);
1634  }
1635  }
1636  else
1637  m_aNewPasswd.realloc(0);
1638 }
1639 
1641 {
1642  ChangePasswd(false);
1643 }
1644 
1646 {
1647  ChangePasswd(true);
1648 }
1649 
1650 
1652 {
1653  const OUString aName = m_xCurName->get_active_text();
1654  GetDialogController()->GetOKButton().set_sensitive(!aName.isEmpty() &&
1655  m_xCurName->find_text(aName) == -1);
1656 }
1657 
1659 {
1660  if (rButton.get_active())
1661  {
1662  if (m_pWrtSh->HasSelection())
1663  {
1664  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
1665  VclMessageType::Question, VclButtonsType::YesNo,
1666  SwResId(STR_QUERY_CONNECT)));
1667  if (RET_NO == xQueryBox->run())
1668  rButton.set_active(false);
1669  }
1670  }
1671 
1672  bool bFile = rButton.get_active();
1673  m_xFileNameFT->set_sensitive(bFile);
1674  m_xFileNameED->set_sensitive(bFile);
1675  m_xFilePB->set_sensitive(bFile);
1676  m_xSubRegionFT->set_sensitive(bFile);
1677  m_xSubRegionED->set_sensitive(bFile);
1678  m_xDDECommandFT->set_sensitive(bFile);
1679  m_xDDECB->set_sensitive(bFile);
1680  if (bFile)
1681  {
1682  m_xFileNameED->grab_focus();
1683  m_xProtectCB->set_active(true);
1684  ChangeProtectHdl(*m_xProtectCB);
1685  }
1686  else
1687  {
1688  m_xDDECB->set_active(false);
1689  DDEHdl(*m_xDDECB);
1690  }
1691 }
1692 
1694 {
1695  m_pDocInserter.reset(new ::sfx2::DocumentInserter(GetFrameWeld(), "swriter"));
1696  m_pDocInserter->StartExecuteModal( LINK( this, SwInsertSectionTabPage, DlgClosedHdl ) );
1697 }
1698 
1700 {
1701  bool bDDE = rButton.get_active();
1702  bool bFile = m_xFileCB->get_active();
1703  m_xFilePB->set_sensitive(!bDDE && bFile);
1704  if (bDDE)
1705  {
1706  m_xFileNameFT->hide();
1707  m_xDDECommandFT->set_sensitive(bDDE);
1708  m_xDDECommandFT->show();
1709  m_xSubRegionFT->hide();
1710  m_xSubRegionED->hide();
1711  m_xFileNameED->set_accessible_name(m_xDDECommandFT->get_label());
1712  }
1713  else
1714  {
1715  m_xDDECommandFT->hide();
1716  m_xFileNameFT->set_sensitive(bFile);
1717  m_xFileNameFT->show();
1718  m_xSubRegionFT->show();
1719  m_xSubRegionED->show();
1720  m_xSubRegionED->set_sensitive(bFile);
1721  m_xFileNameED->set_accessible_name(m_xFileNameFT->get_label());
1722  }
1723 }
1724 
1725 IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void )
1726 {
1727  if ( _pFileDlg->GetError() == ERRCODE_NONE )
1728  {
1729  std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium("sglobal"));
1730  if ( pMedium )
1731  {
1732  m_sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE );
1733  m_sFilterName = pMedium->GetFilter()->GetFilterName();
1734  const SfxPoolItem* pItem;
1735  if ( SfxItemState::SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) )
1736  m_sFilePasswd = static_cast<const SfxStringItem*>(pItem)->GetValue();
1737  m_xFileNameED->set_text( INetURLObject::decode(
1739  ::lcl_ReadSections(*pMedium, *m_xSubRegionED);
1740  }
1741  }
1742  else
1743  {
1744  m_sFilterName.clear();
1745  m_sFilePasswd.clear();
1746  }
1747 }
1748 
1750  : SfxTabPage(pPage, pController, "modules/swriter/ui/footnotesendnotestabpage.ui", "FootnotesEndnotesTabPage", &rAttrSet)
1751  , m_xFootnoteNtAtTextEndCB(m_xBuilder->weld_check_button("ftnntattextend"))
1752  , m_xFootnoteNtNumCB(m_xBuilder->weld_check_button("ftnntnum"))
1753  , m_xFootnoteOffsetLbl(m_xBuilder->weld_label("ftnoffset_label"))
1754  , m_xFootnoteOffsetField(m_xBuilder->weld_spin_button("ftnoffset"))
1755  , m_xFootnoteNtNumFormatCB(m_xBuilder->weld_check_button("ftnntnumfmt"))
1756  , m_xFootnotePrefixFT(m_xBuilder->weld_label("ftnprefix_label"))
1757  , m_xFootnotePrefixED(m_xBuilder->weld_entry("ftnprefix"))
1758  , m_xFootnoteNumViewBox(new SwNumberingTypeListBox(m_xBuilder->weld_combo_box("ftnnumviewbox")))
1759  , m_xFootnoteSuffixFT(m_xBuilder->weld_label("ftnsuffix_label"))
1760  , m_xFootnoteSuffixED(m_xBuilder->weld_entry("ftnsuffix"))
1761  , m_xEndNtAtTextEndCB(m_xBuilder->weld_check_button("endntattextend"))
1762  , m_xEndNtNumCB(m_xBuilder->weld_check_button("endntnum"))
1763  , m_xEndOffsetLbl(m_xBuilder->weld_label("endoffset_label"))
1764  , m_xEndOffsetField(m_xBuilder->weld_spin_button("endoffset"))
1765  , m_xEndNtNumFormatCB(m_xBuilder->weld_check_button("endntnumfmt"))
1766  , m_xEndPrefixFT(m_xBuilder->weld_label("endprefix_label"))
1767  , m_xEndPrefixED(m_xBuilder->weld_entry("endprefix"))
1768  , m_xEndNumViewBox(new SwNumberingTypeListBox(m_xBuilder->weld_combo_box("endnumviewbox")))
1769  , m_xEndSuffixFT(m_xBuilder->weld_label("endsuffix_label"))
1770  , m_xEndSuffixED(m_xBuilder->weld_entry("endsuffix"))
1771 {
1774 
1776  m_xFootnoteNtAtTextEndCB->connect_toggled( aLk );
1777  m_xFootnoteNtNumCB->connect_toggled( aLk );
1778  m_xEndNtAtTextEndCB->connect_toggled( aLk );
1779  m_xEndNtNumCB->connect_toggled( aLk );
1780  m_xFootnoteNtNumFormatCB->connect_toggled( aLk );
1781  m_xEndNtNumFormatCB->connect_toggled( aLk );
1782 }
1783 
1785 {
1786 }
1787 
1789 {
1790  SwFormatFootnoteAtTextEnd aFootnote( m_xFootnoteNtAtTextEndCB->get_active()
1791  ? ( m_xFootnoteNtNumCB->get_active()
1792  ? ( m_xFootnoteNtNumFormatCB->get_active()
1795  : FTNEND_ATTXTEND )
1796  : FTNEND_ATPGORDOCEND );
1797 
1798  switch( aFootnote.GetValue() )
1799  {
1801  aFootnote.SetNumType( m_xFootnoteNumViewBox->GetSelectedNumberingType() );
1802  aFootnote.SetPrefix( m_xFootnotePrefixED->get_text().replaceAll("\\t", "\t") ); // fdo#65666
1803  aFootnote.SetSuffix( m_xFootnoteSuffixED->get_text().replaceAll("\\t", "\t") );
1804  [[fallthrough]];
1805 
1807  aFootnote.SetOffset( static_cast< sal_uInt16 >( m_xFootnoteOffsetField->get_value()-1 ) );
1808  break;
1809  default: break;
1810  }
1811 
1812  SwFormatEndAtTextEnd aEnd( m_xEndNtAtTextEndCB->get_active()
1813  ? ( m_xEndNtNumCB->get_active()
1814  ? ( m_xEndNtNumFormatCB->get_active()
1817  : FTNEND_ATTXTEND )
1818  : FTNEND_ATPGORDOCEND );
1819 
1820  switch( aEnd.GetValue() )
1821  {
1823  aEnd.SetNumType( m_xEndNumViewBox->GetSelectedNumberingType() );
1824  aEnd.SetPrefix( m_xEndPrefixED->get_text().replaceAll("\\t", "\t") );
1825  aEnd.SetSuffix( m_xEndSuffixED->get_text().replaceAll("\\t", "\t") );
1826  [[fallthrough]];
1827 
1829  aEnd.SetOffset( static_cast< sal_uInt16 >( m_xEndOffsetField->get_value()-1 ) );
1830  break;
1831  default: break;
1832  }
1833 
1834  rSet->Put( aFootnote );
1835  rSet->Put( aEnd );
1836 
1837  return true;
1838 }
1839 
1841  const SwFormatFootnoteEndAtTextEnd& rAttr )
1842 {
1843  weld::CheckButton *pNtAtTextEndCB, *pNtNumCB, *pNtNumFormatCB;
1844  weld::Label *pPrefixFT, *pSuffixFT;
1845  weld::Entry *pPrefixED, *pSuffixED;
1846  SwNumberingTypeListBox *pNumViewBox;
1847  weld::Label *pOffsetText;
1848  weld::SpinButton *pOffsetField;
1849 
1850  if( bFootnote )
1851  {
1852  pNtAtTextEndCB = m_xFootnoteNtAtTextEndCB.get();
1853  pNtNumCB = m_xFootnoteNtNumCB.get();
1854  pNtNumFormatCB = m_xFootnoteNtNumFormatCB.get();
1855  pPrefixFT = m_xFootnotePrefixFT.get();
1856  pPrefixED = m_xFootnotePrefixED.get();
1857  pSuffixFT = m_xFootnoteSuffixFT.get();
1858  pSuffixED = m_xFootnoteSuffixED.get();
1859  pNumViewBox = m_xFootnoteNumViewBox.get();
1860  pOffsetText = m_xFootnoteOffsetLbl.get();
1861  pOffsetField = m_xFootnoteOffsetField.get();
1862  }
1863  else
1864  {
1865  pNtAtTextEndCB = m_xEndNtAtTextEndCB.get();
1866  pNtNumCB = m_xEndNtNumCB.get();
1867  pNtNumFormatCB = m_xEndNtNumFormatCB.get();
1868  pPrefixFT = m_xEndPrefixFT.get();
1869  pPrefixED = m_xEndPrefixED.get();
1870  pSuffixFT = m_xEndSuffixFT.get();
1871  pSuffixED = m_xEndSuffixED.get();
1872  pNumViewBox = m_xEndNumViewBox.get();
1873  pOffsetText = m_xEndOffsetLbl.get();
1874  pOffsetField = m_xEndOffsetField.get();
1875  }
1876 
1877  const sal_uInt16 eState = rAttr.GetValue();
1878  switch( eState )
1879  {
1881  pNtNumFormatCB->set_state( TRISTATE_TRUE );
1882  [[fallthrough]];
1883 
1885  pNtNumCB->set_state( TRISTATE_TRUE );
1886  [[fallthrough]];
1887 
1888  case FTNEND_ATTXTEND:
1889  pNtAtTextEndCB->set_state( TRISTATE_TRUE );
1890  // no break;
1891  }
1892 
1893  pNumViewBox->SelectNumberingType( rAttr.GetNumType() );
1894  pOffsetField->set_value( rAttr.GetOffset() + 1 );
1895  pPrefixED->set_text( rAttr.GetPrefix().replaceAll("\t", "\\t") );
1896  pSuffixED->set_text( rAttr.GetSuffix().replaceAll("\t", "\\t") );
1897 
1898  switch( eState )
1899  {
1900  case FTNEND_ATPGORDOCEND:
1901  pNtNumCB->set_sensitive( false );
1902  [[fallthrough]];
1903 
1904  case FTNEND_ATTXTEND:
1905  pNtNumFormatCB->set_sensitive( false );
1906  pOffsetField->set_sensitive( false );
1907  pOffsetText->set_sensitive( false );
1908  [[fallthrough]];
1909 
1911  pNumViewBox->set_sensitive( false );
1912  pPrefixFT->set_sensitive( false );
1913  pPrefixED->set_sensitive( false );
1914  pSuffixFT->set_sensitive( false );
1915  pSuffixED->set_sensitive( false );
1916  // no break;
1917  }
1918 }
1919 
1921 {
1922  ResetState( true, rSet->Get( RES_FTN_AT_TXTEND, false ));
1923  ResetState( false, rSet->Get( RES_END_AT_TXTEND, false ));
1924 }
1925 
1926 std::unique_ptr<SfxTabPage> SwSectionFootnoteEndTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
1927  const SfxItemSet* rAttrSet)
1928 {
1929  return std::make_unique<SwSectionFootnoteEndTabPage>(pPage, pController, *rAttrSet);
1930 }
1931 
1933 {
1934  bool bFoot = m_xFootnoteNtAtTextEndCB.get() == &rBox || m_xFootnoteNtNumCB.get() == &rBox ||
1935  m_xFootnoteNtNumFormatCB.get() == &rBox ;
1936 
1937  weld::CheckButton *pNumBox, *pNumFormatBox, *pEndBox;
1938  SwNumberingTypeListBox* pNumViewBox;
1939  weld::Label *pOffsetText;
1940  weld::SpinButton *pOffsetField;
1941  weld::Label *pPrefixFT, *pSuffixFT;
1942  weld::Entry *pPrefixED, *pSuffixED;
1943 
1944  if( bFoot )
1945  {
1946  pEndBox = m_xFootnoteNtAtTextEndCB.get();
1947  pNumBox = m_xFootnoteNtNumCB.get();
1948  pNumFormatBox = m_xFootnoteNtNumFormatCB.get();
1949  pNumViewBox = m_xFootnoteNumViewBox.get();
1950  pOffsetText = m_xFootnoteOffsetLbl.get();
1951  pOffsetField = m_xFootnoteOffsetField.get();
1952  pPrefixFT = m_xFootnotePrefixFT.get();
1953  pSuffixFT = m_xFootnoteSuffixFT.get();
1954  pPrefixED = m_xFootnotePrefixED.get();
1955  pSuffixED = m_xFootnoteSuffixED.get();
1956  }
1957  else
1958  {
1959  pEndBox = m_xEndNtAtTextEndCB.get();
1960  pNumBox = m_xEndNtNumCB.get();
1961  pNumFormatBox = m_xEndNtNumFormatCB.get();
1962  pNumViewBox = m_xEndNumViewBox.get();
1963  pOffsetText = m_xEndOffsetLbl.get();
1964  pOffsetField = m_xEndOffsetField.get();
1965  pPrefixFT = m_xEndPrefixFT.get();
1966  pSuffixFT = m_xEndSuffixFT.get();
1967  pPrefixED = m_xEndPrefixED.get();
1968  pSuffixED = m_xEndSuffixED.get();
1969  }
1970 
1971  bool bEnableAtEnd = TRISTATE_TRUE == pEndBox->get_state();
1972  bool bEnableNum = bEnableAtEnd && TRISTATE_TRUE == pNumBox->get_state();
1973  bool bEnableNumFormat = bEnableNum && TRISTATE_TRUE == pNumFormatBox->get_state();
1974 
1975  pNumBox->set_sensitive( bEnableAtEnd );
1976  pOffsetText->set_sensitive( bEnableNum );
1977  pOffsetField->set_sensitive( bEnableNum );
1978  pNumFormatBox->set_sensitive( bEnableNum );
1979  pNumViewBox->set_sensitive( bEnableNumFormat );
1980  pPrefixED->set_sensitive( bEnableNumFormat );
1981  pSuffixED->set_sensitive( bEnableNumFormat );
1982  pPrefixFT->set_sensitive( bEnableNumFormat );
1983  pSuffixFT->set_sensitive( bEnableNumFormat );
1984 }
1985 
1987  weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
1988  : SfxTabDialogController(pParent, "modules/swriter/ui/formatsectiondialog.ui",
1989  "FormatSectionDialog", &rSet)
1990  , rWrtSh(rSh)
1991 {
1993  AddTabPage("columns", SwColumnPage::Create, nullptr);
1994  AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
1996  AddTabPage("indents", SwSectionIndentTabPage::Create, nullptr);
1997 
1999  bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ;
2000  if(bWeb)
2001  {
2002  RemoveTabPage("notes");
2003  RemoveTabPage("indents");
2004  if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
2005  RemoveTabPage("columns");
2006  }
2007 }
2008 
2010 {
2011 }
2012 
2013 void SwSectionPropertyTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
2014 {
2015  if (rId == "background")
2016  {
2017  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
2018  aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
2019  rPage.PageCreated(aSet);
2020  }
2021  else if (rId == "columns")
2022  {
2023  static_cast<SwColumnPage&>(rPage).ShowBalance(true);
2024  static_cast<SwColumnPage&>(rPage).SetInSection(true);
2025  }
2026  else if (rId == "indents")
2027  static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh);
2028 }
2029 
2031  : SfxTabPage(pPage, pController, "modules/swriter/ui/indentpage.ui", "IndentPage", &rAttrSet)
2032  , m_xBeforeMF(m_xBuilder->weld_metric_spin_button("before", FieldUnit::CM))
2033  , m_xAfterMF(m_xBuilder->weld_metric_spin_button("after", FieldUnit::CM))
2034  , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin))
2035 {
2036  Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwSectionIndentTabPage, IndentModifyHdl);
2037  m_xBeforeMF->connect_value_changed(aLk);
2038  m_xAfterMF->connect_value_changed(aLk);
2039 }
2040 
2042 {
2043 }
2044 
2046 {
2047  if (m_xBeforeMF->get_value_changed_from_saved() || m_xAfterMF->get_value_changed_from_saved())
2048  {
2049  SvxLRSpaceItem aLRSpace(
2050  m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)) ,
2051  m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)), 0, 0, RES_LR_SPACE);
2052  rSet->Put(aLRSpace);
2053  }
2054  return true;
2055 }
2056 
2058 {
2059  //this page doesn't show up in HTML mode
2060  FieldUnit aMetric = ::GetDfltMetric(false);
2061  SetFieldUnit(*m_xBeforeMF, aMetric);
2062  SetFieldUnit(*m_xAfterMF , aMetric);
2063 
2064  SfxItemState eItemState = rSet->GetItemState( RES_LR_SPACE );
2065  if ( eItemState >= SfxItemState::DEFAULT )
2066  {
2067  const SvxLRSpaceItem& rSpace =
2068  rSet->Get( RES_LR_SPACE );
2069 
2070  m_xBeforeMF->set_value(m_xBeforeMF->normalize(rSpace.GetLeft()), FieldUnit::TWIP);
2071  m_xAfterMF->set_value(m_xAfterMF->normalize(rSpace.GetRight()), FieldUnit::TWIP);
2072  }
2073  else
2074  {
2075  m_xBeforeMF->set_text("");
2076  m_xAfterMF->set_text("");
2077  }
2078  m_xBeforeMF->save_value();
2079  m_xAfterMF->save_value();
2080  IndentModifyHdl(*m_xBeforeMF);
2081 }
2082 
2083 std::unique_ptr<SfxTabPage> SwSectionIndentTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
2084 {
2085  return std::make_unique<SwSectionIndentTabPage>(pPage, pController, *rAttrSet);
2086 }
2087 
2089 {
2090  //set sensible values at the preview
2091  m_aPreviewWin.SetAdjust(SvxAdjust::Block);
2092  m_aPreviewWin.SetLastLine(SvxAdjust::Block);
2093  const SwRect& rPageRect = rSh.GetAnyCurRect( CurRectType::Page );
2094  Size aPageSize(rPageRect.Width(), rPageRect.Height());
2095  m_aPreviewWin.SetSize(aPageSize);
2096 }
2097 
2099 {
2100  m_aPreviewWin.SetLeftMargin(m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)));
2101  m_aPreviewWin.SetRightMargin(m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)));
2102  m_aPreviewWin.Invalidate();
2103 }
2104 
2105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~SwEditRegionDlg() override
Definition: uiregionsw.cxx:528
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:126
SwFormatFootnoteAtTextEnd & GetFootnoteNtAtEnd()
Definition: uiregionsw.cxx:166
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:447
FieldUnit
#define FN_PARAM_REGION_EDIT_IN_READONLY
Definition: cmdid.h:777
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:153
std::unique_ptr< weld::CheckButton > m_xFootnoteNtNumFormatCB
Definition: regionsw.hxx:177
void SetType(SectionType const eNew)
Definition: section.hxx:95
void set_state(TriState eState)
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
static constexpr auto Items
bool IsContent() const
Definition: uiregionsw.cxx:179
std::unique_ptr< SvxBrushItem > m_Brush
Definition: uiregionsw.cxx:147
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:723
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:90
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:186
SwEditRegionDlg(weld::Window *pParent, SwWrtShell &rWrtSh)
Definition: uiregionsw.cxx:313
std::shared_ptr< SvxLRSpaceItem > m_LRSpaceItem
Definition: uiregionsw.cxx:152
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:517
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:167
const ContentProperties & rData
size_t GetArrPos() const
Definition: uiregionsw.cxx:172
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
static OUString decode(std::u16string_view rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
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
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:162
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:286
Array of Undo-history.
Definition: docary.hxx:192
std::unique_ptr< weld::CheckButton > m_xPasswdCB
Definition: regionsw.hxx:69
Used by the UI to modify the document model.
Definition: wrtsh.hxx:93
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
RET_NO
void SetWrtShell(SwWrtShell const &rSh)
virtual short Ok()
IMPL_LINK(SwEditRegionDlg, GetFirstEntryHdl, weld::TreeView &, rBox, void)
Definition: uiregionsw.cxx:562
bool IsStorage()
std::unique_ptr< SwNumberingTypeListBox > m_xEndNumViewBox
Definition: regionsw.hxx:190
std::unique_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:742
const SwView & GetView() const
Definition: wrtsh.hxx:431
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
bool m_bContent
Definition: uiregionsw.cxx:155
std::unique_ptr< weld::TreeView > m_xTree
Definition: regionsw.hxx:58
SwFormatCol m_Col
Definition: uiregionsw.cxx:146
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:189
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:2665
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:111
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
#define FN_PARAM_REGION_PROTECT
Definition: cmdid.h:776
virtual bool FillItemSet(SfxItemSet *) override
SwInsertSectionTabDialog(weld::Window *pParent, const SfxItemSet &rSet, SwWrtShell &rSh)
SwFormatNoBalancedColumns m_Balance
Definition: uiregionsw.cxx:150
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
SwFormatFootnoteAtTextEnd m_FootnoteNtAtEnd
Definition: uiregionsw.cxx:148
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:763
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:343
void SelectSection(std::u16string_view rSectionName)
Definition: uiregionsw.cxx:540
uno::Sequence< sal_Int8 > & GetTempPasswd()
Definition: uiregionsw.cxx:185
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:190
std::unique_ptr< weld::Entry > m_xCurName
Definition: regionsw.hxx:57
std::unique_ptr< SvxBrushItem > & GetBackground()
Definition: uiregionsw.cxx:165
SfxBindings & GetBindings()
std::unique_ptr< weld::CheckButton > m_xProtectCB
Definition: regionsw.hxx:68
std::shared_ptr< SvxFrameDirectionItem > m_FrameDirItem
Definition: uiregionsw.cxx:151
TRISTATE_FALSE
sal_uInt16 Count() const
SwFormatEndAtTextEnd m_EndNtAtEnd
Definition: uiregionsw.cxx:149
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 set_active(bool active)=0
virtual void select_region(int nStartPos, int nEndPos)=0
void ShowExtras(SfxShowExtras nExtras)
bool IsSelected() const
Definition: uiregionsw.cxx:183
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:170
float u
size
bool SelectNumberingType(SvxNumType nType)
std::unique_ptr< weld::Button > m_xDismiss
Definition: regionsw.hxx:78
SvxNumType GetNumType() const
Definition: fmtftntx.hxx:69
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:1127
virtual OUString get_text() const =0
void SetSubRegion(std::u16string_view rSubRegion)
Definition: uiregionsw.cxx:262
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:158
std::unique_ptr< weld::MetricSpinButton > m_xBeforeMF
Definition: regionsw.hxx:211
Rect of current page.
void SetContent(bool const bValue)
Definition: uiregionsw.cxx:180
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:79
std::unique_ptr< weld::Button > m_xPasswdPB
Definition: regionsw.hxx:139
void SetFile(std::u16string_view rFile)
Definition: uiregionsw.cxx:212
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:774
SfxItemState
weld::Entry & rEdit
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
TriState get_state() const
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
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.
OUString aName
RET_OK
std::unique_ptr< SwNumberingTypeListBox > m_xFootnoteNumViewBox
Definition: regionsw.hxx:180
SwFormatCol & GetCol()
Definition: uiregionsw.cxx:164
SwSectionData m_SectionData
Definition: uiregionsw.cxx:145
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:773
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:182
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:169
void SetLastLine(SvxAdjust eNew)
void SetFilter(std::u16string_view rFilter)
Definition: uiregionsw.cxx:240
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:163
virtual size_t GetSectionList(SfxMedium &rMedium, std::vector< OUString > &rStrings) const
Definition: shellio.cxx:637
static SVL_DLLPUBLIC bool CompareHashPassword(const css::uno::Sequence< sal_Int8 > &rOldPassHash, const OUString &sNewPass)
void AppendItem(const SfxPoolItem &)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: column.cxx:588
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:157
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:669
OUString GetSubRegion() const
Definition: uiregionsw.cxx:304
SwFormatNoBalancedColumns & GetBalance()
Definition: uiregionsw.cxx:168
void GetChildSections(SwSections &rArr, SectionSort eSort=SectionSort::Not, bool bAllSections=true) const
Definition: section.cxx:879
bool CheckPasswd(weld::Toggleable *pBox=nullptr)
Definition: uiregionsw.cxx:401
static OUString CollapseWhiteSpaces(const OUString &sName)
Definition: section.cxx:179
void SetWrtShell(SwWrtShell &rSh)
void Height(tools::Long nNew)
Definition: swrect.hxx:193
SwInsertSectionTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rAttrSet)
sal_uInt16 GetExportMode()
virtual bool get_active() const =0
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:775
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:911
const SvxLRSpaceItem & GetLRSpace(bool=true) const
Definition: frmatr.hxx:74
EnumT GetValue() const
OUString sId
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
SfxMedium * GetMedium() const