27 #include <strings.hrc>
32 #include <rtl/ustrbuf.hxx>
42 #include <com/sun/star/i18n/BreakIterator.hpp>
43 #include <com/sun/star/i18n/ScriptType.hpp>
45 #include <osl/diagnose.h>
63 UpdatePaintSettings();
68 CustomWidgetController::SetDrawingArea(pDrawingArea);
75 CustomWidgetController::Resize();
76 UpdatePaintSettings();
82 UpdatePaintSettings();
88 UpdatePaintSettings();
95 mnDistance = nDistance;
97 UpdatePaintSettings();
109 OUStringBuffer
aStr(nChars);
110 for (sal_Int32
i = 0;
i < nChars;
i++)
111 aStr.append(static_cast<sal_Unicode>(
i + 65));
112 return aStr.makeStringAndClear();
123 _nAscent = aMetric.GetAscent();
131 mpPrinter.disposeAndClear();
141 if( maScriptChanges.empty() )
144 scriptType = css::i18n::ScriptType::LATIN;
148 end = maScriptChanges[ 0 ].changePos;
149 scriptType = maScriptChanges[ 0 ].scriptType;
161 if (maScriptChanges.empty() || nIdx >= maScriptChanges.size() - 1 || end >=
maText.getLength())
163 start = maScriptChanges[nIdx++].changePos;
164 end = maScriptChanges[ nIdx ].changePos;
165 scriptType = maScriptChanges[ nIdx ].scriptType;
176 SvxFontItem aFormatFont(static_cast<const SvxFontItem &>( aSet.Get(_nWhich)));
190 mnTotLineH = (GetOutputSizePixel().Height() - 2 *
BORDER) /
LINES;
191 mnLineH = mnTotLineH - 2;
197 auto aLock(
mpPage->rSh.GetView().GetDocShell()->LockAllViews());
199 if (!
mpPage->m_xTemplateBox->get_active())
203 mpPage->rSh.SttCursorMove();
207 mpPage->rSh.MovePara(pSwuifnParaCurr,pSwuifnParaStart);
217 mpPage->rSh.EndCursorMove();
224 mpPage->m_xTemplateBox->get_active_text(),
226 OSL_ENSURE(pFormat,
"character style doesn't exist!");
236 mnTextH = mnLines * mnTotLineH;
238 maCJKFont.SetFontSize(
Size(0, mnTextH));
239 maCTLFont.SetFontSize(
Size(0, mnTextH));
242 maCJKFont.SetTransparent(
true);
243 maCTLFont.SetTransparent(
true);
253 maCJKFont.SetFontSize(
Size(0, maCJKFont.GetFontSize().Height()));
254 maCTLFont.SetFontSize(
Size(0, maCTLFont.GetFontSize().Height()));
261 maTextSize = CalcTextSize();
276 Size aOutputSizePixel(GetOutputSizePixel());
283 OSL_ENSURE(mnLineH > 0,
"We cannot make it that small");
299 const Size aTextSize(maTextSize.Width() + nDistW, maTextSize.Height());
313 vcl::Font aOldFont = mpPrinter->GetFont();
319 GetFirstScriptSegment(nStart, nEnd, nScript);
323 SvxFont& rFnt = (nScript == css::i18n::ScriptType::ASIAN)
325 : ((nScript == css::i18n::ScriptType::COMPLEX)
328 mpPrinter->SetFont(rFnt);
330 rFnt.
DrawPrev(&rRenderContext, mpPrinter, aPt,
maText, nStart, nEnd - nStart);
332 if (!maScriptChanges.empty())
333 aPt.AdjustX(maScriptChanges[nIdx].textWidth );
335 if (!GetNextScriptSegment(nIdx, nStart, nEnd, nScript))
340 mpPrinter->SetFont(aOldFont);
345 if( maScriptText ==
maText )
349 maScriptChanges.clear();
353 xBreak = css::i18n::BreakIterator::create(xContext);
355 sal_Int16 nScript = xBreak->getScriptType(
maText, 0 );
357 if( css::i18n::ScriptType::WEAK == nScript )
359 nChg = xBreak->endOfScript(
maText, nChg, nScript );
360 if( nChg <
maText.getLength() )
361 nScript = xBreak->getScriptType(
maText, nChg );
363 nScript = css::i18n::ScriptType::LATIN;
368 nChg = xBreak->endOfScript(
maText, nChg, nScript );
369 maScriptChanges.emplace_back(nScript, nChg );
370 if( nChg >=
maText.getLength() || nChg < 0 )
372 nScript = xBreak->getScriptType(
maText, nChg );
384 GetFirstScriptSegment(nStart, nEnd, nScript);
394 SvxFont& rFnt = (nScript == css::i18n::ScriptType::ASIAN)
396 : ((nScript == css::i18n::ScriptType::COMPLEX)
402 if (nIdx < maScriptChanges.size())
403 maScriptChanges[nIdx].textWidth = nWidth;
404 nTextWidth += nWidth;
407 case css::i18n::ScriptType::ASIAN:
410 case css::i18n::ScriptType::COMPLEX:
417 if (!GetNextScriptSegment(nIdx, nStart, nEnd, nScript))
423 nCJKHeight -= nCJKAscent;
424 nCTLHeight -= nCTLAscent;
425 if (nHeight < nCJKHeight)
426 nHeight = nCJKHeight;
427 if (nAscent < nCJKAscent)
428 nAscent = nCJKAscent;
429 if (nHeight < nCTLHeight)
430 nHeight = nCTLHeight;
431 if (nAscent < nCTLAscent)
432 nAscent = nCTLAscent;
435 Size aTextSize(nTextWidth, nHeight);
462 :
SfxTabPage(pPage, pController,
"modules/swriter/ui/dropcapspage.ui",
"DropCapPage", &rSet)
466 , m_xDropCapsBox(m_xBuilder->weld_check_button(
"checkCB_SWITCH"))
467 , m_xWholeWordCB(m_xBuilder->weld_check_button(
"checkCB_WORD"))
468 , m_xSwitchText(m_xBuilder->weld_label(
"labelFT_DROPCAPS"))
469 , m_xDropCapsField(m_xBuilder->weld_spin_button(
"spinFLD_DROPCAPS"))
470 , m_xLinesText(m_xBuilder->weld_label(
"labelTXT_LINES"))
471 , m_xLinesField(m_xBuilder->weld_spin_button(
"spinFLD_LINES"))
472 , m_xDistanceText(m_xBuilder->weld_label(
"labelTXT_DISTANCE"))
473 , m_xDistanceField(m_xBuilder->weld_metric_spin_button(
"spinFLD_DISTANCE",
FieldUnit::
CM))
474 , m_xTextText(m_xBuilder->weld_label(
"labelTXT_TEXT"))
475 , m_xTextEdit(m_xBuilder->weld_entry(
"entryEDT_TEXT"))
476 , m_xTemplateText(m_xBuilder->weld_label(
"labelTXT_TEMPLATE"))
477 , m_xTemplateBox(m_xBuilder->weld_combo_box(
"comboBOX_TEMPLATE"))
478 , m_xPict(new
weld::CustomWeld(*m_xBuilder,
"drawingareaWN_EXAMPLE", m_aPict))
488 const int nMaxWidth(
m_xTemplateBox->get_approximate_digit_width() * 50);
519 return DeactivateRC::LeavePage;
524 return std::make_unique<SwDropCapsPage>(pPage, pController, *rSet);
538 if (aFormatDrop.GetLines() > 1)
558 if (aFormatDrop.GetCharFormat())
589 bool bChecked = m_xDropCapsBox->get_active();
591 m_xWholeWordCB->set_sensitive(bChecked && !bHtmlMode);
593 m_xSwitchText->set_sensitive(bChecked && !m_xWholeWordCB->get_active());
594 m_xDropCapsField->set_sensitive(bChecked && !m_xWholeWordCB->get_active());
595 m_xLinesText->set_sensitive( bChecked );
596 m_xLinesField->set_sensitive( bChecked );
597 m_xDistanceText->set_sensitive( bChecked );
598 m_xDistanceField->set_sensitive( bChecked );
599 m_xTemplateText->set_sensitive( bChecked );
600 m_xTemplateBox->set_sensitive( bChecked );
601 m_xTextEdit->set_sensitive( bChecked && !bFormat );
602 m_xTextText->set_sensitive( bChecked && !bFormat );
606 ValueChangedHdl(*m_xDropCapsField);
607 m_xDropCapsField->grab_focus();
617 m_xDropCapsField->set_sensitive(!m_xWholeWordCB->get_active());
618 m_xSwitchText->set_sensitive(!m_xWholeWordCB->get_active());
620 ValueChangedHdl(*m_xDropCapsField);
635 bool bSetText =
false;
647 if (!sEdit.isEmpty() && !sPreview.startsWith(sEdit))
649 sPreview = sEdit.copy(0,
std::min(sEdit.getLength(), sPreview.getLength()));
658 const sal_Int32 nTmp =
m_xTextEdit->get_text().getLength();
686 ModifyEntry(
rEdit.get_widget());
691 m_aPict.UpdatePaintSettings();
735 sText = sText.copy(0, std::min<sal_Int32>(sText.getLength(),
m_xDropCapsField->get_value()));
void SetFamily(FontFamily)
#define LINK(Instance, Class, Member)
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
void SetFillColor(const Color &)
void SetFontSize(const Size &)
void UpdatePaintSettings()
std::unique_ptr< weld::Entry > m_xTextEdit
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
IMPL_LINK_NOARG(SwDropCapsPage, ClickHdl, weld::Toggleable &, void)
bool GetNextScriptSegment(size_t &nIdx, sal_Int32 &start, sal_Int32 &end, sal_uInt16 &scriptType)
Get the details of the first script change.
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Size GetTextSize(const OutputDevice &rOut, const OUString &rTxt, const sal_Int32 nIdx=0, const sal_Int32 nLen=SAL_MAX_INT32) const
IMPL_LINK(SwDropCapsPage, ModifyHdl, weld::Entry &, rEdit, void)
std::unique_ptr< weld::MetricSpinButton > m_xDistanceField
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
void GetFirstScriptSegment(sal_Int32 &start, sal_Int32 &end, sal_uInt16 &scriptType)
Get the details of the first script change.
SwMoveFnCollection const & fnParaStart
weld::Container * get_content_area()
void SetCharSet(rtl_TextEncoding)
static SfxObjectShell * Current()
std::unique_ptr< weld::ComboBox > m_xTemplateBox
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
void SetText(const OUString &rT)
FontPitch GetPitch() const
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
FontFamily GetFamily() const
OUString SwResId(TranslateId aId)
constexpr tools::Long Width() const
void SetLines(sal_uInt8 nL)
void DrawPrev(OutputDevice *pOut, Printer *pPrinter, const Point &rPos, const OUString &rTxt, const sal_Int32 nIdx=0, const sal_Int32 nLen=SAL_MAX_INT32) const
const SwView & GetView() const
rtl_TextEncoding GetCharSet() const
constexpr TypedWhichId< SwFormatDrop > RES_PARATR_DROP(70)
void SetExchangeSupport()
std::unique_ptr< weld::Label > m_xTextText
static SfxViewShell * Current()
SwDropCapsDlg(weld::Window *pParent, const SfxItemSet &rSet)
FontMetric GetFontMetric() const
Size getParagraphPreviewOptimalSize(const OutputDevice &rReference)
void SetDistance(sal_uInt16 nD)
virtual OutputDevice & get_ref_device()=0
std::unique_ptr< weld::CheckButton > m_xDropCapsBox
constexpr OUStringLiteral sPreview
void DrawRect(const tools::Rectangle &rRect)
void SetPitch(FontPitch ePitch)
virtual void Paint(vcl::RenderContext &, const tools::Rectangle &rRect) override
const SfxPoolItem * GetOldItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
const SfxItemPool & GetAttrPool() const
void SetFamilyName(const OUString &rFamilyName)
std::unique_ptr< weld::CheckButton > m_xWholeWordCB
bool(* SwWhichPara)(SwPaM &, SwMoveFnCollection const &)
void FillSet(SfxItemSet &rSet)
SwDropCapsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
SwCharFormat * GetCharStyle(const OUString &rFormatName, GetStyle eCreate=GETSTYLE_NOCREATE)
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
const Size & GetFontSize() const
void SetTabPage(std::unique_ptr< SfxTabPage > xTabPage)
void SetValues(const OUString &rText, sal_uInt8 nLines, sal_uInt16 nDistance)
virtual void Resize() override
SwDocShell * GetDocShell()
void SetColor(const Color &)
virtual bool FillItemSet(SfxItemSet *rSet) override
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
std::unique_ptr< weld::SpinButton > m_xLinesField
virtual ~SwDropCapsPict() override
const OUString & GetFamilyName() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
OUString GetDropText(const sal_Int32 nChars) const
constexpr tools::Long Height() const
void SetFont(const vcl::Font &rNewFont)
void SetTransparent(bool bTransparent)
static Color & GetFontColor()
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
static void GetFontSettings(const SwDropCapsPage &_rPage, vcl::Font &_rFont, sal_uInt16 _nWhich)
static VclPtr< reference_type > Create(Arg &&...arg)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
virtual ~SwDropCapsPage() override
const Color & GetWindowColor() const
static void calcFontHeightAnyAscent(vcl::RenderContext &rWin, vcl::Font const &_rFont, tools::Long &_nHeight, tools::Long &_nAscent)
virtual SfxPrinter * GetPrinter(bool bCreate=false)
void SetDropCapsPage(SwDropCapsPage *pPage)
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
void DrawPrev(vcl::RenderContext &rRenderContext, const Point &rPt)
std::unique_ptr< weld::SpinButton > m_xDropCapsField
static const WhichRangesContainer aPageRg
virtual void Reset(const SfxItemSet *rSet) override
void ModifyEntry(const weld::Entry &rEdit)
tools::Long GetLineHeight() const
#define FN_FORMAT_DROPCAPS
bool m_bDetectedRangeSegmentation false
static OUString GetDefaultString(sal_Int32 nChars)