Add Marathi autocorrect
[LibreOffice.git] / sw / source / uibase / inc / drpcps.hxx
blob4542ebc247499d6a93f0fc13a17f69cc56202cc1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
29 class SwWrtShell;
31 /// Dedicated drop caps dialog, opened by the .uno:FormatDropcap UNO command, which is not in the
32 /// default menus.
33 class SwDropCapsDlg final : public SfxSingleTabDialogController
35 public:
36 SwDropCapsDlg(weld::Window *pParent, const SfxItemSet &rSet);
39 class SwDropCapsPage;
41 class SwDropCapsPict final : public weld::CustomWidgetController
43 SwDropCapsPage* mpPage;
44 OUString maText;
45 OUString maScriptText;
46 Color maBackColor;
47 Color maTextLineColor;
48 sal_uInt8 mnLines;
49 tools::Long mnTotLineH;
50 tools::Long mnLineH;
51 tools::Long mnTextH;
52 sal_uInt16 mnDistance;
53 VclPtr<Printer> mpPrinter;
54 bool mbDelPrinter;
55 /// The ScriptInfo structure holds information on where we change from one
56 /// script to another.
57 struct ScriptInfo
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;
66 SvxFont maFont;
67 SvxFont maCJKFont;
68 SvxFont maCTLFont;
69 Size maTextSize;
70 css::uno::Reference< css::i18n::XBreakIterator > m_xBreak;
72 virtual void Paint(vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle &rRect) override;
73 void CheckScript();
74 Size CalcTextSize();
75 inline void InitPrinter();
76 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);
81 public:
83 SwDropCapsPict()
84 : mpPage(nullptr)
85 , mnLines(0)
86 , mnTotLineH(0)
87 , mnLineH(0)
88 , mnTextH(0)
89 , mnDistance(0)
90 , mpPrinter(nullptr)
91 , mbDelPrinter(false)
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;
117 bool m_bModified;
118 bool m_bFormat;
119 bool m_bHtmlMode;
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;
149 public:
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;}
163 #endif
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */