1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_DRPCPS_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_DRPCPS_HXX
22 #include <com/sun/star/i18n/XBreakIterator.hpp>
23 #include <editeng/svxfont.hxx>
24 #include <sfx2/basedlgs.hxx>
25 #include <sfx2/tabdlg.hxx>
26 #include <vcl/customweld.hxx>
27 #include <vcl/print.hxx>
31 class SwDropCapsDlg
: public SfxSingleTabDialogController
34 SwDropCapsDlg(weld::Window
*pParent
, const SfxItemSet
&rSet
);
39 class SwDropCapsPict
: public weld::CustomWidgetController
41 SwDropCapsPage
* mpPage
;
43 OUString maScriptText
;
45 Color maTextLineColor
;
47 tools::Long mnTotLineH
;
50 sal_uInt16 mnDistance
;
51 VclPtr
<Printer
> mpPrinter
;
53 /// The ScriptInfo structure holds information on where we change from one
54 /// script to another.
57 sal_uLong textWidth
; ///< Physical width of this segment.
58 sal_uInt16 scriptType
; ///< Script type (e.g. Latin, Asian, Complex)
59 sal_Int32 changePos
; ///< Character position where the script changes.
60 ScriptInfo(sal_uInt16 scrptType
, sal_Int32 position
)
61 : textWidth(0), scriptType(scrptType
), changePos(position
) {}
63 std::vector
<ScriptInfo
> maScriptChanges
;
68 css::uno::Reference
< css::i18n::XBreakIterator
> xBreak
;
70 virtual void Paint(vcl::RenderContext
& /*rRenderContext*/, const tools::Rectangle
&rRect
) override
;
73 inline void InitPrinter();
75 static void GetFontSettings( const SwDropCapsPage
& _rPage
, vcl::Font
& _rFont
, sal_uInt16 _nWhich
);
76 void GetFirstScriptSegment(sal_Int32
&start
, sal_Int32
&end
, sal_uInt16
&scriptType
);
77 bool GetNextScriptSegment(size_t &nIdx
, sal_Int32
&start
, sal_Int32
&end
, sal_uInt16
&scriptType
);
92 void SetDropCapsPage(SwDropCapsPage
* pPage
) { mpPage
= pPage
; }
94 virtual ~SwDropCapsPict() override
;
96 void UpdatePaintSettings(); // also invalidates control!
98 virtual void Resize() override
;
100 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
102 void SetText( const OUString
& rT
);
103 void SetLines( sal_uInt8 nL
);
104 void SetDistance( sal_uInt16 nD
);
105 void SetValues( const OUString
& rText
, sal_uInt8 nLines
, sal_uInt16 nDistance
);
107 void DrawPrev(vcl::RenderContext
& rRenderContext
, const Point
& rPt
);
110 class SwDropCapsPage
: public SfxTabPage
112 friend class SwDropCapsPict
;
113 SwDropCapsPict m_aPict
;
121 std::unique_ptr
<weld::CheckButton
> m_xDropCapsBox
;
122 std::unique_ptr
<weld::CheckButton
> m_xWholeWordCB
;
123 std::unique_ptr
<weld::Label
> m_xSwitchText
;
124 std::unique_ptr
<weld::SpinButton
> m_xDropCapsField
;
125 std::unique_ptr
<weld::Label
> m_xLinesText
;
126 std::unique_ptr
<weld::SpinButton
> m_xLinesField
;
127 std::unique_ptr
<weld::Label
> m_xDistanceText
;
128 std::unique_ptr
<weld::MetricSpinButton
> m_xDistanceField
;
129 std::unique_ptr
<weld::Label
> m_xTextText
;
130 std::unique_ptr
<weld::Entry
> m_xTextEdit
;
131 std::unique_ptr
<weld::Label
> m_xTemplateText
;
132 std::unique_ptr
<weld::ComboBox
> m_xTemplateBox
;
133 std::unique_ptr
<weld::CustomWeld
> m_xPict
;
135 virtual DeactivateRC
DeactivatePage(SfxItemSet
*pSet
) override
;
136 void FillSet( SfxItemSet
&rSet
);
138 void ModifyEntry(weld::Entry
& rEdit
);
140 DECL_LINK(ClickHdl
, weld::ToggleButton
&, void);
141 DECL_LINK(MetricValueChangedHdl
, weld::MetricSpinButton
&, void);
142 DECL_LINK(ValueChangedHdl
, weld::SpinButton
&, void);
143 DECL_LINK(ModifyHdl
, weld::Entry
&, void);
144 DECL_LINK(SelectHdl
, weld::ComboBox
&, void);
145 DECL_LINK(WholeWordHdl
, weld::ToggleButton
&, void);
147 static const sal_uInt16 aPageRg
[];
150 SwDropCapsPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
&rSet
);
151 virtual ~SwDropCapsPage() override
;
153 static std::unique_ptr
<SfxTabPage
> Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
*rSet
);
154 static const sal_uInt16
* GetRanges() { return aPageRg
; }
157 virtual bool FillItemSet( SfxItemSet
*rSet
) override
;
158 virtual void Reset (const SfxItemSet
*rSet
) override
;
160 void SetFormat(bool bSet
){bFormat
= bSet
;}
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */