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 
62 using namespace ::com::sun::star;
63 
64 namespace {
65 
66 OUString BuildBitmap(bool bProtect, bool bHidden)
67 {
68  if (bProtect)
69  return bHidden ? OUString(RID_BMP_PROT_HIDE) : OUString(RID_BMP_PROT_NO_HIDE);
70  return bHidden ? OUString(RID_BMP_HIDE) : OUString(RID_BMP_NO_HIDE);
71 }
72 
73 }
74 
75 static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox );
76 
77 static void lcl_FillList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames, const SwSectionFormat* pNewFormat )
78 {
79  if( !pNewFormat )
80  {
81  const size_t nCount = rSh.GetSectionFormatCount();
82  for (size_t i = 0; i<nCount; i++)
83  {
84  SectionType eTmpType;
85  const SwSectionFormat* pFormat = &rSh.GetSectionFormat(i);
86  if( !pFormat->GetParent() &&
87  pFormat->IsInNodesArr() &&
88  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
89  && SectionType::ToxHeader != eTmpType )
90  {
91  const OUString sString(pFormat->GetSection()->GetSectionName());
92  if (pAvailNames)
93  pAvailNames->append_text(sString);
94  rSubRegions.append_text(sString);
95  lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
96  }
97  }
98  }
99  else
100  {
101  SwSections aTmpArr;
102  pNewFormat->GetChildSections(aTmpArr, SectionSort::Pos);
103  if( !aTmpArr.empty() )
104  {
105  SectionType eTmpType;
106  for( const auto pSect : aTmpArr )
107  {
108  const SwSectionFormat* pFormat = pSect->GetFormat();
109  if( pFormat->IsInNodesArr()&&
110  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
111  && SectionType::ToxHeader != eTmpType )
112  {
113  const OUString sString(pFormat->GetSection()->GetSectionName());
114  if (pAvailNames)
115  pAvailNames->append_text(sString);
116  rSubRegions.append_text(sString);
117  lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
118  }
119  }
120  }
121  }
122 }
123 
124 static void lcl_FillSubRegionList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames )
125 {
126  rSubRegions.clear();
127  lcl_FillList( rSh, rSubRegions, pAvailNames, nullptr );
128  IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
129  for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin();
130  ppMark != pMarkAccess->getBookmarksEnd();
131  ++ppMark)
132  {
133  const ::sw::mark::IMark* pBkmk = *ppMark;
134  if( pBkmk->IsExpanded() )
135  rSubRegions.append_text( pBkmk->GetName() );
136  }
137 }
138 
139 // user data class for region information
140 class SectRepr
141 {
142 private:
145  std::unique_ptr<SvxBrushItem> m_Brush;
149  std::shared_ptr<SvxFrameDirectionItem> m_FrameDirItem;
150  std::shared_ptr<SvxLRSpaceItem> m_LRSpaceItem;
151  const size_t m_nArrPos;
152  // shows, if maybe textcontent is in the region
153  bool m_bContent : 1;
154  // for multiselection, mark at first, then work with TreeListBox!
155  bool m_bSelected : 1;
156  uno::Sequence<sal_Int8> m_TempPasswd;
157 
158 public:
159  SectRepr(size_t nPos, SwSection& rSect);
160 
162  SwFormatCol& GetCol() { return m_Col; }
163  std::unique_ptr<SvxBrushItem>& GetBackground() { return m_Brush; }
167  std::shared_ptr<SvxFrameDirectionItem>& GetFrameDir() { return m_FrameDirItem; }
168  std::shared_ptr<SvxLRSpaceItem>& GetLRSpace() { return m_LRSpaceItem; }
169 
170  size_t GetArrPos() const { return m_nArrPos; }
171  OUString GetFile() const;
172  OUString GetSubRegion() const;
173  void SetFile(OUString const& rFile);
174  void SetFilter(OUString const& rFilter);
175  void SetSubRegion(OUString const& rSubRegion);
176 
177  bool IsContent() const { return m_bContent; }
178  void SetContent(bool const bValue) { m_bContent = bValue; }
179 
180  void SetSelected() { m_bSelected = true; }
181  bool IsSelected() const { return m_bSelected; }
182 
183  uno::Sequence<sal_Int8> & GetTempPasswd() { return m_TempPasswd; }
184  void SetTempPasswd(const uno::Sequence<sal_Int8> & rPasswd)
185  { m_TempPasswd = rPasswd; }
186 };
187 
188 SectRepr::SectRepr( size_t nPos, SwSection& rSect )
189  : m_SectionData( rSect )
190  , m_Brush(std::make_unique<SvxBrushItem>(RES_BACKGROUND))
192  , m_LRSpaceItem(std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE))
193  , m_nArrPos(nPos)
194  , m_bContent(m_SectionData.GetLinkFileName().isEmpty())
195  , m_bSelected(false)
196 {
197  SwSectionFormat *pFormat = rSect.GetFormat();
198  if( pFormat )
199  {
200  m_Col = pFormat->GetCol();
201  m_Brush = pFormat->makeBackgroundBrushItem();
203  m_EndNtAtEnd = pFormat->GetEndAtTextEnd();
205  m_FrameDirItem.reset(pFormat->GetFrameDir().Clone());
206  m_LRSpaceItem.reset(pFormat->GetLRSpace().Clone());
207  }
208 }
209 
210 void SectRepr::SetFile( const OUString& rFile )
211 {
212  OUString sNewFile( INetURLObject::decode( rFile,
214  const OUString sOldFileName( m_SectionData.GetLinkFileName() );
215  const OUString sSub( sOldFileName.getToken( 2, sfx2::cTokenSeparator ) );
216 
217  if( !rFile.isEmpty() || !sSub.isEmpty() )
218  {
219  sNewFile += OUStringChar(sfx2::cTokenSeparator);
220  if( !rFile.isEmpty() ) // Filter only with FileName
221  sNewFile += sOldFileName.getToken( 1, sfx2::cTokenSeparator );
222 
223  sNewFile += OUStringChar(sfx2::cTokenSeparator) + sSub;
224  }
225 
226  m_SectionData.SetLinkFileName( sNewFile );
227 
228  if( !rFile.isEmpty() || !sSub.isEmpty() )
229  {
231  }
232  else
233  {
235  }
236 }
237 
238 void SectRepr::SetFilter( const OUString& rFilter )
239 {
240  OUString sNewFile;
241  const OUString sOldFileName( m_SectionData.GetLinkFileName() );
242  sal_Int32 nIdx{ 0 };
243  const OUString sFile( sOldFileName.getToken( 0, sfx2::cTokenSeparator, nIdx ) ); // token 0
244  const OUString sSub( sOldFileName.getToken( 1, sfx2::cTokenSeparator, nIdx ) ); // token 2
245 
246  if( !sFile.isEmpty() )
247  sNewFile = sFile + OUStringChar(sfx2::cTokenSeparator) +
248  rFilter + OUStringChar(sfx2::cTokenSeparator) + sSub;
249  else if( !sSub.isEmpty() )
250  sNewFile = OUStringChar(sfx2::cTokenSeparator) + OUStringChar(sfx2::cTokenSeparator) + sSub;
251 
252  m_SectionData.SetLinkFileName( sNewFile );
253 
254  if( !sNewFile.isEmpty() )
255  {
257  }
258 }
259 
260 void SectRepr::SetSubRegion(const OUString& rSubRegion)
261 {
262  OUString sNewFile;
263  sal_Int32 n(0);
264  const OUString sLinkFileName(m_SectionData.GetLinkFileName());
265  const OUString sOldFileName( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
266  const OUString sFilter( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
267 
268  if( !rSubRegion.isEmpty() || !sOldFileName.isEmpty() )
269  sNewFile = sOldFileName + OUStringChar(sfx2::cTokenSeparator) +
270  sFilter + OUStringChar(sfx2::cTokenSeparator) + rSubRegion;
271 
272  m_SectionData.SetLinkFileName( sNewFile );
273 
274  if( !rSubRegion.isEmpty() || !sOldFileName.isEmpty() )
275  {
277  }
278  else
279  {
281  }
282 }
283 
284 OUString SectRepr::GetFile() const
285 {
286  const OUString sLinkFile( m_SectionData.GetLinkFileName() );
287 
288  if( sLinkFile.isEmpty() )
289  {
290  return sLinkFile;
291  }
293  {
294  sal_Int32 n = 0;
295  return sLinkFile.replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n )
296  .replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n );
297  }
298  return INetURLObject::decode( sLinkFile.getToken( 0, sfx2::cTokenSeparator ),
300 }
301 
302 OUString SectRepr::GetSubRegion() const
303 {
304  const OUString sLinkFile( m_SectionData.GetLinkFileName() );
305  if( !sLinkFile.isEmpty() )
306  return sLinkFile.getToken( 2, sfx2::cTokenSeparator );
307  return sLinkFile;
308 }
309 
310 // dialog edit regions
312  : SfxDialogController(pParent, "modules/swriter/ui/editsectiondialog.ui",
313  "EditSectionDialog")
314  , m_bSubRegionsFilled(false)
315  , rSh(rWrtSh)
316  , bDontCheckPasswd(true)
317  , m_xCurName(m_xBuilder->weld_entry("curname"))
318  , m_xTree(m_xBuilder->weld_tree_view("tree"))
319  , m_xFileCB(m_xBuilder->weld_check_button("link"))
320  , m_xDDECB(m_xBuilder->weld_check_button("dde"))
321  , m_xDDEFrame(m_xBuilder->weld_widget("ddedepend"))
322  , m_xFileNameFT(m_xBuilder->weld_label("filenameft"))
323  , m_xDDECommandFT(m_xBuilder->weld_label("ddeft"))
324  , m_xFileNameED(m_xBuilder->weld_entry("filename"))
325  , m_xFilePB(m_xBuilder->weld_button("file"))
326  , m_xSubRegionFT(m_xBuilder->weld_label("sectionft"))
327  , m_xSubRegionED(m_xBuilder->weld_combo_box("section"))
328  , m_xProtectCB(m_xBuilder->weld_check_button("protect"))
329  , m_xPasswdCB(m_xBuilder->weld_check_button("withpassword"))
330  , m_xPasswdPB(m_xBuilder->weld_button("password"))
331  , m_xHideCB(m_xBuilder->weld_check_button("hide"))
332  , m_xConditionFT(m_xBuilder->weld_label("conditionft"))
333  , m_xConditionED(new ConditionEdit(m_xBuilder->weld_entry("condition")))
334  , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editinro"))
335  , m_xOK(m_xBuilder->weld_button("ok"))
336  , m_xOptionsPB(m_xBuilder->weld_button("options"))
337  , m_xDismiss(m_xBuilder->weld_button("remove"))
338  , m_xHideFrame(m_xBuilder->weld_widget("hideframe"))
339 {
340  m_xTree->set_size_request(-1, m_xTree->get_height_rows(16));
341  m_xFileCB->set_state(TRISTATE_FALSE);
342  m_xSubRegionED->make_sorted();
343  m_xProtectCB->set_state(TRISTATE_FALSE);
344  m_xHideCB->set_state(TRISTATE_FALSE);
345  // edit in readonly sections
347 
348  bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr;
349 
350  m_xTree->connect_changed(LINK(this, SwEditRegionDlg, GetFirstEntryHdl));
351  m_xCurName->connect_changed(LINK(this, SwEditRegionDlg, NameEditHdl));
352  m_xConditionED->connect_changed( LINK( this, SwEditRegionDlg, ConditionEditHdl));
353  m_xOK->connect_clicked( LINK( this, SwEditRegionDlg, OkHdl));
354  m_xPasswdCB->connect_toggled(LINK(this, SwEditRegionDlg, TogglePasswdHdl));
355  m_xPasswdPB->connect_clicked(LINK(this, SwEditRegionDlg, ChangePasswdHdl));
356  m_xHideCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeHideHdl));
357  // edit in readonly sections
358  m_xEditInReadonlyCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeEditInReadonlyHdl));
359 
360  m_xOptionsPB->connect_clicked(LINK(this, SwEditRegionDlg, OptionsHdl));
361  m_xProtectCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeProtectHdl));
362  m_xDismiss->connect_clicked( LINK( this, SwEditRegionDlg, ChangeDismissHdl));
363  m_xFileCB->connect_toggled(LINK(this, SwEditRegionDlg, UseFileHdl));
364  m_xFilePB->connect_clicked(LINK(this, SwEditRegionDlg, FileSearchHdl));
365  m_xFileNameED->connect_changed(LINK(this, SwEditRegionDlg, FileNameEntryHdl));
366  m_xSubRegionED->connect_changed(LINK(this, SwEditRegionDlg, FileNameComboBoxHdl));
367  m_xSubRegionED->connect_popup_toggled(LINK(this, SwEditRegionDlg, SubRegionEventHdl));
368  m_xSubRegionED->set_entry_completion(true, true);
369 
370  m_xTree->set_selection_mode(SelectionMode::Multiple);
371 
372  if (bWeb)
373  {
374  m_xDDECB->hide();
375  m_xHideFrame->hide();
376  m_xPasswdCB->hide();
377  }
378 
379  m_xDDECB->connect_toggled(LINK(this, SwEditRegionDlg, DDEHdl));
380 
382  RecurseList( nullptr, nullptr );
383 
384  // if the cursor is not in a region the first one will always be selected
385  if (!m_xTree->get_selected(nullptr))
386  {
387  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
388  if (m_xTree->get_iter_first(*xIter))
389  {
390  m_xTree->select(*xIter);
391  GetFirstEntryHdl(*m_xTree);
392  }
393  }
394 
395  m_xTree->show();
396  bDontCheckPasswd = false;
397 }
398 
400 {
401  if (bDontCheckPasswd)
402  return true;
403  bool bRet = true;
404 
405  m_xTree->selected_foreach([this, &bRet](weld::TreeIter& rEntry){
406  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
407  if (!pRepr->GetTempPasswd().hasElements()
408  && pRepr->GetSectionData().GetPassword().hasElements())
409  {
410  SfxPasswordDialog aPasswdDlg(m_xDialog.get());
411  bRet = false;
412  if (aPasswdDlg.run())
413  {
414  const OUString sNewPasswd(aPasswdDlg.GetPassword());
415  css::uno::Sequence <sal_Int8 > aNewPasswd;
416  SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
418  pRepr->GetSectionData().GetPassword(), sNewPasswd))
419  {
420  pRepr->SetTempPasswd(aNewPasswd);
421  bRet = true;
422  }
423  else
424  {
425  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
426  VclMessageType::Info, VclButtonsType::Ok,
427  SwResId(STR_WRONG_PASSWORD)));
428  xInfoBox->run();
429  }
430  }
431  }
432  return false;
433  });
434  if (!bRet && pBox)
435  {
436  //reset old button state
437  if (pBox->get_state() != TRISTATE_INDET)
438  pBox->set_active(!pBox->get_active());
439  }
440 
441  return bRet;
442 }
443 
444 // recursively look for child-sections
446 {
447  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
448  if (!pFormat)
449  {
450  const size_t nCount=rSh.GetSectionFormatCount();
451  for ( size_t n = 0; n < nCount; n++ )
452  {
453  SectionType eTmpType;
454  if( !( pFormat = &rSh.GetSectionFormat(n))->GetParent() &&
455  pFormat->IsInNodesArr() &&
456  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
457  && SectionType::ToxHeader != eTmpType )
458  {
459  SwSection *pSect = pFormat->GetSection();
460  SectRepr* pSectRepr = new SectRepr( n, *pSect );
461 
462  OUString sText(pSect->GetSectionName());
463  OUString sImage(BuildBitmap(pSect->IsProtect(),pSect->IsHidden()));
464  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr)));
465  m_xTree->insert(nullptr, -1, &sText, &sId, nullptr, nullptr, false, xIter.get());
466  m_xTree->set_image(*xIter, sImage);
467 
468  RecurseList(pFormat, xIter.get());
469  if (m_xTree->iter_has_child(*xIter))
470  m_xTree->expand_row(*xIter);
471  if (pCurrSect==pSect)
472  {
473  m_xTree->select(*xIter);
474  m_xTree->scroll_to_row(*xIter);
475  GetFirstEntryHdl(*m_xTree);
476  }
477  }
478  }
479  }
480  else
481  {
482  SwSections aTmpArr;
483  pFormat->GetChildSections(aTmpArr, SectionSort::Pos);
484  for( const auto pSect : aTmpArr )
485  {
486  SectionType eTmpType;
487  pFormat = pSect->GetFormat();
488  if( pFormat->IsInNodesArr() &&
489  (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent
490  && SectionType::ToxHeader != eTmpType )
491  {
492  SectRepr* pSectRepr=new SectRepr(
493  FindArrPos( pSect->GetFormat() ), *pSect );
494 
495  OUString sText(pSect->GetSectionName());
496  OUString sImage = BuildBitmap(pSect->IsProtect(), pSect->IsHidden());
497  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr)));
498  m_xTree->insert(pEntry, -1, &sText, &sId, nullptr, nullptr, false, xIter.get());
499  m_xTree->set_image(*xIter, sImage);
500 
501  RecurseList(pSect->GetFormat(), xIter.get());
502  if (m_xTree->iter_has_child(*xIter))
503  m_xTree->expand_row(*xIter);
504  if (pCurrSect==pSect)
505  {
506  m_xTree->select(*xIter);
507  m_xTree->scroll_to_row(*xIter);
508  GetFirstEntryHdl(*m_xTree);
509  }
510  }
511  }
512  }
513 }
514 
516 {
517  const size_t nCount=rSh.GetSectionFormatCount();
518  for ( size_t i = 0; i < nCount; i++ )
519  if ( pFormat == &rSh.GetSectionFormat(i) )
520  return i;
521 
522  OSL_FAIL("SectionFormat not on the list" );
523  return SIZE_MAX;
524 }
525 
527 {
528  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
529  if (m_xTree->get_iter_first(*xIter))
530  {
531  do
532  {
533  delete reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
534  } while (m_xTree->iter_next(*xIter));
535  }
536 }
537 
538 void SwEditRegionDlg::SelectSection(const OUString& rSectionName)
539 {
540  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
541  if (!m_xTree->get_iter_first(*xIter))
542  return;
543 
544  do
545  {
546  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
547  if (pRepr->GetSectionData().GetSectionName() == rSectionName)
548  {
549  m_xTree->unselect_all();
550  m_xTree->select(*xIter);
551  m_xTree->scroll_to_row(*xIter);
552  GetFirstEntryHdl(*m_xTree);
553  break;
554  }
555  } while (m_xTree->iter_next(*xIter));
556 }
557 
558 // selected entry in TreeListBox is showed in Edit window in case of
559 // multiselection some controls are disabled
560 IMPL_LINK(SwEditRegionDlg, GetFirstEntryHdl, weld::TreeView&, rBox, void)
561 {
562  bDontCheckPasswd = true;
563  std::unique_ptr<weld::TreeIter> xIter(rBox.make_iterator());
564  bool bEntry = rBox.get_selected(xIter.get());
565  m_xHideCB->set_sensitive(true);
566  // edit in readonly sections
567  m_xEditInReadonlyCB->set_sensitive(true);
568 
569  m_xProtectCB->set_sensitive(true);
570  m_xFileCB->set_sensitive(true);
571  css::uno::Sequence <sal_Int8> aCurPasswd;
572  if (1 < rBox.count_selected_rows())
573  {
574  m_xHideCB->set_state(TRISTATE_INDET);
575  m_xProtectCB->set_state(TRISTATE_INDET);
576  // edit in readonly sections
577  m_xEditInReadonlyCB->set_state(TRISTATE_INDET);
578  m_xFileCB->set_state(TRISTATE_INDET);
579 
580  bool bHiddenValid = true;
581  bool bProtectValid = true;
582  bool bConditionValid = true;
583  // edit in readonly sections
584  bool bEditInReadonlyValid = true;
585  bool bEditInReadonly = true;
586 
587  bool bHidden = true;
588  bool bProtect = true;
589  OUString sCondition;
590  bool bFirst = true;
591  bool bFileValid = true;
592  bool bFile = true;
593  bool bPasswdValid = true;
594 
595  m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
596  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
597  SwSectionData const& rData( pRepr->GetSectionData() );
598  if(bFirst)
599  {
600  sCondition = rData.GetCondition();
601  bHidden = rData.IsHidden();
602  bProtect = rData.IsProtectFlag();
603  // edit in readonly sections
604  bEditInReadonly = rData.IsEditInReadonlyFlag();
605 
606  bFile = (rData.GetType() != SectionType::Content);
607  aCurPasswd = rData.GetPassword();
608  }
609  else
610  {
611  if(sCondition != rData.GetCondition())
612  bConditionValid = false;
613  bHiddenValid = (bHidden == rData.IsHidden());
614  bProtectValid = (bProtect == rData.IsProtectFlag());
615  // edit in readonly sections
616  bEditInReadonlyValid =
617  (bEditInReadonly == rData.IsEditInReadonlyFlag());
618 
619  bFileValid = (bFile ==
620  (rData.GetType() != SectionType::Content));
621  bPasswdValid = (aCurPasswd == rData.GetPassword());
622  }
623  bFirst = false;
624  return false;
625  });
626 
627  m_xHideCB->set_state(!bHiddenValid ? TRISTATE_INDET :
628  bHidden ? TRISTATE_TRUE : TRISTATE_FALSE);
629  m_xProtectCB->set_state(!bProtectValid ? TRISTATE_INDET :
630  bProtect ? TRISTATE_TRUE : TRISTATE_FALSE);
631  // edit in readonly sections
632  m_xEditInReadonlyCB->set_state(!bEditInReadonlyValid ? TRISTATE_INDET :
633  bEditInReadonly ? TRISTATE_TRUE : TRISTATE_FALSE);
634 
635  m_xFileCB->set_state(!bFileValid ? TRISTATE_INDET :
636  bFile ? TRISTATE_TRUE : TRISTATE_FALSE);
637 
638  if (bConditionValid)
639  m_xConditionED->set_text(sCondition);
640  else
641  {
642  m_xConditionFT->set_sensitive(false);
643  m_xConditionED->set_sensitive(false);
644  }
645 
646  m_xCurName->set_sensitive(false);
647  m_xDDECB->set_sensitive(false);
648  m_xDDEFrame->set_sensitive(false);
649  m_xOptionsPB->set_sensitive(false);
650  bool bPasswdEnabled = m_xProtectCB->get_state() == TRISTATE_TRUE;
651  m_xPasswdCB->set_sensitive(bPasswdEnabled);
652  m_xPasswdPB->set_sensitive(bPasswdEnabled);
653  if(!bPasswdValid)
654  {
655  rBox.get_selected(xIter.get());
656  rBox.unselect_all();
657  rBox.select(*xIter);
658  GetFirstEntryHdl(rBox);
659  return;
660  }
661  else
662  m_xPasswdCB->set_active(aCurPasswd.hasElements());
663  }
664  else if (bEntry )
665  {
666  m_xCurName->set_sensitive(true);
667  m_xOptionsPB->set_sensitive(true);
668  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
669  SwSectionData const& rData( pRepr->GetSectionData() );
670  m_xConditionED->set_text(rData.GetCondition());
671  m_xHideCB->set_sensitive(true);
672  m_xHideCB->set_state((rData.IsHidden()) ? TRISTATE_TRUE : TRISTATE_FALSE);
673  bool bHide = TRISTATE_TRUE == m_xHideCB->get_state();
674  m_xConditionED->set_sensitive(bHide);
675  m_xConditionFT->set_sensitive(bHide);
676  m_xPasswdCB->set_active(rData.GetPassword().hasElements());
677 
678  m_xOK->set_sensitive(true);
679  m_xPasswdCB->set_sensitive(true);
680  m_xCurName->set_text(rBox.get_text(*xIter));
681  m_xCurName->set_sensitive(true);
682  m_xDismiss->set_sensitive(true);
683  const OUString aFile = pRepr->GetFile();
684  const OUString sSub = pRepr->GetSubRegion();
685  m_xSubRegionED->clear();
686  m_xSubRegionED->append_text(""); // put in a dummy entry, which is replaced when m_bSubRegionsFilled is set
687  m_bSubRegionsFilled = false;
688  if( !aFile.isEmpty() || !sSub.isEmpty() )
689  {
690  m_xFileCB->set_active(true);
691  m_xFileNameED->set_text(aFile);
692  m_xSubRegionED->set_entry_text(sSub);
693  m_xDDECB->set_active(rData.GetType() == SectionType::DdeLink);
694  }
695  else
696  {
697  m_xFileCB->set_active(false);
698  m_xFileNameED->set_text(aFile);
699  m_xDDECB->set_sensitive(false);
700  m_xDDECB->set_active(false);
701  }
702  UseFileHdl(*m_xFileCB);
703  DDEHdl(*m_xDDECB);
704  m_xProtectCB->set_state((rData.IsProtectFlag())
705  ? TRISTATE_TRUE : TRISTATE_FALSE);
706  m_xProtectCB->set_sensitive(true);
707 
708  // edit in readonly sections
709  m_xEditInReadonlyCB->set_state((rData.IsEditInReadonlyFlag())
710  ? TRISTATE_TRUE : TRISTATE_FALSE);
711  m_xEditInReadonlyCB->set_sensitive(true);
712 
713  bool bPasswdEnabled = m_xProtectCB->get_active();
714  m_xPasswdCB->set_sensitive(bPasswdEnabled);
715  m_xPasswdPB->set_sensitive(bPasswdEnabled);
716  }
717  bDontCheckPasswd = false;
718 }
719 
720 // in OkHdl the modified settings are being applied and reversed regions are deleted
722 {
723  // temp. Array because during changing of a region the position
724  // inside of the "Core-Arrays" can be shifted:
725  // - at linked regions, when they have more SubRegions or get
726  // new ones.
727  // StartUndo must certainly also happen not before the formats
728  // are copied (ClearRedo!)
729 
730  const SwSectionFormats& rDocFormats = rSh.GetDoc()->GetSections();
731  SwSectionFormats aOrigArray(rDocFormats);
732 
733  rSh.StartAllAction();
734  rSh.StartUndo();
735  rSh.ResetSelect( nullptr,false );
736 
737  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
738  if (m_xTree->get_iter_first(*xIter))
739  {
740  do
741  {
742  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
743  SwSectionFormat* pFormat = aOrigArray[ pRepr->GetArrPos() ];
744  if (!pRepr->GetSectionData().IsProtectFlag())
745  {
746  pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
747  }
748  size_t nNewPos = rDocFormats.GetPos(pFormat);
749  if ( SIZE_MAX != nNewPos )
750  {
751  std::unique_ptr<SfxItemSet> pSet(pFormat->GetAttrSet().Clone( false ));
752  if( pFormat->GetCol() != pRepr->GetCol() )
753  pSet->Put( pRepr->GetCol() );
754 
755  std::unique_ptr<SvxBrushItem> aBrush(pFormat->makeBackgroundBrushItem(false));
756  if( aBrush && pRepr->GetBackground() && *aBrush != *pRepr->GetBackground() )
757  pSet->Put( *pRepr->GetBackground() );
758 
759  if( pFormat->GetFootnoteAtTextEnd(false) != pRepr->GetFootnoteNtAtEnd() )
760  pSet->Put( pRepr->GetFootnoteNtAtEnd() );
761 
762  if( pFormat->GetEndAtTextEnd(false) != pRepr->GetEndNtAtEnd() )
763  pSet->Put( pRepr->GetEndNtAtEnd() );
764 
765  if( pFormat->GetBalancedColumns() != pRepr->GetBalance() )
766  pSet->Put( pRepr->GetBalance() );
767 
768  if( pFormat->GetFrameDir() != *pRepr->GetFrameDir() )
769  pSet->Put( *pRepr->GetFrameDir() );
770 
771  if( pFormat->GetLRSpace() != *pRepr->GetLRSpace())
772  pSet->Put( *pRepr->GetLRSpace());
773 
774  rSh.UpdateSection( nNewPos, pRepr->GetSectionData(),
775  pSet->Count() ? pSet.get() : nullptr );
776  }
777  } while (m_xTree->iter_next(*xIter));
778  }
779 
780  for (SectReprs_t::reverse_iterator it = m_SectReprs.rbegin(), aEnd = m_SectReprs.rend(); it != aEnd; ++it)
781  {
782  assert(it->first == it->second->GetArrPos());
783  SwSectionFormat* pFormat = aOrigArray[ it->second->GetArrPos() ];
784  const size_t nNewPos = rDocFormats.GetPos( pFormat );
785  if( SIZE_MAX != nNewPos )
786  rSh.DelSectionFormat( nNewPos );
787  }
788 
789  aOrigArray.clear();
790 
791  // response must be called ahead of EndAction's end,
792  // otherwise ScrollError can occur.
793  m_xDialog->response(RET_OK);
794 
795  rSh.EndUndo();
796  rSh.EndAllAction();
797 }
798 
799 // Toggle protect
800 IMPL_LINK(SwEditRegionDlg, ChangeProtectHdl, weld::ToggleButton&, rButton, void)
801 {
802  if (!CheckPasswd(&rButton))
803  return;
804  bool bCheck = TRISTATE_TRUE == rButton.get_state();
805  m_xTree->selected_foreach([this, bCheck](weld::TreeIter& rEntry){
806  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
807  pRepr->GetSectionData().SetProtectFlag(bCheck);
808  OUString aImage = BuildBitmap(bCheck, TRISTATE_TRUE == m_xHideCB->get_state());
809  m_xTree->set_image(rEntry, aImage);
810  return false;
811  });
812  m_xPasswdCB->set_sensitive(bCheck);
813  m_xPasswdPB->set_sensitive(bCheck);
814 }
815 
816 // Toggle hide
817 IMPL_LINK( SwEditRegionDlg, ChangeHideHdl, weld::ToggleButton&, rButton, void)
818 {
819  if (!CheckPasswd(&rButton))
820  return;
821  m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){
822  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
823  pRepr->GetSectionData().SetHidden(TRISTATE_TRUE == rButton.get_state());
824  OUString aImage = BuildBitmap(TRISTATE_TRUE == m_xProtectCB->get_state(),
825  TRISTATE_TRUE == rButton.get_state());
826  m_xTree->set_image(rEntry, aImage);
827  return false;
828  });
829  bool bHide = TRISTATE_TRUE == rButton.get_state();
830  m_xConditionED->set_sensitive(bHide);
831  m_xConditionFT->set_sensitive(bHide);
832 }
833 
834 // Toggle edit in readonly
835 IMPL_LINK(SwEditRegionDlg, ChangeEditInReadonlyHdl, weld::ToggleButton&, rButton, void)
836 {
837  if (!CheckPasswd(&rButton))
838  return;
839  m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){
840  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
842  TRISTATE_TRUE == rButton.get_state());
843  return false;
844  });
845 }
846 
847 // clear selected region
848 IMPL_LINK_NOARG(SwEditRegionDlg, ChangeDismissHdl, weld::Button&, void)
849 {
850  if(!CheckPasswd())
851  return;
852  // at first mark all selected
853  m_xTree->selected_foreach([this](weld::TreeIter& rEntry){
854  SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
855  pSectRepr->SetSelected();
856  return false;
857  });
858 
859  std::unique_ptr<weld::TreeIter> xEntry(m_xTree->make_iterator());
860  bool bEntry(m_xTree->get_selected(xEntry.get()));
861  // then delete
862  while (bEntry)
863  {
864  SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xEntry).toInt64());
865  std::unique_ptr<weld::TreeIter> xRemove;
866  bool bRestart = false;
867  if (pSectRepr->IsSelected())
868  {
869  m_SectReprs.insert(std::make_pair(pSectRepr->GetArrPos(),
870  std::unique_ptr<SectRepr>(pSectRepr)));
871  if (m_xTree->iter_has_child(*xEntry))
872  {
873  std::unique_ptr<weld::TreeIter> xChild(m_xTree->make_iterator(xEntry.get()));
874  (void)m_xTree->iter_children(*xChild);
875  std::unique_ptr<weld::TreeIter> xParent(m_xTree->make_iterator(xEntry.get()));
876  if (!m_xTree->iter_parent(*xParent))
877  xParent.reset();
878  bool bChild = true;
879  do
880  {
881  // because of the repositioning we have to start at the beginning again
882  bRestart = true;
883  std::unique_ptr<weld::TreeIter> xMove(m_xTree->make_iterator(xChild.get()));
884  bChild = m_xTree->iter_next_sibling(*xChild);
885  m_xTree->move_subtree(*xMove, xParent.get(), m_xTree->get_iter_index_in_parent(*xEntry));
886  } while (bChild);
887  }
888  xRemove = m_xTree->make_iterator(xEntry.get());
889  }
890  if (bRestart)
891  bEntry = m_xTree->get_iter_first(*xEntry);
892  else
893  bEntry = m_xTree->iter_next(*xEntry);
894  if (xRemove)
895  m_xTree->remove(*xRemove);
896  }
897 
898  if (m_xTree->get_selected(nullptr))
899  return;
900 
901  m_xConditionFT->set_sensitive(false);
902  m_xConditionED->set_sensitive(false);
903  m_xDismiss->set_sensitive(false);
904  m_xCurName->set_sensitive(false);
905  m_xProtectCB->set_sensitive(false);
906  m_xPasswdCB->set_sensitive(false);
907  m_xHideCB->set_sensitive(false);
908  // edit in readonly sections
909  m_xEditInReadonlyCB->set_sensitive(false);
910  m_xEditInReadonlyCB->set_state(TRISTATE_FALSE);
911  m_xProtectCB->set_state(TRISTATE_FALSE);
912  m_xPasswdCB->set_active(false);
913  m_xHideCB->set_state(TRISTATE_FALSE);
914  m_xFileCB->set_active(false);
915  // otherwise the focus would be on HelpButton
916  m_xOK->grab_focus();
917  UseFileHdl(*m_xFileCB);
918 }
919 
920 // link CheckBox to file?
921 IMPL_LINK(SwEditRegionDlg, UseFileHdl, weld::ToggleButton&, rButton, void)
922 {
923  if (!CheckPasswd(&rButton))
924  return;
925  bool bMulti = 1 < m_xTree->count_selected_rows();
926  bool bFile = rButton.get_active();
927  if (m_xTree->get_selected(nullptr))
928  {
929  m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
930  SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
931  bool bContent = pSectRepr->IsContent();
932  if( rButton.get_active() && bContent && rSh.HasSelection() )
933  {
934  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
935  VclMessageType::Question, VclButtonsType::YesNo,
936  SwResId(STR_QUERY_CONNECT)));
937  if (RET_NO == xQueryBox->run())
938  rButton.set_active( false );
939  }
940  if( bFile )
941  pSectRepr->SetContent(false);
942  else
943  {
944  pSectRepr->SetFile(OUString());
945  pSectRepr->SetSubRegion(OUString());
946  pSectRepr->GetSectionData().SetLinkFilePassword(OUString());
947  }
948  return false;
949  });
950  m_xDDECB->set_sensitive(bFile && !bMulti);
951  m_xDDEFrame->set_sensitive(bFile && !bMulti);
952  if( bFile )
953  {
954  m_xProtectCB->set_state(TRISTATE_TRUE);
955  ChangeProtectHdl(*m_xProtectCB);
956  m_xFileNameED->grab_focus();
957 
958  }
959  else
960  {
961  m_xDDECB->set_active(false);
962  m_xSubRegionED->set_entry_text(OUString());
963  }
964  DDEHdl(*m_xDDECB);
965  }
966  else
967  {
968  rButton.set_active(false);
969  rButton.set_sensitive(false);
970  m_xDDECB->set_active(false);
971  m_xDDECB->set_sensitive(false);
972  m_xDDEFrame->set_sensitive(false);
973  }
974 }
975 
976 // call dialog paste file
978 {
979  if(!CheckPasswd())
980  return;
981  m_pDocInserter.reset(new ::sfx2::DocumentInserter(m_xDialog.get(), "swriter"));
982  m_pDocInserter->StartExecuteModal( LINK( this, SwEditRegionDlg, DlgClosedHdl ) );
983 }
984 
986 {
987  if(!CheckPasswd())
988  return;
989  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
990  if (!pSectRepr)
991  return;
992 
993  SfxItemSet aSet(
994  rSh.GetView().GetPool(),
995  svl::Items<
999  RES_COL, RES_COL,
1002  SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE>{});
1003 
1004  aSet.Put( pSectRepr->GetCol() );
1005  aSet.Put( *pSectRepr->GetBackground() );
1006  aSet.Put( pSectRepr->GetFootnoteNtAtEnd() );
1007  aSet.Put( pSectRepr->GetEndNtAtEnd() );
1008  aSet.Put( pSectRepr->GetBalance() );
1009  aSet.Put( *pSectRepr->GetFrameDir() );
1010  aSet.Put( *pSectRepr->GetLRSpace() );
1011 
1012  const SwSectionFormats& rDocFormats = rSh.GetDoc()->GetSections();
1013  SwSectionFormats aOrigArray(rDocFormats);
1014 
1015  SwSectionFormat* pFormat = aOrigArray[pSectRepr->GetArrPos()];
1016  tools::Long nWidth = rSh.GetSectionWidth(*pFormat);
1017  aOrigArray.clear();
1018  if (!nWidth)
1019  nWidth = USHRT_MAX;
1020 
1021  aSet.Put(SwFormatFrameSize(SwFrameSize::Variable, nWidth));
1022  aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
1023 
1024  SwSectionPropertyTabDialog aTabDlg(m_xDialog.get(), aSet, rSh);
1025  if (RET_OK != aTabDlg.run())
1026  return;
1027 
1028  const SfxItemSet* pOutSet = aTabDlg.GetOutputItemSet();
1029  if( !(pOutSet && pOutSet->Count()) )
1030  return;
1031 
1032  const SfxPoolItem *pColItem, *pBrushItem,
1033  *pFootnoteItem, *pEndItem, *pBalanceItem,
1034  *pFrameDirItem, *pLRSpaceItem;
1035  SfxItemState eColState = pOutSet->GetItemState(
1036  RES_COL, false, &pColItem );
1037  SfxItemState eBrushState = pOutSet->GetItemState(
1038  RES_BACKGROUND, false, &pBrushItem );
1039  SfxItemState eFootnoteState = pOutSet->GetItemState(
1040  RES_FTN_AT_TXTEND, false, &pFootnoteItem );
1041  SfxItemState eEndState = pOutSet->GetItemState(
1042  RES_END_AT_TXTEND, false, &pEndItem );
1043  SfxItemState eBalanceState = pOutSet->GetItemState(
1044  RES_COLUMNBALANCE, false, &pBalanceItem );
1045  SfxItemState eFrameDirState = pOutSet->GetItemState(
1046  RES_FRAMEDIR, false, &pFrameDirItem );
1047  SfxItemState eLRState = pOutSet->GetItemState(
1048  RES_LR_SPACE, false, &pLRSpaceItem);
1049 
1050  if( !(SfxItemState::SET == eColState ||
1051  SfxItemState::SET == eBrushState ||
1052  SfxItemState::SET == eFootnoteState ||
1053  SfxItemState::SET == eEndState ||
1054  SfxItemState::SET == eBalanceState||
1055  SfxItemState::SET == eFrameDirState||
1056  SfxItemState::SET == eLRState))
1057  return;
1058 
1059  m_xTree->selected_foreach([&](weld::TreeIter& rEntry){
1060  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
1061  if( SfxItemState::SET == eColState )
1062  pRepr->GetCol() = *static_cast<const SwFormatCol*>(pColItem);
1063  if( SfxItemState::SET == eBrushState )
1064  pRepr->GetBackground().reset(static_cast<SvxBrushItem*>(pBrushItem->Clone()));
1065  if( SfxItemState::SET == eFootnoteState )
1066  pRepr->GetFootnoteNtAtEnd() = *static_cast<const SwFormatFootnoteAtTextEnd*>(pFootnoteItem);
1067  if( SfxItemState::SET == eEndState )
1068  pRepr->GetEndNtAtEnd() = *static_cast<const SwFormatEndAtTextEnd*>(pEndItem);
1069  if( SfxItemState::SET == eBalanceState )
1070  pRepr->GetBalance().SetValue(static_cast<const SwFormatNoBalancedColumns*>(pBalanceItem)->GetValue());
1071  if( SfxItemState::SET == eFrameDirState )
1072  pRepr->GetFrameDir()->SetValue(static_cast<const SvxFrameDirectionItem*>(pFrameDirItem)->GetValue());
1073  if( SfxItemState::SET == eLRState )
1074  pRepr->GetLRSpace().reset(static_cast<SvxLRSpaceItem*>(pLRSpaceItem->Clone()));
1075  return false;
1076  });
1077 }
1078 
1079 IMPL_LINK(SwEditRegionDlg, FileNameComboBoxHdl, weld::ComboBox&, rEdit, void)
1080 {
1081  int nStartPos, nEndPos;
1082  rEdit.get_entry_selection_bounds(nStartPos, nEndPos);
1083  if (!CheckPasswd())
1084  return;
1085  rEdit.select_entry_region(nStartPos, nEndPos);
1086  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1087  pSectRepr->SetSubRegion( rEdit.get_active_text() );
1088 }
1089 
1090 // Applying of the filename or the linked region
1091 IMPL_LINK(SwEditRegionDlg, FileNameEntryHdl, weld::Entry&, rEdit, void)
1092 {
1093  int nStartPos, nEndPos;
1094  rEdit.get_selection_bounds(nStartPos, nEndPos);
1095  if (!CheckPasswd())
1096  return;
1097  rEdit.select_region(nStartPos, nEndPos);
1098  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1099  m_xSubRegionED->clear();
1100  m_xSubRegionED->append_text(""); // put in a dummy entry, which is replaced when m_bSubRegionsFilled is set
1101  m_bSubRegionsFilled = false;
1102  if (m_xDDECB->get_active())
1103  {
1104  OUString sLink( SwSectionData::CollapseWhiteSpaces(rEdit.get_text()) );
1105  sal_Int32 nPos = 0;
1106  sLink = sLink.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1107  if (nPos>=0)
1108  {
1109  sLink = sLink.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos );
1110  }
1111 
1112  pSectRepr->GetSectionData().SetLinkFileName( sLink );
1114  }
1115  else
1116  {
1117  OUString sTmp(rEdit.get_text());
1118  if(!sTmp.isEmpty())
1119  {
1120  SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
1121  INetURLObject aAbs;
1122  if( pMedium )
1123  aAbs = pMedium->GetURLObject();
1124  sTmp = URIHelper::SmartRel2Abs(
1125  aAbs, sTmp, URIHelper::GetMaybeFileHdl() );
1126  }
1127  pSectRepr->SetFile( sTmp );
1128  pSectRepr->GetSectionData().SetLinkFilePassword(OUString());
1129  }
1130 }
1131 
1133 {
1134  if (!CheckPasswd(&rButton))
1135  return;
1136  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1137  if (!pSectRepr)
1138  return;
1139 
1140  bool bFile = m_xFileCB->get_active();
1141  SwSectionData & rData( pSectRepr->GetSectionData() );
1142  bool bDDE = rButton.get_active();
1143  if(bDDE)
1144  {
1145  m_xFileNameFT->hide();
1146  m_xDDECommandFT->set_sensitive(true);
1147  m_xDDECommandFT->show();
1148  m_xSubRegionFT->hide();
1149  m_xSubRegionED->hide();
1150  if (SectionType::FileLink == rData.GetType())
1151  {
1152  pSectRepr->SetFile(OUString());
1153  m_xFileNameED->set_text(OUString());
1154  rData.SetLinkFilePassword(OUString());
1155  }
1156  rData.SetType(SectionType::DdeLink);
1157  }
1158  else
1159  {
1160  m_xDDECommandFT->hide();
1161  m_xFileNameFT->set_sensitive(bFile);
1162  m_xFileNameFT->show();
1163  m_xSubRegionED->show();
1164  m_xSubRegionFT->show();
1165  m_xSubRegionED->set_sensitive(bFile);
1166  m_xSubRegionFT->set_sensitive(bFile);
1167  m_xSubRegionED->set_sensitive(bFile);
1168  if (SectionType::DdeLink == rData.GetType())
1169  {
1170  rData.SetType(SectionType::FileLink);
1171  pSectRepr->SetFile(OUString());
1172  rData.SetLinkFilePassword(OUString());
1173  m_xFileNameED->set_text(OUString());
1174  }
1175  }
1176  m_xFilePB->set_sensitive(bFile && !bDDE);
1177 }
1178 
1180 {
1181  if (!CheckPasswd())
1182  {
1183  if (!bChange)
1184  m_xPasswdCB->set_active(!m_xPasswdCB->get_active());
1185  return;
1186  }
1187 
1188  bool bSet = bChange ? bChange : m_xPasswdCB->get_active();
1189 
1190  m_xTree->selected_foreach([this, bChange, bSet](weld::TreeIter& rEntry){
1191  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
1192  if(bSet)
1193  {
1194  if(!pRepr->GetTempPasswd().hasElements() || bChange)
1195  {
1196  SfxPasswordDialog aPasswdDlg(m_xDialog.get());
1197  aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
1198  if (RET_OK == aPasswdDlg.run())
1199  {
1200  const OUString sNewPasswd(aPasswdDlg.GetPassword());
1201  if (aPasswdDlg.GetConfirm() == sNewPasswd)
1202  {
1203  SvPasswordHelper::GetHashPassword( pRepr->GetTempPasswd(), sNewPasswd );
1204  }
1205  else
1206  {
1207  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
1208  VclMessageType::Info, VclButtonsType::Ok,
1209  SwResId(STR_WRONG_PASSWD_REPEAT)));
1210  xInfoBox->run();
1211  ChangePasswd(bChange);
1212  return true;
1213  }
1214  }
1215  else
1216  {
1217  if(!bChange)
1218  m_xPasswdCB->set_active(false);
1219  return true;
1220  }
1221  }
1222  pRepr->GetSectionData().SetPassword(pRepr->GetTempPasswd());
1223  }
1224  else
1225  {
1226  pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
1227  }
1228  return false;
1229  });
1230 }
1231 
1233 {
1234  ChangePasswd(false);
1235 }
1236 
1238 {
1239  ChangePasswd(true);
1240 }
1241 
1242 // the current region name is being added to the TreeListBox immediately during
1243 // editing, with empty string no Ok()
1245 {
1246  if(!CheckPasswd())
1247  return;
1248  std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator());
1249  if (m_xTree->get_selected(xIter.get()))
1250  {
1251  const OUString aName = m_xCurName->get_text();
1252  m_xTree->set_text(*xIter, aName);
1253  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64());
1254  pRepr->GetSectionData().SetSectionName(aName);
1255 
1256  m_xOK->set_sensitive(!aName.isEmpty());
1257  }
1258 }
1259 
1260 IMPL_LINK( SwEditRegionDlg, ConditionEditHdl, weld::Entry&, rEdit, void )
1261 {
1262  int nStartPos, nEndPos;
1263  rEdit.get_selection_bounds(nStartPos, nEndPos);
1264  if(!CheckPasswd())
1265  return;
1266  rEdit.select_region(nStartPos, nEndPos);
1267 
1268  m_xTree->selected_foreach([this, &rEdit](weld::TreeIter& rEntry){
1269  SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64());
1271  return false;
1272  });
1273 }
1274 
1275 IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void )
1276 {
1277  OUString sFileName, sFilterName, sPassword;
1278  if ( _pFileDlg->GetError() == ERRCODE_NONE )
1279  {
1280  std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium("sglobal"));
1281  if ( pMedium )
1282  {
1283  sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE );
1284  sFilterName = pMedium->GetFilter()->GetFilterName();
1285  const SfxPoolItem* pItem;
1286  if ( SfxItemState::SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) )
1287  sPassword = static_cast<const SfxStringItem*>(pItem )->GetValue();
1288  ::lcl_ReadSections(*pMedium, *m_xSubRegionED);
1289  }
1290  }
1291 
1292  SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64());
1293  if (pSectRepr)
1294  {
1295  pSectRepr->SetFile( sFileName );
1296  pSectRepr->SetFilter( sFilterName );
1297  pSectRepr->GetSectionData().SetLinkFilePassword(sPassword);
1298  m_xFileNameED->set_text(pSectRepr->GetFile());
1299  }
1300 }
1301 
1303 {
1304  if (m_bSubRegionsFilled)
1305  return;
1306 
1307  //if necessary fill the names bookmarks/sections/tables now
1308 
1309  OUString sFileName = m_xFileNameED->get_text();
1310  if(!sFileName.isEmpty())
1311  {
1312  SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
1313  INetURLObject aAbs;
1314  if( pMedium )
1315  aAbs = pMedium->GetURLObject();
1316  sFileName = URIHelper::SmartRel2Abs(
1317  aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
1318 
1319  //load file and set the shell
1320  SfxMedium aMedium( sFileName, StreamMode::STD_READ );
1322  ::lcl_ReadSections(aMedium, *m_xSubRegionED);
1323  }
1324  else
1325  lcl_FillSubRegionList(rSh, *m_xSubRegionED, nullptr);
1326  m_bSubRegionsFilled = true;
1327 }
1328 
1329 // helper function - read section names from medium
1330 static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox )
1331 {
1332  rBox.clear();
1333  uno::Reference < embed::XStorage > xStg;
1334  if( !(rMedium.IsStorage() && (xStg = rMedium.GetStorage()).is()) )
1335  return;
1336 
1337  std::vector<OUString> aArr;
1339  if ( nFormat == SotClipboardFormatId::STARWRITER_60 || nFormat == SotClipboardFormatId::STARWRITERGLOB_60 ||
1340  nFormat == SotClipboardFormatId::STARWRITER_8 || nFormat == SotClipboardFormatId::STARWRITERGLOB_8)
1341  SwGetReaderXML()->GetSectionList( rMedium, aArr );
1342 
1343  for (auto const& it : aArr)
1344  {
1345  rBox.append_text(it);
1346  }
1347 }
1348 
1350  weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
1351  : SfxTabDialogController(pParent, "modules/swriter/ui/insertsectiondialog.ui",
1352  "InsertSectionDialog",&rSet)
1353  , rWrtSh(rSh)
1354 {
1356  AddTabPage("section", SwInsertSectionTabPage::Create, nullptr);
1357  AddTabPage("columns", SwColumnPage::Create, nullptr);
1358  AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
1360  AddTabPage("indents", SwSectionIndentTabPage::Create, nullptr);
1361 
1362  SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
1363  tools::Long nHtmlMode = rHtmlOpt.GetExportMode();
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::ToggleButton&, 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 
1998  SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
1999  tools::Long nHtmlMode = rHtmlOpt.GetExportMode();
2000  bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ;
2001  if(bWeb)
2002  {
2003  RemoveTabPage("notes");
2004  RemoveTabPage("indents");
2005  if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
2006  RemoveTabPage("columns");
2007  }
2008 }
2009 
2011 {
2012 }
2013 
2014 void SwSectionPropertyTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
2015 {
2016  if (rId == "background")
2017  {
2018  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
2019  aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
2020  rPage.PageCreated(aSet);
2021  }
2022  else if (rId == "columns")
2023  {
2024  static_cast<SwColumnPage&>(rPage).ShowBalance(true);
2025  static_cast<SwColumnPage&>(rPage).SetInSection(true);
2026  }
2027  else if (rId == "indents")
2028  static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh);
2029 }
2030 
2032  : SfxTabPage(pPage, pController, "modules/swriter/ui/indentpage.ui", "IndentPage", &rAttrSet)
2033  , m_xBeforeMF(m_xBuilder->weld_metric_spin_button("before", FieldUnit::CM))
2034  , m_xAfterMF(m_xBuilder->weld_metric_spin_button("after", FieldUnit::CM))
2035  , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin))
2036 {
2037  Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwSectionIndentTabPage, IndentModifyHdl);
2038  m_xBeforeMF->connect_value_changed(aLk);
2039  m_xAfterMF->connect_value_changed(aLk);
2040 }
2041 
2043 {
2044 }
2045 
2047 {
2048  if (m_xBeforeMF->get_value_changed_from_saved() || m_xAfterMF->get_value_changed_from_saved())
2049  {
2050  SvxLRSpaceItem aLRSpace(
2051  m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)) ,
2052  m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)), 0, 0, RES_LR_SPACE);
2053  rSet->Put(aLRSpace);
2054  }
2055  return true;
2056 }
2057 
2059 {
2060  //this page doesn't show up in HTML mode
2061  FieldUnit aMetric = ::GetDfltMetric(false);
2062  SetFieldUnit(*m_xBeforeMF, aMetric);
2063  SetFieldUnit(*m_xAfterMF , aMetric);
2064 
2065  SfxItemState eItemState = rSet->GetItemState( RES_LR_SPACE );
2066  if ( eItemState >= SfxItemState::DEFAULT )
2067  {
2068  const SvxLRSpaceItem& rSpace =
2069  rSet->Get( RES_LR_SPACE );
2070 
2071  m_xBeforeMF->set_value(m_xBeforeMF->normalize(rSpace.GetLeft()), FieldUnit::TWIP);
2072  m_xAfterMF->set_value(m_xAfterMF->normalize(rSpace.GetRight()), FieldUnit::TWIP);
2073  }
2074  else
2075  {
2076  m_xBeforeMF->set_text("");
2077  m_xAfterMF->set_text("");
2078  }
2079  m_xBeforeMF->save_value();
2080  m_xAfterMF->save_value();
2081  IndentModifyHdl(*m_xBeforeMF);
2082 }
2083 
2084 std::unique_ptr<SfxTabPage> SwSectionIndentTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
2085 {
2086  return std::make_unique<SwSectionIndentTabPage>(pPage, pController, *rAttrSet);
2087 }
2088 
2090 {
2091  //set sensible values at the preview
2092  m_aPreviewWin.SetAdjust(SvxAdjust::Block);
2093  m_aPreviewWin.SetLastLine(SvxAdjust::Block);
2094  const SwRect& rPageRect = rSh.GetAnyCurRect( CurRectType::Page );
2095  Size aPageSize(rPageRect.Width(), rPageRect.Height());
2096  m_aPreviewWin.SetSize(aPageSize);
2097 }
2098 
2100 {
2101  m_aPreviewWin.SetLeftMargin(m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)));
2102  m_aPreviewWin.SetRightMargin(m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)));
2103  m_aPreviewWin.Invalidate();
2104 }
2105 
2106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~SwEditRegionDlg() override
Definition: uiregionsw.cxx:526
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:124
SwFormatFootnoteAtTextEnd & GetFootnoteNtAtEnd()
Definition: uiregionsw.cxx:164
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:445
FieldUnit
#define FN_PARAM_REGION_EDIT_IN_READONLY
Definition: cmdid.h:774
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:151
std::unique_ptr< weld::CheckButton > m_xFootnoteNtNumFormatCB
Definition: regionsw.hxx:177
void SetType(SectionType const eNew)
Definition: section.hxx:95
void SetFilter(OUString const &rFilter)
Definition: uiregionsw.cxx:238
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 SetSubRegion(OUString const &rSubRegion)
Definition: uiregionsw.cxx:260
void SetLinkFileName(OUString const &rNew)
Definition: section.hxx:117
bool IsContent() const
Definition: uiregionsw.cxx:177
std::unique_ptr< SvxBrushItem > m_Brush
Definition: uiregionsw.cxx:145
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:721
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:184
SwEditRegionDlg(weld::Window *pParent, SwWrtShell &rWrtSh)
Definition: uiregionsw.cxx:311
std::shared_ptr< SvxLRSpaceItem > m_LRSpaceItem
Definition: uiregionsw.cxx:150
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:279
sal_Int64 n
Provides access to the marks of a document.
SwSection const * InsertSection(SwSectionData &rNewData, SfxItemSet const *const =nullptr)
Definition: edsect.cxx:34
If text in multi-column sections should be evenly distributed.
Definition: fmtclbl.hxx:28
size_t FindArrPos(const SwSectionFormat *pFormat)
Definition: uiregionsw.cxx:515
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:165
const ContentProperties & rData
size_t GetArrPos() const
Definition: uiregionsw.cxx:170
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:210
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:70
OUString GetFile() const
Definition: uiregionsw.cxx:284
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:90
RET_NO
void SetWrtShell(SwWrtShell const &rSh)
virtual short Ok()
IMPL_LINK(SwEditRegionDlg, GetFirstEntryHdl, weld::TreeView &, rBox, void)
Definition: uiregionsw.cxx:560
bool IsStorage()
std::unique_ptr< SwNumberingTypeListBox > m_xEndNumViewBox
Definition: regionsw.hxx:190
std::unique_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:761
const SwView & GetView() const
Definition: wrtsh.hxx:428
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:153
std::unique_ptr< weld::TreeView > m_xTree
Definition: regionsw.hxx:58
SwFormatCol m_Col
Definition: uiregionsw.cxx:144
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:2667
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:147
TRISTATE_INDET
const SwSectionFormat & GetSectionFormat(size_t nFormat) const
Definition: edsect.cxx:141
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:773
virtual bool FillItemSet(SfxItemSet *) override
SwInsertSectionTabDialog(weld::Window *pParent, const SfxItemSet &rSet, SwWrtShell &rSh)
void SelectSection(const OUString &rSectionName)
Definition: uiregionsw.cxx:538
SwFormatNoBalancedColumns m_Balance
Definition: uiregionsw.cxx:148
static SvxHtmlOptions & Get()
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:20
SwFormatFootnoteAtTextEnd m_FootnoteNtAtEnd
Definition: uiregionsw.cxx:146
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:686
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
uno::Sequence< sal_Int8 > & GetTempPasswd()
Definition: uiregionsw.cxx:183
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:188
std::unique_ptr< weld::Entry > m_xCurName
Definition: regionsw.hxx:57
std::unique_ptr< SvxBrushItem > & GetBackground()
Definition: uiregionsw.cxx:163
SfxBindings & GetBindings()
std::unique_ptr< weld::CheckButton > m_xProtectCB
Definition: regionsw.hxx:68
std::shared_ptr< SvxFrameDirectionItem > m_FrameDirItem
Definition: uiregionsw.cxx:149
TRISTATE_FALSE
sal_uInt16 Count() const
SwFormatEndAtTextEnd m_EndNtAtEnd
Definition: uiregionsw.cxx:147
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:181
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:168
size
bool SelectNumberingType(SvxNumType nType)
bool CheckPasswd(weld::ToggleButton *pBox=nullptr)
Definition: uiregionsw.cxx:399
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:165
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:91
void SetCondition(OUString const &rNew)
Definition: section.hxx:114
void SetValue(bool const bTheValue)
SwDocShell * GetDocShell()
Definition: view.cxx:1109
virtual OUString get_text() const =0
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:156
std::unique_ptr< weld::MetricSpinButton > m_xBeforeMF
Definition: regionsw.hxx:211
Rect of current page.
void SetContent(bool const bValue)
Definition: uiregionsw.cxx:178
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:77
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:113
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:771
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:165
#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:162
SwSectionData m_SectionData
Definition: uiregionsw.cxx:143
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:770
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:180
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:167
void SetLastLine(SvxAdjust eNew)
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:161
virtual size_t GetSectionList(SfxMedium &rMedium, std::vector< OUString > &rStrings) const
Definition: shellio.cxx:636
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:155
void set_state(TriState eState)
SectionType GetType() const
Definition: section.hxx:170
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
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:302
SwFormatNoBalancedColumns & GetBalance()
Definition: uiregionsw.cxx:166
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:772
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)