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