34#include <com/sun/star/frame/XModel.hpp>
35#include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
36#include <com/sun/star/text/XTextTablesSupplier.hpp>
37#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
38#include <com/sun/star/text/XTextFramesSupplier.hpp>
51 OUString m_aFieldTypeName;
53 std::unique_ptr<weld::ComboBox> m_xLbLevel;
54 std::unique_ptr<weld::Entry> m_xEdDelim;
56 std::unique_ptr<weld::ComboBox> m_xLbCharStyle;
57 std::unique_ptr<weld::CheckButton> m_xApplyBorderAndShadowCB;
60 std::unique_ptr<weld::ComboBox> m_xLbCaptionOrder;
66 bool IsApplyBorderAndShadow()
const {
return m_xApplyBorderAndShadowCB->get_active(); }
67 void SetApplyBorderAndShadow(
bool bSet ) { m_xApplyBorderAndShadowCB->set_active(bSet); }
70 bool IsOrderNumberingFirst()
const {
return m_xLbCaptionOrder->get_active() == 1; }
71 void SetOrderNumberingFirst(
bool bSet) { m_xLbCaptionOrder->set_active(bSet ? 1 : 0); }
73 void SetCharacterStyle(
const OUString& rStyle);
74 OUString GetCharacterStyle()
const;
91 :
SfxDialogController(pParent,
"modules/swriter/ui/insertcaption.ui",
"InsertCaptionDialog")
93 , m_aTextFilter(m_sNone)
95 , m_pMgr(new
SwFieldMgr(m_rView.GetWrtShellPtr()))
96 , m_bCopyAttributes(false)
97 , m_bOrderNumberingFirst(
SW_MOD()->GetModuleConfig()->IsCaptionOrderNumberingFirst())
98 , m_xTextEdit(m_xBuilder->weld_entry(
"caption_edit"))
99 , m_xCategoryBox(m_xBuilder->weld_combo_box(
"category"))
100 , m_xFormatText(m_xBuilder->weld_label(
"numbering_label"))
101 , m_xFormatBox(m_xBuilder->weld_combo_box(
"numbering"))
102 , m_xNumberingSeparatorFT(m_xBuilder->weld_label(
"num_separator"))
103 , m_xNumberingSeparatorED(m_xBuilder->weld_entry(
"num_separator_edit"))
104 , m_xSepText(m_xBuilder->weld_label(
"separator_label"))
105 , m_xSepEdit(m_xBuilder->weld_entry(
"separator_edit"))
106 , m_xPosBox(m_xBuilder->weld_combo_box(
"position"))
108 , m_xAutoCaptionButton(m_xBuilder->weld_button(
"auto"))
109 , m_xOptionButton(m_xBuilder->weld_button(
"options"))
110 , m_xPreview(new
weld::CustomWeld(*m_xBuilder,
"preview", m_aPreview))
121 uno::Reference< text::XTextEmbeddedObjectsSupplier > xObjs(
xModel, uno::UNO_QUERY);
148 sal_uInt16 nPoolId = 0;
165 uno::Reference< text::XTextGraphicObjectsSupplier > xGraphics(
xModel, uno::UNO_QUERY);
174 uno::Reference< text::XTextTablesSupplier > xTables(
xModel, uno::UNO_QUERY);
181 uno::Reference< text::XTextFramesSupplier > xFrames(
xModel, uno::UNO_QUERY);
196 if (sString.isEmpty())
213 nSelFormat = o3tl::narrowing<sal_uInt16>(
static_cast<SwSetExpFieldType*
>(pFieldType)->GetSeqFormat());
219 for ( sal_uInt16
i = 0;
i < nFormatCount; ++
i )
223 if (nFormatId == nSelFormat)
296 short nRet = SfxDialogController::run();
304 OUString sFieldTypeName = m_xCategoryBox->get_active_text();
305 if(sFieldTypeName == m_sNone)
306 sFieldTypeName.clear();
307 auto pDlg = std::make_shared<SwSequenceOptionDialog>(
m_xDialog.get(), m_rView, sFieldTypeName);
308 pDlg->SetApplyBorderAndShadow(m_bCopyAttributes);
309 pDlg->SetCharacterStyle( m_sCharacterStyle );
310 pDlg->SetOrderNumberingFirst( m_bOrderNumberingFirst );
312 GenericDialogController::runAsync(pDlg, [pDlg,
this](sal_Int32 nResult){
315 m_bCopyAttributes = pDlg->IsApplyBorderAndShadow();
316 m_sCharacterStyle = pDlg->GetCharacterStyle();
318 if( m_bOrderNumberingFirst != pDlg->IsOrderNumberingFirst() )
320 m_bOrderNumberingFirst = pDlg->IsOrderNumberingFirst();
321 SW_MOD()->GetModuleConfig()->SetCaptionOrderNumberingFirst(m_bOrderNumberingFirst);
338 bool bCorrectFieldName = !sFieldTypeName.isEmpty();
339 bool bNone = sFieldTypeName ==
m_sNone;
363 OUString sText = m_xCategoryBox->get_active_text();
364 OUString sAllowedText = m_aTextFilter.filter(sText);
365 if (sText != sAllowedText)
367 m_xCategoryBox->set_entry_text(sAllowedText);
368 m_xCategoryBox->select_entry_region(sAllowedText.getLength(), sAllowedText.getLength());
387 bool bNone = sFieldTypeName ==
m_sNone;
390 const sal_uInt16 nNumFormat =
m_xFormatBox->get_active_id().toUInt32();
397 aStr = sFieldTypeName;
398 if ( !
aStr.isEmpty() )
408 aNumVector.insert(aNumVector.end(), pFieldType->
GetOutlineLvl() + 1, 1);
411 MakeNumString(aNumVector,
false ));
412 if( !sNumber.isEmpty() )
424 default:
aStr +=
"1";
break;
433 if( !sCaption.isEmpty() )
447SwSequenceOptionDialog::SwSequenceOptionDialog(
weld::Window *pParent,
SwView &rV, OUString aSeqFieldType )
448 : GenericDialogController(pParent,
"modules/swriter/ui/captionoptions.ui",
"CaptionOptionsDialog")
450 , m_aFieldTypeName(
std::move(aSeqFieldType))
451 , m_xLbLevel(m_xBuilder->weld_combo_box(
"level"))
452 , m_xEdDelim(m_xBuilder->weld_entry(
"separator"))
453 , m_xLbCharStyle(m_xBuilder->weld_combo_box(
"style"))
454 , m_xApplyBorderAndShadowCB(m_xBuilder->weld_check_button(
"border_and_shadow"))
455 , m_xLbCaptionOrder(m_xBuilder->weld_combo_box(
"caption_order"))
461 m_xLbLevel->append_text(sNone);
463 m_xLbLevel->append_text(OUString::number(n + 1));
469 OUString sDelim(
": ");
476 m_xLbLevel->set_active(nLvl <
MAXLEVEL ? nLvl + 1 : 0);
477 m_xEdDelim->set_text(sDelim);
479 m_xLbCharStyle->append_text(sNone);
481 m_xLbCharStyle->set_active(0);
484void SwSequenceOptionDialog::Apply()
499 else if( !m_aFieldTypeName.isEmpty() && nLvl <
MAXLEVEL )
503 aFieldType.SetDelimiter( OUString(cDelim) );
504 aFieldType.SetOutlineLvl( nLvl );
514OUString SwSequenceOptionDialog::GetCharacterStyle()
const
516 if (m_xLbCharStyle->get_active() != -1)
517 return m_xLbCharStyle->get_active_text();
521void SwSequenceOptionDialog::SetCharacterStyle(
const OUString& rStyle)
523 const int nPos = m_xLbCharStyle->find_text(rStyle);
525 m_xLbCharStyle->set_active(0);
527 m_xLbCharStyle->set_active(nPos);
Reference< XExecutableDialog > m_xDialog
void SetCategory(const OUString &rCat)
void SetNumType(const sal_uInt16 nNT)
void SetCaption(const OUString &rCap)
void SetSeparator(const OUString &rSep)
void SetPos(const sal_uInt16 nP)
void SetCharacterStyle(const OUString &rStyle)
void SetNumSeparator(const OUString &rSet)
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
static SW_DLLPUBLIC bool IsValidVarName(const OUString &rStr, OUString *pValidName=nullptr)
std::unique_ptr< weld::Label > m_xNumberingSeparatorFT
css::uno::Reference< css::container::XNameAccess > m_xNameAccess
bool m_bOrderNumberingFirst
std::unique_ptr< weld::ComboBox > m_xPosBox
static OUString s_aSepTextSave
std::unique_ptr< weld::Entry > m_xSepEdit
std::unique_ptr< weld::Label > m_xFormatText
std::unique_ptr< weld::Entry > m_xNumberingSeparatorED
std::unique_ptr< weld::ComboBox > m_xCategoryBox
std::unique_ptr< weld::ComboBox > m_xFormatBox
std::unique_ptr< weld::Label > m_xSepText
std::unique_ptr< weld::Entry > m_xTextEdit
virtual short run() override
SwCaptionPreview m_aPreview
virtual ~SwCaptionDialog() override
OUString m_sCharacterStyle
std::unique_ptr< weld::Button > m_xOptionButton
std::unique_ptr< SwFieldMgr > m_pMgr
SwCaptionDialog(weld::Window *pParent, SwView &rV)
std::unique_ptr< weld::Button > m_xAutoCaptionButton
std::unique_ptr< weld::Button > m_xOKButton
void SetPreviewText(const OUString &rText)
SwDoc * GetDoc()
returns Doc. But be careful!
const SwAttrPool & GetAttrPool() const
SwFieldType * GetFieldType(size_t nField, SwFieldIds nResId=SwFieldIds::Unknown) const
get field types with a ResId, if 0 get all
const SwNumRule * GetOutlineNumRule() const
SwFieldType * InsertFieldType(const SwFieldType &)
insert field type
void UpdateExpFields(bool bCloseDB=false)
only every expression fields update
bool IsUsed(const sw::BroadcastingModify &) const
Query if the paragraph-/character-/frame-/page-style is used.
Instances of SwFields and those derived from it occur 0 to n times.
virtual OUString GetName() const
Only in derived classes.
const OUString & GetDelimiter() const
Number sequence fields chapterwise if required.
sal_uInt16 GetType() const
void SetOutlineLvl(sal_uInt8 n)
void SetDelimiter(const OUString &s)
sal_uInt8 GetOutlineLvl() const
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
SwWrtShell & GetWrtShell() const
const OUString & GetOldGrfCat()
const OUString & GetOldFrameCat()
SwDocShell * GetDocShell()
const OUString & GetOldDrwCat()
void InsertCaption(const InsCaptionOpt *pOpt)
const OUString & GetOldTabCat()
Used by the UI to modify the document model.
SelectionType GetSelectionType() const
virtual OUString filter(const OUString &rText) override
IMPL_LINK_NOARG(SwCaptionDialog, OKHdl, weld::Button &, void)
std::unique_ptr< weld::Button > m_xOKButton
#define LINK(Instance, Class, Member)
std::vector< tSwNumTreeNumber > tNumberVector
OString strip(const OString &rIn, char c)
const SwGetSetExpType GSE_SEQ
Sequence.
@ RES_POOLCOLL_LABEL_DRAWING
Label drawing objects.
@ RES_POOLCOLL_LABEL_FRAME
Label frame.
@ RES_POOLCOLL_LABEL_FIGURE
Label figure.
@ RES_POOLCOLL_LABEL_TABLE
Label table.
@ RES_POOLCOLL_LABEL_ABB
Label illustration.
Reference< XModel > xModel
SVX_NUM_CHARS_LOWER_LETTER_N
SVX_NUM_CHARS_LOWER_LETTER
SVX_NUM_CHARS_UPPER_LETTER
SVX_NUM_CHARS_UPPER_LETTER_N
OUString SwResId(TranslateId aId)
constexpr sal_uInt8 MAXLEVEL
constexpr OUStringLiteral sNone