diff options
Diffstat (limited to 'sw/source/ui/dialog')
-rw-r--r-- | sw/source/ui/dialog/abstract.cxx | 43 | ||||
-rw-r--r-- | sw/source/ui/dialog/addrdlg.cxx | 36 | ||||
-rw-r--r-- | sw/source/ui/dialog/ascfldlg.cxx | 434 | ||||
-rw-r--r-- | sw/source/ui/dialog/docstdlg.cxx | 125 | ||||
-rw-r--r-- | sw/source/ui/dialog/macassgn.cxx | 133 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 1258 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 787 | ||||
-rw-r--r-- | sw/source/ui/dialog/swmessdialog.cxx | 20 | ||||
-rw-r--r-- | sw/source/ui/dialog/swuiexp.cxx | 41 | ||||
-rw-r--r-- | sw/source/ui/dialog/uiregionsw.cxx | 2104 | ||||
-rw-r--r-- | sw/source/ui/dialog/wordcountdialog.cxx | 150 |
11 files changed, 5131 insertions, 0 deletions
diff --git a/sw/source/ui/dialog/abstract.cxx b/sw/source/ui/dialog/abstract.cxx new file mode 100644 index 000000000..01f4b1ea2 --- /dev/null +++ b/sw/source/ui/dialog/abstract.cxx @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <abstract.hxx> + +SwInsertAbstractDlg::SwInsertAbstractDlg(weld::Window* pParent) + : SfxDialogController(pParent, "modules/swriter/ui/abstractdialog.ui", "AbstractDialog") + , m_xLevelNF(m_xBuilder->weld_spin_button("outlines")) + , m_xParaNF(m_xBuilder->weld_spin_button("paras")) +{ +} + +SwInsertAbstractDlg::~SwInsertAbstractDlg() +{ +} + +sal_uInt8 SwInsertAbstractDlg::GetLevel() const +{ + return static_cast<sal_uInt8>(m_xLevelNF->get_value() - 1); +} + +sal_uInt8 SwInsertAbstractDlg::GetPara() const +{ + return static_cast<sal_uInt8>(m_xParaNF->get_value()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/addrdlg.cxx b/sw/source/ui/dialog/addrdlg.cxx new file mode 100644 index 000000000..3c16519ab --- /dev/null +++ b/sw/source/ui/dialog/addrdlg.cxx @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <addrdlg.hxx> +#include <sfx2/pageids.hxx> +#include <sfx2/sfxdlg.hxx> + +SwAddrDlg::SwAddrDlg(weld::Window* pParent, const SfxItemSet& rSet) + : SfxSingleTabDialogController(pParent, &rSet) +{ + SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); + ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SFXPAGE_GENERAL ); + if ( fnCreatePage ) + { + // create TabPage + SetTabPage(fnCreatePage(get_content_area(), this, &rSet)); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx new file mode 100644 index 000000000..327c5573e --- /dev/null +++ b/sw/source/ui/dialog/ascfldlg.cxx @@ -0,0 +1,434 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <utility> + +#include <hintids.hxx> +#include <rtl/textenc.h> +#include <i18nlangtag/mslangid.hxx> +#include <com/sun/star/i18n/ScriptType.hpp> +#include <unotools/lingucfg.hxx> +#include <unotools/viewoptions.hxx> +#include <sfx2/sfxsids.hrc> +#include <sfx2/printer.hxx> +#include <svl/languageoptions.hxx> +#include <editeng/langitem.hxx> +#include <swtypes.hxx> +#include <ascfldlg.hxx> +#include <shellio.hxx> +#include <docsh.hxx> +#include <doc.hxx> +#include <IDocumentDeviceAccess.hxx> + +#include <vcl/metric.hxx> + +using namespace ::com::sun::star; + +namespace +{ + +const sal_Unicode cDialogExtraDataClose = '}'; +const char sDialogImpExtraData[] = "EncImpDlg:{"; +const char sDialogExpExtraData[] = "EncExpDlg:{"; +const sal_Int32 nDialogExtraDataLen = 11; // 12345678901 + +} + +SwAsciiFilterDlg::SwAsciiFilterDlg( weld::Window* pParent, SwDocShell& rDocSh, + SvStream* pStream ) + : SfxDialogController(pParent, "modules/swriter/ui/asciifilterdialog.ui", "AsciiFilterDialog") + , m_bSaveLineStatus(true) + , m_xCharSetLB(new SvxTextEncodingBox(m_xBuilder->weld_combo_box("charset"))) + , m_xFontFT(m_xBuilder->weld_label("fontft")) + , m_xFontLB(m_xBuilder->weld_combo_box("font")) + , m_xLanguageFT(m_xBuilder->weld_label("languageft")) + , m_xLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("language"))) + , m_xCRLF_RB(m_xBuilder->weld_radio_button("crlf")) + , m_xCR_RB(m_xBuilder->weld_radio_button("cr")) + , m_xLF_RB(m_xBuilder->weld_radio_button("lf")) + , m_xIncludeBOM_CB(m_xBuilder->weld_check_button("includebom")) +{ + m_xFontLB->make_sorted(); + + SwAsciiOptions aOpt; + { + SvtViewOptions aDlgOpt(EViewType::Dialog, OStringToOUString(m_xDialog->get_help_id(), RTL_TEXTENCODING_UTF8)); + if (aDlgOpt.Exists()) + { + css::uno::Any aUserItem = aDlgOpt.GetUserItem("UserItem"); + aUserItem >>= m_sExtraData; + } + + const OUString sFindNm = OUString::createFromAscii( + pStream ? sDialogImpExtraData + : sDialogExpExtraData); + sal_Int32 nEnd, nStt = m_sExtraData.indexOf( sFindNm ); + if( -1 != nStt ) + { + nStt += nDialogExtraDataLen; + nEnd = m_sExtraData.indexOf( cDialogExtraDataClose, nStt ); + if( -1 != nEnd ) + { + aOpt.ReadUserData(m_sExtraData.copy(nStt, nEnd - nStt)); + nStt -= nDialogExtraDataLen; + m_sExtraData = m_sExtraData.replaceAt(nStt, nEnd - nStt + 1, ""); + } + } + } + + // read the first chars and check the charset, (language - with L&H) + if( pStream ) + { + char aBuffer[ 4098 ]; + const sal_uLong nOldPos = pStream->Tell(); + const size_t nBytesRead = pStream->ReadBytes(aBuffer, 4096); + pStream->Seek( nOldPos ); + + if( nBytesRead <= 4096 ) + { + aBuffer[ nBytesRead ] = '0'; + aBuffer[ nBytesRead+1 ] = '0'; + } + + bool bCR = false, bLF = false, bNullChar = false; + for( sal_uLong nCnt = 0; nCnt < nBytesRead; ++nCnt ) + switch( aBuffer[ nCnt ] ) + { + case 0x0: bNullChar = true; break; + case 0xA: bLF = true; break; + case 0xD: bCR = true; break; + case 0xC: + case 0x1A: + case 0x9: break; + default: break; + } + + if( !bNullChar ) + { + if( bCR ) + { + if( bLF ) + { + aOpt.SetParaFlags( LINEEND_CRLF ); + } + else + { + aOpt.SetParaFlags( LINEEND_CR ); + } + } + else if( bLF ) + { + aOpt.SetParaFlags( LINEEND_LF ); + } + } + + const sal_uInt16 nAppScriptType = SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ); + SwDoc* pDoc = rDocSh.GetDoc(); + + // initialize language + { + if( !aOpt.GetLanguage() ) + { + if(pDoc) + { + const sal_uInt16 nWhich = GetWhichOfScript( RES_CHRATR_LANGUAGE, nAppScriptType); + aOpt.SetLanguage( static_cast<const SvxLanguageItem&>(pDoc-> + GetDefault( nWhich )).GetLanguage()); + } + else + { + SvtLinguOptions aLinguOpt; + SvtLinguConfig().GetOptions( aLinguOpt ); + switch(nAppScriptType) + { + case css::i18n::ScriptType::ASIAN: + aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, css::i18n::ScriptType::ASIAN)); + break; + case css::i18n::ScriptType::COMPLEX: + aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, css::i18n::ScriptType::COMPLEX)); + break; + //SvtScriptType::LATIN: + default: + aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, css::i18n::ScriptType::LATIN)); + } + } + } + + m_xLanguageLB->SetLanguageList( SvxLanguageListFlags::ALL, true ); + m_xLanguageLB->set_active_id(aOpt.GetLanguage()); + } + + { + bool bDelPrinter = false; + VclPtr<SfxPrinter> pPrt = pDoc ? pDoc->getIDocumentDeviceAccess().getPrinter(false) : nullptr; + if( !pPrt ) + { + auto pSet = std::make_unique<SfxItemSet>( rDocSh.GetPool(), + svl::Items<SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, + SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC>{} ); + pPrt = VclPtr<SfxPrinter>::Create( std::move(pSet) ); + bDelPrinter = true; + } + + // get the set of distinct available family names + std::set< OUString > aFontNames; + int nFontNames = pPrt->GetDevFontCount(); + for( int i = 0; i < nFontNames; i++ ) + { + FontMetric aFontMetric( pPrt->GetDevFont( i ) ); + aFontNames.insert( aFontMetric.GetFamilyName() ); + } + + // insert into listbox + for( const auto& rFontName : aFontNames ) + { + m_xFontLB->append_text(rFontName); + } + + if( aOpt.GetFontName().isEmpty() ) + { + LanguageType eLang = aOpt.GetLanguage(); + vcl::Font aTmpFont(OutputDevice::GetDefaultFont(DefaultFontType::FIXED, eLang, GetDefaultFontFlags::OnlyOne, pPrt)); + aOpt.SetFontName(aTmpFont.GetFamilyName()); + } + + m_xFontLB->set_active_text(aOpt.GetFontName()); + + if( bDelPrinter ) + pPrt.disposeAndClear(); + } + + // hide the unused Controls for Export + m_xIncludeBOM_CB->hide(); + } + else + { + // hide the unused Controls for Export + m_xFontFT->hide(); + m_xFontLB->hide(); + m_xLanguageFT->hide(); + m_xLanguageLB->hide(); + + + SetIncludeBOM(aOpt.GetIncludeBOM()); + m_xIncludeBOM_CB->save_state(); + } + + // initialize character set + m_xCharSetLB->FillFromTextEncodingTable( pStream != nullptr ); + m_xCharSetLB->SelectTextEncoding( aOpt.GetCharSet() ); + + m_xCharSetLB->connect_changed( LINK( this, SwAsciiFilterDlg, CharSetSelHdl )); + m_xCRLF_RB->connect_toggled( LINK( this, SwAsciiFilterDlg, LineEndHdl )); + m_xLF_RB->connect_toggled( LINK( this, SwAsciiFilterDlg, LineEndHdl )); + m_xCR_RB->connect_toggled( LINK( this, SwAsciiFilterDlg, LineEndHdl )); + + SetCRLF( aOpt.GetParaFlags() ); + + m_xCRLF_RB->save_state(); + m_xLF_RB->save_state(); + m_xCR_RB->save_state(); + + UpdateIncludeBOMSensitiveState(); +} + +SwAsciiFilterDlg::~SwAsciiFilterDlg() +{ + SvtViewOptions aDlgOpt(EViewType::Dialog, OStringToOUString(m_xDialog->get_help_id(), RTL_TEXTENCODING_UTF8)); + aDlgOpt.SetUserItem("UserItem", uno::makeAny(m_sExtraData)); +} + +void SwAsciiFilterDlg::FillOptions( SwAsciiOptions& rOptions ) +{ + sal_uLong nCCode = m_xCharSetLB->GetSelectTextEncoding(); + OUString sFont; + LanguageType nLng = LANGUAGE_SYSTEM; + if (m_xFontLB->get_visible()) + { + sFont = m_xFontLB->get_active_text(); + nLng = m_xLanguageLB->get_active_id(); + } + + rOptions.SetFontName( sFont ); + rOptions.SetCharSet( rtl_TextEncoding( nCCode ) ); + rOptions.SetLanguage( nLng ); + rOptions.SetParaFlags( GetCRLF() ); + rOptions.SetIncludeBOM( GetIncludeBOM() ); + + // save the user settings + OUString sData; + rOptions.WriteUserData( sData ); + if (!sData.isEmpty()) + { + const OUString sFindNm = OUString::createFromAscii( + m_xFontLB->get_visible() ? sDialogImpExtraData + : sDialogExpExtraData); + sal_Int32 nEnd, nStt = m_sExtraData.indexOf( sFindNm ); + if( -1 != nStt ) + { + // called twice, so remove "old" settings + nEnd = m_sExtraData.indexOf( cDialogExtraDataClose, + nStt + nDialogExtraDataLen ); + if( -1 != nEnd ) + m_sExtraData = m_sExtraData.replaceAt( nStt, nEnd - nStt + 1, "" ); + } + m_sExtraData += sFindNm + sData + OUStringChar(cDialogExtraDataClose); + } +} + +void SwAsciiFilterDlg::SetCRLF( LineEnd eEnd ) +{ + switch (eEnd) + { + case LINEEND_CR: + m_xCR_RB->set_active(true); + break; + case LINEEND_CRLF: + m_xCRLF_RB->set_active(true); + break; + case LINEEND_LF: + m_xLF_RB->set_active(true); + break; + } +} + +LineEnd SwAsciiFilterDlg::GetCRLF() const +{ + LineEnd eEnd; + if(m_xCR_RB->get_active()) + eEnd = LINEEND_CR; + else if (m_xLF_RB->get_active()) + eEnd = LINEEND_LF; + else + eEnd = LINEEND_CRLF; + return eEnd; +} + +void SwAsciiFilterDlg::SetIncludeBOM( bool bIncludeBOM ) +{ + m_xIncludeBOM_CB->set_state(bIncludeBOM ? TRISTATE_TRUE : TRISTATE_FALSE); +} + +bool SwAsciiFilterDlg::GetIncludeBOM() const +{ + return m_xIncludeBOM_CB->get_state() != TRISTATE_FALSE; +} + +void SwAsciiFilterDlg::UpdateIncludeBOMSensitiveState() +{ + if (m_xIncludeBOM_CB->get_visible()) + { + switch (m_xCharSetLB->GetSelectTextEncoding()) + { + case RTL_TEXTENCODING_UTF8: + case RTL_TEXTENCODING_UCS2: + m_xIncludeBOM_CB->set_sensitive(true); + break; + default: + m_xIncludeBOM_CB->set_sensitive(false); + break; + } + } +} + +IMPL_LINK_NOARG(SwAsciiFilterDlg, CharSetSelHdl, weld::ComboBox&, void) +{ + LineEnd eOldEnd = GetCRLF(), eEnd = LineEnd(-1); + LanguageType nLng = m_xFontLB->get_visible() + ? m_xLanguageLB->get_active_id() + : LANGUAGE_SYSTEM, + nOldLng = nLng; + + rtl_TextEncoding nChrSet = m_xCharSetLB->GetSelectTextEncoding(); + if( nChrSet == osl_getThreadTextEncoding() ) + eEnd = GetSystemLineEnd(); + else + { + switch( nChrSet ) + { + case RTL_TEXTENCODING_MS_1252: +#ifdef UNX + eEnd = LINEEND_LF; +#else + eEnd = LINEEND_CRLF; // ANSI +#endif + break; + + case RTL_TEXTENCODING_APPLE_ROMAN: // MAC + eEnd = LINEEND_CR; + break; + + case RTL_TEXTENCODING_IBM_850: // DOS + eEnd = LINEEND_CRLF; + break; + + case RTL_TEXTENCODING_APPLE_ARABIC: + case RTL_TEXTENCODING_APPLE_CENTEURO: + case RTL_TEXTENCODING_APPLE_CROATIAN: + case RTL_TEXTENCODING_APPLE_CYRILLIC: + case RTL_TEXTENCODING_APPLE_DEVANAGARI: + case RTL_TEXTENCODING_APPLE_FARSI: + case RTL_TEXTENCODING_APPLE_GREEK: + case RTL_TEXTENCODING_APPLE_GUJARATI: + case RTL_TEXTENCODING_APPLE_GURMUKHI: + case RTL_TEXTENCODING_APPLE_HEBREW: + case RTL_TEXTENCODING_APPLE_ICELAND: + case RTL_TEXTENCODING_APPLE_ROMANIAN: + case RTL_TEXTENCODING_APPLE_THAI: + case RTL_TEXTENCODING_APPLE_TURKISH: + case RTL_TEXTENCODING_APPLE_UKRAINIAN: + case RTL_TEXTENCODING_APPLE_CHINSIMP: + case RTL_TEXTENCODING_APPLE_CHINTRAD: + case RTL_TEXTENCODING_APPLE_JAPANESE: + case RTL_TEXTENCODING_APPLE_KOREAN: + eEnd = LINEEND_CR; + break; + } + } + + m_bSaveLineStatus = false; + if( eEnd != LineEnd(-1) ) // changed? + { + if( eOldEnd != eEnd ) + SetCRLF( eEnd ); + } + else + { + // restore old user choice (not the automatic!) + m_xCRLF_RB->set_state(m_xCRLF_RB->get_saved_state()); + m_xCR_RB->set_state(m_xCR_RB->get_saved_state()); + m_xLF_RB->set_state(m_xLF_RB->get_saved_state()); + } + m_bSaveLineStatus = true; + + if (nOldLng != nLng && m_xFontLB->get_visible()) + m_xLanguageLB->set_active_id(nLng); + + UpdateIncludeBOMSensitiveState(); +} + +IMPL_LINK(SwAsciiFilterDlg, LineEndHdl, weld::ToggleButton&, rBtn, void) +{ + if (m_bSaveLineStatus) + rBtn.save_state(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/docstdlg.cxx b/sw/source/ui/dialog/docstdlg.cxx new file mode 100644 index 000000000..7aacfd94c --- /dev/null +++ b/sw/source/ui/dialog/docstdlg.cxx @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <swwait.hxx> +#include <wrtsh.hxx> +#include <view.hxx> +#include <docsh.hxx> +#include <pview.hxx> +#include <doc.hxx> +#include <docstdlg.hxx> +#include <IDocumentStatistics.hxx> + +#include <unotools/localedatawrapper.hxx> +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> + +std::unique_ptr<SfxTabPage> SwDocStatPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet) +{ + return std::make_unique<SwDocStatPage>(pPage, pController, *rSet); +} + +SwDocStatPage::SwDocStatPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet) + : SfxTabPage(pPage, pController, "modules/swriter/ui/statisticsinfopage.ui", "StatisticsInfoPage", &rSet) + , m_xPageNo(m_xBuilder->weld_label("nopages")) + , m_xTableNo(m_xBuilder->weld_label("notables")) + , m_xGrfNo(m_xBuilder->weld_label("nogrfs")) + , m_xOLENo(m_xBuilder->weld_label("nooles")) + , m_xParaNo(m_xBuilder->weld_label("noparas")) + , m_xWordNo(m_xBuilder->weld_label("nowords")) + , m_xCharNo(m_xBuilder->weld_label("nochars")) + , m_xCharExclSpacesNo(m_xBuilder->weld_label("nocharsexspaces")) + , m_xLineLbl(m_xBuilder->weld_label("lineft")) + , m_xLineNo(m_xBuilder->weld_label("nolines")) + , m_xUpdatePB(m_xBuilder->weld_button("update")) +{ + Update(); + m_xUpdatePB->connect_clicked(LINK(this, SwDocStatPage, UpdateHdl)); + //#111684# is the current view a page preview no SwFEShell can be found -> hide the update button + SwDocShell* pDocShell = static_cast<SwDocShell*>( SfxObjectShell::Current() ); + SwFEShell* pFEShell = pDocShell->GetFEShell(); + if(!pFEShell) + { + m_xUpdatePB->hide(); + m_xLineLbl->hide(); + m_xLineNo->hide(); + } +} + +SwDocStatPage::~SwDocStatPage() +{ +} + +// Description: fill ItemSet when changed +bool SwDocStatPage::FillItemSet(SfxItemSet * /*rSet*/) +{ + return false; +} + +void SwDocStatPage::Reset(const SfxItemSet *) +{ +} + +// Description: update / set data +void SwDocStatPage::SetData(const SwDocStat &rStat) +{ + const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetUILocaleDataWrapper(); + m_xTableNo->set_label(rLocaleData.getNum(rStat.nTable, 0)); + m_xGrfNo->set_label(rLocaleData.getNum(rStat.nGrf, 0)); + m_xOLENo->set_label(rLocaleData.getNum(rStat.nOLE, 0)); + m_xPageNo->set_label(rLocaleData.getNum(rStat.nPage, 0)); + m_xParaNo->set_label(rLocaleData.getNum(rStat.nPara, 0)); + m_xWordNo->set_label(rLocaleData.getNum(rStat.nWord, 0)); + m_xCharNo->set_label(rLocaleData.getNum(rStat.nChar, 0)); + m_xCharExclSpacesNo->set_label(rLocaleData.getNum(rStat.nCharExcludingSpaces, 0)); +} + +// Description: update statistics +void SwDocStatPage::Update() +{ + SfxViewShell *pVSh = SfxViewShell::Current(); + SwViewShell *pSh = nullptr; + if ( dynamic_cast< const SwView *>( pVSh ) != nullptr ) + pSh = static_cast<SwView*>(pVSh)->GetWrtShellPtr(); + else if ( dynamic_cast< const SwPagePreview *>( pVSh ) != nullptr ) + pSh = static_cast<SwPagePreview*>(pVSh)->GetViewShell(); + + OSL_ENSURE( pSh, "Shell not found" ); + + if (!pSh) + return; + + SwWait aWait( *pSh->GetDoc()->GetDocShell(), true ); + pSh->StartAction(); + aDocStat = pSh->GetDoc()->getIDocumentStatistics().GetUpdatedDocStat( false, true ); + pSh->EndAction(); + + SetData(aDocStat); +} + +IMPL_LINK_NOARG(SwDocStatPage, UpdateHdl, weld::Button&, void) +{ + Update(); + SwDocShell* pDocShell = static_cast<SwDocShell*>( SfxObjectShell::Current()); + SwFEShell* pFEShell = pDocShell->GetFEShell(); + if (pFEShell) + m_xLineNo->set_label(OUString::number(pFEShell->GetLineCount())); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/macassgn.cxx b/sw/source/ui/dialog/macassgn.cxx new file mode 100644 index 000000000..3edef40ea --- /dev/null +++ b/sw/source/ui/dialog/macassgn.cxx @@ -0,0 +1,133 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <hintids.hxx> + +#include <sfx2/htmlmode.hxx> +#include <svx/svxids.hrc> +#include <svl/macitem.hxx> + +#include <swtypes.hxx> +#include <wrtsh.hxx> +#include <viewopt.hxx> +#include <macassgn.hxx> +#include <docsh.hxx> +#include <strings.hrc> +#include <view.hxx> +#include <sfx2/viewfrm.hxx> + +#include <svx/svxdlg.hxx> + + +SfxEventNamesItem SwMacroAssignDlg::AddEvents( DlgEventType eType ) +{ + SfxEventNamesItem aItem(SID_EVENTCONFIG); + + sal_uInt16 nHtmlMode = ::GetHtmlMode(static_cast<const SwDocShell*>(SfxObjectShell::Current())); + bool bHtmlMode = nHtmlMode & HTMLMODE_ON; + + switch( eType ) + { + case MACASSGN_AUTOTEXT: + aItem.AddEvent( SwResId(STR_EVENT_START_INS_GLOSSARY), OUString(), + SvMacroItemId::SwStartInsGlossary ); + aItem.AddEvent( SwResId(STR_EVENT_END_INS_GLOSSARY), OUString(), + SvMacroItemId::SwEndInsGlossary); + // in order for the new handler to become active! + break; + case MACASSGN_ALLFRM: + case MACASSGN_GRAPHIC: // graphics + { + aItem.AddEvent( SwResId(STR_EVENT_IMAGE_ERROR), OUString(), + SvMacroItemId::OnImageLoadError); + aItem.AddEvent( SwResId(STR_EVENT_IMAGE_ABORT), OUString(), + SvMacroItemId::OnImageLoadCancel); + aItem.AddEvent( SwResId(STR_EVENT_IMAGE_LOAD), OUString(), + SvMacroItemId::OnImageLoadDone); + } + [[fallthrough]]; + case MACASSGN_FRMURL: // Frame - URL-Attributes + { + if( !bHtmlMode && + (MACASSGN_FRMURL == eType || MACASSGN_ALLFRM == eType)) + { + aItem.AddEvent( SwResId( STR_EVENT_FRM_KEYINPUT_A ), OUString(), + SvMacroItemId::SwFrmKeyInputAlpha ); + aItem.AddEvent( SwResId( STR_EVENT_FRM_KEYINPUT_NOA ), OUString(), + SvMacroItemId::SwFrmKeyInputNoAlpha ); + aItem.AddEvent( SwResId( STR_EVENT_FRM_RESIZE ), OUString(), + SvMacroItemId::SwFrmResize ); + aItem.AddEvent( SwResId( STR_EVENT_FRM_MOVE ), OUString(), + SvMacroItemId::SwFrmMove ); + } + } + [[fallthrough]]; + case MACASSGN_OLE: // OLE + { + if( !bHtmlMode ) + aItem.AddEvent( SwResId(STR_EVENT_OBJECT_SELECT), OUString(), + SvMacroItemId::SwObjectSelect ); + } + [[fallthrough]]; + case MACASSGN_INETFMT: // INetFormat-Attributes + { + aItem.AddEvent( SwResId(STR_EVENT_MOUSEOVER_OBJECT), OUString(), + SvMacroItemId::OnMouseOver ); + aItem.AddEvent( SwResId(STR_EVENT_MOUSECLICK_OBJECT), OUString(), + SvMacroItemId::OnClick); + aItem.AddEvent( SwResId(STR_EVENT_MOUSEOUT_OBJECT), OUString(), + SvMacroItemId::OnMouseOut); + } + break; + } + + return aItem; +} + +bool SwMacroAssignDlg::INetFormatDlg(weld::Window* pParent, SwWrtShell& rSh, + std::unique_ptr<SvxMacroItem>& rpINetItem ) +{ + bool bRet = false; + SfxItemSet aSet( rSh.GetAttrPool(), svl::Items<RES_FRMMACRO, RES_FRMMACRO, SID_EVENTCONFIG, SID_EVENTCONFIG>{} ); + SvxMacroItem aItem( RES_FRMMACRO ); + if( !rpINetItem ) + rpINetItem.reset(new SvxMacroItem( RES_FRMMACRO )); + else + aItem.SetMacroTable( rpINetItem->GetMacroTable() ); + + aSet.Put( aItem ); + aSet.Put( AddEvents( MACASSGN_INETFMT ) ); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr<SfxAbstractDialog> pMacroDlg( pFact->CreateEventConfigDialog(pParent, aSet, + rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface() ) ); + if ( pMacroDlg && pMacroDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet(); + const SfxPoolItem* pItem; + if( SfxItemState::SET == pOutSet->GetItemState( RES_FRMMACRO, false, &pItem )) + { + rpINetItem->SetMacroTable( static_cast<const SvxMacroItem*>(pItem)->GetMacroTable() ); + bRet = true; + } + } + return bRet; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx new file mode 100644 index 000000000..163d315bb --- /dev/null +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -0,0 +1,1258 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <config_features.h> + +#include "swdlgfact.hxx" +#include <svl/style.hxx> +#include <globals.hrc> + +#include <wordcountdialog.hxx> +#include <abstract.hxx> +#include <addrdlg.hxx> +#include <ascfldlg.hxx> +#include <bookmark.hxx> +#include <break.hxx> +#include <changedb.hxx> +#include <chrdlg.hxx> +#include <colwd.hxx> +#include <convert.hxx> +#include <cption.hxx> +#include <dbinsdlg.hxx> +#include <docfnote.hxx> +#include <docstdlg.hxx> +#include <DateFormFieldDialog.hxx> +#include <DropDownFieldDialog.hxx> +#include <DropDownFormFieldDialog.hxx> +#include <envlop.hxx> +#include <label.hxx> +#include <drpcps.hxx> +#include <swuipardlg.hxx> +#include <pattern.hxx> +#include <pardlg.hxx> +#include <rowht.hxx> +#include <selglos.hxx> +#include <splittbl.hxx> +#include <srtdlg.hxx> +#include <tautofmt.hxx> +#include <tblnumfm.hxx> +#include <wrap.hxx> +#include <tabledlg.hxx> +#include <fldtdlg.hxx> +#include <fldedt.hxx> +#include <swrenamexnameddlg.hxx> +#include <swmodalredlineacceptdlg.hxx> +#include <frmdlg.hxx> +#include <tmpdlg.hxx> +#include <glossary.hxx> +#include <inpdlg.hxx> +#include <insfnote.hxx> +#include <instable.hxx> +#include <javaedit.hxx> +#include <linenum.hxx> +#include <titlepage.hxx> +#include <mailmrge.hxx> +#include <mergetbl.hxx> +#include <multmrk.hxx> +#include <num.hxx> +#include <outline.hxx> +#include <column.hxx> +#include <cnttab.hxx> +#include <swuicnttab.hxx> +#include <regionsw.hxx> +#include <optcomp.hxx> +#include <optload.hxx> +#include <optpage.hxx> +#include <swuiidxmrk.hxx> +#include <svx/dialogs.hrc> +#include <mailmergewizard.hxx> +#include <mailconfigpage.hxx> +#include <uiborder.hxx> +#include <mmresultdialogs.hxx> + + +using namespace ::com::sun::star; +using namespace css::frame; +using namespace css::uno; + +short AbstractSwWordCountFloatDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwInsertAbstractDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short SwAbstractSfxController_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwAsciiFilterDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSplitTableDialog_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwBreakDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwTableWidthDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwTableHeightDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwMergeTableDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractGenericDialog_Impl::Execute() +{ + return m_xDlg->run(); +} + +bool AbstractGenericDialog_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + +short AbstractSwSortDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractMultiTOXMarkDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractTabController_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwConvertTableDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwInsertDBColAutoPilot_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractDropDownFieldDialog_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractDropDownFormFieldDialog_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractDateFormFieldDialog_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwLabDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwSelGlossaryDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwAutoFormatDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwFieldDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwRenameXNamedDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractSwModalRedlineAcceptDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractGlossaryDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractFieldInputDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractInsFootNoteDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractJavaEditDialog_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractMailMergeDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractMailMergeCreateFromDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractMailMergeFieldConnectionsDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractMultiTOXTabDialog_Impl::Execute() +{ + return m_xDlg->run(); +} + +bool AbstractMultiTOXTabDialog_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return SfxTabDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + +short AbstractEditRegionDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractInsertSectionTabDialog_Impl::Execute() +{ + return m_xDlg->run(); +} + +bool AbstractInsertSectionTabDialog_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return SfxTabDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + +short AbstractIndexMarkFloatDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +short AbstractAuthMarkFloatDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +void AbstractTabController_Impl::SetCurPageId( const OString &rName ) +{ + m_xDlg->SetCurPageId( rName ); +} + +const SfxItemSet* AbstractTabController_Impl::GetOutputItemSet() const +{ + return m_xDlg->GetOutputItemSet(); +} + +const sal_uInt16* AbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem ) +{ + return m_xDlg->GetInputRanges( pItem ); +} + +void AbstractTabController_Impl::SetInputSet( const SfxItemSet* pInSet ) +{ + m_xDlg->SetInputSet( pInSet ); +} + +bool AbstractTabController_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return SfxTabDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + +//From class Window. +void AbstractTabController_Impl::SetText( const OUString& rStr ) +{ + m_xDlg->set_title(rStr); +} + +IMPL_LINK_NOARG(AbstractApplyTabController_Impl, ApplyHdl, weld::Button&, void) +{ + if (m_xDlg->Apply()) + { + m_aHandler.Call(nullptr); + m_xDlg->Applied(); + } +} + +void AbstractApplyTabController_Impl::SetApplyHdl( const Link<LinkParamNone*,void>& rLink ) +{ + m_aHandler = rLink; + m_xDlg->SetApplyHandler(LINK(this, AbstractApplyTabController_Impl, ApplyHdl)); +} + +sal_uInt8 AbstractSwInsertAbstractDlg_Impl::GetLevel() const +{ + return m_xDlg->GetLevel(); +} + +sal_uInt8 AbstractSwInsertAbstractDlg_Impl::GetPara() const +{ + return m_xDlg->GetPara(); +} + +const SfxItemSet* SwAbstractSfxController_Impl::GetOutputItemSet() const +{ + return m_xDlg->GetOutputItemSet(); +} + +void SwAbstractSfxController_Impl::SetText(const OUString& rStr) +{ + m_xDlg->set_title(rStr); +} + +void AbstractSwAsciiFilterDlg_Impl::FillOptions( SwAsciiOptions& rOptions ) +{ + m_xDlg->FillOptions(rOptions); +} + +SplitTable_HeadlineOption AbstractSplitTableDialog_Impl::GetSplitMode() +{ + return m_xDlg->GetSplitMode(); +} + +OUString AbstractSwBreakDlg_Impl::GetTemplateName() +{ + return m_xDlg->GetTemplateName(); +} + +sal_uInt16 AbstractSwBreakDlg_Impl:: GetKind() +{ + return m_xDlg->GetKind(); +} + +::std::optional<sal_uInt16> AbstractSwBreakDlg_Impl:: GetPageNumber() +{ + return m_xDlg->GetPageNumber(); +} + +void AbstractSwConvertTableDlg_Impl::GetValues( sal_Unicode& rDelim,SwInsertTableOptions& rInsTableFlags, + SwTableAutoFormat const*& prTAFormat) +{ + m_xDlg->GetValues(rDelim,rInsTableFlags, prTAFormat); +} + +void AbstractSwInsertDBColAutoPilot_Impl::DataToDoc( const uno::Sequence< uno::Any >& rSelection, + uno::Reference< sdbc::XDataSource> rxSource, + uno::Reference< sdbc::XConnection> xConnection, + uno::Reference< sdbc::XResultSet > xResultSet) +{ +#if HAVE_FEATURE_DBCONNECTIVITY + m_xDlg->DataToDoc(rSelection, rxSource, xConnection, xResultSet); +#else + (void) rSelection; + (void) rxSource; + (void) xConnection; + (void) xResultSet; +#endif +} + +bool AbstractDropDownFieldDialog_Impl::PrevButtonPressed() const +{ + return m_xDlg->PrevButtonPressed(); +} + +bool AbstractDropDownFieldDialog_Impl::NextButtonPressed() const +{ + return m_xDlg->NextButtonPressed(); +} + +void AbstractSwLabDlg_Impl::SetCurPageId( const OString &rName ) +{ + m_xDlg->SetCurPageId( rName ); +} + +const SfxItemSet* AbstractSwLabDlg_Impl::GetOutputItemSet() const +{ + return m_xDlg->GetOutputItemSet(); +} + +const sal_uInt16* AbstractSwLabDlg_Impl::GetInputRanges(const SfxItemPool& pItem ) +{ + return m_xDlg->GetInputRanges( pItem ); +} + +void AbstractSwLabDlg_Impl::SetInputSet( const SfxItemSet* pInSet ) +{ + m_xDlg->SetInputSet( pInSet ); +} + +void AbstractSwLabDlg_Impl::SetText( const OUString& rStr ) +{ + m_xDlg->set_title(rStr); +} + +const OUString& AbstractSwLabDlg_Impl::GetBusinessCardStr() const +{ + return m_xDlg->GetBusinessCardStr(); +} + +Printer * AbstractSwLabDlg_Impl::GetPrt() +{ + return m_xDlg->GetPrt(); +} + +void AbstractSwSelGlossaryDlg_Impl::InsertGlos(const OUString &rRegion, const OUString &rGlosName) +{ + m_xDlg->InsertGlos( rRegion, rGlosName ); +} + +sal_Int32 AbstractSwSelGlossaryDlg_Impl::GetSelectedIdx() const +{ + return m_xDlg->GetSelectedIdx(); +} + +void AbstractSwSelGlossaryDlg_Impl::SelectEntryPos(sal_Int32 nIdx) +{ + m_xDlg->SelectEntryPos( nIdx ); +} + +std::unique_ptr<SwTableAutoFormat> AbstractSwAutoFormatDlg_Impl::FillAutoFormatOfIndex() const +{ + return m_xDlg->FillAutoFormatOfIndex(); +} + +void AbstractSwFieldDlg_Impl::SetCurPageId( const OString &rName ) +{ + m_xDlg->SetCurPageId( rName ); +} + +const SfxItemSet* AbstractSwFieldDlg_Impl::GetOutputItemSet() const +{ + return m_xDlg->GetOutputItemSet(); +} + +const sal_uInt16* AbstractSwFieldDlg_Impl::GetInputRanges(const SfxItemPool& pItem ) +{ + return m_xDlg->GetInputRanges( pItem ); +} + +void AbstractSwFieldDlg_Impl::SetInputSet( const SfxItemSet* pInSet ) +{ + m_xDlg->SetInputSet( pInSet ); +} + +void AbstractSwFieldDlg_Impl::SetText( const OUString& rStr ) +{ + m_xDlg->set_title(rStr); +} + +bool AbstractSwFieldDlg_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + auto xDlg = m_xDlg; + return SfxTabDialogController::runAsync(m_xDlg, [=](sal_Int32 nResult){ + xDlg->Close(); + if (rCtx.isSet()) + rCtx.maEndDialogFn(nResult); + }); +} + +void AbstractSwFieldDlg_Impl::Initialize(SfxChildWinInfo *pInfo) +{ + m_xDlg->Initialize( pInfo ); +} + +void AbstractSwFieldDlg_Impl::ReInitDlg() +{ + m_xDlg->ReInitDlg(); +} + +void AbstractSwFieldDlg_Impl::ActivateDatabasePage() +{ + m_xDlg->ActivateDatabasePage(); +} + +void AbstractSwFieldDlg_Impl::ShowReferencePage() +{ + m_xDlg->ShowReferencePage(); +} + +std::shared_ptr<SfxDialogController> AbstractSwFieldDlg_Impl::GetController() +{ + return m_xDlg; +} + +void AbstractSwRenameXNamedDlg_Impl::SetForbiddenChars( const OUString& rSet ) +{ + m_xDlg->SetForbiddenChars( rSet ); +} + +void AbstractSwRenameXNamedDlg_Impl::SetAlternativeAccess( + css::uno::Reference< css::container::XNameAccess > & xSecond, + css::uno::Reference< css::container::XNameAccess > & xThird ) +{ + m_xDlg->SetAlternativeAccess( xSecond, xThird); +} + +void AbstractSwModalRedlineAcceptDlg_Impl::AcceptAll( bool bAccept ) +{ + m_xDlg->AcceptAll( bAccept); +} + +OUString AbstractGlossaryDlg_Impl::GetCurrGrpName() const +{ + return m_xDlg->GetCurrGrpName(); +} + +OUString AbstractGlossaryDlg_Impl::GetCurrShortName() const +{ + return m_xDlg->GetCurrShortName(); +} + +void AbstractFieldInputDlg_Impl::EndDialog(sal_Int32 n) +{ + m_xDlg->response(n); +} + +bool AbstractFieldInputDlg_Impl::PrevButtonPressed() const +{ + return m_xDlg->PrevButtonPressed(); +} + +bool AbstractFieldInputDlg_Impl::NextButtonPressed() const +{ + return m_xDlg->NextButtonPressed(); +} + +OUString AbstractInsFootNoteDlg_Impl::GetFontName() +{ + return m_xDlg->GetFontName(); +} + +bool AbstractInsFootNoteDlg_Impl::IsEndNote() +{ + return m_xDlg->IsEndNote(); +} + +OUString AbstractInsFootNoteDlg_Impl::GetStr() +{ + return m_xDlg->GetStr(); +} + +void AbstractInsFootNoteDlg_Impl::SetHelpId(const OString& rHelpId) +{ + m_xDlg->set_help_id(rHelpId); +} + +void AbstractInsFootNoteDlg_Impl::SetText( const OUString& rStr ) +{ + m_xDlg->set_title(rStr); +} + +void AbstractInsTableDlg_Impl::GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol, + SwInsertTableOptions& rInsTableFlags, OUString& rTableAutoFormatName, + std::unique_ptr<SwTableAutoFormat>& prTAFormat ) +{ + SwInsTableDlg* pDlg = dynamic_cast<SwInsTableDlg*>(m_xDlg.get()); + if (pDlg) + pDlg->GetValues(rName, rRow, rCol, rInsTableFlags, rTableAutoFormatName, prTAFormat); +} + +OUString AbstractJavaEditDialog_Impl::GetScriptText() const +{ + return m_xDlg->GetScriptText(); +} + +OUString AbstractJavaEditDialog_Impl::GetScriptType() const +{ + return m_xDlg->GetScriptType(); +} + +bool AbstractJavaEditDialog_Impl::IsUrl() const +{ + return m_xDlg->IsUrl(); +} + +bool AbstractJavaEditDialog_Impl::IsNew() const +{ + return m_xDlg->IsNew(); +} + +bool AbstractJavaEditDialog_Impl::IsUpdate() const +{ + return m_xDlg->IsUpdate(); +} + +DBManagerOptions AbstractMailMergeDlg_Impl::GetMergeType() +{ + return m_xDlg->GetMergeType(); +} + +const OUString& AbstractMailMergeDlg_Impl::GetSaveFilter() const +{ + return m_xDlg->GetSaveFilter(); +} + +css::uno::Sequence< css::uno::Any > AbstractMailMergeDlg_Impl::GetSelection() const +{ + return m_xDlg->GetSelection(); +} + +uno::Reference< sdbc::XResultSet> AbstractMailMergeDlg_Impl::GetResultSet() const +{ + return m_xDlg->GetResultSet(); +} + +bool AbstractMailMergeDlg_Impl::IsSaveSingleDoc() const +{ + return m_xDlg->IsSaveSingleDoc(); +} + +bool AbstractMailMergeDlg_Impl::IsGenerateFromDataBase() const +{ + return m_xDlg->IsGenerateFromDataBase(); +} + +bool AbstractMailMergeDlg_Impl::IsFileEncryptedFromDataBase() const +{ + return m_xDlg->IsFileEncryptedFromDataBase(); +} + +OUString AbstractMailMergeDlg_Impl::GetColumnName() const +{ + return m_xDlg->GetColumnName(); +} + +OUString AbstractMailMergeDlg_Impl::GetPasswordColumnName() const +{ + return m_xDlg->GetPasswordColumnName(); +} + +OUString AbstractMailMergeDlg_Impl::GetTargetURL() const +{ + return m_xDlg->GetTargetURL(); +} + +bool AbstractMailMergeCreateFromDlg_Impl::IsThisDocument() const +{ + return m_xDlg->IsThisDocument(); +} + +bool AbstractMailMergeFieldConnectionsDlg_Impl::IsUseExistingConnections() const +{ + return m_xDlg->IsUseExistingConnections(); +} + +CurTOXType AbstractMultiTOXTabDialog_Impl::GetCurrentTOXType() const +{ + return m_xDlg->GetCurrentTOXType(); +} + +SwTOXDescription& AbstractMultiTOXTabDialog_Impl::GetTOXDescription(CurTOXType eTOXTypes) +{ + return m_xDlg->GetTOXDescription(eTOXTypes); +} + +const SfxItemSet* AbstractMultiTOXTabDialog_Impl::GetOutputItemSet() const +{ + return m_xDlg->GetOutputItemSet(); +} + +void AbstractEditRegionDlg_Impl::SelectSection(const OUString& rSectionName) +{ + m_xDlg->SelectSection(rSectionName); +} + +void +AbstractInsertSectionTabDialog_Impl::SetSectionData(SwSectionData const& rSect) +{ + m_xDlg->SetSectionData(rSect); +} + +void AbstractIndexMarkFloatDlg_Impl::ReInitDlg(SwWrtShell& rWrtShell) +{ + m_xDlg->ReInitDlg( rWrtShell); +} + +std::shared_ptr<SfxDialogController> AbstractIndexMarkFloatDlg_Impl::GetController() +{ + return m_xDlg; +} + +void AbstractAuthMarkFloatDlg_Impl::ReInitDlg(SwWrtShell& rWrtShell) +{ + m_xDlg->ReInitDlg(rWrtShell); +} + +std::shared_ptr<SfxDialogController> AbstractAuthMarkFloatDlg_Impl::GetController() +{ + return m_xDlg; +} + +std::shared_ptr<SfxDialogController> AbstractSwWordCountFloatDlg_Impl::GetController() +{ + return m_xDlg; +} + +void AbstractSwWordCountFloatDlg_Impl::UpdateCounts() +{ + m_xDlg->UpdateCounts(); +} + +void AbstractSwWordCountFloatDlg_Impl::SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat) +{ + m_xDlg->SetCounts(rCurrCnt, rDocStat); +} + +AbstractMailMergeWizard_Impl::~AbstractMailMergeWizard_Impl() +{ +} + +bool AbstractMailMergeWizard_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + // SwMailMergeWizardExecutor wants to run the lifecycle of this dialog + // so clear mxOwner here and leave it up to SwMailMergeWizardExecutor + rCtx.mxOwner.clear(); + return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + +short AbstractMailMergeWizard_Impl::Execute() +{ + return m_xDlg->run(); +} + +OUString AbstractMailMergeWizard_Impl::GetReloadDocument() const +{ + return m_xDlg->GetReloadDocument(); +} + +void AbstractMailMergeWizard_Impl::ShowPage( sal_uInt16 nLevel ) +{ + m_xDlg->skipUntil(nLevel); +} + +sal_uInt16 AbstractMailMergeWizard_Impl::GetRestartPage() const +{ + return m_xDlg->GetRestartPage(); +} + +VclPtr<AbstractSwInsertAbstractDlg> SwAbstractDialogFactory_Impl::CreateSwInsertAbstractDlg(weld::Window* pParent) +{ + return VclPtr<AbstractSwInsertAbstractDlg_Impl>::Create(std::make_unique<SwInsertAbstractDlg>(pParent)); +} + +VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwAddressAbstractDlg(weld::Window* pParent, + const SfxItemSet& rSet) +{ + return VclPtr<SwAbstractSfxController_Impl>::Create(std::make_unique<SwAddrDlg>(pParent, rSet)); +} + +VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwDropCapsDialog(weld::Window* pParent, + const SfxItemSet& rSet) +{ + return VclPtr<SwAbstractSfxController_Impl>::Create(std::make_unique<SwDropCapsDlg>(pParent, rSet)); +} + +VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwBackgroundDialog(weld::Window* pParent, + const SfxItemSet& rSet) +{ + return VclPtr<SwAbstractSfxController_Impl>::Create(std::make_unique<SwBackgroundDlg>(pParent, rSet)); +} + +VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateNumFormatDialog(weld::Widget* pParent, const SfxItemSet& rSet) +{ + return VclPtr<SwAbstractSfxController_Impl>::Create(std::make_unique<SwNumFormatDlg>(pParent, rSet)); +} + +VclPtr<AbstractSwAsciiFilterDlg> SwAbstractDialogFactory_Impl::CreateSwAsciiFilterDlg(weld::Window* pParent, + SwDocShell& rDocSh, SvStream* pStream) +{ + return VclPtr<AbstractSwAsciiFilterDlg_Impl>::Create(std::make_unique<SwAsciiFilterDlg>(pParent, rDocSh, pStream)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwInsertBookmarkDlg(weld::Window *pParent, + SwWrtShell &rSh, SfxRequest& rReq) +{ + return VclPtr<AbstractGenericDialog_Impl>::Create(std::make_shared<SwInsertBookmarkDlg>(pParent, rSh, rReq)); +} + +VclPtr<AbstractSwBreakDlg> SwAbstractDialogFactory_Impl::CreateSwBreakDlg(weld::Window* pParent, SwWrtShell &rSh) +{ + return VclPtr<AbstractSwBreakDlg_Impl>::Create(std::make_unique<SwBreakDlg>(pParent, rSh)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwChangeDBDlg(SwView& rVw) +{ +#if HAVE_FEATURE_DBCONNECTIVITY + return VclPtr<AbstractGenericDialog_Impl>::Create(std::make_shared<SwChangeDBDlg>(rVw)); +#else + (void) rVw; + return nullptr; +#endif +} + +VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwCharDlg(weld::Window* pParent, SwView& pVw, + const SfxItemSet& rCoreSet, SwCharDlgMode nDialogMode, const OUString* pFormatStr) +{ + return VclPtr<AbstractTabController_Impl>::Create(std::make_shared<SwCharDlg>(pParent, pVw, rCoreSet, nDialogMode, pFormatStr)); +} + +VclPtr<AbstractSwConvertTableDlg> SwAbstractDialogFactory_Impl::CreateSwConvertTableDlg(SwView& rView, bool bToTable) +{ + return VclPtr<AbstractSwConvertTableDlg_Impl>::Create(std::make_unique<SwConvertTableDlg>(rView, bToTable)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwCaptionDialog(weld::Window *pParent, SwView &rV) +{ + return VclPtr<AbstractGenericDialog_Impl>::Create(std::make_shared<SwCaptionDialog>(pParent, rV)); +} + +VclPtr<AbstractSwInsertDBColAutoPilot> SwAbstractDialogFactory_Impl::CreateSwInsertDBColAutoPilot( SwView& rView, + uno::Reference< sdbc::XDataSource> rxSource, + uno::Reference<sdbcx::XColumnsSupplier> xColSupp, + const SwDBData& rData) +{ +#if HAVE_FEATURE_DBCONNECTIVITY + return VclPtr<AbstractSwInsertDBColAutoPilot_Impl>::Create(std::make_unique<SwInsertDBColAutoPilot>(rView, rxSource, xColSupp, rData)); +#else + (void) rView; + (void) rxSource; + (void) xColSupp; + (void) rData; + return nullptr; +#endif +} + +VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwFootNoteOptionDlg(weld::Window *pParent, SwWrtShell &rSh) +{ + return VclPtr<AbstractTabController_Impl>::Create(std::make_shared<SwFootNoteOptionDlg>(pParent, rSh)); +} + +VclPtr<AbstractDropDownFieldDialog> SwAbstractDialogFactory_Impl::CreateDropDownFieldDialog(weld::Widget *pParent, + SwWrtShell &rSh, SwField* pField, bool bPrevButton, bool bNextButton) +{ + return VclPtr<AbstractDropDownFieldDialog_Impl>::Create(std::make_unique<sw::DropDownFieldDialog>(pParent, rSh, pField, bPrevButton, bNextButton)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateDropDownFormFieldDialog(weld::Widget *pParent, sw::mark::IFieldmark* pDropDownField) +{ + return VclPtr<AbstractDropDownFormFieldDialog_Impl>::Create(std::make_unique<sw::DropDownFormFieldDialog>(pParent, pDropDownField)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateDateFormFieldDialog(weld::Widget *pParent, sw::mark::IDateFieldmark* pDateField, SwDoc* pDoc) +{ + return VclPtr<AbstractDateFormFieldDialog_Impl>::Create(std::make_unique<sw::DateFormFieldDialog>(pParent, pDateField, pDoc)); +} + +VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, + SwWrtShell* pWrtSh, Printer* pPrt, + bool bInsert) +{ + return VclPtr<AbstractTabController_Impl>::Create(std::make_shared<SwEnvDlg>(pParent, rSet, pWrtSh,pPrt, bInsert)); +} + +VclPtr<AbstractSwLabDlg> SwAbstractDialogFactory_Impl::CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, + SwDBManager* pDBManager, bool bLabel) +{ + return VclPtr<AbstractSwLabDlg_Impl>::Create(std::make_unique<SwLabDlg>(pParent, rSet, pDBManager, bLabel)); +} + +SwLabDlgMethod SwAbstractDialogFactory_Impl::GetSwLabDlgStaticMethod () +{ + return SwLabDlg::UpdateFieldInformation; +} + +VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwParaDlg(weld::Window *pParent, SwView& rVw, + const SfxItemSet& rCoreSet, + bool bDraw , + const OString& sDefPage) +{ + return VclPtr<AbstractTabController_Impl>::Create(std::make_shared<SwParaDlg>(pParent, rVw, rCoreSet, DLG_STD, nullptr, bDraw, sDefPage)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwAutoMarkDialog(weld::Window *pParent, SwWrtShell &rSh) +{ + return VclPtr<AbstractGenericDialog_Impl>::Create(std::make_shared<SwAuthMarkModalDlg>(pParent, rSh)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwColumnDialog(weld::Window *pParent, SwWrtShell &rSh) +{ + return VclPtr<AbstractGenericDialog_Impl>::Create(std::make_shared<SwColumnDlg>(pParent, rSh)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwTableHeightDialog(weld::Window *pParent, SwWrtShell &rSh) +{ + return VclPtr<AbstractSwTableHeightDlg_Impl>::Create(std::make_unique<SwTableHeightDlg>(pParent, rSh)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwSortingDialog(weld::Window *pParent, SwWrtShell &rSh) +{ + return VclPtr<AbstractSwSortDlg_Impl>::Create(std::make_unique<SwSortDlg>(pParent, rSh)); +} + +VclPtr<AbstractSplitTableDialog> SwAbstractDialogFactory_Impl::CreateSplitTableDialog(weld::Window *pParent, SwWrtShell &rSh) +{ + return VclPtr<AbstractSplitTableDialog_Impl>::Create(std::make_unique<SwSplitTableDlg>(pParent, rSh)); +} + +VclPtr<AbstractSwSelGlossaryDlg> SwAbstractDialogFactory_Impl::CreateSwSelGlossaryDlg(weld::Window *pParent, const OUString &rShortName) +{ + return VclPtr<AbstractSwSelGlossaryDlg_Impl>::Create(std::make_unique<SwSelGlossaryDlg>(pParent, rShortName)); +} + +VclPtr<AbstractSwAutoFormatDlg> SwAbstractDialogFactory_Impl::CreateSwAutoFormatDlg(weld::Window* pParent, + SwWrtShell* pShell, bool bSetAutoFormat, const SwTableAutoFormat* pSelFormat) +{ + return VclPtr<AbstractSwAutoFormatDlg_Impl>::Create( + std::unique_ptr<SwAutoFormatDlg, o3tl::default_delete<SwAutoFormatDlg>>( + new SwAutoFormatDlg(pParent, pShell, bSetAutoFormat, pSelFormat))); +} + +VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwBorderDlg(weld::Window* pParent, SfxItemSet& rSet, SwBorderModes nType ) +{ + return VclPtr<SwAbstractSfxController_Impl>::Create(std::make_unique<SwBorderDlg>(pParent, rSet, nType)); +} + +VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwWrapDlg(weld::Window* pParent, SfxItemSet& rSet, SwWrtShell* pSh) +{ + return VclPtr<SwAbstractSfxController_Impl>::Create(std::make_unique<SwWrapDlg>(pParent, rSet, pSh, true/*bDrawMode*/)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwTableWidthDlg(weld::Window *pParent, SwTableFUNC &rFnc) +{ + return VclPtr<AbstractSwTableWidthDlg_Impl>::Create(std::make_unique<SwTableWidthDlg>(pParent, rFnc)); +} + +VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwTableTabDlg(weld::Window* pParent, + const SfxItemSet* pItemSet, SwWrtShell* pSh) +{ + return VclPtr<AbstractTabController_Impl>::Create(std::make_shared<SwTableTabDlg>(pParent, pItemSet, pSh)); +} + +VclPtr<AbstractSwFieldDlg> SwAbstractDialogFactory_Impl::CreateSwFieldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, weld::Window *pParent) +{ + return VclPtr<AbstractSwFieldDlg_Impl>::Create(std::make_shared<SwFieldDlg>(pB, pCW, pParent)); +} + +VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwFieldEditDlg(SwView& rVw) +{ + return VclPtr<SwAbstractSfxController_Impl>::Create(std::make_unique<SwFieldEditDlg>(rVw)); +} + +VclPtr<AbstractSwRenameXNamedDlg> SwAbstractDialogFactory_Impl::CreateSwRenameXNamedDlg(weld::Window* pParent, + css::uno::Reference< css::container::XNamed > & xNamed, + css::uno::Reference< css::container::XNameAccess > & xNameAccess) +{ + return VclPtr<AbstractSwRenameXNamedDlg_Impl>::Create(std::make_unique<SwRenameXNamedDlg>(pParent,xNamed, xNameAccess)); +} + +VclPtr<AbstractSwModalRedlineAcceptDlg> SwAbstractDialogFactory_Impl::CreateSwModalRedlineAcceptDlg(weld::Window *pParent) +{ + return VclPtr<AbstractSwModalRedlineAcceptDlg_Impl>::Create(std::make_unique<SwModalRedlineAcceptDlg>(pParent)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateTableMergeDialog(weld::Window* pParent, bool& rWithPrev) +{ + return VclPtr<AbstractSwMergeTableDlg_Impl>::Create(std::make_unique<SwMergeTableDlg>(pParent, rWithPrev)); +} + +VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateFrameTabDialog(const OUString &rDialogType, + SfxViewFrame *pFrame, weld::Window *pParent, + const SfxItemSet& rCoreSet, + bool bNewFrame, + const OString& sDefPage ) +{ + return VclPtr<AbstractTabController_Impl>::Create(std::make_shared<SwFrameDlg>(pFrame, pParent, rCoreSet, bNewFrame, rDialogType, false/*bFormat*/, sDefPage, nullptr)); +} + +VclPtr<SfxAbstractApplyTabDialog> SwAbstractDialogFactory_Impl::CreateTemplateDialog( + weld::Window *pParent, + SfxStyleSheetBase& rBase, + SfxStyleFamily nRegion, + const OString& sPage, + SwWrtShell* pActShell, + bool bNew ) +{ + return VclPtr<AbstractApplyTabController_Impl>::Create(std::make_shared<SwTemplateDlgController>(pParent, rBase, nRegion, + sPage, pActShell, bNew)); +} + +VclPtr<AbstractGlossaryDlg> SwAbstractDialogFactory_Impl::CreateGlossaryDlg(SfxViewFrame* pViewFrame, SwGlossaryHdl* pGlosHdl, + SwWrtShell *pWrtShell) +{ + return VclPtr<AbstractGlossaryDlg_Impl>::Create(std::make_unique<SwGlossaryDlg>(pViewFrame, pGlosHdl, pWrtShell)); +} + +VclPtr<AbstractFieldInputDlg> SwAbstractDialogFactory_Impl::CreateFieldInputDlg(weld::Widget *pParent, + SwWrtShell &rSh, SwField* pField, bool bPrevButton, bool bNextButton) +{ + return VclPtr<AbstractFieldInputDlg_Impl>::Create(std::make_unique<SwFieldInputDlg>(pParent, rSh, pField, bPrevButton, bNextButton)); +} + +VclPtr<AbstractInsFootNoteDlg> SwAbstractDialogFactory_Impl::CreateInsFootNoteDlg( + weld::Window * pParent, SwWrtShell &rSh, bool bEd ) +{ + return VclPtr<AbstractInsFootNoteDlg_Impl>::Create(std::make_unique<SwInsFootNoteDlg>(pParent, rSh, bEd)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateTitlePageDlg(weld::Window *pParent) +{ + return VclPtr<AbstractGenericDialog_Impl>::Create(std::make_shared<SwTitlePageDlg>(pParent)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateVclSwViewDialog(SwView& rView) +{ + return VclPtr<AbstractGenericDialog_Impl>::Create(std::make_shared<SwLineNumberingDlg>(rView)); +} + +std::shared_ptr<AbstractInsTableDlg> SwAbstractDialogFactory_Impl::CreateInsTableDlg(SwView& rView) +{ + return std::make_shared<AbstractInsTableDlg_Impl>(std::make_shared<SwInsTableDlg>(rView)); +} + +VclPtr<AbstractJavaEditDialog> SwAbstractDialogFactory_Impl::CreateJavaEditDialog( + weld::Window* pParent, SwWrtShell* pWrtSh) +{ + return VclPtr<AbstractJavaEditDialog_Impl>::Create(std::make_unique<SwJavaEditDialog>(pParent, pWrtSh)); +} + +VclPtr<AbstractMailMergeDlg> SwAbstractDialogFactory_Impl::CreateMailMergeDlg( + weld::Window* pParent, SwWrtShell& rSh, + const OUString& rSourceName, + const OUString& rTableName, + sal_Int32 nCommandType, + const uno::Reference< sdbc::XConnection>& xConnection ) +{ + return VclPtr<AbstractMailMergeDlg_Impl>::Create(std::make_unique<SwMailMergeDlg>(pParent, rSh, rSourceName, rTableName, nCommandType, xConnection, nullptr)); +} + +VclPtr<AbstractMailMergeCreateFromDlg> SwAbstractDialogFactory_Impl::CreateMailMergeCreateFromDlg(weld::Window* pParent) +{ + return VclPtr<AbstractMailMergeCreateFromDlg_Impl>::Create(std::make_unique<SwMailMergeCreateFromDlg>(pParent)); +} + +VclPtr<AbstractMailMergeFieldConnectionsDlg> SwAbstractDialogFactory_Impl::CreateMailMergeFieldConnectionsDlg(weld::Window* pParent) +{ + return VclPtr<AbstractMailMergeFieldConnectionsDlg_Impl>::Create(std::make_unique<SwMailMergeFieldConnectionsDlg>(pParent)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateMultiTOXMarkDlg(weld::Window* pParent, SwTOXMgr &rTOXMgr) +{ + return VclPtr<AbstractMultiTOXMarkDlg_Impl>::Create(std::make_unique<SwMultiTOXMarkDlg>(pParent, rTOXMgr)); +} + +VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSvxNumBulletTabDialog(weld::Window* pParent, + const SfxItemSet* pSwItemSet, + SwWrtShell & rWrtSh) +{ + return VclPtr<AbstractTabController_Impl>::Create(std::make_shared<SwSvxNumBulletTabDialog>(pParent, pSwItemSet, rWrtSh)); +} + +VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateOutlineTabDialog(weld::Window* pParent, + const SfxItemSet* pSwItemSet, + SwWrtShell & rWrtSh ) +{ + return VclPtr<AbstractTabController_Impl>::Create(std::make_shared<SwOutlineTabDialog>(pParent, pSwItemSet, rWrtSh)); +} + +VclPtr<AbstractMultiTOXTabDialog> SwAbstractDialogFactory_Impl::CreateMultiTOXTabDialog(weld::Window* pParent, const SfxItemSet& rSet, + SwWrtShell &rShell, SwTOXBase* pCurTOX, bool bGlobal) +{ + return VclPtr<AbstractMultiTOXTabDialog_Impl>::Create(std::make_shared<SwMultiTOXTabDialog>(pParent, rSet, rShell, pCurTOX, USHRT_MAX, bGlobal)); +} + +VclPtr<AbstractEditRegionDlg> SwAbstractDialogFactory_Impl::CreateEditRegionDlg(weld::Window* pParent, SwWrtShell& rWrtSh) +{ + return VclPtr<AbstractEditRegionDlg_Impl>::Create(std::make_shared<SwEditRegionDlg>(pParent, rWrtSh)); +} + +VclPtr<AbstractInsertSectionTabDialog> SwAbstractDialogFactory_Impl::CreateInsertSectionTabDialog(weld::Window* pParent, + const SfxItemSet& rSet, SwWrtShell& rSh) +{ + return VclPtr<AbstractInsertSectionTabDialog_Impl>::Create(std::make_shared<SwInsertSectionTabDialog>(pParent, rSet, rSh)); +} + +VclPtr<AbstractMarkFloatDlg> SwAbstractDialogFactory_Impl::CreateIndexMarkFloatDlg( + SfxBindings* pBindings, + SfxChildWindow* pChild, + weld::Window *pParent, + SfxChildWinInfo* pInfo ) +{ + return VclPtr<AbstractIndexMarkFloatDlg_Impl>::Create(std::make_shared<SwIndexMarkFloatDlg>(pBindings, pChild, pParent, pInfo, true/*bNew*/)); +} + +VclPtr<AbstractMarkFloatDlg> SwAbstractDialogFactory_Impl::CreateAuthMarkFloatDlg( + SfxBindings* pBindings, + SfxChildWindow* pChild, + weld::Window *pParent, + SfxChildWinInfo* pInfo) +{ + return VclPtr<AbstractAuthMarkFloatDlg_Impl>::Create(std::make_shared<SwAuthMarkFloatDlg>(pBindings, pChild, pParent, pInfo, true/*bNew*/)); +} + +VclPtr<AbstractSwWordCountFloatDlg> SwAbstractDialogFactory_Impl::CreateSwWordCountDialog( + SfxBindings* pBindings, + SfxChildWindow* pChild, + weld::Window *pParent, + SfxChildWinInfo* pInfo) +{ + return VclPtr<AbstractSwWordCountFloatDlg_Impl>::Create(std::make_shared<SwWordCountFloatDlg>(pBindings, pChild, pParent, pInfo)); +} + +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateIndexMarkModalDlg(weld::Window *pParent, SwWrtShell& rSh, SwTOXMark* pCurTOXMark ) +{ + return VclPtr<AbstractGenericDialog_Impl>::Create(std::make_shared<SwIndexMarkModalDlg>(pParent, rSh, pCurTOXMark)); +} + +VclPtr<AbstractMailMergeWizard> SwAbstractDialogFactory_Impl::CreateMailMergeWizard( + SwView& rView, std::shared_ptr<SwMailMergeConfigItem>& rConfigItem) +{ +#if HAVE_FEATURE_DBCONNECTIVITY + return VclPtr<AbstractMailMergeWizard_Impl>::Create(std::make_shared<SwMailMergeWizard>(rView, rConfigItem)); +#else + (void) rView; + (void) rConfigItem; + return nullptr; +#endif +} + +GlossaryGetCurrGroup SwAbstractDialogFactory_Impl::GetGlossaryCurrGroupFunc() +{ + return SwGlossaryDlg::GetCurrGroup; +} + +GlossarySetActGroup SwAbstractDialogFactory_Impl::SetGlossaryActGroupFunc() +{ + return SwGlossaryDlg::SetActGroup; +} + +// Factories for TabPages +CreateTabPage SwAbstractDialogFactory_Impl::GetTabPageCreatorFunc( sal_uInt16 nId ) +{ + CreateTabPage pRet = nullptr; + switch ( nId ) + { + case RID_SW_TP_OPTCOMPATIBILITY_PAGE : + pRet = SwCompatibilityOptPage::Create; + break; + case RID_SW_TP_OPTLOAD_PAGE : + pRet = SwLoadOptPage::Create; + break; + case RID_SW_TP_OPTCAPTION_PAGE: + return SwCaptionOptPage::Create; + case RID_SW_TP_CONTENT_OPT: + case RID_SW_TP_HTML_CONTENT_OPT: + pRet = SwContentOptPage::Create; + break; + case RID_SW_TP_OPTSHDWCRSR: + case RID_SW_TP_HTML_OPTSHDWCRSR: + pRet = SwShdwCursorOptionsTabPage::Create; + break; + case RID_SW_TP_REDLINE_OPT : + pRet = SwRedlineOptionsTabPage::Create; + break; + case RID_SW_TP_OPTTEST_PAGE : +#ifdef DBG_UTIL + pRet = SwTestTabPage::Create; +#endif + break; + case TP_OPTPRINT_PAGE : + case RID_SW_TP_HTML_OPTPRINT_PAGE: + case RID_SW_TP_OPTPRINT_PAGE: + pRet = SwAddPrinterTabPage::Create; + break; + case RID_SW_TP_STD_FONT: + case RID_SW_TP_STD_FONT_CJK: + case RID_SW_TP_STD_FONT_CTL: + pRet = SwStdFontTabPage::Create; + break; + case RID_SW_TP_HTML_OPTTABLE_PAGE: + case RID_SW_TP_OPTTABLE_PAGE: + pRet = SwTableOptionsTabPage::Create; + break; + case RID_SW_TP_DOC_STAT : + pRet = SwDocStatPage::Create; + break; + case RID_SW_TP_MAILCONFIG: + pRet = SwMailConfigPage::Create; + break; + case RID_SW_TP_COMPARISON_OPT : + pRet = SwCompareOptionsTabPage::Create; + break; + } + + return pRet; +} + +void SwAbstractDialogFactory_Impl::ExecuteMMResultSaveDialog(weld::Window* pParent) +{ +#if HAVE_FEATURE_DBCONNECTIVITY + SwMMResultSaveDialog aDialog(pParent); + aDialog.run(); +#else + (void) pParent; +#endif +} + +void SwAbstractDialogFactory_Impl::ExecuteMMResultPrintDialog(weld::Window* pParent) +{ +#if HAVE_FEATURE_DBCONNECTIVITY + SwMMResultPrintDialog aDialog(pParent); + aDialog.run(); +#else + (void) pParent; +#endif +} + +void SwAbstractDialogFactory_Impl::ExecuteMMResultEmailDialog(weld::Window* pParent) +{ +#if HAVE_FEATURE_DBCONNECTIVITY + SwMMResultEmailDialog aDialog(pParent); + aDialog.run(); +#else + (void) pParent; +#endif +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx new file mode 100644 index 000000000..0f1a7c94f --- /dev/null +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -0,0 +1,787 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SW_SOURCE_UI_DIALOG_SWDLGFACT_HXX +#define INCLUDED_SW_SOURCE_UI_DIALOG_SWDLGFACT_HXX + +#include <swabstdlg.hxx> + +#include <abstract.hxx> +#include <ascfldlg.hxx> +#include <break.hxx> +#include <cnttab.hxx> +#include <colwd.hxx> +#include <convert.hxx> +#include <DateFormFieldDialog.hxx> +#include <dbinsdlg.hxx> +#include <DropDownFieldDialog.hxx> +#include <DropDownFormFieldDialog.hxx> +#include <fldtdlg.hxx> +#include <glossary.hxx> +#include <inpdlg.hxx> +#include <insfnote.hxx> +#include <instable.hxx> +#include <javaedit.hxx> +#include <label.hxx> +#include <mailmergewizard.hxx> +#include <mailmrge.hxx> +#include <mergetbl.hxx> +#include <multmrk.hxx> +#include <regionsw.hxx> +#include <rowht.hxx> +#include <selglos.hxx> +#include <splittbl.hxx> +#include <srtdlg.hxx> +#include <swmodalredlineacceptdlg.hxx> +#include <swrenamexnameddlg.hxx> +#include <swuicnttab.hxx> +#include <swuiidxmrk.hxx> +#include <tautofmt.hxx> +#include <wordcountdialog.hxx> + +class SwInsertAbstractDlg; +class SwAsciiFilterDlg; +class SwBreakDlg; +class SwMultiTOXMarkDlg; +class SwSortDlg; +class SwTableHeightDlg; +class SwTableWidthDlg; +class SwMergeTableDlg; +class SfxTabDialog; +class SwConvertTableDlg; +class SwInsertDBColAutoPilot; +class SwLabDlg; +class SwSelGlossaryDlg; +class SwAutoFormatDlg; +class SwFieldDlg; +class SwRenameXNamedDlg; +class SwModalRedlineAcceptDlg; +class SwTOXMark; +class SwSplitTableDlg; + +#include <itabenum.hxx> +#include <optional> +#include <o3tl/deleter.hxx> + +namespace sw +{ +class DropDownFieldDialog; +class DropDownFormFieldDialog; +class DateFormFieldDialog; +} + +class SwWordCountFloatDlg; +class AbstractSwWordCountFloatDlg_Impl : public AbstractSwWordCountFloatDlg +{ + std::shared_ptr<SwWordCountFloatDlg> m_xDlg; +public: + explicit AbstractSwWordCountFloatDlg_Impl(std::shared_ptr<SwWordCountFloatDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual void UpdateCounts() override; + virtual void SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat) override; + virtual std::shared_ptr<SfxDialogController> GetController() override; +}; + +class AbstractSwInsertAbstractDlg_Impl : public AbstractSwInsertAbstractDlg +{ + std::unique_ptr<SwInsertAbstractDlg> m_xDlg; +public: + explicit AbstractSwInsertAbstractDlg_Impl(std::unique_ptr<SwInsertAbstractDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual sal_uInt8 GetLevel() const override ; + virtual sal_uInt8 GetPara() const override ; +}; + +class SwAbstractSfxController_Impl : public SfxAbstractDialog +{ + std::unique_ptr<SfxSingleTabDialogController> m_xDlg; +public: + explicit SwAbstractSfxController_Impl(std::unique_ptr<SfxSingleTabDialogController> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual const SfxItemSet* GetOutputItemSet() const override; + virtual void SetText(const OUString& rStr) override; +}; + +class AbstractSwAsciiFilterDlg_Impl : public AbstractSwAsciiFilterDlg +{ + std::unique_ptr<SwAsciiFilterDlg> m_xDlg; +public: + explicit AbstractSwAsciiFilterDlg_Impl(std::unique_ptr<SwAsciiFilterDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual void FillOptions( SwAsciiOptions& rOptions ) override; +}; + +class AbstractGenericDialog_Impl : public VclAbstractDialog +{ + std::shared_ptr<weld::GenericDialogController> m_xDlg; +public: + explicit AbstractGenericDialog_Impl(std::shared_ptr<weld::GenericDialogController> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; +}; + +class AbstractSwSortDlg_Impl : public VclAbstractDialog +{ + std::unique_ptr<SwSortDlg> m_xDlg; +public: + explicit AbstractSwSortDlg_Impl(std::unique_ptr<SwSortDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; +}; + +class AbstractMultiTOXMarkDlg_Impl : public VclAbstractDialog +{ + std::unique_ptr<SwMultiTOXMarkDlg> m_xDlg; +public: + explicit AbstractMultiTOXMarkDlg_Impl(std::unique_ptr<SwMultiTOXMarkDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; +}; + +class AbstractSwBreakDlg_Impl : public AbstractSwBreakDlg +{ + std::unique_ptr<SwBreakDlg> m_xDlg; +public: + explicit AbstractSwBreakDlg_Impl(std::unique_ptr<SwBreakDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual OUString GetTemplateName() override; + virtual sal_uInt16 GetKind() override; + virtual ::std::optional<sal_uInt16> GetPageNumber() override; +}; + +class AbstractSwTableWidthDlg_Impl : public VclAbstractDialog +{ + std::unique_ptr<SwTableWidthDlg> m_xDlg; +public: + explicit AbstractSwTableWidthDlg_Impl(std::unique_ptr<SwTableWidthDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; +}; + +class AbstractSwTableHeightDlg_Impl : public VclAbstractDialog +{ + std::unique_ptr<SwTableHeightDlg> m_xDlg; +public: + explicit AbstractSwTableHeightDlg_Impl(std::unique_ptr<SwTableHeightDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; +}; + +class AbstractSwMergeTableDlg_Impl : public VclAbstractDialog +{ + std::unique_ptr<SwMergeTableDlg> m_xDlg; +public: + explicit AbstractSwMergeTableDlg_Impl(std::unique_ptr<SwMergeTableDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; +}; + +class AbstractSplitTableDialog_Impl : public AbstractSplitTableDialog // add for +{ + std::unique_ptr<SwSplitTableDlg> m_xDlg; +public: + explicit AbstractSplitTableDialog_Impl(std::unique_ptr<SwSplitTableDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual SplitTable_HeadlineOption GetSplitMode() override; +}; + +class AbstractTabController_Impl : virtual public SfxAbstractTabDialog +{ +protected: + std::shared_ptr<SfxTabDialogController> m_xDlg; +public: + explicit AbstractTabController_Impl(std::shared_ptr<SfxTabDialogController> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; + virtual void SetCurPageId( const OString &rName ) override; + virtual const SfxItemSet* GetOutputItemSet() const override; + virtual const sal_uInt16* GetInputRanges( const SfxItemPool& pItem ) override; + virtual void SetInputSet( const SfxItemSet* pInSet ) override; + //From class Window. + virtual void SetText( const OUString& rStr ) override; +}; + +class AbstractApplyTabController_Impl : public AbstractTabController_Impl, virtual public SfxAbstractApplyTabDialog +{ +public: + explicit AbstractApplyTabController_Impl(std::shared_ptr<SfxTabDialogController> p) + : AbstractTabController_Impl(std::move(p)) + { + } + DECL_LINK(ApplyHdl, weld::Button&, void); +private: + Link<LinkParamNone*,void> m_aHandler; + virtual void SetApplyHdl( const Link<LinkParamNone*,void>& rLink ) override; +}; + +class AbstractSwConvertTableDlg_Impl : public AbstractSwConvertTableDlg +{ + std::unique_ptr<SwConvertTableDlg> m_xDlg; +public: + explicit AbstractSwConvertTableDlg_Impl(std::unique_ptr<SwConvertTableDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual void GetValues( sal_Unicode& rDelim,SwInsertTableOptions& rInsTableFlags, + SwTableAutoFormat const*& prTAFormat) override; +}; + +class AbstractSwInsertDBColAutoPilot_Impl : public AbstractSwInsertDBColAutoPilot +{ + std::unique_ptr<SwInsertDBColAutoPilot> m_xDlg; +public: + explicit AbstractSwInsertDBColAutoPilot_Impl(std::unique_ptr<SwInsertDBColAutoPilot> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual void DataToDoc( const css::uno::Sequence< css::uno::Any >& rSelection, + css::uno::Reference< css::sdbc::XDataSource> rxSource, + css::uno::Reference< css::sdbc::XConnection> xConnection, + css::uno::Reference< css::sdbc::XResultSet > xResultSet) override; +}; + +class AbstractDropDownFieldDialog_Impl : public AbstractDropDownFieldDialog +{ + std::unique_ptr<sw::DropDownFieldDialog> m_xDlg; +public: + explicit AbstractDropDownFieldDialog_Impl(std::unique_ptr<sw::DropDownFieldDialog> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool PrevButtonPressed() const override; + virtual bool NextButtonPressed() const override; +}; + +class AbstractDropDownFormFieldDialog_Impl : public VclAbstractDialog +{ + std::unique_ptr<sw::DropDownFormFieldDialog> m_xDlg; +public: + explicit AbstractDropDownFormFieldDialog_Impl(std::unique_ptr<sw::DropDownFormFieldDialog> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; +}; + +class AbstractDateFormFieldDialog_Impl : public VclAbstractDialog +{ + std::unique_ptr<sw::DateFormFieldDialog> m_xDlg; +public: + explicit AbstractDateFormFieldDialog_Impl(std::unique_ptr<sw::DateFormFieldDialog> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; +}; + +class AbstractSwLabDlg_Impl : public AbstractSwLabDlg +{ + std::unique_ptr<SwLabDlg> m_xDlg; +public: + explicit AbstractSwLabDlg_Impl(std::unique_ptr<SwLabDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual void SetCurPageId( const OString &rName ) override; + virtual const SfxItemSet* GetOutputItemSet() const override; + virtual const sal_uInt16* GetInputRanges( const SfxItemPool& pItem ) override; + virtual void SetInputSet( const SfxItemSet* pInSet ) override; + //From class Window. + virtual void SetText( const OUString& rStr ) override; + virtual const OUString& GetBusinessCardStr() const override; + virtual Printer *GetPrt() override; +}; + +class AbstractSwSelGlossaryDlg_Impl : public AbstractSwSelGlossaryDlg +{ + std::unique_ptr<SwSelGlossaryDlg> m_xDlg; +public: + explicit AbstractSwSelGlossaryDlg_Impl(std::unique_ptr<SwSelGlossaryDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual void InsertGlos(const OUString &rRegion, const OUString &rGlosName) override; // inline + virtual sal_Int32 GetSelectedIdx() const override; // inline + virtual void SelectEntryPos(sal_Int32 nIdx) override; // inline +}; + +class AbstractSwAutoFormatDlg_Impl : public AbstractSwAutoFormatDlg +{ + std::unique_ptr<SwAutoFormatDlg, o3tl::default_delete<SwAutoFormatDlg>> m_xDlg; +public: + explicit AbstractSwAutoFormatDlg_Impl(std::unique_ptr<SwAutoFormatDlg, o3tl::default_delete<SwAutoFormatDlg>> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual std::unique_ptr<SwTableAutoFormat> FillAutoFormatOfIndex() const override; +}; + +class AbstractSwFieldDlg_Impl : public AbstractSwFieldDlg +{ + std::shared_ptr<SwFieldDlg> m_xDlg; +public: + explicit AbstractSwFieldDlg_Impl(std::shared_ptr<SwFieldDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; + virtual void SetCurPageId( const OString &rName ) override; + virtual const SfxItemSet* GetOutputItemSet() const override; + virtual const sal_uInt16* GetInputRanges( const SfxItemPool& pItem ) override; + virtual void SetInputSet( const SfxItemSet* pInSet ) override; + //From class Window. + virtual void SetText( const OUString& rStr ) override; + virtual void ShowReferencePage() override; + virtual void Initialize(SfxChildWinInfo *pInfo) override; + virtual void ReInitDlg() override; + virtual void ActivateDatabasePage() override; + virtual std::shared_ptr<SfxDialogController> GetController() override; +}; + +class AbstractSwRenameXNamedDlg_Impl : public AbstractSwRenameXNamedDlg +{ + std::unique_ptr<SwRenameXNamedDlg> m_xDlg; +public: + explicit AbstractSwRenameXNamedDlg_Impl(std::unique_ptr<SwRenameXNamedDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual void SetForbiddenChars( const OUString& rSet ) override; + virtual void SetAlternativeAccess( + css::uno::Reference< css::container::XNameAccess > & xSecond, + css::uno::Reference< css::container::XNameAccess > & xThird ) override; +}; + +class AbstractSwModalRedlineAcceptDlg_Impl : public AbstractSwModalRedlineAcceptDlg +{ + std::unique_ptr<SwModalRedlineAcceptDlg> m_xDlg; +public: + explicit AbstractSwModalRedlineAcceptDlg_Impl(std::unique_ptr<SwModalRedlineAcceptDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual void AcceptAll(bool bAccept) override; +}; + +class SwGlossaryDlg; +class AbstractGlossaryDlg_Impl : public AbstractGlossaryDlg +{ + std::unique_ptr<SwGlossaryDlg> m_xDlg; +public: + explicit AbstractGlossaryDlg_Impl(std::unique_ptr<SwGlossaryDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual OUString GetCurrGrpName() const override; + virtual OUString GetCurrShortName() const override; +}; + +class SwFieldInputDlg; +class AbstractFieldInputDlg_Impl : public AbstractFieldInputDlg +{ + std::unique_ptr<SwFieldInputDlg> m_xDlg; +public: + explicit AbstractFieldInputDlg_Impl(std::unique_ptr<SwFieldInputDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual void EndDialog(sal_Int32) override; + virtual bool PrevButtonPressed() const override; + virtual bool NextButtonPressed() const override; +}; + +class SwInsFootNoteDlg; +class AbstractInsFootNoteDlg_Impl : public AbstractInsFootNoteDlg +{ + std::unique_ptr<SwInsFootNoteDlg> m_xDlg; +public: + explicit AbstractInsFootNoteDlg_Impl(std::unique_ptr<SwInsFootNoteDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual OUString GetFontName() override; + virtual bool IsEndNote() override; + virtual OUString GetStr() override; + //from class Window + virtual void SetHelpId( const OString& sHelpId ) override; + virtual void SetText( const OUString& rStr ) override; +}; + +class SwInsTableDlg; +class AbstractInsTableDlg_Impl : public AbstractInsTableDlg +{ +protected: + std::shared_ptr<weld::DialogController> m_xDlg; +public: + explicit AbstractInsTableDlg_Impl(std::shared_ptr<weld::DialogController> p) + : m_xDlg(p) + { + } + virtual void GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol, + SwInsertTableOptions& rInsTableFlags, OUString& rTableAutoFormatName, + std::unique_ptr<SwTableAutoFormat>& prTAFormat ) override; + virtual std::shared_ptr<weld::DialogController> getDialogController() override { return m_xDlg; } +}; + +class SwJavaEditDialog; +class AbstractJavaEditDialog_Impl : public AbstractJavaEditDialog +{ + std::unique_ptr<SwJavaEditDialog> m_xDlg; +public: + explicit AbstractJavaEditDialog_Impl(std::unique_ptr<SwJavaEditDialog> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual OUString GetScriptText() const override; + virtual OUString GetScriptType() const override; + virtual bool IsUrl() const override; + virtual bool IsNew() const override; + virtual bool IsUpdate() const override; +}; + +class SwMailMergeDlg; +class AbstractMailMergeDlg_Impl : public AbstractMailMergeDlg +{ + std::unique_ptr<SwMailMergeDlg> m_xDlg; +public: + explicit AbstractMailMergeDlg_Impl(std::unique_ptr<SwMailMergeDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual DBManagerOptions GetMergeType() override ; + virtual const OUString& GetSaveFilter() const override; + virtual css::uno::Sequence< css::uno::Any > GetSelection() const override ; + virtual css::uno::Reference< css::sdbc::XResultSet> GetResultSet() const override; + virtual bool IsSaveSingleDoc() const override; + virtual bool IsGenerateFromDataBase() const override; + virtual bool IsFileEncryptedFromDataBase() const override; + virtual OUString GetColumnName() const override; + virtual OUString GetPasswordColumnName() const override; + virtual OUString GetTargetURL() const override; +}; + +class SwMailMergeCreateFromDlg; +class AbstractMailMergeCreateFromDlg_Impl : public AbstractMailMergeCreateFromDlg +{ + std::unique_ptr<SwMailMergeCreateFromDlg> m_xDlg; +public: + explicit AbstractMailMergeCreateFromDlg_Impl(std::unique_ptr<SwMailMergeCreateFromDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool IsThisDocument() const override ; +}; + +class SwMailMergeFieldConnectionsDlg; +class AbstractMailMergeFieldConnectionsDlg_Impl : public AbstractMailMergeFieldConnectionsDlg +{ + std::unique_ptr<SwMailMergeFieldConnectionsDlg> m_xDlg; +public: + explicit AbstractMailMergeFieldConnectionsDlg_Impl(std::unique_ptr<SwMailMergeFieldConnectionsDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool IsUseExistingConnections() const override ; +}; + +class SwMultiTOXTabDialog; +class AbstractMultiTOXTabDialog_Impl : public AbstractMultiTOXTabDialog +{ +protected: + std::shared_ptr<SwMultiTOXTabDialog> m_xDlg; +public: + explicit AbstractMultiTOXTabDialog_Impl(std::shared_ptr<SwMultiTOXTabDialog> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override; + virtual CurTOXType GetCurrentTOXType() const override ; + virtual SwTOXDescription& GetTOXDescription(CurTOXType eTOXTypes) override; + //from SfxTabDialog + virtual const SfxItemSet* GetOutputItemSet() const override; +}; + +class SwEditRegionDlg; +class AbstractEditRegionDlg_Impl : public AbstractEditRegionDlg +{ + std::shared_ptr<SwEditRegionDlg> m_xDlg; +public: + explicit AbstractEditRegionDlg_Impl(std::shared_ptr<SwEditRegionDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual void SelectSection(const OUString& rSectionName) override; +}; + +class SwInsertSectionTabDialog; +class AbstractInsertSectionTabDialog_Impl : public AbstractInsertSectionTabDialog +{ + std::shared_ptr<SwInsertSectionTabDialog> m_xDlg; +public: + explicit AbstractInsertSectionTabDialog_Impl(std::shared_ptr<SwInsertSectionTabDialog> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; + virtual void SetSectionData(SwSectionData const& rSect) override; +}; + +class SwIndexMarkFloatDlg; +class AbstractIndexMarkFloatDlg_Impl : public AbstractMarkFloatDlg +{ + std::shared_ptr<SwIndexMarkFloatDlg> m_xDlg; +public: + explicit AbstractIndexMarkFloatDlg_Impl(std::shared_ptr<SwIndexMarkFloatDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual void ReInitDlg(SwWrtShell& rWrtShell) override; + virtual std::shared_ptr<SfxDialogController> GetController() override; +}; + +class SwAuthMarkFloatDlg; +class AbstractAuthMarkFloatDlg_Impl : public AbstractMarkFloatDlg +{ + std::shared_ptr<SwAuthMarkFloatDlg> m_xDlg; +public: + explicit AbstractAuthMarkFloatDlg_Impl(std::shared_ptr<SwAuthMarkFloatDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual void ReInitDlg(SwWrtShell& rWrtShell) override; + virtual std::shared_ptr<SfxDialogController> GetController() override; +}; + +class SwMailMergeWizard; +class AbstractMailMergeWizard_Impl : public AbstractMailMergeWizard +{ + std::shared_ptr<SwMailMergeWizard> m_xDlg; + +public: + explicit AbstractMailMergeWizard_Impl(std::shared_ptr<SwMailMergeWizard> p) + : m_xDlg(std::move(p)) + { + } + virtual ~AbstractMailMergeWizard_Impl() override; + virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override; + virtual short Execute() override; + + virtual OUString GetReloadDocument() const override; + virtual void ShowPage( sal_uInt16 nLevel ) override; + virtual sal_uInt16 GetRestartPage() const override; +}; + +//AbstractDialogFactory_Impl implementations +class SwAbstractDialogFactory_Impl : public SwAbstractDialogFactory +{ + +public: + virtual ~SwAbstractDialogFactory_Impl() {} + + virtual VclPtr<SfxAbstractDialog> CreateNumFormatDialog(weld::Widget* pParent, const SfxItemSet& rAttr) override; + virtual VclPtr<SfxAbstractDialog> CreateSwDropCapsDialog(weld::Window* pParent, const SfxItemSet& rSet) override; + virtual VclPtr<SfxAbstractDialog> CreateSwBackgroundDialog(weld::Window* pParent, const SfxItemSet& rSet) override; + virtual VclPtr<AbstractSwWordCountFloatDlg> CreateSwWordCountDialog(SfxBindings* pBindings, + SfxChildWindow* pChild, weld::Window *pParent, SfxChildWinInfo* pInfo) override; + virtual VclPtr<AbstractSwInsertAbstractDlg> CreateSwInsertAbstractDlg(weld::Window* pParent) override; + virtual VclPtr<SfxAbstractDialog> CreateSwAddressAbstractDlg(weld::Window* pParent, const SfxItemSet& rSet) override; + virtual VclPtr<AbstractSwAsciiFilterDlg> CreateSwAsciiFilterDlg(weld::Window* pParent, SwDocShell& rDocSh, + SvStream* pStream) override; + virtual VclPtr<VclAbstractDialog> CreateSwInsertBookmarkDlg(weld::Window *pParent, SwWrtShell &rSh, SfxRequest& rReq) override; + virtual VclPtr<AbstractSwBreakDlg> CreateSwBreakDlg(weld::Window *pParent, SwWrtShell &rSh) override; + virtual VclPtr<VclAbstractDialog> CreateSwChangeDBDlg(SwView& rVw) override; + virtual VclPtr<SfxAbstractTabDialog> CreateSwCharDlg(weld::Window* pParent, SwView& pVw, const SfxItemSet& rCoreSet, + SwCharDlgMode nDialogMode, const OUString* pFormatStr = nullptr) override; + virtual VclPtr<AbstractSwConvertTableDlg> CreateSwConvertTableDlg(SwView& rView, bool bToTable) override; + virtual VclPtr<VclAbstractDialog> CreateSwCaptionDialog(weld::Window *pParent, SwView &rV) override; + virtual VclPtr<AbstractSwInsertDBColAutoPilot> CreateSwInsertDBColAutoPilot(SwView& rView, + css::uno::Reference< css::sdbc::XDataSource> rxSource, + css::uno::Reference<css::sdbcx::XColumnsSupplier> xColSupp, + const SwDBData& rData) override; + virtual VclPtr<SfxAbstractTabDialog> CreateSwFootNoteOptionDlg(weld::Window *pParent, SwWrtShell &rSh) override; + + virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(weld::Widget* pParent, SwWrtShell &rSh, + SwField* pField, bool bPrevButton, bool bNextButton) override; + virtual VclPtr<VclAbstractDialog> CreateDropDownFormFieldDialog(weld::Widget* pParent, sw::mark::IFieldmark* pDropDownField) override; + virtual VclPtr<VclAbstractDialog> CreateDateFormFieldDialog(weld::Widget* pParent, sw::mark::IDateFieldmark* pDateField, SwDoc* pDoc) override; + + virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert) override; + virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, + SwDBManager* pDBManager, bool bLabel) override; + + virtual SwLabDlgMethod GetSwLabDlgStaticMethod () override; + virtual VclPtr<SfxAbstractTabDialog> CreateSwParaDlg(weld::Window *pParent, + SwView& rVw, + const SfxItemSet& rCoreSet, + bool bDraw, + const OString& sDefPage = OString()) override; + + virtual VclPtr<VclAbstractDialog> CreateSwAutoMarkDialog(weld::Window *pParent, SwWrtShell &rSh) override; + virtual VclPtr<AbstractSwSelGlossaryDlg> CreateSwSelGlossaryDlg(weld::Window *pParent, const OUString &rShortName) override; + virtual VclPtr<VclAbstractDialog> CreateSwSortingDialog(weld::Window *pParent, SwWrtShell &rSh) override; + virtual VclPtr<VclAbstractDialog> CreateSwTableHeightDialog(weld::Window *pParent, SwWrtShell &rSh) override; + virtual VclPtr<VclAbstractDialog> CreateSwColumnDialog(weld::Window *pParent, SwWrtShell &rSh) override; + virtual VclPtr<AbstractSplitTableDialog> CreateSplitTableDialog(weld::Window* pParent, SwWrtShell &rSh) override; + + virtual VclPtr<AbstractSwAutoFormatDlg> CreateSwAutoFormatDlg(weld::Window* pParent, SwWrtShell* pShell, + bool bSetAutoFormat = true, + const SwTableAutoFormat* pSelFormat = nullptr) override; + virtual VclPtr<SfxAbstractDialog> CreateSwBorderDlg(weld::Window* pParent, SfxItemSet& rSet, SwBorderModes nType) override; + + virtual VclPtr<SfxAbstractDialog> CreateSwWrapDlg(weld::Window* pParent, SfxItemSet& rSet, SwWrtShell* pSh) override; + virtual VclPtr<VclAbstractDialog> CreateSwTableWidthDlg(weld::Window *pParent, SwTableFUNC &rFnc) override; + virtual VclPtr<SfxAbstractTabDialog> CreateSwTableTabDlg(weld::Window* pParent, + const SfxItemSet* pItemSet, SwWrtShell* pSh) override; + virtual VclPtr<AbstractSwFieldDlg> CreateSwFieldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, weld::Window *pParent) override; + virtual VclPtr<SfxAbstractDialog> CreateSwFieldEditDlg ( SwView& rVw ) override; + virtual VclPtr<AbstractSwRenameXNamedDlg> CreateSwRenameXNamedDlg(weld::Window* pParent, + css::uno::Reference< css::container::XNamed > & xNamed, + css::uno::Reference< css::container::XNameAccess > & xNameAccess) override; + virtual VclPtr<AbstractSwModalRedlineAcceptDlg> CreateSwModalRedlineAcceptDlg(weld::Window *pParent) override; + + virtual VclPtr<VclAbstractDialog> CreateTableMergeDialog(weld::Window* pParent, bool& rWithPrev) override; + virtual VclPtr<SfxAbstractTabDialog> CreateFrameTabDialog( const OUString &rDialogType, + SfxViewFrame *pFrame, weld::Window *pParent, + const SfxItemSet& rCoreSet, + bool bNewFrame = true, + const OString& sDefPage = OString()) override; + virtual VclPtr<SfxAbstractApplyTabDialog> CreateTemplateDialog( + weld::Window *pParent, + SfxStyleSheetBase& rBase, + SfxStyleFamily nRegion, + const OString& sPage, + SwWrtShell* pActShell, + bool bNew) override; + virtual VclPtr<AbstractGlossaryDlg> CreateGlossaryDlg(SfxViewFrame* pViewFrame, + SwGlossaryHdl* pGlosHdl, + SwWrtShell *pWrtShell) override; + virtual VclPtr<AbstractFieldInputDlg> CreateFieldInputDlg(weld::Widget *pParent, + SwWrtShell &rSh, SwField* pField, bool bPrevButton, bool bNextButton) override; + virtual VclPtr<AbstractInsFootNoteDlg> CreateInsFootNoteDlg( + weld::Window * pParent, SwWrtShell &rSh, bool bEd = false) override; + virtual VclPtr<VclAbstractDialog> CreateTitlePageDlg(weld::Window* pParent) override; + virtual VclPtr<VclAbstractDialog> CreateVclSwViewDialog(SwView& rView) override; + virtual std::shared_ptr<AbstractInsTableDlg> CreateInsTableDlg(SwView& rView) override; + virtual VclPtr<AbstractJavaEditDialog> CreateJavaEditDialog(weld::Window* pParent, + SwWrtShell* pWrtSh) override; + virtual VclPtr<AbstractMailMergeDlg> CreateMailMergeDlg( + weld::Window* pParent, SwWrtShell& rSh, + const OUString& rSourceName, + const OUString& rTableName, + sal_Int32 nCommandType, + const css::uno::Reference< css::sdbc::XConnection>& xConnection ) override; + virtual VclPtr<AbstractMailMergeCreateFromDlg> CreateMailMergeCreateFromDlg(weld::Window* pParent) override; + virtual VclPtr<AbstractMailMergeFieldConnectionsDlg> CreateMailMergeFieldConnectionsDlg(weld::Window* pParent) override; + virtual VclPtr<VclAbstractDialog> CreateMultiTOXMarkDlg(weld::Window* pParent, SwTOXMgr &rTOXMgr) override; + virtual VclPtr<SfxAbstractTabDialog> CreateOutlineTabDialog(weld::Window* pParent, const SfxItemSet* pSwItemSet, + SwWrtShell &) override; + virtual VclPtr<SfxAbstractTabDialog> CreateSvxNumBulletTabDialog(weld::Window* pParent, + const SfxItemSet* pSwItemSet, + SwWrtShell &) override; + virtual VclPtr<AbstractMultiTOXTabDialog> CreateMultiTOXTabDialog( + weld::Window* pParent, const SfxItemSet& rSet, + SwWrtShell &rShell, + SwTOXBase* pCurTOX, + bool bGlobal) override; + virtual VclPtr<AbstractEditRegionDlg> CreateEditRegionDlg(weld::Window* pParent, SwWrtShell& rWrtSh) override; + virtual VclPtr<AbstractInsertSectionTabDialog> CreateInsertSectionTabDialog( + weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh) override; + virtual VclPtr<AbstractMarkFloatDlg> CreateIndexMarkFloatDlg( + SfxBindings* pBindings, + SfxChildWindow* pChild, + weld::Window *pParent, + SfxChildWinInfo* pInfo) override; + virtual VclPtr<AbstractMarkFloatDlg> CreateAuthMarkFloatDlg( + SfxBindings* pBindings, + SfxChildWindow* pChild, + weld::Window *pParent, + SfxChildWinInfo* pInfo) override; + virtual VclPtr<VclAbstractDialog> CreateIndexMarkModalDlg( + weld::Window *pParent, SwWrtShell& rSh, SwTOXMark* pCurTOXMark ) override; + + virtual VclPtr<AbstractMailMergeWizard> CreateMailMergeWizard(SwView& rView, std::shared_ptr<SwMailMergeConfigItem>& rConfigItem) override; + + virtual GlossaryGetCurrGroup GetGlossaryCurrGroupFunc() override; + virtual GlossarySetActGroup SetGlossaryActGroupFunc() override; + + // For TabPage + virtual CreateTabPage GetTabPageCreatorFunc( sal_uInt16 nId ) override; + + virtual void ExecuteMMResultSaveDialog(weld::Window* pParent) override; + virtual void ExecuteMMResultPrintDialog(weld::Window* pParent) override; + virtual void ExecuteMMResultEmailDialog(weld::Window* pParent) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/swmessdialog.cxx b/sw/source/ui/dialog/swmessdialog.cxx new file mode 100644 index 000000000..d244dd7b8 --- /dev/null +++ b/sw/source/ui/dialog/swmessdialog.cxx @@ -0,0 +1,20 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmessdialog.hxx> + +SwMessageAndEditDialog::SwMessageAndEditDialog(weld::Window* pParent, const OString& rID, + const OUString& rUIXMLDescription) + : MessageDialogController(pParent, rUIXMLDescription, rID, "grid") + , m_xEdit(m_xBuilder->weld_entry("edit")) + , m_xOKPB(m_xBuilder->weld_button("ok")) +{ +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/swuiexp.cxx b/sw/source/ui/dialog/swuiexp.cxx new file mode 100644 index 000000000..846618ac0 --- /dev/null +++ b/sw/source/ui/dialog/swuiexp.cxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "swdlgfact.hxx" + +#include <swuiexp.hxx> + +namespace swui +{ + SwAbstractDialogFactory& GetFactory() + { + static SwAbstractDialogFactory_Impl aFactory; + return aFactory; + } +} + +extern "C" +{ + SAL_DLLPUBLIC_EXPORT SwAbstractDialogFactory* SwCreateDialogFactory() + { + return &::swui::GetFactory(); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx new file mode 100644 index 000000000..ac8c987ea --- /dev/null +++ b/sw/source/ui/dialog/uiregionsw.cxx @@ -0,0 +1,2104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <hintids.hxx> +#include <regionsw.hxx> +#include <svl/urihelper.hxx> +#include <svl/PasswordHelper.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> +#include <svl/stritem.hxx> +#include <svl/eitem.hxx> +#include <sfx2/passwd.hxx> +#include <sfx2/docfilt.hxx> +#include <sfx2/request.hxx> +#include <sfx2/docfile.hxx> +#include <sfx2/linkmgr.hxx> +#include <sfx2/docinsert.hxx> +#include <sfx2/filedlghelper.hxx> +#include <editeng/sizeitem.hxx> +#include <svtools/htmlcfg.hxx> + +#include <uitool.hxx> +#include <IMark.hxx> +#include <section.hxx> +#include <docary.hxx> +#include <doc.hxx> +#include <wdocsh.hxx> +#include <view.hxx> +#include <wrtsh.hxx> +#include <column.hxx> +#include <fmtclbl.hxx> +#include <fmtfsize.hxx> +#include <frmatr.hxx> +#include <shellio.hxx> + +#include <cmdid.h> +#include <strings.hrc> +#include <bitmaps.hlst> +#include <sfx2/bindings.hxx> +#include <sfx2/sfxdlg.hxx> +#include <sfx2/viewfrm.hxx> +#include <svx/dialogs.hrc> +#include <svx/flagsdef.hxx> +#include <memory> + +using namespace ::com::sun::star; + +namespace { + +OUString BuildBitmap(bool bProtect, bool bHidden) +{ + if (bProtect) + return bHidden ? OUString(RID_BMP_PROT_HIDE) : OUString(RID_BMP_PROT_NO_HIDE); + return bHidden ? OUString(RID_BMP_HIDE) : OUString(RID_BMP_NO_HIDE); +} + +} + +static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox ); + +static void lcl_FillList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames, const SwSectionFormat* pNewFormat ) +{ + if( !pNewFormat ) + { + const size_t nCount = rSh.GetSectionFormatCount(); + for (size_t i = 0; i<nCount; i++) + { + SectionType eTmpType; + const SwSectionFormat* pFormat = &rSh.GetSectionFormat(i); + if( !pFormat->GetParent() && + pFormat->IsInNodesArr() && + (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent + && SectionType::ToxHeader != eTmpType ) + { + const OUString sString(pFormat->GetSection()->GetSectionName()); + if (pAvailNames) + pAvailNames->append_text(sString); + rSubRegions.append_text(sString); + lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat ); + } + } + } + else + { + SwSections aTmpArr; + pNewFormat->GetChildSections(aTmpArr, SectionSort::Pos); + if( !aTmpArr.empty() ) + { + SectionType eTmpType; + for( const auto pSect : aTmpArr ) + { + const SwSectionFormat* pFormat = pSect->GetFormat(); + if( pFormat->IsInNodesArr()&& + (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent + && SectionType::ToxHeader != eTmpType ) + { + const OUString sString(pFormat->GetSection()->GetSectionName()); + if (pAvailNames) + pAvailNames->append_text(sString); + rSubRegions.append_text(sString); + lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat ); + } + } + } + } +} + +static void lcl_FillSubRegionList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames ) +{ + rSubRegions.clear(); + lcl_FillList( rSh, rSubRegions, pAvailNames, nullptr ); + IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess(); + for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin(); + ppMark != pMarkAccess->getBookmarksEnd(); + ++ppMark) + { + const ::sw::mark::IMark* pBkmk = *ppMark; + if( pBkmk->IsExpanded() ) + rSubRegions.append_text( pBkmk->GetName() ); + } +} + +// user data class for region information +class SectRepr +{ +private: + SwSectionData m_SectionData; + SwFormatCol m_Col; + std::unique_ptr<SvxBrushItem> m_Brush; + SwFormatFootnoteAtTextEnd m_FootnoteNtAtEnd; + SwFormatEndAtTextEnd m_EndNtAtEnd; + SwFormatNoBalancedColumns m_Balance; + std::shared_ptr<SvxFrameDirectionItem> m_FrameDirItem; + std::shared_ptr<SvxLRSpaceItem> m_LRSpaceItem; + const size_t m_nArrPos; + // shows, if maybe textcontent is in the region + bool m_bContent : 1; + // for multiselection, mark at first, then work with TreeListBox! + bool m_bSelected : 1; + uno::Sequence<sal_Int8> m_TempPasswd; + +public: + SectRepr(size_t nPos, SwSection& rSect); + + SwSectionData & GetSectionData() { return m_SectionData; } + SwFormatCol& GetCol() { return m_Col; } + std::unique_ptr<SvxBrushItem>& GetBackground() { return m_Brush; } + SwFormatFootnoteAtTextEnd& GetFootnoteNtAtEnd() { return m_FootnoteNtAtEnd; } + SwFormatEndAtTextEnd& GetEndNtAtEnd() { return m_EndNtAtEnd; } + SwFormatNoBalancedColumns& GetBalance() { return m_Balance; } + std::shared_ptr<SvxFrameDirectionItem>& GetFrameDir() { return m_FrameDirItem; } + std::shared_ptr<SvxLRSpaceItem>& GetLRSpace() { return m_LRSpaceItem; } + + size_t GetArrPos() const { return m_nArrPos; } + OUString GetFile() const; + OUString GetSubRegion() const; + void SetFile(OUString const& rFile); + void SetFilter(OUString const& rFilter); + void SetSubRegion(OUString const& rSubRegion); + + bool IsContent() const { return m_bContent; } + void SetContent(bool const bValue) { m_bContent = bValue; } + + void SetSelected() { m_bSelected = true; } + bool IsSelected() const { return m_bSelected; } + + uno::Sequence<sal_Int8> & GetTempPasswd() { return m_TempPasswd; } + void SetTempPasswd(const uno::Sequence<sal_Int8> & rPasswd) + { m_TempPasswd = rPasswd; } +}; + +SectRepr::SectRepr( size_t nPos, SwSection& rSect ) + : m_SectionData( rSect ) + , m_Brush(std::make_unique<SvxBrushItem>(RES_BACKGROUND)) + , m_FrameDirItem(std::make_shared<SvxFrameDirectionItem>(SvxFrameDirection::Environment, RES_FRAMEDIR)) + , m_LRSpaceItem(std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE)) + , m_nArrPos(nPos) + , m_bContent(m_SectionData.GetLinkFileName().isEmpty()) + , m_bSelected(false) +{ + SwSectionFormat *pFormat = rSect.GetFormat(); + if( pFormat ) + { + m_Col = pFormat->GetCol(); + m_Brush = pFormat->makeBackgroundBrushItem(); + m_FootnoteNtAtEnd = pFormat->GetFootnoteAtTextEnd(); + m_EndNtAtEnd = pFormat->GetEndAtTextEnd(); + m_Balance.SetValue(pFormat->GetBalancedColumns().GetValue()); + m_FrameDirItem.reset(pFormat->GetFrameDir().Clone()); + m_LRSpaceItem.reset(pFormat->GetLRSpace().Clone()); + } +} + +void SectRepr::SetFile( const OUString& rFile ) +{ + OUString sNewFile( INetURLObject::decode( rFile, + INetURLObject::DecodeMechanism::Unambiguous )); + const OUString sOldFileName( m_SectionData.GetLinkFileName() ); + const OUString sSub( sOldFileName.getToken( 2, sfx2::cTokenSeparator ) ); + + if( !rFile.isEmpty() || !sSub.isEmpty() ) + { + sNewFile += OUStringChar(sfx2::cTokenSeparator); + if( !rFile.isEmpty() ) // Filter only with FileName + sNewFile += sOldFileName.getToken( 1, sfx2::cTokenSeparator ); + + sNewFile += OUStringChar(sfx2::cTokenSeparator) + sSub; + } + + m_SectionData.SetLinkFileName( sNewFile ); + + if( !rFile.isEmpty() || !sSub.isEmpty() ) + { + m_SectionData.SetType( SectionType::FileLink ); + } + else + { + m_SectionData.SetType( SectionType::Content ); + } +} + +void SectRepr::SetFilter( const OUString& rFilter ) +{ + OUString sNewFile; + const OUString sOldFileName( m_SectionData.GetLinkFileName() ); + sal_Int32 nIdx{ 0 }; + const OUString sFile( sOldFileName.getToken( 0, sfx2::cTokenSeparator, nIdx ) ); // token 0 + const OUString sSub( sOldFileName.getToken( 1, sfx2::cTokenSeparator, nIdx ) ); // token 2 + + if( !sFile.isEmpty() ) + sNewFile = sFile + OUStringChar(sfx2::cTokenSeparator) + + rFilter + OUStringChar(sfx2::cTokenSeparator) + sSub; + else if( !sSub.isEmpty() ) + sNewFile = OUStringChar(sfx2::cTokenSeparator) + OUStringChar(sfx2::cTokenSeparator) + sSub; + + m_SectionData.SetLinkFileName( sNewFile ); + + if( !sNewFile.isEmpty() ) + { + m_SectionData.SetType( SectionType::FileLink ); + } +} + +void SectRepr::SetSubRegion(const OUString& rSubRegion) +{ + OUString sNewFile; + sal_Int32 n(0); + const OUString sLinkFileName(m_SectionData.GetLinkFileName()); + const OUString sOldFileName( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) ); + const OUString sFilter( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) ); + + if( !rSubRegion.isEmpty() || !sOldFileName.isEmpty() ) + sNewFile = sOldFileName + OUStringChar(sfx2::cTokenSeparator) + + sFilter + OUStringChar(sfx2::cTokenSeparator) + rSubRegion; + + m_SectionData.SetLinkFileName( sNewFile ); + + if( !rSubRegion.isEmpty() || !sOldFileName.isEmpty() ) + { + m_SectionData.SetType( SectionType::FileLink ); + } + else + { + m_SectionData.SetType( SectionType::Content ); + } +} + +OUString SectRepr::GetFile() const +{ + const OUString sLinkFile( m_SectionData.GetLinkFileName() ); + + if( sLinkFile.isEmpty() ) + { + return sLinkFile; + } + if (SectionType::DdeLink == m_SectionData.GetType()) + { + sal_Int32 n = 0; + return sLinkFile.replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n ) + .replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n ); + } + return INetURLObject::decode( sLinkFile.getToken( 0, sfx2::cTokenSeparator ), + INetURLObject::DecodeMechanism::Unambiguous ); +} + +OUString SectRepr::GetSubRegion() const +{ + const OUString sLinkFile( m_SectionData.GetLinkFileName() ); + if( !sLinkFile.isEmpty() ) + return sLinkFile.getToken( 2, sfx2::cTokenSeparator ); + return sLinkFile; +} + +// dialog edit regions +SwEditRegionDlg::SwEditRegionDlg(weld::Window* pParent, SwWrtShell& rWrtSh) + : SfxDialogController(pParent, "modules/swriter/ui/editsectiondialog.ui", + "EditSectionDialog") + , m_bSubRegionsFilled(false) + , rSh(rWrtSh) + , bDontCheckPasswd(true) + , m_xCurName(m_xBuilder->weld_entry("curname")) + , m_xTree(m_xBuilder->weld_tree_view("tree")) + , m_xFileCB(m_xBuilder->weld_check_button("link")) + , m_xDDECB(m_xBuilder->weld_check_button("dde")) + , m_xDDEFrame(m_xBuilder->weld_widget("ddedepend")) + , m_xFileNameFT(m_xBuilder->weld_label("filenameft")) + , m_xDDECommandFT(m_xBuilder->weld_label("ddeft")) + , m_xFileNameED(m_xBuilder->weld_entry("filename")) + , m_xFilePB(m_xBuilder->weld_button("file")) + , m_xSubRegionFT(m_xBuilder->weld_label("sectionft")) + , m_xSubRegionED(m_xBuilder->weld_combo_box("section")) + , m_xProtectCB(m_xBuilder->weld_check_button("protect")) + , m_xPasswdCB(m_xBuilder->weld_check_button("withpassword")) + , m_xPasswdPB(m_xBuilder->weld_button("password")) + , m_xHideCB(m_xBuilder->weld_check_button("hide")) + , m_xConditionFT(m_xBuilder->weld_label("conditionft")) + , m_xConditionED(new ConditionEdit(m_xBuilder->weld_entry("condition"))) + , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editinro")) + , m_xOK(m_xBuilder->weld_button("ok")) + , m_xOptionsPB(m_xBuilder->weld_button("options")) + , m_xDismiss(m_xBuilder->weld_button("remove")) + , m_xHideFrame(m_xBuilder->weld_widget("hideframe")) +{ + m_xTree->set_size_request(-1, m_xTree->get_height_rows(16)); + m_xFileCB->set_state(TRISTATE_FALSE); + m_xSubRegionED->make_sorted(); + m_xProtectCB->set_state(TRISTATE_FALSE); + m_xHideCB->set_state(TRISTATE_FALSE); + // edit in readonly sections + m_xEditInReadonlyCB->set_state(TRISTATE_FALSE); + + bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr; + + m_xTree->connect_changed(LINK(this, SwEditRegionDlg, GetFirstEntryHdl)); + m_xCurName->connect_changed(LINK(this, SwEditRegionDlg, NameEditHdl)); + m_xConditionED->connect_changed( LINK( this, SwEditRegionDlg, ConditionEditHdl)); + m_xOK->connect_clicked( LINK( this, SwEditRegionDlg, OkHdl)); + m_xPasswdCB->connect_toggled(LINK(this, SwEditRegionDlg, TogglePasswdHdl)); + m_xPasswdPB->connect_clicked(LINK(this, SwEditRegionDlg, ChangePasswdHdl)); + m_xHideCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeHideHdl)); + // edit in readonly sections + m_xEditInReadonlyCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeEditInReadonlyHdl)); + + m_xOptionsPB->connect_clicked(LINK(this, SwEditRegionDlg, OptionsHdl)); + m_xProtectCB->connect_toggled(LINK(this, SwEditRegionDlg, ChangeProtectHdl)); + m_xDismiss->connect_clicked( LINK( this, SwEditRegionDlg, ChangeDismissHdl)); + m_xFileCB->connect_toggled(LINK(this, SwEditRegionDlg, UseFileHdl)); + m_xFilePB->connect_clicked(LINK(this, SwEditRegionDlg, FileSearchHdl)); + m_xFileNameED->connect_changed(LINK(this, SwEditRegionDlg, FileNameEntryHdl)); + m_xSubRegionED->connect_changed(LINK(this, SwEditRegionDlg, FileNameComboBoxHdl)); + m_xSubRegionED->connect_popup_toggled(LINK(this, SwEditRegionDlg, SubRegionEventHdl)); + m_xSubRegionED->set_entry_completion(true, true); + + m_xTree->set_selection_mode(SelectionMode::Multiple); + + if (bWeb) + { + m_xDDECB->hide(); + m_xHideFrame->hide(); + m_xPasswdCB->hide(); + } + + m_xDDECB->connect_toggled(LINK(this, SwEditRegionDlg, DDEHdl)); + + pCurrSect = rSh.GetCurrSection(); + RecurseList( nullptr, nullptr ); + + // if the cursor is not in a region the first one will always be selected + if (!m_xTree->get_selected(nullptr)) + { + std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator()); + if (m_xTree->get_iter_first(*xIter)) + { + m_xTree->select(*xIter); + GetFirstEntryHdl(*m_xTree); + } + } + + m_xTree->show(); + bDontCheckPasswd = false; +} + +bool SwEditRegionDlg::CheckPasswd(weld::ToggleButton* pBox) +{ + if (bDontCheckPasswd) + return true; + bool bRet = true; + + m_xTree->selected_foreach([this, &bRet](weld::TreeIter& rEntry){ + SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64()); + if (!pRepr->GetTempPasswd().hasElements() + && pRepr->GetSectionData().GetPassword().hasElements()) + { + SfxPasswordDialog aPasswdDlg(m_xDialog.get()); + bRet = false; + if (aPasswdDlg.run()) + { + const OUString sNewPasswd(aPasswdDlg.GetPassword()); + css::uno::Sequence <sal_Int8 > aNewPasswd; + SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd ); + if (SvPasswordHelper::CompareHashPassword( + pRepr->GetSectionData().GetPassword(), sNewPasswd)) + { + pRepr->SetTempPasswd(aNewPasswd); + bRet = true; + } + else + { + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), + VclMessageType::Info, VclButtonsType::Ok, + SwResId(STR_WRONG_PASSWORD))); + xInfoBox->run(); + } + } + } + return false; + }); + if (!bRet && pBox) + { + //reset old button state + if (pBox->get_state() != TRISTATE_INDET) + pBox->set_active(!pBox->get_active()); + } + + return bRet; +} + +// recursively look for child-sections +void SwEditRegionDlg::RecurseList(const SwSectionFormat* pFormat, const weld::TreeIter* pEntry) +{ + std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator()); + if (!pFormat) + { + const size_t nCount=rSh.GetSectionFormatCount(); + for ( size_t n = 0; n < nCount; n++ ) + { + SectionType eTmpType; + if( !( pFormat = &rSh.GetSectionFormat(n))->GetParent() && + pFormat->IsInNodesArr() && + (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent + && SectionType::ToxHeader != eTmpType ) + { + SwSection *pSect = pFormat->GetSection(); + SectRepr* pSectRepr = new SectRepr( n, *pSect ); + + OUString sText(pSect->GetSectionName()); + OUString sImage(BuildBitmap(pSect->IsProtect(),pSect->IsHidden())); + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr))); + m_xTree->insert(nullptr, -1, &sText, &sId, nullptr, nullptr, &sImage, false, xIter.get()); + + RecurseList(pFormat, xIter.get()); + if (m_xTree->iter_has_child(*xIter)) + m_xTree->expand_row(*xIter); + if (pCurrSect==pSect) + { + m_xTree->select(*xIter); + m_xTree->scroll_to_row(*xIter); + GetFirstEntryHdl(*m_xTree); + } + } + } + } + else + { + SwSections aTmpArr; + pFormat->GetChildSections(aTmpArr, SectionSort::Pos); + for( const auto pSect : aTmpArr ) + { + SectionType eTmpType; + pFormat = pSect->GetFormat(); + if( pFormat->IsInNodesArr() && + (eTmpType = pFormat->GetSection()->GetType()) != SectionType::ToxContent + && SectionType::ToxHeader != eTmpType ) + { + SectRepr* pSectRepr=new SectRepr( + FindArrPos( pSect->GetFormat() ), *pSect ); + + OUString sText(pSect->GetSectionName()); + OUString sImage = BuildBitmap(pSect->IsProtect(), pSect->IsHidden()); + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pSectRepr))); + m_xTree->insert(pEntry, -1, &sText, &sId, nullptr, nullptr, &sImage, false, xIter.get()); + + RecurseList(pSect->GetFormat(), xIter.get()); + if (m_xTree->iter_has_child(*xIter)) + m_xTree->expand_row(*xIter); + if (pCurrSect==pSect) + { + m_xTree->select(*xIter); + m_xTree->scroll_to_row(*xIter); + GetFirstEntryHdl(*m_xTree); + } + } + } + } +} + +size_t SwEditRegionDlg::FindArrPos(const SwSectionFormat* pFormat ) +{ + const size_t nCount=rSh.GetSectionFormatCount(); + for ( size_t i = 0; i < nCount; i++ ) + if ( pFormat == &rSh.GetSectionFormat(i) ) + return i; + + OSL_FAIL("SectionFormat not on the list" ); + return SIZE_MAX; +} + +SwEditRegionDlg::~SwEditRegionDlg( ) +{ + std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator()); + if (m_xTree->get_iter_first(*xIter)) + { + do + { + delete reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64()); + } while (m_xTree->iter_next(*xIter)); + } +} + +void SwEditRegionDlg::SelectSection(const OUString& rSectionName) +{ + std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator()); + if (m_xTree->get_iter_first(*xIter)) + { + do + { + SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64()); + if (pRepr->GetSectionData().GetSectionName() == rSectionName) + { + m_xTree->unselect_all(); + m_xTree->select(*xIter); + m_xTree->scroll_to_row(*xIter); + GetFirstEntryHdl(*m_xTree); + break; + } + } while (m_xTree->iter_next(*xIter)); + } +} + +// selected entry in TreeListBox is showed in Edit window in case of +// multiselection some controls are disabled +IMPL_LINK(SwEditRegionDlg, GetFirstEntryHdl, weld::TreeView&, rBox, void) +{ + bDontCheckPasswd = true; + std::unique_ptr<weld::TreeIter> xIter(rBox.make_iterator()); + bool bEntry = rBox.get_selected(xIter.get()); + m_xHideCB->set_sensitive(true); + // edit in readonly sections + m_xEditInReadonlyCB->set_sensitive(true); + + m_xProtectCB->set_sensitive(true); + m_xFileCB->set_sensitive(true); + css::uno::Sequence <sal_Int8> aCurPasswd; + if (1 < rBox.count_selected_rows()) + { + m_xHideCB->set_state(TRISTATE_INDET); + m_xProtectCB->set_state(TRISTATE_INDET); + // edit in readonly sections + m_xEditInReadonlyCB->set_state(TRISTATE_INDET); + m_xFileCB->set_state(TRISTATE_INDET); + + bool bHiddenValid = true; + bool bProtectValid = true; + bool bConditionValid = true; + // edit in readonly sections + bool bEditInReadonlyValid = true; + bool bEditInReadonly = true; + + bool bHidden = true; + bool bProtect = true; + OUString sCondition; + bool bFirst = true; + bool bFileValid = true; + bool bFile = true; + bool bPasswdValid = true; + + m_xTree->selected_foreach([&](weld::TreeIter& rEntry){ + SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64()); + SwSectionData const& rData( pRepr->GetSectionData() ); + if(bFirst) + { + sCondition = rData.GetCondition(); + bHidden = rData.IsHidden(); + bProtect = rData.IsProtectFlag(); + // edit in readonly sections + bEditInReadonly = rData.IsEditInReadonlyFlag(); + + bFile = (rData.GetType() != SectionType::Content); + aCurPasswd = rData.GetPassword(); + } + else + { + if(sCondition != rData.GetCondition()) + bConditionValid = false; + bHiddenValid = (bHidden == rData.IsHidden()); + bProtectValid = (bProtect == rData.IsProtectFlag()); + // edit in readonly sections + bEditInReadonlyValid = + (bEditInReadonly == rData.IsEditInReadonlyFlag()); + + bFileValid = (bFile == + (rData.GetType() != SectionType::Content)); + bPasswdValid = (aCurPasswd == rData.GetPassword()); + } + bFirst = false; + return false; + }); + + m_xHideCB->set_state(!bHiddenValid ? TRISTATE_INDET : + bHidden ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xProtectCB->set_state(!bProtectValid ? TRISTATE_INDET : + bProtect ? TRISTATE_TRUE : TRISTATE_FALSE); + // edit in readonly sections + m_xEditInReadonlyCB->set_state(!bEditInReadonlyValid ? TRISTATE_INDET : + bEditInReadonly ? TRISTATE_TRUE : TRISTATE_FALSE); + + m_xFileCB->set_state(!bFileValid ? TRISTATE_INDET : + bFile ? TRISTATE_TRUE : TRISTATE_FALSE); + + if (bConditionValid) + m_xConditionED->set_text(sCondition); + else + { + m_xConditionFT->set_sensitive(false); + m_xConditionED->set_sensitive(false); + } + + m_xCurName->set_sensitive(false); + m_xDDECB->set_sensitive(false); + m_xDDEFrame->set_sensitive(false); + m_xOptionsPB->set_sensitive(false); + bool bPasswdEnabled = m_xProtectCB->get_state() == TRISTATE_TRUE; + m_xPasswdCB->set_sensitive(bPasswdEnabled); + m_xPasswdPB->set_sensitive(bPasswdEnabled); + if(!bPasswdValid) + { + rBox.get_selected(xIter.get()); + rBox.unselect_all(); + rBox.select(*xIter); + GetFirstEntryHdl(rBox); + return; + } + else + m_xPasswdCB->set_active(aCurPasswd.hasElements()); + } + else if (bEntry ) + { + m_xCurName->set_sensitive(true); + m_xOptionsPB->set_sensitive(true); + SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64()); + SwSectionData const& rData( pRepr->GetSectionData() ); + m_xConditionED->set_text(rData.GetCondition()); + m_xHideCB->set_sensitive(true); + m_xHideCB->set_state((rData.IsHidden()) ? TRISTATE_TRUE : TRISTATE_FALSE); + bool bHide = TRISTATE_TRUE == m_xHideCB->get_state(); + m_xConditionED->set_sensitive(bHide); + m_xConditionFT->set_sensitive(bHide); + m_xPasswdCB->set_active(rData.GetPassword().hasElements()); + + m_xOK->set_sensitive(true); + m_xPasswdCB->set_sensitive(true); + m_xCurName->set_text(rBox.get_text(*xIter)); + m_xCurName->set_sensitive(true); + m_xDismiss->set_sensitive(true); + const OUString aFile = pRepr->GetFile(); + const OUString sSub = pRepr->GetSubRegion(); + m_xSubRegionED->clear(); + m_xSubRegionED->append_text(""); // put in a dummy entry, which is replaced when m_bSubRegionsFilled is set + m_bSubRegionsFilled = false; + if( !aFile.isEmpty() || !sSub.isEmpty() ) + { + m_xFileCB->set_active(true); + m_xFileNameED->set_text(aFile); + m_xSubRegionED->set_entry_text(sSub); + m_xDDECB->set_active(rData.GetType() == SectionType::DdeLink); + } + else + { + m_xFileCB->set_active(false); + m_xFileNameED->set_text(aFile); + m_xDDECB->set_sensitive(false); + m_xDDECB->set_active(false); + } + UseFileHdl(*m_xFileCB); + DDEHdl(*m_xDDECB); + m_xProtectCB->set_state((rData.IsProtectFlag()) + ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xProtectCB->set_sensitive(true); + + // edit in readonly sections + m_xEditInReadonlyCB->set_state((rData.IsEditInReadonlyFlag()) + ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xEditInReadonlyCB->set_sensitive(true); + + bool bPasswdEnabled = m_xProtectCB->get_active(); + m_xPasswdCB->set_sensitive(bPasswdEnabled); + m_xPasswdPB->set_sensitive(bPasswdEnabled); + } + bDontCheckPasswd = false; +} + +// in OkHdl the modified settings are being applied and reversed regions are deleted +IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl, weld::Button&, void) +{ + // temp. Array because during changing of a region the position + // inside of the "Core-Arrays" can be shifted: + // - at linked regions, when they have more SubRegions or get + // new ones. + // StartUndo must certainly also happen not before the formats + // are copied (ClearRedo!) + + const SwSectionFormats& rDocFormats = rSh.GetDoc()->GetSections(); + SwSectionFormats aOrigArray(rDocFormats); + + rSh.StartAllAction(); + rSh.StartUndo(); + rSh.ResetSelect( nullptr,false ); + + std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator()); + if (m_xTree->get_iter_first(*xIter)) + { + do + { + SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64()); + SwSectionFormat* pFormat = aOrigArray[ pRepr->GetArrPos() ]; + if (!pRepr->GetSectionData().IsProtectFlag()) + { + pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >()); + } + size_t nNewPos = rDocFormats.GetPos(pFormat); + if ( SIZE_MAX != nNewPos ) + { + std::unique_ptr<SfxItemSet> pSet(pFormat->GetAttrSet().Clone( false )); + if( pFormat->GetCol() != pRepr->GetCol() ) + pSet->Put( pRepr->GetCol() ); + + std::unique_ptr<SvxBrushItem> aBrush(pFormat->makeBackgroundBrushItem(false)); + if( aBrush && pRepr->GetBackground() && *aBrush != *pRepr->GetBackground() ) + pSet->Put( *pRepr->GetBackground() ); + + if( pFormat->GetFootnoteAtTextEnd(false) != pRepr->GetFootnoteNtAtEnd() ) + pSet->Put( pRepr->GetFootnoteNtAtEnd() ); + + if( pFormat->GetEndAtTextEnd(false) != pRepr->GetEndNtAtEnd() ) + pSet->Put( pRepr->GetEndNtAtEnd() ); + + if( pFormat->GetBalancedColumns() != pRepr->GetBalance() ) + pSet->Put( pRepr->GetBalance() ); + + if( pFormat->GetFrameDir() != *pRepr->GetFrameDir() ) + pSet->Put( *pRepr->GetFrameDir() ); + + if( pFormat->GetLRSpace() != *pRepr->GetLRSpace()) + pSet->Put( *pRepr->GetLRSpace()); + + rSh.UpdateSection( nNewPos, pRepr->GetSectionData(), + pSet->Count() ? pSet.get() : nullptr ); + } + } while (m_xTree->iter_next(*xIter)); + } + + for (SectReprs_t::reverse_iterator it = m_SectReprs.rbegin(), aEnd = m_SectReprs.rend(); it != aEnd; ++it) + { + assert(it->first == it->second->GetArrPos()); + SwSectionFormat* pFormat = aOrigArray[ it->second->GetArrPos() ]; + const size_t nNewPos = rDocFormats.GetPos( pFormat ); + if( SIZE_MAX != nNewPos ) + rSh.DelSectionFormat( nNewPos ); + } + + aOrigArray.clear(); + + // response must be called ahead of EndAction's end, + // otherwise ScrollError can occur. + m_xDialog->response(RET_OK); + + rSh.EndUndo(); + rSh.EndAllAction(); +} + +// Toggle protect +IMPL_LINK(SwEditRegionDlg, ChangeProtectHdl, weld::ToggleButton&, rButton, void) +{ + if (!CheckPasswd(&rButton)) + return; + bool bCheck = TRISTATE_TRUE == rButton.get_state(); + m_xTree->selected_foreach([this, bCheck](weld::TreeIter& rEntry){ + SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64()); + pRepr->GetSectionData().SetProtectFlag(bCheck); + OUString aImage = BuildBitmap(bCheck, TRISTATE_TRUE == m_xHideCB->get_state()); + m_xTree->set_image(rEntry, aImage); + return false; + }); + m_xPasswdCB->set_sensitive(bCheck); + m_xPasswdPB->set_sensitive(bCheck); +} + +// Toggle hide +IMPL_LINK( SwEditRegionDlg, ChangeHideHdl, weld::ToggleButton&, rButton, void) +{ + if (!CheckPasswd(&rButton)) + return; + m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){ + SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64()); + pRepr->GetSectionData().SetHidden(TRISTATE_TRUE == rButton.get_state()); + OUString aImage = BuildBitmap(TRISTATE_TRUE == m_xProtectCB->get_state(), + TRISTATE_TRUE == rButton.get_state()); + m_xTree->set_image(rEntry, aImage); + return false; + }); + bool bHide = TRISTATE_TRUE == rButton.get_state(); + m_xConditionED->set_sensitive(bHide); + m_xConditionFT->set_sensitive(bHide); +} + +// Toggle edit in readonly +IMPL_LINK(SwEditRegionDlg, ChangeEditInReadonlyHdl, weld::ToggleButton&, rButton, void) +{ + if (!CheckPasswd(&rButton)) + return; + m_xTree->selected_foreach([this, &rButton](weld::TreeIter& rEntry){ + SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64()); + pRepr->GetSectionData().SetEditInReadonlyFlag( + TRISTATE_TRUE == rButton.get_state()); + return false; + }); +} + +// clear selected region +IMPL_LINK_NOARG(SwEditRegionDlg, ChangeDismissHdl, weld::Button&, void) +{ + if(!CheckPasswd()) + return; + // at first mark all selected + m_xTree->selected_foreach([this](weld::TreeIter& rEntry){ + SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64()); + pSectRepr->SetSelected(); + return false; + }); + + std::unique_ptr<weld::TreeIter> xEntry(m_xTree->make_iterator()); + bool bEntry(m_xTree->get_selected(xEntry.get())); + // then delete + while (bEntry) + { + SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xEntry).toInt64()); + std::unique_ptr<weld::TreeIter> xRemove; + bool bRestart = false; + if (pSectRepr->IsSelected()) + { + m_SectReprs.insert(std::make_pair(pSectRepr->GetArrPos(), + std::unique_ptr<SectRepr>(pSectRepr))); + if (m_xTree->iter_has_child(*xEntry)) + { + std::unique_ptr<weld::TreeIter> xChild(m_xTree->make_iterator(xEntry.get())); + (void)m_xTree->iter_children(*xChild); + std::unique_ptr<weld::TreeIter> xParent(m_xTree->make_iterator(xEntry.get())); + if (!m_xTree->iter_parent(*xParent)) + xParent.reset(); + bool bChild = true; + do + { + // because of the repositioning we have to start at the beginning again + bRestart = true; + std::unique_ptr<weld::TreeIter> xMove(m_xTree->make_iterator(xChild.get())); + bChild = m_xTree->iter_next_sibling(*xChild); + m_xTree->move_subtree(*xMove, xParent.get(), m_xTree->get_iter_index_in_parent(*xEntry)); + } while (bChild); + } + xRemove = m_xTree->make_iterator(xEntry.get()); + } + if (bRestart) + bEntry = m_xTree->get_iter_first(*xEntry); + else + bEntry = m_xTree->iter_next(*xEntry); + if (xRemove) + m_xTree->remove(*xRemove); + } + + if (m_xTree->get_selected(nullptr)) + return; + + m_xConditionFT->set_sensitive(false); + m_xConditionED->set_sensitive(false); + m_xDismiss->set_sensitive(false); + m_xCurName->set_sensitive(false); + m_xProtectCB->set_sensitive(false); + m_xPasswdCB->set_sensitive(false); + m_xHideCB->set_sensitive(false); + // edit in readonly sections + m_xEditInReadonlyCB->set_sensitive(false); + m_xEditInReadonlyCB->set_state(TRISTATE_FALSE); + m_xProtectCB->set_state(TRISTATE_FALSE); + m_xPasswdCB->set_active(false); + m_xHideCB->set_state(TRISTATE_FALSE); + m_xFileCB->set_active(false); + // otherwise the focus would be on HelpButton + m_xOK->grab_focus(); + UseFileHdl(*m_xFileCB); +} + +// link CheckBox to file? +IMPL_LINK(SwEditRegionDlg, UseFileHdl, weld::ToggleButton&, rButton, void) +{ + if (!CheckPasswd(&rButton)) + return; + bool bMulti = 1 < m_xTree->count_selected_rows(); + bool bFile = rButton.get_active(); + if (m_xTree->get_selected(nullptr)) + { + m_xTree->selected_foreach([&](weld::TreeIter& rEntry){ + SectRepr* const pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64()); + bool bContent = pSectRepr->IsContent(); + if( rButton.get_active() && bContent && rSh.HasSelection() ) + { + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(), + VclMessageType::Question, VclButtonsType::YesNo, + SwResId(STR_QUERY_CONNECT))); + if (RET_NO == xQueryBox->run()) + rButton.set_active( false ); + } + if( bFile ) + pSectRepr->SetContent(false); + else + { + pSectRepr->SetFile(OUString()); + pSectRepr->SetSubRegion(OUString()); + pSectRepr->GetSectionData().SetLinkFilePassword(OUString()); + } + return false; + }); + m_xDDECB->set_sensitive(bFile && !bMulti); + m_xDDEFrame->set_sensitive(bFile && !bMulti); + if( bFile ) + { + m_xProtectCB->set_state(TRISTATE_TRUE); + ChangeProtectHdl(*m_xProtectCB); + m_xFileNameED->grab_focus(); + + } + else + { + m_xDDECB->set_active(false); + m_xSubRegionED->set_entry_text(OUString()); + } + DDEHdl(*m_xDDECB); + } + else + { + rButton.set_active(false); + rButton.set_sensitive(false); + m_xDDECB->set_active(false); + m_xDDECB->set_sensitive(false); + m_xDDEFrame->set_sensitive(false); + } +} + +// call dialog paste file +IMPL_LINK_NOARG(SwEditRegionDlg, FileSearchHdl, weld::Button&, void) +{ + if(!CheckPasswd()) + return; + m_pDocInserter.reset(new ::sfx2::DocumentInserter(m_xDialog.get(), "swriter")); + m_pDocInserter->StartExecuteModal( LINK( this, SwEditRegionDlg, DlgClosedHdl ) ); +} + +IMPL_LINK_NOARG(SwEditRegionDlg, OptionsHdl, weld::Button&, void) +{ + if(!CheckPasswd()) + return; + SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64()); + if (!pSectRepr) + return; + + SfxItemSet aSet( + rSh.GetView().GetPool(), + svl::Items< + RES_FRM_SIZE, RES_FRM_SIZE, + RES_LR_SPACE, RES_LR_SPACE, + RES_BACKGROUND, RES_BACKGROUND, + RES_COL, RES_COL, + RES_FTN_AT_TXTEND, RES_FRAMEDIR, + XATTR_FILL_FIRST, XATTR_FILL_LAST, + SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE>{}); + + aSet.Put( pSectRepr->GetCol() ); + aSet.Put( *pSectRepr->GetBackground() ); + aSet.Put( pSectRepr->GetFootnoteNtAtEnd() ); + aSet.Put( pSectRepr->GetEndNtAtEnd() ); + aSet.Put( pSectRepr->GetBalance() ); + aSet.Put( *pSectRepr->GetFrameDir() ); + aSet.Put( *pSectRepr->GetLRSpace() ); + + const SwSectionFormats& rDocFormats = rSh.GetDoc()->GetSections(); + SwSectionFormats aOrigArray(rDocFormats); + + SwSectionFormat* pFormat = aOrigArray[pSectRepr->GetArrPos()]; + long nWidth = rSh.GetSectionWidth(*pFormat); + aOrigArray.clear(); + if (!nWidth) + nWidth = USHRT_MAX; + + aSet.Put(SwFormatFrameSize(SwFrameSize::Variable, nWidth)); + aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth))); + + SwSectionPropertyTabDialog aTabDlg(m_xDialog.get(), aSet, rSh); + if (RET_OK == aTabDlg.run()) + { + const SfxItemSet* pOutSet = aTabDlg.GetOutputItemSet(); + if( pOutSet && pOutSet->Count() ) + { + const SfxPoolItem *pColItem, *pBrushItem, + *pFootnoteItem, *pEndItem, *pBalanceItem, + *pFrameDirItem, *pLRSpaceItem; + SfxItemState eColState = pOutSet->GetItemState( + RES_COL, false, &pColItem ); + SfxItemState eBrushState = pOutSet->GetItemState( + RES_BACKGROUND, false, &pBrushItem ); + SfxItemState eFootnoteState = pOutSet->GetItemState( + RES_FTN_AT_TXTEND, false, &pFootnoteItem ); + SfxItemState eEndState = pOutSet->GetItemState( + RES_END_AT_TXTEND, false, &pEndItem ); + SfxItemState eBalanceState = pOutSet->GetItemState( + RES_COLUMNBALANCE, false, &pBalanceItem ); + SfxItemState eFrameDirState = pOutSet->GetItemState( + RES_FRAMEDIR, false, &pFrameDirItem ); + SfxItemState eLRState = pOutSet->GetItemState( + RES_LR_SPACE, false, &pLRSpaceItem); + + if( SfxItemState::SET == eColState || + SfxItemState::SET == eBrushState || + SfxItemState::SET == eFootnoteState || + SfxItemState::SET == eEndState || + SfxItemState::SET == eBalanceState|| + SfxItemState::SET == eFrameDirState|| + SfxItemState::SET == eLRState) + { + m_xTree->selected_foreach([&](weld::TreeIter& rEntry){ + SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64()); + if( SfxItemState::SET == eColState ) + pRepr->GetCol() = *static_cast<const SwFormatCol*>(pColItem); + if( SfxItemState::SET == eBrushState ) + pRepr->GetBackground().reset(static_cast<SvxBrushItem*>(pBrushItem->Clone())); + if( SfxItemState::SET == eFootnoteState ) + pRepr->GetFootnoteNtAtEnd() = *static_cast<const SwFormatFootnoteAtTextEnd*>(pFootnoteItem); + if( SfxItemState::SET == eEndState ) + pRepr->GetEndNtAtEnd() = *static_cast<const SwFormatEndAtTextEnd*>(pEndItem); + if( SfxItemState::SET == eBalanceState ) + pRepr->GetBalance().SetValue(static_cast<const SwFormatNoBalancedColumns*>(pBalanceItem)->GetValue()); + if( SfxItemState::SET == eFrameDirState ) + pRepr->GetFrameDir()->SetValue(static_cast<const SvxFrameDirectionItem*>(pFrameDirItem)->GetValue()); + if( SfxItemState::SET == eLRState ) + pRepr->GetLRSpace().reset(static_cast<SvxLRSpaceItem*>(pLRSpaceItem->Clone())); + return false; + }); + } + } + } +} + +IMPL_LINK(SwEditRegionDlg, FileNameComboBoxHdl, weld::ComboBox&, rEdit, void) +{ + int nStartPos, nEndPos; + rEdit.get_entry_selection_bounds(nStartPos, nEndPos); + if (!CheckPasswd()) + return; + rEdit.select_entry_region(nStartPos, nEndPos); + SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64()); + pSectRepr->SetSubRegion( rEdit.get_active_text() ); +} + +// Applying of the filename or the linked region +IMPL_LINK(SwEditRegionDlg, FileNameEntryHdl, weld::Entry&, rEdit, void) +{ + int nStartPos, nEndPos; + rEdit.get_selection_bounds(nStartPos, nEndPos); + if (!CheckPasswd()) + return; + rEdit.select_region(nStartPos, nEndPos); + SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64()); + m_xSubRegionED->clear(); + m_xSubRegionED->append_text(""); // put in a dummy entry, which is replaced when m_bSubRegionsFilled is set + m_bSubRegionsFilled = false; + if (m_xDDECB->get_active()) + { + OUString sLink( SwSectionData::CollapseWhiteSpaces(rEdit.get_text()) ); + sal_Int32 nPos = 0; + sLink = sLink.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos ); + if (nPos>=0) + { + sLink = sLink.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos ); + } + + pSectRepr->GetSectionData().SetLinkFileName( sLink ); + pSectRepr->GetSectionData().SetType( SectionType::DdeLink ); + } + else + { + OUString sTmp(rEdit.get_text()); + if(!sTmp.isEmpty()) + { + SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium(); + INetURLObject aAbs; + if( pMedium ) + aAbs = pMedium->GetURLObject(); + sTmp = URIHelper::SmartRel2Abs( + aAbs, sTmp, URIHelper::GetMaybeFileHdl() ); + } + pSectRepr->SetFile( sTmp ); + pSectRepr->GetSectionData().SetLinkFilePassword(OUString()); + } +} + +IMPL_LINK(SwEditRegionDlg, DDEHdl, weld::ToggleButton&, rButton, void) +{ + if (!CheckPasswd(&rButton)) + return; + SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64()); + if (pSectRepr) + { + bool bFile = m_xFileCB->get_active(); + SwSectionData & rData( pSectRepr->GetSectionData() ); + bool bDDE = rButton.get_active(); + if(bDDE) + { + m_xFileNameFT->hide(); + m_xDDECommandFT->set_sensitive(true); + m_xDDECommandFT->show(); + m_xSubRegionFT->hide(); + m_xSubRegionED->hide(); + if (SectionType::FileLink == rData.GetType()) + { + pSectRepr->SetFile(OUString()); + m_xFileNameED->set_text(OUString()); + rData.SetLinkFilePassword(OUString()); + } + rData.SetType(SectionType::DdeLink); + } + else + { + m_xDDECommandFT->hide(); + m_xFileNameFT->set_sensitive(bFile); + m_xFileNameFT->show(); + m_xSubRegionED->show(); + m_xSubRegionFT->show(); + m_xSubRegionED->set_sensitive(bFile); + m_xSubRegionFT->set_sensitive(bFile); + m_xSubRegionED->set_sensitive(bFile); + if (SectionType::DdeLink == rData.GetType()) + { + rData.SetType(SectionType::FileLink); + pSectRepr->SetFile(OUString()); + rData.SetLinkFilePassword(OUString()); + m_xFileNameED->set_text(OUString()); + } + } + m_xFilePB->set_sensitive(bFile && !bDDE); + } +} + +void SwEditRegionDlg::ChangePasswd(bool bChange) +{ + if (!CheckPasswd()) + { + if (!bChange) + m_xPasswdCB->set_active(!m_xPasswdCB->get_active()); + return; + } + + bool bSet = bChange ? bChange : m_xPasswdCB->get_active(); + + m_xTree->selected_foreach([this, bChange, bSet](weld::TreeIter& rEntry){ + SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64()); + if(bSet) + { + if(!pRepr->GetTempPasswd().hasElements() || bChange) + { + SfxPasswordDialog aPasswdDlg(m_xDialog.get()); + aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM); + if (RET_OK == aPasswdDlg.run()) + { + const OUString sNewPasswd(aPasswdDlg.GetPassword()); + if (aPasswdDlg.GetConfirm() == sNewPasswd) + { + SvPasswordHelper::GetHashPassword( pRepr->GetTempPasswd(), sNewPasswd ); + } + else + { + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), + VclMessageType::Info, VclButtonsType::Ok, + SwResId(STR_WRONG_PASSWD_REPEAT))); + xInfoBox->run(); + ChangePasswd(bChange); + return true; + } + } + else + { + if(!bChange) + m_xPasswdCB->set_active(false); + return true; + } + } + pRepr->GetSectionData().SetPassword(pRepr->GetTempPasswd()); + } + else + { + pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >()); + } + return false; + }); +} + +IMPL_LINK_NOARG(SwEditRegionDlg, TogglePasswdHdl, weld::ToggleButton&, void) +{ + ChangePasswd(false); +} + +IMPL_LINK_NOARG(SwEditRegionDlg, ChangePasswdHdl, weld::Button&, void) +{ + ChangePasswd(true); +} + +// the current region name is being added to the TreeListBox immediately during +// editing, with empty string no Ok() +IMPL_LINK_NOARG(SwEditRegionDlg, NameEditHdl, weld::Entry&, void) +{ + if(!CheckPasswd()) + return; + std::unique_ptr<weld::TreeIter> xIter(m_xTree->make_iterator()); + if (m_xTree->get_selected(xIter.get())) + { + const OUString aName = m_xCurName->get_text(); + m_xTree->set_text(*xIter, aName); + SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(*xIter).toInt64()); + pRepr->GetSectionData().SetSectionName(aName); + + m_xOK->set_sensitive(!aName.isEmpty()); + } +} + +IMPL_LINK( SwEditRegionDlg, ConditionEditHdl, weld::Entry&, rEdit, void ) +{ + int nStartPos, nEndPos; + rEdit.get_selection_bounds(nStartPos, nEndPos); + if(!CheckPasswd()) + return; + rEdit.select_region(nStartPos, nEndPos); + + m_xTree->selected_foreach([this, &rEdit](weld::TreeIter& rEntry){ + SectRepr* pRepr = reinterpret_cast<SectRepr*>(m_xTree->get_id(rEntry).toInt64()); + pRepr->GetSectionData().SetCondition(rEdit.get_text()); + return false; + }); +} + +IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void ) +{ + OUString sFileName, sFilterName, sPassword; + if ( _pFileDlg->GetError() == ERRCODE_NONE ) + { + std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium("sglobal")); + if ( pMedium ) + { + sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE ); + sFilterName = pMedium->GetFilter()->GetFilterName(); + const SfxPoolItem* pItem; + if ( SfxItemState::SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) ) + sPassword = static_cast<const SfxStringItem*>(pItem )->GetValue(); + ::lcl_ReadSections(*pMedium, *m_xSubRegionED); + } + } + + SectRepr* pSectRepr = reinterpret_cast<SectRepr*>(m_xTree->get_selected_id().toInt64()); + if (pSectRepr) + { + pSectRepr->SetFile( sFileName ); + pSectRepr->SetFilter( sFilterName ); + pSectRepr->GetSectionData().SetLinkFilePassword(sPassword); + m_xFileNameED->set_text(pSectRepr->GetFile()); + } +} + +IMPL_LINK_NOARG(SwEditRegionDlg, SubRegionEventHdl, weld::ComboBox&, void) +{ + if (!m_bSubRegionsFilled) + { + //if necessary fill the names bookmarks/sections/tables now + + OUString sFileName = m_xFileNameED->get_text(); + if(!sFileName.isEmpty()) + { + SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium(); + INetURLObject aAbs; + if( pMedium ) + aAbs = pMedium->GetURLObject(); + sFileName = URIHelper::SmartRel2Abs( + aAbs, sFileName, URIHelper::GetMaybeFileHdl() ); + + //load file and set the shell + SfxMedium aMedium( sFileName, StreamMode::STD_READ ); + sFileName = aMedium.GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE ); + ::lcl_ReadSections(aMedium, *m_xSubRegionED); + } + else + lcl_FillSubRegionList(rSh, *m_xSubRegionED, nullptr); + m_bSubRegionsFilled = true; + } +} + +// helper function - read section names from medium +static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox ) +{ + rBox.clear(); + uno::Reference < embed::XStorage > xStg; + if( rMedium.IsStorage() && (xStg = rMedium.GetStorage()).is() ) + { + std::vector<OUString> aArr; + SotClipboardFormatId nFormat = SotStorage::GetFormatID( xStg ); + if ( nFormat == SotClipboardFormatId::STARWRITER_60 || nFormat == SotClipboardFormatId::STARWRITERGLOB_60 || + nFormat == SotClipboardFormatId::STARWRITER_8 || nFormat == SotClipboardFormatId::STARWRITERGLOB_8) + SwGetReaderXML()->GetSectionList( rMedium, aArr ); + + for (auto const& it : aArr) + { + rBox.append_text(it); + } + } +} + +SwInsertSectionTabDialog::SwInsertSectionTabDialog( + weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh) + : SfxTabDialogController(pParent, "modules/swriter/ui/insertsectiondialog.ui", + "InsertSectionDialog",&rSet) + , rWrtSh(rSh) +{ + SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); + AddTabPage("section", SwInsertSectionTabPage::Create, nullptr); + AddTabPage("columns", SwColumnPage::Create, nullptr); + AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr); + AddTabPage("notes", SwSectionFootnoteEndTabPage::Create, nullptr); + AddTabPage("indents", SwSectionIndentTabPage::Create, nullptr); + + SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get(); + long nHtmlMode = rHtmlOpt.GetExportMode(); + + bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ; + if(bWeb) + { + RemoveTabPage("notes"); + RemoveTabPage("indents"); + if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode) + RemoveTabPage("columns"); + } + SetCurPageId("section"); +} + +SwInsertSectionTabDialog::~SwInsertSectionTabDialog() +{ +} + +void SwInsertSectionTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) +{ + if (rId == "section") + static_cast<SwInsertSectionTabPage&>(rPage).SetWrtShell(rWrtSh); + else if (rId == "background") + { + SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); + aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR))); + rPage.PageCreated(aSet); + } + else if (rId == "columns") + { + const SwFormatFrameSize& rSize = GetInputSetImpl()->Get(RES_FRM_SIZE); + static_cast<SwColumnPage&>(rPage).SetPageWidth(rSize.GetWidth()); + static_cast<SwColumnPage&>(rPage).ShowBalance(true); + static_cast<SwColumnPage&>(rPage).SetInSection(true); + } + else if (rId == "indents") + static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh); +} + +void SwInsertSectionTabDialog::SetSectionData(SwSectionData const& rSect) +{ + m_pSectionData.reset( new SwSectionData(rSect) ); +} + +short SwInsertSectionTabDialog::Ok() +{ + short nRet = SfxTabDialogController::Ok(); + OSL_ENSURE(m_pSectionData, "SwInsertSectionTabDialog: no SectionData?"); + const SfxItemSet* pOutputItemSet = GetOutputItemSet(); + rWrtSh.InsertSection(*m_pSectionData, pOutputItemSet); + SfxViewFrame* pViewFrame = rWrtSh.GetView().GetViewFrame(); + uno::Reference< frame::XDispatchRecorder > xRecorder = + pViewFrame->GetBindings().GetRecorder(); + if ( xRecorder.is() ) + { + SfxRequest aRequest( pViewFrame, FN_INSERT_REGION); + const SfxPoolItem* pCol; + if(SfxItemState::SET == pOutputItemSet->GetItemState(RES_COL, false, &pCol)) + { + aRequest.AppendItem(SfxUInt16Item(SID_ATTR_COLUMNS, + static_cast<const SwFormatCol*>(pCol)->GetColumns().size())); + } + aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_NAME, + m_pSectionData->GetSectionName())); + aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_CONDITION, + m_pSectionData->GetCondition())); + aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_HIDDEN, + m_pSectionData->IsHidden())); + aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_PROTECT, + m_pSectionData->IsProtectFlag())); + // edit in readonly sections + aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_EDIT_IN_READONLY, + m_pSectionData->IsEditInReadonlyFlag())); + + const OUString sLinkFileName( m_pSectionData->GetLinkFileName() ); + sal_Int32 n = 0; + aRequest.AppendItem(SfxStringItem( FN_PARAM_1, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ))); + aRequest.AppendItem(SfxStringItem( FN_PARAM_2, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ))); + aRequest.AppendItem(SfxStringItem( FN_PARAM_3, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ))); + aRequest.Done(); + } + return nRet; +} + +SwInsertSectionTabPage::SwInsertSectionTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rAttrSet) + : SfxTabPage(pPage, pController, "modules/swriter/ui/sectionpage.ui", "SectionPage", &rAttrSet) + , m_pWrtSh(nullptr) + , m_xCurName(m_xBuilder->weld_entry_tree_view("sectionnames", "sectionnames-entry", + "sectionnames-list")) + , m_xFileCB(m_xBuilder->weld_check_button("link")) + , m_xDDECB(m_xBuilder->weld_check_button("dde")) + , m_xDDECommandFT(m_xBuilder->weld_label("ddelabel")) + , m_xFileNameFT(m_xBuilder->weld_label("filelabel")) + , m_xFileNameED(m_xBuilder->weld_entry("filename")) + , m_xFilePB(m_xBuilder->weld_button("selectfile")) + , m_xSubRegionFT(m_xBuilder->weld_label("sectionlabel")) + , m_xSubRegionED(m_xBuilder->weld_combo_box("sectionname")) + , m_xProtectCB(m_xBuilder->weld_check_button("protect")) + , m_xPasswdCB(m_xBuilder->weld_check_button("withpassword")) + , m_xPasswdPB(m_xBuilder->weld_button("selectpassword")) + , m_xHideCB(m_xBuilder->weld_check_button("hide")) + , m_xConditionFT(m_xBuilder->weld_label("condlabel")) + , m_xConditionED(new ConditionEdit(m_xBuilder->weld_entry("withcond"))) + // edit in readonly sections + , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editable")) +{ + m_xCurName->make_sorted(); + m_xCurName->set_height_request_by_rows(12); + m_xSubRegionED->make_sorted(); + + m_xProtectCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeProtectHdl)); + m_xPasswdCB->connect_toggled( LINK( this, SwInsertSectionTabPage, TogglePasswdHdl)); + m_xPasswdPB->connect_clicked( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl)); + m_xHideCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeHideHdl)); + m_xFileCB->connect_toggled( LINK( this, SwInsertSectionTabPage, UseFileHdl )); + m_xFilePB->connect_clicked( LINK( this, SwInsertSectionTabPage, FileSearchHdl )); + m_xCurName->connect_changed( LINK( this, SwInsertSectionTabPage, NameEditHdl)); + m_xDDECB->connect_toggled( LINK( this, SwInsertSectionTabPage, DDEHdl )); + ChangeProtectHdl(*m_xProtectCB); + m_xSubRegionED->set_entry_completion(true, true); +} + +SwInsertSectionTabPage::~SwInsertSectionTabPage() +{ +} + +void SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh) +{ + m_pWrtSh = &rSh; + + bool bWeb = dynamic_cast<SwWebDocShell*>( m_pWrtSh->GetView().GetDocShell() )!= nullptr; + if(bWeb) + { + m_xHideCB->hide(); + m_xConditionED->hide(); + m_xConditionFT->hide(); + m_xDDECB->hide(); + m_xDDECommandFT->hide(); + } + + lcl_FillSubRegionList(*m_pWrtSh, *m_xSubRegionED, m_xCurName.get()); + + SwSectionData *const pSectionData = + static_cast<SwInsertSectionTabDialog*>(GetDialogController()) + ->GetSectionData(); + if (pSectionData) // something set? + { + const OUString sSectionName(pSectionData->GetSectionName()); + m_xCurName->set_entry_text(rSh.GetUniqueSectionName(&sSectionName)); + m_xProtectCB->set_active( pSectionData->IsProtectFlag() ); + ChangeProtectHdl(*m_xProtectCB); + m_sFileName = pSectionData->GetLinkFileName(); + m_sFilePasswd = pSectionData->GetLinkFilePassword(); + m_xFileCB->set_active( !m_sFileName.isEmpty() ); + m_xFileNameED->set_text( m_sFileName ); + UseFileHdl(*m_xFileCB); + } + else + { + m_xCurName->set_entry_text(rSh.GetUniqueSectionName()); + } +} + +bool SwInsertSectionTabPage::FillItemSet( SfxItemSet* ) +{ + SwSectionData aSection(SectionType::Content, m_xCurName->get_active_text()); + aSection.SetCondition(m_xConditionED->get_text()); + bool bProtected = m_xProtectCB->get_active(); + aSection.SetProtectFlag(bProtected); + aSection.SetHidden(m_xHideCB->get_active()); + // edit in readonly sections + aSection.SetEditInReadonlyFlag(m_xEditInReadonlyCB->get_active()); + + if(bProtected) + { + aSection.SetPassword(m_aNewPasswd); + } + const OUString sFileName = m_xFileNameED->get_text(); + const OUString sSubRegion = m_xSubRegionED->get_active_text(); + bool bDDe = m_xDDECB->get_active(); + if (m_xFileCB->get_active() && (!sFileName.isEmpty() || !sSubRegion.isEmpty() || bDDe)) + { + OUString aLinkFile; + if( bDDe ) + { + aLinkFile = SwSectionData::CollapseWhiteSpaces(sFileName); + sal_Int32 nPos = 0; + aLinkFile = aLinkFile.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos ); + if (nPos>=0) + { + aLinkFile = aLinkFile.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nPos ); + } + } + else + { + if(!sFileName.isEmpty()) + { + SfxMedium* pMedium = m_pWrtSh->GetView().GetDocShell()->GetMedium(); + INetURLObject aAbs; + if( pMedium ) + aAbs = pMedium->GetURLObject(); + aLinkFile = URIHelper::SmartRel2Abs( + aAbs, sFileName, URIHelper::GetMaybeFileHdl() ); + aSection.SetLinkFilePassword( m_sFilePasswd ); + } + + aLinkFile += OUStringChar(sfx2::cTokenSeparator) + m_sFilterName + + OUStringChar(sfx2::cTokenSeparator) + sSubRegion; + } + + aSection.SetLinkFileName(aLinkFile); + if (!aLinkFile.isEmpty()) + { + aSection.SetType( m_xDDECB->get_active() ? + SectionType::DdeLink : + SectionType::FileLink); + } + } + static_cast<SwInsertSectionTabDialog*>(GetDialogController())->SetSectionData(aSection); + return true; +} + +void SwInsertSectionTabPage::Reset( const SfxItemSet* ) +{ +} + +std::unique_ptr<SfxTabPage> SwInsertSectionTabPage::Create(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet* rAttrSet) +{ + return std::make_unique<SwInsertSectionTabPage>(pPage, pController, *rAttrSet); +} + +IMPL_LINK(SwInsertSectionTabPage, ChangeHideHdl, weld::ToggleButton&, rBox, void) +{ + bool bHide = rBox.get_active(); + m_xConditionED->set_sensitive(bHide); + m_xConditionFT->set_sensitive(bHide); +} + +IMPL_LINK(SwInsertSectionTabPage, ChangeProtectHdl, weld::ToggleButton&, rBox, void) +{ + bool bCheck = rBox.get_active(); + m_xPasswdCB->set_sensitive(bCheck); + m_xPasswdPB->set_sensitive(bCheck); +} + +void SwInsertSectionTabPage::ChangePasswd(bool bChange) +{ + bool bSet = bChange ? bChange : m_xPasswdCB->get_active(); + if (bSet) + { + if(!m_aNewPasswd.hasElements() || bChange) + { + SfxPasswordDialog aPasswdDlg(GetFrameWeld()); + aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM); + if (RET_OK == aPasswdDlg.run()) + { + const OUString sNewPasswd(aPasswdDlg.GetPassword()); + if (aPasswdDlg.GetConfirm() == sNewPasswd) + { + SvPasswordHelper::GetHashPassword( m_aNewPasswd, sNewPasswd ); + } + else + { + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + SwResId(STR_WRONG_PASSWD_REPEAT))); + xInfoBox->run(); + } + } + else if(!bChange) + m_xPasswdCB->set_active(false); + } + } + else + m_aNewPasswd.realloc(0); +} + +IMPL_LINK_NOARG(SwInsertSectionTabPage, TogglePasswdHdl, weld::ToggleButton&, void) +{ + ChangePasswd(false); +} + +IMPL_LINK_NOARG(SwInsertSectionTabPage, ChangePasswdHdl, weld::Button&, void) +{ + ChangePasswd(true); +} + + +IMPL_LINK_NOARG(SwInsertSectionTabPage, NameEditHdl, weld::ComboBox&, void) +{ + const OUString aName = m_xCurName->get_active_text(); + GetDialogController()->GetOKButton().set_sensitive(!aName.isEmpty() && + m_xCurName->find_text(aName) == -1); +} + +IMPL_LINK(SwInsertSectionTabPage, UseFileHdl, weld::ToggleButton&, rButton, void) +{ + if (rButton.get_active()) + { + if (m_pWrtSh->HasSelection()) + { + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + SwResId(STR_QUERY_CONNECT))); + if (RET_NO == xQueryBox->run()) + rButton.set_active(false); + } + } + + bool bFile = rButton.get_active(); + m_xFileNameFT->set_sensitive(bFile); + m_xFileNameED->set_sensitive(bFile); + m_xFilePB->set_sensitive(bFile); + m_xSubRegionFT->set_sensitive(bFile); + m_xSubRegionED->set_sensitive(bFile); + m_xDDECommandFT->set_sensitive(bFile); + m_xDDECB->set_sensitive(bFile); + if (bFile) + { + m_xFileNameED->grab_focus(); + m_xProtectCB->set_active(true); + ChangeProtectHdl(*m_xProtectCB); + } + else + { + m_xDDECB->set_active(false); + DDEHdl(*m_xDDECB); + } +} + +IMPL_LINK_NOARG(SwInsertSectionTabPage, FileSearchHdl, weld::Button&, void) +{ + m_pDocInserter.reset(new ::sfx2::DocumentInserter(GetFrameWeld(), "swriter")); + m_pDocInserter->StartExecuteModal( LINK( this, SwInsertSectionTabPage, DlgClosedHdl ) ); +} + +IMPL_LINK( SwInsertSectionTabPage, DDEHdl, weld::ToggleButton&, rButton, void ) +{ + bool bDDE = rButton.get_active(); + bool bFile = m_xFileCB->get_active(); + m_xFilePB->set_sensitive(!bDDE && bFile); + if (bDDE) + { + m_xFileNameFT->hide(); + m_xDDECommandFT->set_sensitive(bDDE); + m_xDDECommandFT->show(); + m_xSubRegionFT->hide(); + m_xSubRegionED->hide(); + m_xFileNameED->set_accessible_name(m_xDDECommandFT->get_label()); + } + else + { + m_xDDECommandFT->hide(); + m_xFileNameFT->set_sensitive(bFile); + m_xFileNameFT->show(); + m_xSubRegionFT->show(); + m_xSubRegionED->show(); + m_xSubRegionED->set_sensitive(bFile); + m_xFileNameED->set_accessible_name(m_xFileNameFT->get_label()); + } +} + +IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void ) +{ + if ( _pFileDlg->GetError() == ERRCODE_NONE ) + { + std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium("sglobal")); + if ( pMedium ) + { + m_sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE ); + m_sFilterName = pMedium->GetFilter()->GetFilterName(); + const SfxPoolItem* pItem; + if ( SfxItemState::SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) ) + m_sFilePasswd = static_cast<const SfxStringItem*>(pItem)->GetValue(); + m_xFileNameED->set_text( INetURLObject::decode( + m_sFileName, INetURLObject::DecodeMechanism::Unambiguous ) ); + ::lcl_ReadSections(*pMedium, *m_xSubRegionED); + } + } + else + { + m_sFilterName.clear(); + m_sFilePasswd.clear(); + } +} + +SwSectionFootnoteEndTabPage::SwSectionFootnoteEndTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rAttrSet) + : SfxTabPage(pPage, pController, "modules/swriter/ui/footnotesendnotestabpage.ui", "FootnotesEndnotesTabPage", &rAttrSet) + , m_xFootnoteNtAtTextEndCB(m_xBuilder->weld_check_button("ftnntattextend")) + , m_xFootnoteNtNumCB(m_xBuilder->weld_check_button("ftnntnum")) + , m_xFootnoteOffsetLbl(m_xBuilder->weld_label("ftnoffset_label")) + , m_xFootnoteOffsetField(m_xBuilder->weld_spin_button("ftnoffset")) + , m_xFootnoteNtNumFormatCB(m_xBuilder->weld_check_button("ftnntnumfmt")) + , m_xFootnotePrefixFT(m_xBuilder->weld_label("ftnprefix_label")) + , m_xFootnotePrefixED(m_xBuilder->weld_entry("ftnprefix")) + , m_xFootnoteNumViewBox(new SwNumberingTypeListBox(m_xBuilder->weld_combo_box("ftnnumviewbox"))) + , m_xFootnoteSuffixFT(m_xBuilder->weld_label("ftnsuffix_label")) + , m_xFootnoteSuffixED(m_xBuilder->weld_entry("ftnsuffix")) + , m_xEndNtAtTextEndCB(m_xBuilder->weld_check_button("endntattextend")) + , m_xEndNtNumCB(m_xBuilder->weld_check_button("endntnum")) + , m_xEndOffsetLbl(m_xBuilder->weld_label("endoffset_label")) + , m_xEndOffsetField(m_xBuilder->weld_spin_button("endoffset")) + , m_xEndNtNumFormatCB(m_xBuilder->weld_check_button("endntnumfmt")) + , m_xEndPrefixFT(m_xBuilder->weld_label("endprefix_label")) + , m_xEndPrefixED(m_xBuilder->weld_entry("endprefix")) + , m_xEndNumViewBox(new SwNumberingTypeListBox(m_xBuilder->weld_combo_box("endnumviewbox"))) + , m_xEndSuffixFT(m_xBuilder->weld_label("endsuffix_label")) + , m_xEndSuffixED(m_xBuilder->weld_entry("endsuffix")) +{ + m_xFootnoteNumViewBox->Reload(SwInsertNumTypes::Extended); + m_xEndNumViewBox->Reload(SwInsertNumTypes::Extended); + + Link<weld::ToggleButton&,void> aLk( LINK( this, SwSectionFootnoteEndTabPage, FootEndHdl)); + m_xFootnoteNtAtTextEndCB->connect_toggled( aLk ); + m_xFootnoteNtNumCB->connect_toggled( aLk ); + m_xEndNtAtTextEndCB->connect_toggled( aLk ); + m_xEndNtNumCB->connect_toggled( aLk ); + m_xFootnoteNtNumFormatCB->connect_toggled( aLk ); + m_xEndNtNumFormatCB->connect_toggled( aLk ); +} + +SwSectionFootnoteEndTabPage::~SwSectionFootnoteEndTabPage() +{ +} + +bool SwSectionFootnoteEndTabPage::FillItemSet( SfxItemSet* rSet ) +{ + SwFormatFootnoteAtTextEnd aFootnote( m_xFootnoteNtAtTextEndCB->get_active() + ? ( m_xFootnoteNtNumCB->get_active() + ? ( m_xFootnoteNtNumFormatCB->get_active() + ? FTNEND_ATTXTEND_OWNNUMANDFMT + : FTNEND_ATTXTEND_OWNNUMSEQ ) + : FTNEND_ATTXTEND ) + : FTNEND_ATPGORDOCEND ); + + switch( aFootnote.GetValue() ) + { + case FTNEND_ATTXTEND_OWNNUMANDFMT: + aFootnote.SetNumType( m_xFootnoteNumViewBox->GetSelectedNumberingType() ); + aFootnote.SetPrefix( m_xFootnotePrefixED->get_text().replaceAll("\\t", "\t") ); // fdo#65666 + aFootnote.SetSuffix( m_xFootnoteSuffixED->get_text().replaceAll("\\t", "\t") ); + [[fallthrough]]; + + case FTNEND_ATTXTEND_OWNNUMSEQ: + aFootnote.SetOffset( static_cast< sal_uInt16 >( m_xFootnoteOffsetField->get_value()-1 ) ); + break; + default: break; + } + + SwFormatEndAtTextEnd aEnd( m_xEndNtAtTextEndCB->get_active() + ? ( m_xEndNtNumCB->get_active() + ? ( m_xEndNtNumFormatCB->get_active() + ? FTNEND_ATTXTEND_OWNNUMANDFMT + : FTNEND_ATTXTEND_OWNNUMSEQ ) + : FTNEND_ATTXTEND ) + : FTNEND_ATPGORDOCEND ); + + switch( aEnd.GetValue() ) + { + case FTNEND_ATTXTEND_OWNNUMANDFMT: + aEnd.SetNumType( m_xEndNumViewBox->GetSelectedNumberingType() ); + aEnd.SetPrefix( m_xEndPrefixED->get_text().replaceAll("\\t", "\t") ); + aEnd.SetSuffix( m_xEndSuffixED->get_text().replaceAll("\\t", "\t") ); + [[fallthrough]]; + + case FTNEND_ATTXTEND_OWNNUMSEQ: + aEnd.SetOffset( static_cast< sal_uInt16 >( m_xEndOffsetField->get_value()-1 ) ); + break; + default: break; + } + + rSet->Put( aFootnote ); + rSet->Put( aEnd ); + + return true; +} + +void SwSectionFootnoteEndTabPage::ResetState( bool bFootnote, + const SwFormatFootnoteEndAtTextEnd& rAttr ) +{ + weld::CheckButton *pNtAtTextEndCB, *pNtNumCB, *pNtNumFormatCB; + weld::Label *pPrefixFT, *pSuffixFT; + weld::Entry *pPrefixED, *pSuffixED; + SwNumberingTypeListBox *pNumViewBox; + weld::Label *pOffsetText; + weld::SpinButton *pOffsetField; + + if( bFootnote ) + { + pNtAtTextEndCB = m_xFootnoteNtAtTextEndCB.get(); + pNtNumCB = m_xFootnoteNtNumCB.get(); + pNtNumFormatCB = m_xFootnoteNtNumFormatCB.get(); + pPrefixFT = m_xFootnotePrefixFT.get(); + pPrefixED = m_xFootnotePrefixED.get(); + pSuffixFT = m_xFootnoteSuffixFT.get(); + pSuffixED = m_xFootnoteSuffixED.get(); + pNumViewBox = m_xFootnoteNumViewBox.get(); + pOffsetText = m_xFootnoteOffsetLbl.get(); + pOffsetField = m_xFootnoteOffsetField.get(); + } + else + { + pNtAtTextEndCB = m_xEndNtAtTextEndCB.get(); + pNtNumCB = m_xEndNtNumCB.get(); + pNtNumFormatCB = m_xEndNtNumFormatCB.get(); + pPrefixFT = m_xEndPrefixFT.get(); + pPrefixED = m_xEndPrefixED.get(); + pSuffixFT = m_xEndSuffixFT.get(); + pSuffixED = m_xEndSuffixED.get(); + pNumViewBox = m_xEndNumViewBox.get(); + pOffsetText = m_xEndOffsetLbl.get(); + pOffsetField = m_xEndOffsetField.get(); + } + + const sal_uInt16 eState = rAttr.GetValue(); + switch( eState ) + { + case FTNEND_ATTXTEND_OWNNUMANDFMT: + pNtNumFormatCB->set_state( TRISTATE_TRUE ); + [[fallthrough]]; + + case FTNEND_ATTXTEND_OWNNUMSEQ: + pNtNumCB->set_state( TRISTATE_TRUE ); + [[fallthrough]]; + + case FTNEND_ATTXTEND: + pNtAtTextEndCB->set_state( TRISTATE_TRUE ); + // no break; + } + + pNumViewBox->SelectNumberingType( rAttr.GetNumType() ); + pOffsetField->set_value( rAttr.GetOffset() + 1 ); + pPrefixED->set_text( rAttr.GetPrefix().replaceAll("\t", "\\t") ); + pSuffixED->set_text( rAttr.GetSuffix().replaceAll("\t", "\\t") ); + + switch( eState ) + { + case FTNEND_ATPGORDOCEND: + pNtNumCB->set_sensitive( false ); + [[fallthrough]]; + + case FTNEND_ATTXTEND: + pNtNumFormatCB->set_sensitive( false ); + pOffsetField->set_sensitive( false ); + pOffsetText->set_sensitive( false ); + [[fallthrough]]; + + case FTNEND_ATTXTEND_OWNNUMSEQ: + pNumViewBox->set_sensitive( false ); + pPrefixFT->set_sensitive( false ); + pPrefixED->set_sensitive( false ); + pSuffixFT->set_sensitive( false ); + pSuffixED->set_sensitive( false ); + // no break; + } +} + +void SwSectionFootnoteEndTabPage::Reset( const SfxItemSet* rSet ) +{ + ResetState( true, rSet->Get( RES_FTN_AT_TXTEND, false )); + ResetState( false, rSet->Get( RES_END_AT_TXTEND, false )); +} + +std::unique_ptr<SfxTabPage> SwSectionFootnoteEndTabPage::Create( weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet* rAttrSet) +{ + return std::make_unique<SwSectionFootnoteEndTabPage>(pPage, pController, *rAttrSet); +} + +IMPL_LINK( SwSectionFootnoteEndTabPage, FootEndHdl, weld::ToggleButton&, rBox, void ) +{ + bool bFoot = m_xFootnoteNtAtTextEndCB.get() == &rBox || m_xFootnoteNtNumCB.get() == &rBox || + m_xFootnoteNtNumFormatCB.get() == &rBox ; + + weld::CheckButton *pNumBox, *pNumFormatBox, *pEndBox; + SwNumberingTypeListBox* pNumViewBox; + weld::Label *pOffsetText; + weld::SpinButton *pOffsetField; + weld::Label *pPrefixFT, *pSuffixFT; + weld::Entry *pPrefixED, *pSuffixED; + + if( bFoot ) + { + pEndBox = m_xFootnoteNtAtTextEndCB.get(); + pNumBox = m_xFootnoteNtNumCB.get(); + pNumFormatBox = m_xFootnoteNtNumFormatCB.get(); + pNumViewBox = m_xFootnoteNumViewBox.get(); + pOffsetText = m_xFootnoteOffsetLbl.get(); + pOffsetField = m_xFootnoteOffsetField.get(); + pPrefixFT = m_xFootnotePrefixFT.get(); + pSuffixFT = m_xFootnoteSuffixFT.get(); + pPrefixED = m_xFootnotePrefixED.get(); + pSuffixED = m_xFootnoteSuffixED.get(); + } + else + { + pEndBox = m_xEndNtAtTextEndCB.get(); + pNumBox = m_xEndNtNumCB.get(); + pNumFormatBox = m_xEndNtNumFormatCB.get(); + pNumViewBox = m_xEndNumViewBox.get(); + pOffsetText = m_xEndOffsetLbl.get(); + pOffsetField = m_xEndOffsetField.get(); + pPrefixFT = m_xEndPrefixFT.get(); + pSuffixFT = m_xEndSuffixFT.get(); + pPrefixED = m_xEndPrefixED.get(); + pSuffixED = m_xEndSuffixED.get(); + } + + bool bEnableAtEnd = TRISTATE_TRUE == pEndBox->get_state(); + bool bEnableNum = bEnableAtEnd && TRISTATE_TRUE == pNumBox->get_state(); + bool bEnableNumFormat = bEnableNum && TRISTATE_TRUE == pNumFormatBox->get_state(); + + pNumBox->set_sensitive( bEnableAtEnd ); + pOffsetText->set_sensitive( bEnableNum ); + pOffsetField->set_sensitive( bEnableNum ); + pNumFormatBox->set_sensitive( bEnableNum ); + pNumViewBox->set_sensitive( bEnableNumFormat ); + pPrefixED->set_sensitive( bEnableNumFormat ); + pSuffixED->set_sensitive( bEnableNumFormat ); + pPrefixFT->set_sensitive( bEnableNumFormat ); + pSuffixFT->set_sensitive( bEnableNumFormat ); +} + +SwSectionPropertyTabDialog::SwSectionPropertyTabDialog( + weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh) + : SfxTabDialogController(pParent, "modules/swriter/ui/formatsectiondialog.ui", + "FormatSectionDialog", &rSet) + , rWrtSh(rSh) +{ + SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); + AddTabPage("columns", SwColumnPage::Create, nullptr); + AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr); + AddTabPage("notes", SwSectionFootnoteEndTabPage::Create, nullptr); + AddTabPage("indents", SwSectionIndentTabPage::Create, nullptr); + + SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get(); + long nHtmlMode = rHtmlOpt.GetExportMode(); + bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ; + if(bWeb) + { + RemoveTabPage("notes"); + RemoveTabPage("indents"); + if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode) + RemoveTabPage("columns"); + } +} + +SwSectionPropertyTabDialog::~SwSectionPropertyTabDialog() +{ +} + +void SwSectionPropertyTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) +{ + if (rId == "background") + { + SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); + aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR))); + rPage.PageCreated(aSet); + } + else if (rId == "columns") + { + static_cast<SwColumnPage&>(rPage).ShowBalance(true); + static_cast<SwColumnPage&>(rPage).SetInSection(true); + } + else if (rId == "indents") + static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh); +} + +SwSectionIndentTabPage::SwSectionIndentTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rAttrSet) + : SfxTabPage(pPage, pController, "modules/swriter/ui/indentpage.ui", "IndentPage", &rAttrSet) + , m_xBeforeMF(m_xBuilder->weld_metric_spin_button("before", FieldUnit::CM)) + , m_xAfterMF(m_xBuilder->weld_metric_spin_button("after", FieldUnit::CM)) + , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin)) +{ + Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwSectionIndentTabPage, IndentModifyHdl); + m_xBeforeMF->connect_value_changed(aLk); + m_xAfterMF->connect_value_changed(aLk); +} + +SwSectionIndentTabPage::~SwSectionIndentTabPage() +{ +} + +bool SwSectionIndentTabPage::FillItemSet(SfxItemSet* rSet) +{ + if (m_xBeforeMF->get_value_changed_from_saved() || m_xAfterMF->get_value_changed_from_saved()) + { + SvxLRSpaceItem aLRSpace( + m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)) , + m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)), 0, 0, RES_LR_SPACE); + rSet->Put(aLRSpace); + } + return true; +} + +void SwSectionIndentTabPage::Reset( const SfxItemSet* rSet) +{ + //this page doesn't show up in HTML mode + FieldUnit aMetric = ::GetDfltMetric(false); + SetFieldUnit(*m_xBeforeMF, aMetric); + SetFieldUnit(*m_xAfterMF , aMetric); + + SfxItemState eItemState = rSet->GetItemState( RES_LR_SPACE ); + if ( eItemState >= SfxItemState::DEFAULT ) + { + const SvxLRSpaceItem& rSpace = + rSet->Get( RES_LR_SPACE ); + + m_xBeforeMF->set_value(m_xBeforeMF->normalize(rSpace.GetLeft()), FieldUnit::TWIP); + m_xAfterMF->set_value(m_xAfterMF->normalize(rSpace.GetRight()), FieldUnit::TWIP); + } + else + { + m_xBeforeMF->set_text(""); + m_xAfterMF->set_text(""); + } + m_xBeforeMF->save_value(); + m_xAfterMF->save_value(); + IndentModifyHdl(*m_xBeforeMF); +} + +std::unique_ptr<SfxTabPage> SwSectionIndentTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet) +{ + return std::make_unique<SwSectionIndentTabPage>(pPage, pController, *rAttrSet); +} + +void SwSectionIndentTabPage::SetWrtShell(SwWrtShell const & rSh) +{ + //set sensible values at the preview + m_aPreviewWin.SetAdjust(SvxAdjust::Block); + m_aPreviewWin.SetLastLine(SvxAdjust::Block); + const SwRect& rPageRect = rSh.GetAnyCurRect( CurRectType::Page ); + Size aPageSize(rPageRect.Width(), rPageRect.Height()); + m_aPreviewWin.SetSize(aPageSize); +} + +IMPL_LINK_NOARG(SwSectionIndentTabPage, IndentModifyHdl, weld::MetricSpinButton&, void) +{ + m_aPreviewWin.SetLeftMargin(m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP))); + m_aPreviewWin.SetRightMargin(m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP))); + m_aPreviewWin.Invalidate(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/wordcountdialog.cxx b/sw/source/ui/dialog/wordcountdialog.cxx new file mode 100644 index 000000000..ba159d4e6 --- /dev/null +++ b/sw/source/ui/dialog/wordcountdialog.cxx @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <officecfg/Office/Writer.hxx> +#include <wordcountdialog.hxx> +#include <docstat.hxx> +#include <swmodule.hxx> +#include <view.hxx> +#include <swwait.hxx> +#include <wrtsh.hxx> +#include <rtl/math.hxx> +#include <svl/cjkoptions.hxx> +#include <unotools/localedatawrapper.hxx> +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> +#include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> + +#define IS_MOBILE_PHONE (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone()) + +SwWordCountFloatDlg::~SwWordCountFloatDlg() +{ + SwViewShell::SetCareDialog(nullptr); +} + +namespace +{ + void setValue(weld::Label& rWidget, sal_uLong nValue, const LocaleDataWrapper& rLocaleData) + { + rWidget.set_label(rLocaleData.getNum(nValue, 0)); + } + + void setDoubleValue(weld::Label& rWidget, double fValue) + { + OUString sValue(OUString::number(::rtl::math::round(fValue, 1))); + rWidget.set_label(sValue); + } +} + +void SwWordCountFloatDlg::SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc) +{ + const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetUILocaleDataWrapper(); + setValue(*m_xCurrentWordFT, rCurrent.nWord, rLocaleData); + setValue(*m_xCurrentCharacterFT, rCurrent.nChar, rLocaleData); + setValue(*m_xCurrentCharacterExcludingSpacesFT, rCurrent.nCharExcludingSpaces, rLocaleData); + setValue(*m_xCurrentCjkcharsFT, rCurrent.nAsianWord, rLocaleData); + setValue(*m_xDocWordFT, rDoc.nWord, rLocaleData); + setValue(*m_xDocCharacterFT, rDoc.nChar, rLocaleData); + setValue(*m_xDocCharacterExcludingSpacesFT, rDoc.nCharExcludingSpaces, rLocaleData); + setValue(*m_xDocCjkcharsFT, rDoc.nAsianWord, rLocaleData); + + if (m_xStandardizedPagesLabelFT->get_visible()) + { + sal_Int64 nCharsPerStandardizedPage = officecfg::Office::Writer::WordCount::StandardizedPageSize::get(); + setDoubleValue(*m_xCurrentStandardizedPagesFT, + static_cast<double>(rCurrent.nChar) / nCharsPerStandardizedPage); + setDoubleValue(*m_xDocStandardizedPagesFT, + static_cast<double>(rDoc.nChar) / nCharsPerStandardizedPage); + } + + bool bShowCJK = (SvtCJKOptions().IsAnyEnabled() || rDoc.nAsianWord); + bool bToggleCJK = m_xCurrentCjkcharsFT->get_visible() != bShowCJK; + if (bToggleCJK) + { + showCJK(bShowCJK); + m_xDialog->resize_to_request(); //force resize of dialog + } +} + +void SwWordCountFloatDlg::showCJK(bool bShowCJK) +{ + m_xCurrentCjkcharsFT->set_visible(bShowCJK); + m_xDocCjkcharsFT->set_visible(bShowCJK); + if (m_xCjkcharsLabelFT2) + m_xCjkcharsLabelFT2->set_visible(bShowCJK); + m_xCjkcharsLabelFT->set_visible(bShowCJK); +} + +void SwWordCountFloatDlg::showStandardizedPages(bool bShowStandardizedPages) +{ + m_xCurrentStandardizedPagesFT->set_visible(bShowStandardizedPages); + m_xDocStandardizedPagesFT->set_visible(bShowStandardizedPages); + if (m_xStandardizedPagesLabelFT2) + m_xStandardizedPagesLabelFT2->set_visible(bShowStandardizedPages); + m_xStandardizedPagesLabelFT->set_visible(bShowStandardizedPages); +} + +SwWordCountFloatDlg::SwWordCountFloatDlg(SfxBindings* _pBindings, + SfxChildWindow* pChild, + weld::Window *pParent, + SfxChildWinInfo const * pInfo) + : SfxModelessDialogController(_pBindings, pChild, pParent, IS_MOBILE_PHONE ? OUString("modules/swriter/ui/wordcount-mobile.ui") : OUString("modules/swriter/ui/wordcount.ui"), "WordCountDialog") + , m_xCurrentWordFT(m_xBuilder->weld_label("selectwords")) + , m_xCurrentCharacterFT(m_xBuilder->weld_label("selectchars")) + , m_xCurrentCharacterExcludingSpacesFT(m_xBuilder->weld_label("selectcharsnospaces")) + , m_xCurrentCjkcharsFT(m_xBuilder->weld_label("selectcjkchars")) + , m_xCurrentStandardizedPagesFT(m_xBuilder->weld_label("selectstandardizedpages")) + , m_xDocWordFT(m_xBuilder->weld_label("docwords")) + , m_xDocCharacterFT(m_xBuilder->weld_label("docchars")) + , m_xDocCharacterExcludingSpacesFT(m_xBuilder->weld_label("doccharsnospaces")) + , m_xDocCjkcharsFT(m_xBuilder->weld_label("doccjkchars")) + , m_xDocStandardizedPagesFT(m_xBuilder->weld_label("docstandardizedpages")) + , m_xCjkcharsLabelFT(m_xBuilder->weld_label("cjkcharsft")) + , m_xCjkcharsLabelFT2(m_xBuilder->weld_label("cjkcharsft2")) + , m_xStandardizedPagesLabelFT(m_xBuilder->weld_label("standardizedpages")) + , m_xStandardizedPagesLabelFT2(m_xBuilder->weld_label("standardizedpages2")) +{ + showCJK(SvtCJKOptions().IsAnyEnabled()); + showStandardizedPages(officecfg::Office::Writer::WordCount::ShowStandardizedPageCount::get()); + + Initialize(pInfo); +} + +void SwWordCountFloatDlg::UpdateCounts() +{ + SwWrtShell &rSh = ::GetActiveView()->GetWrtShell(); + SwDocStat aCurrCnt; + SwDocStat aDocStat; + { + SwWait aWait( *::GetActiveView()->GetDocShell(), true ); + rSh.StartAction(); + rSh.CountWords( aCurrCnt ); + aDocStat = rSh.GetUpdatedDocStat(); + rSh.EndAction(); + } + SetValues(aCurrCnt, aDocStat); +} + +void SwWordCountFloatDlg::SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat) +{ + SetValues(rCurrCnt, rDocStat); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |