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 /// Dedicated drop caps dialog, opened by the .uno:FormatDropcap UNO command, which is not in the
33 class SwDropCapsDlg final
: public SfxSingleTabDialogController
36 SwDropCapsDlg(weld::Window
*pParent
, const SfxItemSet
&rSet
);
41 class SwDropCapsPict final
: public weld::CustomWidgetController
43 SwDropCapsPage
* mpPage
;
45 OUString maScriptText
;
47 Color maTextLineColor
;
49 tools::Long mnTotLineH
;
52 sal_uInt16 mnDistance
;
53 VclPtr
<Printer
> mpPrinter
;
55 /// The ScriptInfo structure holds information on where we change from one
56 /// script to another.
59 sal_uLong textWidth
; ///< Physical width of this segment.
60 sal_uInt16 scriptType
; ///< Script type (e.g. Latin, Asian, Complex)
61 sal_Int32 changePos
; ///< Character position where the script changes.
62 ScriptInfo(sal_uInt16 scrptType
, sal_Int32 position
)
63 : textWidth(0), scriptType(scrptType
), changePos(position
) {}
65 std::vector
<ScriptInfo
> maScriptChanges
;
70 css::uno::Reference
< css::i18n::XBreakIterator
> m_xBreak
;
72 virtual void Paint(vcl::RenderContext
& /*rRenderContext*/, const tools::Rectangle
&rRect
) override
;
75 inline void InitPrinter();
77 static void GetFontSettings( vcl::Font
& _rFont
, sal_uInt16 _nWhich
);
78 void GetFirstScriptSegment(sal_Int32
&start
, sal_Int32
&end
, sal_uInt16
&scriptType
);
79 bool GetNextScriptSegment(size_t &nIdx
, sal_Int32
&start
, sal_Int32
&end
, sal_uInt16
&scriptType
);
94 void SetDropCapsPage(SwDropCapsPage
* pPage
) { mpPage
= pPage
; }
96 virtual ~SwDropCapsPict() override
;
98 void UpdatePaintSettings(); // also invalidates control!
100 virtual void Resize() override
;
102 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
104 void SetText( const OUString
& rT
);
105 void SetLines( sal_uInt8 nL
);
106 void SetDistance( sal_uInt16 nD
);
107 void SetValues( const OUString
& rText
, sal_uInt8 nLines
, sal_uInt16 nDistance
);
109 void DrawPrev(vcl::RenderContext
& rRenderContext
, const Point
& rPt
);
112 class SwDropCapsPage final
: public SfxTabPage
114 friend class SwDropCapsPict
;
115 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(const weld::Entry
& rEdit
);
140 DECL_LINK(ClickHdl
, weld::Toggleable
&, 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::Toggleable
&, void);
147 static const WhichRangesContainer s_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 WhichRangesContainer
& GetRanges() { return s_aPageRg
; }
157 virtual bool FillItemSet( SfxItemSet
*rSet
) override
;
158 virtual void Reset (const SfxItemSet
*rSet
) override
;
160 void SetFormat(bool bSet
){m_bFormat
= bSet
;}
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */