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