LibreOffice Module svtools (master) 1
ctrlbox.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sal/config.h>
21#include <config_folders.h>
22
23#include <comphelper/lok.hxx>
24#include <i18nutil/unicode.hxx>
25#include <officecfg/Office/Common.hxx>
26#include <tools/stream.hxx>
27#include <vcl/customweld.hxx>
28#include <vcl/event.hxx>
29#include <vcl/svapp.hxx>
30#include <vcl/fieldvalues.hxx>
31#include <vcl/settings.hxx>
32#include <vcl/image.hxx>
33#include <vcl/virdev.hxx>
34#include <vcl/weldutils.hxx>
35#include <rtl/math.hxx>
36#include <sal/macros.h>
37#include <sal/log.hxx>
38#include <comphelper/string.hxx>
41
44#include <svtools/svtresid.hxx>
45#include <svtools/strings.hrc>
46#include <svtools/ctrlbox.hxx>
47#include <svtools/ctrltool.hxx>
49#include <svtools/valueset.hxx>
50
54
55#include <rtl/bootstrap.hxx>
56
57#include <borderline.hrc>
58
59#include <stdio.h>
60
61#define IMGOUTERTEXTSPACE 5
62#define EXTRAFONTSIZE 5
63#define GAPTOEXTRAPREVIEW 10
64#define MINGAPWIDTH 2
65
66constexpr OUStringLiteral FONTNAMEBOXMRUENTRIESFILE = u"/user/config/fontnameboxmruentries";
67
68
69BorderWidthImpl::BorderWidthImpl( BorderWidthImplFlags nFlags, double nRate1, double nRate2, double nRateGap ):
70 m_nFlags( nFlags ),
71 m_nRate1( nRate1 ),
72 m_nRate2( nRate2 ),
73 m_nRateGap( nRateGap )
74{
75}
76
78{
79 return ( m_nFlags == r.m_nFlags ) &&
80 ( m_nRate1 == r.m_nRate1 ) &&
81 ( m_nRate2 == r.m_nRate2 ) &&
82 ( m_nRateGap == r.m_nRateGap );
83}
84
86{
87 tools::Long result = static_cast<tools::Long>(m_nRate1);
89 {
92 result = std::max<tools::Long>(0,
93 static_cast<tools::Long>((m_nRate1 * nWidth) + 0.5)
94 - (nConstant2 + nConstantD));
95 if (result == 0 && m_nRate1 > 0.0 && nWidth > 0)
96 { // fdo#51777: hack to essentially treat 1 twip DOUBLE border
97 result = 1; // as 1 twip SINGLE border
98 }
99 }
100 return result;
101}
102
104{
105 tools::Long result = static_cast<tools::Long>(m_nRate2);
107 {
110 result = std::max<tools::Long>(0,
111 static_cast<tools::Long>((m_nRate2 * nWidth) + 0.5)
112 - (nConstant1 + nConstantD));
113 }
114 return result;
115}
116
118{
121 {
124 result = std::max<tools::Long>(0,
125 static_cast<tools::Long>((m_nRateGap * nWidth) + 0.5)
126 - (nConstant1 + nConstant2));
127 }
128
129 // Avoid having too small distances (less than 0.1pt)
130 if ( result < MINGAPWIDTH && m_nRate1 > 0 && m_nRate2 > 0 )
132
133 return result;
134}
135
136static double lcl_getGuessedWidth( tools::Long nTested, double nRate, bool bChanging )
137{
138 double nWidth = -1.0;
139 if ( bChanging )
140 nWidth = double( nTested ) / nRate;
141 else
142 {
143 if ( rtl::math::approxEqual(double( nTested ), nRate) )
144 nWidth = nRate;
145 }
146
147 return nWidth;
148}
149
151{
152 std::vector< double > aToCompare;
153 bool bInvalid = false;
154
155 bool bLine1Change = bool( m_nFlags & BorderWidthImplFlags::CHANGE_LINE1 );
156 double nWidth1 = lcl_getGuessedWidth( nLine1, m_nRate1, bLine1Change );
157 if ( bLine1Change )
158 aToCompare.push_back( nWidth1 );
159 else if (nWidth1 < 0)
160 bInvalid = true;
161
162 bool bLine2Change = bool( m_nFlags & BorderWidthImplFlags::CHANGE_LINE2 );
163 double nWidth2 = lcl_getGuessedWidth( nLine2, m_nRate2, bLine2Change );
164 if ( bLine2Change )
165 aToCompare.push_back( nWidth2 );
166 else if (nWidth2 < 0)
167 bInvalid = true;
168
169 bool bGapChange = bool( m_nFlags & BorderWidthImplFlags::CHANGE_DIST );
170 double nWidthGap = lcl_getGuessedWidth( nGap, m_nRateGap, bGapChange );
171 if ( bGapChange && nGap >= MINGAPWIDTH )
172 aToCompare.push_back( nWidthGap );
173 else if ( !bGapChange && nWidthGap < 0 )
174 bInvalid = true;
175
176 // non-constant line width factors must sum to 1
177 assert((((bLine1Change) ? m_nRate1 : 0) +
178 ((bLine2Change) ? m_nRate2 : 0) +
179 ((bGapChange) ? m_nRateGap : 0)) - 1.0 < 0.00001 );
180
181 double nWidth = 0.0;
182 if ( (!bInvalid) && (!aToCompare.empty()) )
183 {
184 nWidth = *aToCompare.begin();
185 for (auto const& elem : aToCompare)
186 {
187 bInvalid = ( nWidth != elem );
188 if (bInvalid)
189 break;
190 }
191 nWidth = bInvalid ? 0.0 : nLine1 + nLine2 + nGap;
192 }
193
194 return nWidth;
195}
196
197static void lclDrawPolygon( OutputDevice& rDev, const basegfx::B2DPolygon& rPolygon, tools::Long nWidth, SvxBorderLineStyle nDashing )
198{
199 AntialiasingFlags nOldAA = rDev.GetAntialiasing();
200 rDev.SetAntialiasing( nOldAA & ~AntialiasingFlags::Enable );
201
202 tools::Long nPix = rDev.PixelToLogic(Size(1, 1)).Width();
203 basegfx::B2DPolyPolygon aPolygons = svtools::ApplyLineDashing(rPolygon, nDashing, nPix);
204
205 // Handle problems of width 1px in Pixel mode: 0.5px gives a 1px line
206 if (rDev.GetMapMode().GetMapUnit() == MapUnit::MapPixel && nWidth == nPix)
207 nWidth = 0;
208
209 for ( sal_uInt32 i = 0; i < aPolygons.count( ); i++ )
210 {
211 const basegfx::B2DPolygon& aDash = aPolygons.getB2DPolygon( i );
212 basegfx::B2DPoint aStart = aDash.getB2DPoint( 0 );
213 basegfx::B2DPoint aEnd = aDash.getB2DPoint( aDash.count() - 1 );
214
215 basegfx::B2DVector aVector( aEnd - aStart );
216 aVector.normalize( );
217 const basegfx::B2DVector aPerpendicular(basegfx::getPerpendicular(aVector));
218
219 const basegfx::B2DVector aWidthOffset( double( nWidth ) / 2 * aPerpendicular);
220 basegfx::B2DPolygon aDashPolygon;
221 aDashPolygon.append( aStart + aWidthOffset );
222 aDashPolygon.append( aEnd + aWidthOffset );
223 aDashPolygon.append( aEnd - aWidthOffset );
224 aDashPolygon.append( aStart - aWidthOffset );
225 aDashPolygon.setClosed( true );
226
227 rDev.DrawPolygon( aDashPolygon );
228 }
229
230 rDev.SetAntialiasing( nOldAA );
231}
232
233namespace svtools {
234
238static std::vector<double> GetDashing( SvxBorderLineStyle nDashing )
239{
240 std::vector<double> aPattern;
241 switch (nDashing)
242 {
243 case SvxBorderLineStyle::DOTTED:
244 aPattern.push_back( 1.0 ); // line
245 aPattern.push_back( 2.0 ); // blank
246 break;
247 case SvxBorderLineStyle::DASHED:
248 aPattern.push_back( 16.0 ); // line
249 aPattern.push_back( 5.0 ); // blank
250 break;
251 case SvxBorderLineStyle::FINE_DASHED:
252 aPattern.push_back( 6.0 ); // line
253 aPattern.push_back( 2.0 ); // blank
254 break;
255 case SvxBorderLineStyle::DASH_DOT:
256 aPattern.push_back( 16.0 ); // line
257 aPattern.push_back( 5.0 ); // blank
258 aPattern.push_back( 5.0 ); // line
259 aPattern.push_back( 5.0 ); // blank
260 break;
261 case SvxBorderLineStyle::DASH_DOT_DOT:
262 aPattern.push_back( 16.0 ); // line
263 aPattern.push_back( 5.0 ); // blank
264 aPattern.push_back( 5.0 ); // line
265 aPattern.push_back( 5.0 ); // blank
266 aPattern.push_back( 5.0 ); // line
267 aPattern.push_back( 5.0 ); // blank
268 break;
269 default:
270 ;
271 }
272
273 return aPattern;
274}
275
276namespace {
277
278class ApplyScale
279{
280 double mfScale;
281public:
282 explicit ApplyScale( double fScale ) : mfScale(fScale) {}
283 void operator() ( double& rVal )
284 {
285 rVal *= mfScale;
286 }
287};
288
289}
290
291std::vector<double> GetLineDashing( SvxBorderLineStyle nDashing, double fScale )
292{
293 std::vector<double> aPattern = GetDashing(nDashing);
294 std::for_each(aPattern.begin(), aPattern.end(), ApplyScale(fScale));
295 return aPattern;
296}
297
299{
300 std::vector<double> aPattern = GetDashing(nDashing);
301 std::for_each(aPattern.begin(), aPattern.end(), ApplyScale(fScale));
302
303 basegfx::B2DPolyPolygon aPolygons;
304
305 if (aPattern.empty())
306 aPolygons.append(rPolygon);
307 else
308 basegfx::utils::applyLineDashing(rPolygon, aPattern, &aPolygons);
309
310 return aPolygons;
311}
312
313void DrawLine( OutputDevice& rDev, const Point& rP1, const Point& rP2,
314 sal_uInt32 nWidth, SvxBorderLineStyle nDashing )
315{
316 DrawLine( rDev, basegfx::B2DPoint( rP1.X(), rP1.Y() ),
317 basegfx::B2DPoint( rP2.X(), rP2.Y( ) ), nWidth, nDashing );
318}
319
320void DrawLine( OutputDevice& rDev, const basegfx::B2DPoint& rP1, const basegfx::B2DPoint& rP2,
321 sal_uInt32 nWidth, SvxBorderLineStyle nDashing )
322{
323 basegfx::B2DPolygon aPolygon;
324 aPolygon.append( rP1 );
325 aPolygon.append( rP2 );
326 lclDrawPolygon( rDev, aPolygon, nWidth, nDashing );
327}
328
329}
330
332static int gFontNameBoxes;
333static size_t gPreviewsPerDevice;
334static std::vector<VclPtr<VirtualDevice>> gFontPreviewVirDevs;
335static std::vector<OUString> gRenderedFontNames;
336
337namespace
338{
339 void calcCustomItemSize(const weld::ComboBox& rComboBox)
340 {
341 gUserItemSz = Size(rComboBox.get_approximate_digit_width() * 52, rComboBox.get_text_height());
344
345 size_t nMaxDeviceHeight = SAL_MAX_INT16 / 16; // see limitXCreatePixmap and be generous wrt up to x16 hidpi
346 assert(gUserItemSz.Height() != 0);
347 gPreviewsPerDevice = gUserItemSz.Height() == 0 ? 16 : nMaxDeviceHeight / gUserItemSz.Height();
348 }
349}
350
351IMPL_LINK(FontNameBox, SettingsChangedHdl, VclSimpleEvent&, rEvent, void)
352{
353 if (rEvent.GetId() != VclEventId::ApplicationDataChanged)
354 return;
355
356 DataChangedEvent* pData = static_cast<DataChangedEvent*>(static_cast<VclWindowEvent&>(rEvent).GetData());
357 if (pData->GetType() == DataChangedEventType::SETTINGS)
358 {
359 for (auto &rDev : gFontPreviewVirDevs)
360 rDev.disposeAndClear();
361 gFontPreviewVirDevs.clear();
362 gRenderedFontNames.clear();
363 calcCustomItemSize(*m_xComboBox);
364 if (mbWYSIWYG && mpFontList && !mpFontList->empty())
365 {
366 mnPreviewProgress = 0;
367 maUpdateIdle.Start();
368 }
369 }
370}
371
372FontNameBox::FontNameBox(std::unique_ptr<weld::ComboBox> p)
373 : m_xComboBox(std::move(p))
374 , mnPreviewProgress(0)
375 , mbWYSIWYG(false)
376 , maUpdateIdle("FontNameBox Preview Update")
377{
380
381 maUpdateIdle.SetPriority(TaskPriority::LOWEST);
383
384 Application::AddEventListener(LINK(this, FontNameBox, SettingsChangedHdl));
385}
386
388{
389 Application::RemoveEventListener(LINK(this, FontNameBox, SettingsChangedHdl));
390
391 if (mpFontList)
392 {
395 }
397 if (!gFontNameBoxes)
398 {
399 for (auto &rDev : gFontPreviewVirDevs)
400 rDev.disposeAndClear();
401 gFontPreviewVirDevs.clear();
402 gRenderedFontNames.clear();
403 }
404}
405
406void FontNameBox::SaveMRUEntries(const OUString& aFontMRUEntriesFile) const
407{
408 OString aEntries(OUStringToOString(m_xComboBox->get_mru_entries(),
409 RTL_TEXTENCODING_UTF8));
410
411 if (aEntries.isEmpty() || aFontMRUEntriesFile.isEmpty())
412 return;
413
414 SvFileStream aStream;
415 aStream.Open( aFontMRUEntriesFile, StreamMode::WRITE | StreamMode::TRUNC );
416 if( ! (aStream.IsOpen() && aStream.IsWritable()) )
417 {
418 SAL_INFO("svtools.control", "FontNameBox::SaveMRUEntries: opening mru entries file " << aFontMRUEntriesFile << " failed");
419 return;
420 }
421
422 aStream.SetLineDelimiter( LINEEND_LF );
423 aStream.WriteLine( aEntries );
424 aStream.WriteLine( "" );
425}
426
427void FontNameBox::LoadMRUEntries( const OUString& aFontMRUEntriesFile )
428{
429 if (aFontMRUEntriesFile.isEmpty())
430 return;
431
432 if (!officecfg::Office::Common::Font::View::ShowFontBoxWYSIWYG::get())
433 return;
434
435 SvFileStream aStream( aFontMRUEntriesFile, StreamMode::READ );
436 if( ! aStream.IsOpen() )
437 {
438 SAL_INFO("svtools.control", "FontNameBox::LoadMRUEntries: opening mru entries file " << aFontMRUEntriesFile << " failed");
439 return;
440 }
441
442 OString aLine;
443 aStream.ReadLine( aLine );
444 OUString aEntries = OStringToOUString(aLine,
445 RTL_TEXTENCODING_UTF8);
446 m_xComboBox->set_mru_entries(aEntries);
447}
448
450{
451 OUString sUserConfigDir("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}");
452 rtl::Bootstrap::expandMacros(sUserConfigDir);
453
454 maFontMRUEntriesFile = sUserConfigDir;
455 if( !maFontMRUEntriesFile.isEmpty() )
456 {
458 }
459}
460
462{
463 mpFontList.reset();
466}
467
468void FontNameBox::Fill( const FontList* pList )
469{
470 // store old text and clear box
471 OUString aOldText = m_xComboBox->get_active_text();
472 OUString rEntries = m_xComboBox->get_mru_entries();
473 bool bLoadFromFile = rEntries.isEmpty();
474 m_xComboBox->freeze();
475 m_xComboBox->clear();
476
478 mpFontList.reset(new ImplFontList);
479
480 // insert fonts
481 size_t nFontCount = pList->GetFontNameCount();
482 for (size_t i = 0; i < nFontCount; ++i)
483 {
484 const FontMetric& rFontMetric = pList->GetFontName(i);
485 m_xComboBox->append(OUString::number(i), rFontMetric.GetFamilyName());
486 mpFontList->push_back(rFontMetric);
487 }
488
489 if (bLoadFromFile)
491 else
492 m_xComboBox->set_mru_entries(rEntries);
493
494 m_xComboBox->thaw();
495
496 if (mbWYSIWYG && nFontCount)
497 {
498 assert(mnPreviewProgress == 0 && "ImplDestroyFontList wasn't called");
500 }
501
502 // restore text
503 if (!aOldText.isEmpty())
504 set_active_or_entry_text(aOldText);
505}
506
507static bool IsRunningUnitTest() { return getenv("LO_TESTNAME") != nullptr; }
508
510{
512 return;
513 if (mbWYSIWYG == bEnable)
514 return;
515 mbWYSIWYG = bEnable;
516
517 if (mbWYSIWYG)
518 {
519 calcCustomItemSize(*m_xComboBox);
520 m_xComboBox->connect_custom_get_size(LINK(this, FontNameBox, CustomGetSizeHdl));
521 m_xComboBox->connect_custom_render(LINK(this, FontNameBox, CustomRenderHdl));
522 }
523 else
524 {
525 m_xComboBox->connect_custom_get_size(Link<OutputDevice&, Size>());
527 }
528 m_xComboBox->set_custom_renderer(mbWYSIWYG);
529}
530
532{
533 return mbWYSIWYG ? gUserItemSz : Size();
534}
535
536namespace
537{
538 tools::Long shrinkFontToFit(OUString const &rSampleText, tools::Long nH, vcl::Font &rFont, OutputDevice &rDevice, tools::Rectangle &rTextRect)
539 {
540 tools::Long nWidth = 0;
541
542 Size aSize( rFont.GetFontSize() );
543
544 //Make sure it fits in the available height
545 while (aSize.Height() > 0)
546 {
547 if (!rDevice.GetTextBoundRect(rTextRect, rSampleText))
548 break;
549 if (rTextRect.GetHeight() <= nH)
550 {
551 nWidth = rTextRect.GetWidth();
552 break;
553 }
554
555 aSize.AdjustHeight( -(EXTRAFONTSIZE) );
556 rFont.SetFontSize(aSize);
557 rDevice.SetFont(rFont);
558 }
559
560 return nWidth;
561 }
562}
563
565{
566 CachePreview(mnPreviewProgress++, nullptr);
567 // tdf#132536 limit to ~25 pre-rendered for now. The font caches look
568 // b0rked, the massive charmaps are ~never swapped out, and don't count
569 // towards the size of a font in the font cache.
570 if (mnPreviewProgress < std::min<size_t>(25, mpFontList->size()))
571 maUpdateIdle.Start();
572}
573
574static void DrawPreview(const FontMetric& rFontMetric, const Point& rTopLeft, OutputDevice& rDevice, bool bSelected)
575{
577
578 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
579 if (bSelected)
580 rDevice.SetTextColor(rStyleSettings.GetHighlightTextColor());
581 else
582 rDevice.SetTextColor(rStyleSettings.GetDialogTextColor());
583
584 tools::Long nX = rTopLeft.X();
586
587 nX += IMGOUTERTEXTSPACE;
588
589 const bool bSymbolFont = isSymbolFont(rFontMetric);
590
591 vcl::Font aOldFont(rDevice.GetFont());
592 Size aSize( aOldFont.GetFontSize() );
594 vcl::Font aFont( rFontMetric );
595 aFont.SetFontSize( aSize );
596 rDevice.SetFont(aFont);
597
598 bool bUsingCorrectFont = true;
599 tools::Rectangle aTextRect;
600
601 // Preview the font name
602 const OUString& sFontName = rFontMetric.GetFamilyName();
603
604 //If it shouldn't or can't draw its own name because it doesn't have the glyphs
605 if (!canRenderNameOfSelectedFont(rDevice))
606 bUsingCorrectFont = false;
607 else
608 {
609 //Make sure it fits in the available height, shrinking the font if necessary
610 bUsingCorrectFont = shrinkFontToFit(sFontName, nH, aFont, rDevice, aTextRect) != 0;
611 }
612
613 if (!bUsingCorrectFont)
614 {
615 rDevice.SetFont(aOldFont);
616 rDevice.GetTextBoundRect(aTextRect, sFontName);
617 }
618
619 tools::Long nTextHeight = aTextRect.GetHeight();
620 tools::Long nDesiredGap = (nH-nTextHeight)/2;
621 tools::Long nVertAdjust = nDesiredGap - aTextRect.Top();
622 Point aPos( nX, rTopLeft.Y() + nVertAdjust );
623 rDevice.DrawText(aPos, sFontName);
624 tools::Long nTextX = aPos.X() + aTextRect.GetWidth() + GAPTOEXTRAPREVIEW;
625
626 if (!bUsingCorrectFont)
627 rDevice.SetFont(aFont);
628
629 OUString sSampleText;
630
631 if (!bSymbolFont)
632 {
633 const bool bNameBeginsWithLatinText = rFontMetric.GetFamilyName()[0] <= 'z';
634
635 if (bNameBeginsWithLatinText || !bUsingCorrectFont)
636 sSampleText = makeShortRepresentativeTextForSelectedFont(rDevice);
637 }
638
639 //If we're not a symbol font, but could neither render our own name and
640 //we can't determine what script it would like to render, then try a
641 //few well known scripts
642 if (sSampleText.isEmpty() && !bUsingCorrectFont)
643 {
644 static const UScriptCode aScripts[] =
645 {
646 USCRIPT_ARABIC,
647 USCRIPT_HEBREW,
648
649 USCRIPT_BENGALI,
650 USCRIPT_GURMUKHI,
651 USCRIPT_GUJARATI,
652 USCRIPT_ORIYA,
653 USCRIPT_TAMIL,
654 USCRIPT_TELUGU,
655 USCRIPT_KANNADA,
656 USCRIPT_MALAYALAM,
657 USCRIPT_SINHALA,
658 USCRIPT_DEVANAGARI,
659
660 USCRIPT_THAI,
661 USCRIPT_LAO,
662 USCRIPT_GEORGIAN,
663 USCRIPT_TIBETAN,
664 USCRIPT_SYRIAC,
665 USCRIPT_MYANMAR,
666 USCRIPT_ETHIOPIC,
667 USCRIPT_KHMER,
668 USCRIPT_MONGOLIAN,
669
670 USCRIPT_KOREAN,
671 USCRIPT_JAPANESE,
672 USCRIPT_HAN,
673 USCRIPT_SIMPLIFIED_HAN,
674 USCRIPT_TRADITIONAL_HAN,
675
676 USCRIPT_GREEK
677 };
678
679 for (const UScriptCode& rScript : aScripts)
680 {
681 OUString sText = makeShortRepresentativeTextForScript(rScript);
682 if (!sText.isEmpty())
683 {
684 bool bHasSampleTextGlyphs = (-1 == rDevice.HasGlyphs(aFont, sText));
685 if (bHasSampleTextGlyphs)
686 {
687 sSampleText = sText;
688 break;
689 }
690 }
691 }
692
693 static const UScriptCode aMinimalScripts[] =
694 {
695 USCRIPT_HEBREW, //e.g. biblical hebrew
696 USCRIPT_GREEK
697 };
698
699 for (const UScriptCode& rMinimalScript : aMinimalScripts)
700 {
701 OUString sText = makeShortMinimalTextForScript(rMinimalScript);
702 if (!sText.isEmpty())
703 {
704 bool bHasSampleTextGlyphs = (-1 == rDevice.HasGlyphs(aFont, sText));
705 if (bHasSampleTextGlyphs)
706 {
707 sSampleText = sText;
708 break;
709 }
710 }
711 }
712 }
713
714 //If we're a symbol font, or for some reason the font still couldn't
715 //render something representative of what it would like to render then
716 //make up some semi-random text that it *can* display
717 if (bSymbolFont || (!bUsingCorrectFont && sSampleText.isEmpty()))
719
720 if (!sSampleText.isEmpty())
721 {
722 const Size &rItemSize = gUserItemSz;
723
724 //leave a little border at the edge
725 tools::Long nSpace = rItemSize.Width() - nTextX - IMGOUTERTEXTSPACE;
726 if (nSpace >= 0)
727 {
728 //Make sure it fits in the available height, and get how wide that would be
729 tools::Long nWidth = shrinkFontToFit(sSampleText, nH, aFont, rDevice, aTextRect);
730 //Chop letters off until it fits in the available width
731 while (nWidth > nSpace || nWidth > gUserItemSz.Width())
732 {
733 sSampleText = sSampleText.copy(0, sSampleText.getLength()-1);
734 nWidth = rDevice.GetTextBoundRect(aTextRect, sSampleText) ?
735 aTextRect.GetWidth() : 0;
736 }
737
738 //center the text on the line
739 if (!sSampleText.isEmpty() && nWidth)
740 {
741 nTextHeight = aTextRect.GetHeight();
742 nDesiredGap = (nH-nTextHeight)/2;
743 nVertAdjust = nDesiredGap - aTextRect.Top();
744 aPos = Point(nTextX + nSpace - nWidth, rTopLeft.Y() + nVertAdjust);
745 rDevice.DrawText(aPos, sSampleText);
746 }
747 }
748 }
749
750 rDevice.SetFont(aOldFont);
751 rDevice.Pop();
752}
753
755{
756 SolarMutexGuard aGuard;
757 const FontMetric& rFontMetric = (*mpFontList)[nIndex];
758 const OUString& rFontName = rFontMetric.GetFamilyName();
759
760 size_t nPreviewIndex;
761 auto xFind = std::find(gRenderedFontNames.begin(), gRenderedFontNames.end(), rFontName);
762 bool bPreviewAvailable = xFind != gRenderedFontNames.end();
763 if (!bPreviewAvailable)
764 {
765 nPreviewIndex = gRenderedFontNames.size();
766 gRenderedFontNames.push_back(rFontName);
767 }
768 else
769 nPreviewIndex = std::distance(gRenderedFontNames.begin(), xFind);
770
771 size_t nPage = nPreviewIndex / gPreviewsPerDevice;
772 size_t nIndexInPage = nPreviewIndex - (nPage * gPreviewsPerDevice);
773
774 Point aTopLeft(0, gUserItemSz.Height() * nIndexInPage);
775
776 if (!bPreviewAvailable)
777 {
778 if (nPage >= gFontPreviewVirDevs.size())
779 {
780 gFontPreviewVirDevs.emplace_back(m_xComboBox->create_render_virtual_device());
781 VirtualDevice& rDevice = *gFontPreviewVirDevs.back();
783 weld::SetPointFont(rDevice, m_xComboBox->get_font());
784 assert(gFontPreviewVirDevs.size() == nPage + 1);
785 }
786
787 DrawPreview(rFontMetric, aTopLeft, *gFontPreviewVirDevs.back(), false);
788 }
789
790 if (pTopLeft)
791 *pTopLeft = aTopLeft;
792
793 return *gFontPreviewVirDevs[nPage];
794}
795
796IMPL_LINK(FontNameBox, CustomRenderHdl, weld::ComboBox::render_args, aPayload, void)
797{
798 vcl::RenderContext& rRenderContext = std::get<0>(aPayload);
799 const ::tools::Rectangle& rRect = std::get<1>(aPayload);
800 bool bSelected = std::get<2>(aPayload);
801 const OUString& rId = std::get<3>(aPayload);
802
803 sal_uInt32 nIndex = rId.toUInt32();
804
805 Point aDestPoint(rRect.TopLeft());
806 auto nMargin = (rRect.GetHeight() - gUserItemSz.Height()) / 2;
807 aDestPoint.AdjustY(nMargin);
808
809 if (bSelected)
810 {
811 const FontMetric& rFontMetric = (*mpFontList)[nIndex];
812 DrawPreview(rFontMetric, aDestPoint, rRenderContext, true);
813 }
814 else
815 {
816 // use cache of unselected entries
817 Point aTopLeft;
818 OutputDevice& rDevice = CachePreview(nIndex, &aTopLeft);
819
820 rRenderContext.DrawOutDev(aDestPoint, gUserItemSz,
821 aTopLeft, gUserItemSz,
822 rDevice);
823 }
824}
825
826void FontNameBox::set_active_or_entry_text(const OUString& rText)
827{
828 const int nFound = m_xComboBox->find_text(rText);
829 if (nFound != -1)
830 m_xComboBox->set_active(nFound);
831 m_xComboBox->set_entry_text(rText);
832}
833
834FontStyleBox::FontStyleBox(std::unique_ptr<weld::ComboBox> p)
835 : m_xComboBox(std::move(p))
836{
837 //Use the standard texts to get an optimal size and stick to that size.
838 //That should stop the character dialog dancing around.
839 auto nMaxLen = m_xComboBox->get_pixel_size(SvtResId(STR_SVT_STYLE_LIGHT)).Width();
840 nMaxLen = std::max(nMaxLen, m_xComboBox->get_pixel_size(SvtResId(STR_SVT_STYLE_LIGHT_ITALIC)).Width());
841 nMaxLen = std::max(nMaxLen, m_xComboBox->get_pixel_size(SvtResId(STR_SVT_STYLE_NORMAL)).Width());
842 nMaxLen = std::max(nMaxLen, m_xComboBox->get_pixel_size(SvtResId(STR_SVT_STYLE_NORMAL_ITALIC)).Width());
843 nMaxLen = std::max(nMaxLen, m_xComboBox->get_pixel_size(SvtResId(STR_SVT_STYLE_BOLD)).Width());
844 nMaxLen = std::max(nMaxLen, m_xComboBox->get_pixel_size(SvtResId(STR_SVT_STYLE_BOLD_ITALIC)).Width());
845 nMaxLen = std::max(nMaxLen, m_xComboBox->get_pixel_size(SvtResId(STR_SVT_STYLE_BLACK)).Width());
846 nMaxLen = std::max(nMaxLen, m_xComboBox->get_pixel_size(SvtResId(STR_SVT_STYLE_BLACK_ITALIC)).Width());
847 m_xComboBox->set_entry_width_chars(std::ceil(nMaxLen / m_xComboBox->get_approximate_digit_width()));
848}
849
850void FontStyleBox::Fill( std::u16string_view rName, const FontList* pList )
851{
852 OUString aOldText = m_xComboBox->get_active_text();
853 int nPos = m_xComboBox->get_active();
854
855 m_xComboBox->freeze();
856 m_xComboBox->clear();
857
858 // does a font with this name already exist?
859 sal_Handle hFontMetric = pList->GetFirstFontMetric( rName );
860 if ( hFontMetric )
861 {
862 OUString aStyleText;
863 FontWeight eLastWeight = WEIGHT_DONTKNOW;
864 FontItalic eLastItalic = ITALIC_NONE;
865 FontWidth eLastWidth = WIDTH_DONTKNOW;
866 bool bNormal = false;
867 bool bItalic = false;
868 bool bBold = false;
869 bool bBoldItalic = false;
870 bool bInsert = false;
871 FontMetric aFontMetric;
872 while ( hFontMetric )
873 {
874 aFontMetric = FontList::GetFontMetric( hFontMetric );
875
876 FontWeight eWeight = aFontMetric.GetWeight();
877 FontItalic eItalic = aFontMetric.GetItalic();
878 FontWidth eWidth = aFontMetric.GetWidthType();
879 // Only if the attributes are different, we insert the
880 // Font to avoid double Entries in different languages
881 if ( (eWeight != eLastWeight) || (eItalic != eLastItalic) ||
882 (eWidth != eLastWidth) )
883 {
884 if ( bInsert )
885 m_xComboBox->append_text(aStyleText);
886
887 if ( eWeight <= WEIGHT_NORMAL )
888 {
889 if ( eItalic != ITALIC_NONE )
890 bItalic = true;
891 else
892 bNormal = true;
893 }
894 else
895 {
896 if ( eItalic != ITALIC_NONE )
897 bBoldItalic = true;
898 else
899 bBold = true;
900 }
901
902 // For wrong StyleNames we replace this with the correct once
903 aStyleText = pList->GetStyleName( aFontMetric );
904 bInsert = m_xComboBox->find_text(aStyleText) == -1;
905 if ( !bInsert )
906 {
907 aStyleText = pList->GetStyleName( eWeight, eItalic );
908 bInsert = m_xComboBox->find_text(aStyleText) == -1;
909 }
910
911 eLastWeight = eWeight;
912 eLastItalic = eItalic;
913 eLastWidth = eWidth;
914 }
915 else
916 {
917 if ( bInsert )
918 {
919 // If we have two names for the same attributes
920 // we prefer the translated standard names
921 const OUString& rAttrStyleText = pList->GetStyleName( eWeight, eItalic );
922 if (rAttrStyleText != aStyleText)
923 {
924 OUString aTempStyleText = pList->GetStyleName( aFontMetric );
925 if (rAttrStyleText == aTempStyleText)
926 aStyleText = rAttrStyleText;
927 bInsert = m_xComboBox->find_text(aStyleText) == -1;
928 }
929 }
930 }
931
932 if ( !bItalic && (aStyleText == pList->GetItalicStr()) )
933 bItalic = true;
934 else if ( !bBold && (aStyleText == pList->GetBoldStr()) )
935 bBold = true;
936 else if ( !bBoldItalic && (aStyleText == pList->GetBoldItalicStr()) )
937 bBoldItalic = true;
938
939 hFontMetric = FontList::GetNextFontMetric( hFontMetric );
940 }
941
942 if ( bInsert )
943 m_xComboBox->append_text(aStyleText);
944
945 // certain style as copy
946 if ( bNormal )
947 {
948 if ( !bItalic )
949 m_xComboBox->append_text(pList->GetItalicStr());
950 if ( !bBold )
951 m_xComboBox->append_text(pList->GetBoldStr());
952 }
953 if ( !bBoldItalic )
954 {
955 if ( bNormal || bItalic || bBold )
956 m_xComboBox->append_text(pList->GetBoldItalicStr());
957 }
958 }
959 else
960 {
961 // insert standard styles if no font
962 m_xComboBox->append_text(pList->GetNormalStr());
963 m_xComboBox->append_text(pList->GetItalicStr());
964 m_xComboBox->append_text(pList->GetBoldStr());
965 m_xComboBox->append_text(pList->GetBoldItalicStr());
966 }
967
968 m_xComboBox->thaw();
969
970 if (!aOldText.isEmpty())
971 {
972 int nFound = m_xComboBox->find_text(aOldText);
973 if (nFound != -1)
974 m_xComboBox->set_active(nFound);
975 else
976 {
977 if (nPos >= m_xComboBox->get_count())
978 m_xComboBox->set_active(0);
979 else
980 m_xComboBox->set_active(nPos);
981 }
982 }
983}
984
985FontSizeBox::FontSizeBox(std::unique_ptr<weld::ComboBox> p)
986 : pFontList(nullptr)
987 , nSavedValue(0)
988 , nMin(20)
989 , nMax(9999)
990 , eUnit(FieldUnit::POINT)
991 , nDecimalDigits(1)
992 , nRelMin(0)
993 , nRelMax(0)
994 , nRelStep(0)
995 , nPtRelMin(0)
996 , nPtRelMax(0)
997 , nPtRelStep(0)
998 , bRelativeMode(false)
999 , bRelative(false)
1000 , bPtRelative(false)
1001 , bStdSize(false)
1002 , m_xComboBox(std::move(p))
1003{
1004 m_xComboBox->set_entry_width_chars(std::ceil(m_xComboBox->get_pixel_size(format_number(105)).Width() /
1005 m_xComboBox->get_approximate_digit_width()));
1006 m_xComboBox->connect_focus_out(LINK(this, FontSizeBox, ReformatHdl));
1007 m_xComboBox->connect_changed(LINK(this, FontSizeBox, ModifyHdl));
1008}
1009
1010void FontSizeBox::set_active_or_entry_text(const OUString& rText)
1011{
1012 const int nFound = m_xComboBox->find_text(rText);
1013 if (nFound != -1)
1014 m_xComboBox->set_active(nFound);
1015 m_xComboBox->set_entry_text(rText);
1016}
1017
1018IMPL_LINK(FontSizeBox, ReformatHdl, weld::Widget&, rWidget, void)
1019{
1020 FontSizeNames aFontSizeNames(Application::GetSettings().GetUILanguageTag().getLanguageType());
1021 if (!bRelativeMode || !aFontSizeNames.IsEmpty())
1022 {
1023 if (aFontSizeNames.Name2Size(m_xComboBox->get_active_text()) != 0)
1024 return;
1025 }
1026
1027 set_value(get_value());
1028
1029 m_aFocusOutHdl.Call(rWidget);
1030}
1031
1032IMPL_LINK(FontSizeBox, ModifyHdl, weld::ComboBox&, rBox, void)
1033{
1034 if (bRelativeMode)
1035 {
1036 OUString aStr = comphelper::string::stripStart(rBox.get_active_text(), ' ');
1037
1038 bool bNewMode = bRelative;
1039 bool bOldPtRelMode = bPtRelative;
1040
1041 if ( bRelative )
1042 {
1043 bPtRelative = false;
1044 const sal_Unicode* pStr = aStr.getStr();
1045 while ( *pStr )
1046 {
1047 if ( ((*pStr < '0') || (*pStr > '9')) && (*pStr != '%') && !unicode::isSpace(*pStr) )
1048 {
1049 if ( ('-' == *pStr || '+' == *pStr) && !bPtRelative )
1050 bPtRelative = true;
1051 else if ( bPtRelative && 'p' == *pStr && 't' == *++pStr )
1052 ;
1053 else
1054 {
1055 bNewMode = false;
1056 break;
1057 }
1058 }
1059 pStr++;
1060 }
1061 }
1062 else if (!aStr.isEmpty())
1063 {
1064 if ( -1 != aStr.indexOf('%') )
1065 {
1066 bNewMode = true;
1067 bPtRelative = false;
1068 }
1069
1070 if ( '-' == aStr[0] || '+' == aStr[0] )
1071 {
1072 bNewMode = true;
1073 bPtRelative = true;
1074 }
1075 }
1076
1077 if ( bNewMode != bRelative || bPtRelative != bOldPtRelMode )
1078 SetRelative( bNewMode );
1079 }
1080 m_aChangeHdl.Call(rBox);
1081}
1082
1083void FontSizeBox::Fill( const FontList* pList )
1084{
1085 // remember for relative mode
1086 pFontList = pList;
1087
1088 // no font sizes need to be set for relative mode
1089 if ( bRelative )
1090 return;
1091
1092 // query font sizes
1093 const int* pTempAry;
1094 const int* pAry = nullptr;
1095
1096 pAry = FontList::GetStdSizeAry();
1097
1098 // first insert font size names (for simplified/traditional chinese)
1099 FontSizeNames aFontSizeNames( Application::GetSettings().GetUILanguageTag().getLanguageType() );
1100 if ( pAry == FontList::GetStdSizeAry() )
1101 {
1102 // for standard sizes we don't need to bother
1103 if (bStdSize && m_xComboBox->get_count() && aFontSizeNames.IsEmpty())
1104 return;
1105 bStdSize = true;
1106 }
1107 else
1108 bStdSize = false;
1109
1110 int nSelectionStart, nSelectionEnd;
1111 m_xComboBox->get_entry_selection_bounds(nSelectionStart, nSelectionEnd);
1112 OUString aStr = m_xComboBox->get_active_text();
1113
1114 m_xComboBox->freeze();
1115 m_xComboBox->clear();
1116 int nPos = 0;
1117
1118 if ( !aFontSizeNames.IsEmpty() )
1119 {
1120 if ( pAry == FontList::GetStdSizeAry() )
1121 {
1122 // for scalable fonts all font size names
1123 sal_uLong nCount = aFontSizeNames.Count();
1124 for( sal_uLong i = 0; i < nCount; i++ )
1125 {
1126 OUString aSizeName = aFontSizeNames.GetIndexName( i );
1127 int nSize = aFontSizeNames.GetIndexSize( i );
1128 OUString sId(OUString::number(-nSize)); // mark as special
1129 m_xComboBox->insert(nPos, aSizeName, &sId, nullptr, nullptr);
1130 nPos++;
1131 }
1132 }
1133 else
1134 {
1135 // for fixed size fonts only selectable font size names
1136 pTempAry = pAry;
1137 while ( *pTempAry )
1138 {
1139 OUString aSizeName = aFontSizeNames.Size2Name( *pTempAry );
1140 if ( !aSizeName.isEmpty() )
1141 {
1142 OUString sId(OUString::number(-(*pTempAry))); // mark as special
1143 m_xComboBox->insert(nPos, aSizeName, &sId, nullptr, nullptr);
1144 nPos++;
1145 }
1146 pTempAry++;
1147 }
1148 }
1149 }
1150
1151 // then insert numerical font size values
1152 pTempAry = pAry;
1153 while (*pTempAry)
1154 {
1155 InsertValue(*pTempAry);
1156 ++pTempAry;
1157 }
1158
1159 m_xComboBox->thaw();
1161 m_xComboBox->select_entry_region(nSelectionStart, nSelectionEnd);
1162}
1163
1164void FontSizeBox::EnableRelativeMode( sal_uInt16 nNewMin, sal_uInt16 nNewMax, sal_uInt16 nStep )
1165{
1166 bRelativeMode = true;
1167 nRelMin = nNewMin;
1168 nRelMax = nNewMax;
1169 nRelStep = nStep;
1170 SetUnit(FieldUnit::POINT);
1171}
1172
1173void FontSizeBox::EnablePtRelativeMode( short nNewMin, short nNewMax, short nStep )
1174{
1175 bRelativeMode = true;
1176 nPtRelMin = nNewMin;
1177 nPtRelMax = nNewMax;
1178 nPtRelStep = nStep;
1179 SetUnit(FieldUnit::POINT);
1180}
1181
1183{
1184 OUString sNumber(OUString::number(i));
1185 m_xComboBox->append(sNumber, format_number(i));
1186}
1187
1188void FontSizeBox::SetRelative( bool bNewRelative )
1189{
1190 if ( !bRelativeMode )
1191 return;
1192
1193 int nSelectionStart, nSelectionEnd;
1194 m_xComboBox->get_entry_selection_bounds(nSelectionStart, nSelectionEnd);
1195 OUString aStr = comphelper::string::stripStart(m_xComboBox->get_active_text(), ' ');
1196
1197 if (bNewRelative)
1198 {
1199 bRelative = true;
1200 bStdSize = false;
1201
1202 m_xComboBox->clear();
1203
1204 if (bPtRelative)
1205 {
1206 SetDecimalDigits( 1 );
1208 SetUnit(FieldUnit::POINT);
1209
1210 short i = nPtRelMin, n = 0;
1211 // JP 30.06.98: more than 100 values are not useful
1212 while ( i <= nPtRelMax && n++ < 100 )
1213 {
1214 InsertValue( i );
1215 i = i + nPtRelStep;
1216 }
1217 }
1218 else
1219 {
1222 SetUnit(FieldUnit::PERCENT);
1223
1224 sal_uInt16 i = nRelMin;
1225 while ( i <= nRelMax )
1226 {
1227 InsertValue( i );
1228 i = i + nRelStep;
1229 }
1230 }
1231 }
1232 else
1233 {
1234 if (pFontList)
1235 m_xComboBox->clear();
1236 bRelative = bPtRelative = false;
1238 SetRange(20, 9999);
1239 SetUnit(FieldUnit::POINT);
1240 if ( pFontList)
1241 Fill( pFontList );
1242 }
1243
1245 m_xComboBox->select_entry_region(nSelectionStart, nSelectionEnd);
1246}
1247
1248OUString FontSizeBox::format_number(int nValue) const
1249{
1250 OUString sRet;
1251
1252 //pawn percent off to icu to decide whether percent is separated from its number for this locale
1253 if (eUnit == FieldUnit::PERCENT)
1254 {
1255 double fValue = nValue;
1257 sRet = unicode::formatPercent(fValue, Application::GetSettings().GetUILanguageTag());
1258 }
1259 else
1260 {
1261 const SvtSysLocale aSysLocale;
1262 const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
1263 sRet = rLocaleData.getNum(nValue, nDecimalDigits, true, false);
1264 if (eUnit != FieldUnit::NONE && eUnit != FieldUnit::DEGREE)
1265 sRet += " ";
1266 assert(eUnit != FieldUnit::PERCENT);
1268 }
1269
1270 if (bRelativeMode && bPtRelative && (0 <= nValue) && !sRet.isEmpty())
1271 sRet = "+" + sRet;
1272
1273 return sRet;
1274}
1275
1276void FontSizeBox::SetValue(int nNewValue, FieldUnit eInUnit)
1277{
1278 auto nTempValue = vcl::ConvertValue(nNewValue, 0, GetDecimalDigits(), eInUnit, GetUnit());
1279 if (nTempValue < nMin)
1280 nTempValue = nMin;
1281 else if (nTempValue > nMax)
1282 nTempValue = nMax;
1283 if (!bRelative)
1284 {
1285 FontSizeNames aFontSizeNames(Application::GetSettings().GetUILanguageTag().getLanguageType());
1286 // conversion loses precision; however font sizes should
1287 // never have a problem with that
1288 OUString aName = aFontSizeNames.Size2Name(nTempValue);
1289 if (!aName.isEmpty() && m_xComboBox->find_text(aName) != -1)
1290 {
1291 m_xComboBox->set_active_text(aName);
1292 return;
1293 }
1294 }
1295 OUString aResult = format_number(nTempValue);
1296 set_active_or_entry_text(aResult);
1297}
1298
1299void FontSizeBox::set_value(int nNewValue)
1300{
1301 SetValue(nNewValue, eUnit);
1302}
1303
1305{
1306 OUString aStr = m_xComboBox->get_active_text();
1307 if (!bRelative)
1308 {
1309 FontSizeNames aFontSizeNames(Application::GetSettings().GetUILanguageTag().getLanguageType());
1310 auto nValue = aFontSizeNames.Name2Size(aStr);
1311 if (nValue)
1313 }
1314
1315 const SvtSysLocale aSysLocale;
1316 const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
1317 double fResult(0.0);
1318 (void)vcl::TextToValue(aStr, fResult, 0, GetDecimalDigits(), rLocaleData, GetUnit());
1319 if (!aStr.isEmpty())
1320 {
1321 if (fResult < nMin)
1322 fResult = nMin;
1323 else if (fResult > nMax)
1324 fResult = nMax;
1325 }
1326 return fResult;
1327}
1328
1330{
1331 if (m_xLineSet->IsNoSelection())
1332 return SvxBorderLineStyle::NONE;
1333 auto nId = m_xLineSet->GetSelectedItemId();
1334 return static_cast<SvxBorderLineStyle>(nId - 1);
1335}
1336
1337namespace
1338{
1339 Size getPreviewSize(const weld::Widget& rControl)
1340 {
1341 return Size(rControl.get_approximate_digit_width() * 15, rControl.get_text_height());
1342 }
1343}
1344
1346 Color aColor1, Color aColor2, Color aColorDist,
1347 SvxBorderLineStyle nStyle, BitmapEx& rBmp )
1348{
1349 Size aSize(getPreviewSize(*m_xControl));
1350
1351 // SourceUnit to Twips
1352 if ( eSourceUnit == FieldUnit::POINT )
1353 {
1354 nLine1 /= 5;
1355 nLine2 /= 5;
1356 nDistance /= 5;
1357 }
1358
1359 // Paint the lines
1360 aSize = aVirDev->PixelToLogic( aSize );
1361 tools::Long nPix = aVirDev->PixelToLogic( Size( 0, 1 ) ).Height();
1362 sal_uInt32 n1 = nLine1;
1363 sal_uInt32 n2 = nLine2;
1364 tools::Long nDist = nDistance;
1365 n1 += nPix-1;
1366 n1 -= n1%nPix;
1367 if ( n2 )
1368 {
1369 nDist += nPix-1;
1370 nDist -= nDist%nPix;
1371 n2 += nPix-1;
1372 n2 -= n2%nPix;
1373 }
1374 tools::Long nVirHeight = n1+nDist+n2;
1375 if ( nVirHeight > aSize.Height() )
1376 aSize.setHeight( nVirHeight );
1377 // negative width should not be drawn
1378 if ( aSize.Width() <= 0 )
1379 return;
1380
1381 Size aVirSize = aVirDev->LogicToPixel( aSize );
1382 if ( aVirDev->GetOutputSizePixel() != aVirSize )
1383 aVirDev->SetOutputSizePixel( aVirSize );
1384 aVirDev->SetFillColor( aColorDist );
1385 aVirDev->DrawRect( tools::Rectangle( Point(), aSize ) );
1386
1387 aVirDev->SetFillColor( aColor1 );
1388
1389 double y1 = double( n1 ) / 2;
1390 svtools::DrawLine( *aVirDev, basegfx::B2DPoint( 0, y1 ), basegfx::B2DPoint( aSize.Width( ), y1 ), n1, nStyle );
1391
1392 if ( n2 )
1393 {
1394 double y2 = n1 + nDist + double( n2 ) / 2;
1395 aVirDev->SetFillColor( aColor2 );
1396 svtools::DrawLine( *aVirDev, basegfx::B2DPoint( 0, y2 ), basegfx::B2DPoint( aSize.Width(), y2 ), n2, SvxBorderLineStyle::SOLID );
1397 }
1398 rBmp = aVirDev->GetBitmapEx( Point(), Size( aSize.Width(), n1+nDist+n2 ) );
1399}
1400
1401SvtLineListBox::SvtLineListBox(std::unique_ptr<weld::MenuButton> pControl)
1402 : WeldToolbarPopup(css::uno::Reference<css::frame::XFrame>(), pControl.get(), "svt/ui/linewindow.ui", "line_popup_window")
1403 , m_xControl(std::move(pControl))
1404 , m_xNoneButton(m_xBuilder->weld_button("none_line_button"))
1405 , m_xLineSet(new ValueSet(nullptr))
1406 , m_xLineSetWin(new weld::CustomWeld(*m_xBuilder, "lineset", *m_xLineSet))
1407 , m_nWidth( 5 )
1408 , aVirDev(VclPtr<VirtualDevice>::Create())
1409 , aColor(COL_BLACK)
1410{
1411 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1413 m_xLineSet->SetItemHeight(rStyleSettings.GetListBoxPreviewDefaultPixelSize().Height() + 1);
1414 m_xLineSet->SetColCount(1);
1415 m_xLineSet->SetSelectHdl(LINK(this, SvtLineListBox, ValueSelectHdl));
1416
1417 m_xNoneButton->connect_clicked(LINK(this, SvtLineListBox, NoneHdl));
1418
1419 m_xControl->set_popover(m_xTopLevel.get());
1420 m_xControl->connect_toggled(LINK(this, SvtLineListBox, ToggleHdl));
1421 m_xControl->connect_style_updated(LINK(this, SvtLineListBox, StyleUpdatedHdl));
1422
1423 // lock size to these maxes height/width so it doesn't jump around in size
1424 m_xControl->set_label(GetLineStyleName(SvxBorderLineStyle::NONE));
1425 Size aNonePrefSize = m_xControl->get_preferred_size();
1426 m_xControl->set_label("");
1427 aVirDev->SetOutputSizePixel(getPreviewSize(*m_xControl));
1428 m_xControl->set_image(aVirDev);
1429 Size aSolidPrefSize = m_xControl->get_preferred_size();
1430 m_xControl->set_size_request(std::max(aNonePrefSize.Width(), aSolidPrefSize.Width()),
1431 std::max(aNonePrefSize.Height(), aSolidPrefSize.Height()));
1432
1433 eSourceUnit = FieldUnit::POINT;
1434
1435 aVirDev->SetLineColor();
1436 aVirDev->SetMapMode(MapMode(MapUnit::MapTwip));
1437}
1438
1440{
1441 if (GetSelectEntryStyle() == SvxBorderLineStyle::NONE)
1442 m_xNoneButton->grab_focus();
1443 else
1444 m_xLineSet->GrabFocus();
1445}
1446
1447IMPL_LINK(SvtLineListBox, ToggleHdl, weld::Toggleable&, rButton, void)
1448{
1449 if (rButton.get_active())
1450 GrabFocus();
1451}
1452
1454{
1455 UpdateEntries();
1456 UpdatePreview();
1457}
1458
1460{
1461 SelectEntry(SvxBorderLineStyle::NONE);
1462 ValueSelectHdl(nullptr);
1463}
1464
1466{
1467}
1468
1470{
1471 OUString sRet;
1472 for (sal_uInt32 i = 0; i < SAL_N_ELEMENTS(RID_SVXSTR_BORDERLINE); ++i)
1473 {
1474 if (eStyle == RID_SVXSTR_BORDERLINE[i].second)
1475 {
1476 sRet = SvtResId(RID_SVXSTR_BORDERLINE[i].first);
1477 break;
1478 }
1479 }
1480 return sRet;
1481}
1482
1484{
1485 if (nStyle == SvxBorderLineStyle::NONE)
1486 m_xLineSet->SetNoSelection();
1487 else
1488 m_xLineSet->SelectItem(static_cast<sal_Int16>(nStyle) + 1);
1489 UpdatePreview();
1490}
1491
1493 const BorderWidthImpl& rWidthImpl, SvxBorderLineStyle nStyle, tools::Long nMinWidth,
1494 ColorFunc pColor1Fn, ColorFunc pColor2Fn, ColorDistFunc pColorDistFn )
1495{
1496 m_vLineList.emplace_back(new ImpLineListData(
1497 rWidthImpl, nStyle, nMinWidth, pColor1Fn, pColor2Fn, pColorDistFn));
1498}
1499
1501{
1503
1504 // Remove the old entries
1505 m_xLineSet->Clear();
1506
1508 Color aFieldColor = rSettings.GetFieldColor();
1509
1510 // Add the new entries based on the defined width
1511 sal_uInt16 n = 0;
1512 sal_uInt16 nCount = m_vLineList.size( );
1513 while ( n < nCount )
1514 {
1515 auto& pData = m_vLineList[ n ];
1516 BitmapEx aBmp;
1517 ImpGetLine( pData->GetLine1ForWidth( m_nWidth ),
1518 pData->GetLine2ForWidth( m_nWidth ),
1519 pData->GetDistForWidth( m_nWidth ),
1520 pData->GetColorLine1(aColor),
1521 pData->GetColorLine2(aColor),
1522 pData->GetColorDist(aColor, aFieldColor),
1523 pData->GetStyle(), aBmp );
1524 sal_Int16 nItemId = static_cast<sal_Int16>(pData->GetStyle()) + 1;
1525 m_xLineSet->InsertItem(nItemId, Image(aBmp), GetLineStyleName(pData->GetStyle()));
1526 if (pData->GetStyle() == eSelected)
1527 m_xLineSet->SelectItem(nItemId);
1528 n++;
1529 }
1530
1531 m_xLineSet->SetOptimalSize();
1532}
1533
1535{
1536 maSelectHdl.Call(*this);
1537 UpdatePreview();
1538 if (m_xControl->get_active())
1539 m_xControl->set_active(false);
1540}
1541
1543{
1545 for (sal_uInt32 i = 0; i < SAL_N_ELEMENTS(RID_SVXSTR_BORDERLINE); ++i)
1546 {
1547 if (eStyle == RID_SVXSTR_BORDERLINE[i].second)
1548 {
1549 m_xControl->set_label(SvtResId(RID_SVXSTR_BORDERLINE[i].first));
1550 break;
1551 }
1552 }
1553
1554 if (eStyle == SvxBorderLineStyle::NONE)
1555 {
1556 m_xControl->set_image(nullptr);
1557 m_xControl->set_label(GetLineStyleName(SvxBorderLineStyle::NONE));
1558 }
1559 else
1560 {
1561 Image aImage(m_xLineSet->GetItemImage(m_xLineSet->GetSelectedItemId()));
1562 m_xControl->set_label("");
1563 const auto nPos = (aVirDev->GetOutputSizePixel().Height() - aImage.GetSizePixel().Height()) / 2;
1565 aVirDev->SetMapMode(MapMode(MapUnit::MapPixel));
1567 aVirDev->SetBackground(rSettings.GetFieldColor());
1568 aVirDev->Erase();
1569 aVirDev->DrawImage(Point(0, nPos), aImage);
1570 m_xControl->set_image(aVirDev.get());
1571 aVirDev->Pop();
1572 }
1573}
1574
1575SvtCalendarBox::SvtCalendarBox(std::unique_ptr<weld::MenuButton> pControl, bool bUseLabel)
1576 : m_bUseLabel(bUseLabel)
1577 , m_xControl(std::move(pControl))
1578 , m_xBuilder(Application::CreateBuilder(m_xControl.get(), "svt/ui/datewindow.ui"))
1579 , m_xTopLevel(m_xBuilder->weld_popover("date_popup_window"))
1580 , m_xCalendar(m_xBuilder->weld_calendar("date_picker"))
1581{
1582 m_xControl->set_popover(m_xTopLevel.get());
1583 m_xCalendar->connect_selected(LINK(this, SvtCalendarBox, SelectHdl));
1584 m_xCalendar->connect_activated(LINK(this, SvtCalendarBox, ActivateHdl));
1585}
1586
1588{
1589 m_xCalendar->set_date(rDate);
1591}
1592
1594{
1595 if (!m_bUseLabel)
1596 return;
1598 m_xControl->set_label(rLocaleData.getDate(m_xCalendar->get_date()));
1599}
1600
1602{
1603 set_label_from_date();
1604 m_aSelectHdl.Call(*this);
1605}
1606
1608{
1609 if (m_xControl->get_active())
1610 m_xControl->set_active(false);
1611 m_aActivatedHdl.Call(*this);
1612}
1613
1615{
1616}
1617
1618/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AntialiasingFlags
SvxBorderLineStyle
BorderWidthImplFlags
Class computing border widths shared between Line style listbox and the SvxBorderLine implementation.
Definition: borderline.hxx:44
const StyleSettings & GetStyleSettings() const
const LocaleDataWrapper & GetLocaleDataWrapper() const
static void AddEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
static const AllSettings & GetSettings()
static void RemoveEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
tools::Long GetLine2(tools::Long nWidth) const
Definition: ctrlbox.cxx:103
tools::Long GetGap(tools::Long nWidth) const
Definition: ctrlbox.cxx:117
tools::Long GuessWidth(tools::Long nLine1, tools::Long nLine2, tools::Long nGap)
Definition: ctrlbox.cxx:150
BorderWidthImplFlags m_nFlags
Definition: borderline.hxx:56
tools::Long GetLine1(tools::Long nWidth) const
Definition: ctrlbox.cxx:85
BorderWidthImpl(BorderWidthImplFlags nFlags=BorderWidthImplFlags::CHANGE_LINE1, double nRate1=0.0, double nRate2=0.0, double nRateGap=0.0)
Definition: ctrlbox.cxx:69
bool operator==(const BorderWidthImpl &r) const
Definition: ctrlbox.cxx:77
const OUString & GetItalicStr() const
Definition: ctrltool.hxx:165
const OUString & GetBoldItalicStr() const
Definition: ctrltool.hxx:167
size_t GetFontNameCount() const
Definition: ctrltool.hxx:178
static sal_Handle GetNextFontMetric(sal_Handle hFontMetric)
Definition: ctrltool.cxx:735
static const FontMetric & GetFontMetric(sal_Handle hFontMetric)
Definition: ctrltool.cxx:741
static const int * GetStdSizeAry()
Definition: ctrltool.hxx:187
const OUString & GetNormalStr() const
Definition: ctrltool.hxx:164
sal_Handle GetFirstFontMetric(std::u16string_view rName) const
Definition: ctrltool.cxx:726
const OUString & GetStyleName(FontWeight eWeight, FontItalic eItalic) const
Definition: ctrltool.cxx:393
const OUString & GetBoldStr() const
Definition: ctrltool.hxx:166
const FontMetric & GetFontName(size_t nFont) const
Definition: ctrltool.cxx:719
void EnableWYSIWYG(bool bEnable)
Definition: ctrlbox.cxx:509
void Fill(const FontList *pList)
Definition: ctrlbox.cxx:468
SVT_DLLPRIVATE void ImplDestroyFontList()
Definition: ctrlbox.cxx:461
std::unique_ptr< ImplFontList > mpFontList
Definition: ctrlbox.hxx:327
std::unique_ptr< weld::ComboBox > m_xComboBox
Definition: ctrlbox.hxx:326
void set_active_or_entry_text(const OUString &rText)
Definition: ctrlbox.cxx:826
void LoadMRUEntries(const OUString &aFontMRUEntriesFile)
Definition: ctrlbox.cxx:427
OUString maFontMRUEntriesFile
Definition: ctrlbox.hxx:330
size_t mnPreviewProgress
Definition: ctrlbox.hxx:328
void SaveMRUEntries(const OUString &aFontMRUEntriesFile) const
Definition: ctrlbox.cxx:406
void InitFontMRUEntriesFile()
Definition: ctrlbox.cxx:449
bool mbWYSIWYG
Definition: ctrlbox.hxx:329
FontNameBox(std::unique_ptr< weld::ComboBox > p)
Definition: ctrlbox.cxx:372
OutputDevice & CachePreview(size_t nIndex, Point *pTopLeft)
Definition: ctrlbox.cxx:754
Idle maUpdateIdle
Definition: ctrlbox.hxx:331
bool bPtRelative
Definition: ctrlbox.hxx:432
sal_uInt16 nRelStep
Definition: ctrlbox.hxx:426
sal_uInt16 nDecimalDigits
Definition: ctrlbox.hxx:423
FieldUnit GetUnit() const
Definition: ctrlbox.hxx:440
sal_uInt16 nRelMax
Definition: ctrlbox.hxx:425
OUString format_number(int nValue) const
Definition: ctrlbox.cxx:1248
void EnableRelativeMode(sal_uInt16 nMin, sal_uInt16 nMax, sal_uInt16 nStep=5)
Definition: ctrlbox.cxx:1164
void SetDecimalDigits(sal_uInt16 nDigits)
Definition: ctrlbox.hxx:439
void SetValue(int nNewValue, FieldUnit eInUnit)
Definition: ctrlbox.cxx:1276
void Fill(const FontList *pList)
Definition: ctrlbox.cxx:1083
void EnablePtRelativeMode(short nMin, short nMax, short nStep=10)
Definition: ctrlbox.cxx:1173
void set_active_or_entry_text(const OUString &rText)
Definition: ctrlbox.cxx:1010
bool bRelativeMode
Definition: ctrlbox.hxx:430
sal_uInt16 nRelMin
Definition: ctrlbox.hxx:424
const FontList * pFontList
Definition: ctrlbox.hxx:418
sal_uInt16 GetDecimalDigits() const
Definition: ctrlbox.hxx:438
void SetRelative(bool bRelative)
Definition: ctrlbox.cxx:1188
void SetRange(int nNewMin, int nNewMax)
Definition: ctrlbox.hxx:442
FieldUnit eUnit
Definition: ctrlbox.hxx:422
void set_value(int nValue)
Definition: ctrlbox.cxx:1299
short nPtRelMin
Definition: ctrlbox.hxx:427
bool bStdSize
Definition: ctrlbox.hxx:433
void InsertValue(int i)
Definition: ctrlbox.cxx:1182
short nPtRelStep
Definition: ctrlbox.hxx:429
int get_value() const
Definition: ctrlbox.cxx:1304
FontSizeBox(std::unique_ptr< weld::ComboBox > p)
Definition: ctrlbox.cxx:985
bool bRelative
Definition: ctrlbox.hxx:431
short nPtRelMax
Definition: ctrlbox.hxx:428
std::unique_ptr< weld::ComboBox > m_xComboBox
Definition: ctrlbox.hxx:436
void SetUnit(FieldUnit _eUnit)
Definition: ctrlbox.hxx:441
std::unique_ptr< weld::ComboBox > m_xComboBox
Definition: ctrlbox.hxx:394
void Fill(std::u16string_view rName, const FontList *pList)
Definition: ctrlbox.cxx:850
FontStyleBox(std::unique_ptr< weld::ComboBox > p)
Definition: ctrlbox.cxx:834
virtual void Start(bool bStartTimer=true) override
Size GetSizePixel() const
Utility class storing the border line width, style and colors.
Definition: ctrlbox.hxx:43
OUString getDate(const Date &rDate) const
OUString getNum(sal_Int64 nNumber, sal_uInt16 nDecimals, bool bUseThousandSep=true, bool bTrailingZeros=true) const
MapUnit GetMapUnit() const
const vcl::Font & GetFont() const
void SetAntialiasing(AntialiasingFlags nMode)
void SetFont(const vcl::Font &rNewFont)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, KernArraySpan aDXArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}, const SalLayoutGlyphs *pGlyphs=nullptr) const
void DrawPolygon(const tools::Polygon &rPoly)
void SetTextColor(const Color &rColor)
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
sal_Int32 HasGlyphs(const vcl::Font &rFont, std::u16string_view rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1) const
const MapMode & GetMapMode() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
AntialiasingFlags GetAntialiasing() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
constexpr tools::Long Y() const
tools::Long AdjustY(tools::Long nVertMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const Color & GetDialogTextColor() const
const Color & GetFieldColor() const
const Color & GetHighlightTextColor() const
const Size & GetListBoxPreviewDefaultPixelSize() const
bool IsOpen() const
void Open(const OUString &rFileName, StreamMode eOpenMode)
bool IsWritable() const
void SetLineDelimiter(LineEnd eLineEnd)
bool WriteLine(std::string_view rStr)
bool ReadLine(OStringBuffer &rStr, sal_Int32 nMaxBytesToRead=0xFFFE)
std::unique_ptr< weld::Calendar > m_xCalendar
Definition: ctrlbox.hxx:315
std::unique_ptr< weld::Widget > m_xTopLevel
Definition: ctrlbox.hxx:314
void set_label_from_date()
Definition: ctrlbox.cxx:1593
void set_date(const Date &rDate)
Definition: ctrlbox.cxx:1587
bool m_bUseLabel
Definition: ctrlbox.hxx:310
std::unique_ptr< weld::MenuButton > m_xControl
Definition: ctrlbox.hxx:312
SvtCalendarBox(std::unique_ptr< weld::MenuButton > pControl, bool bUseLabel=true)
Definition: ctrlbox.cxx:1575
virtual void GrabFocus() override
Definition: ctrlbox.cxx:1439
FieldUnit eSourceUnit
Definition: ctrlbox.hxx:277
tools::Long m_nWidth
Definition: ctrlbox.hxx:274
void UpdatePreview()
Definition: ctrlbox.cxx:1542
std::unique_ptr< ValueSet > m_xLineSet
Definition: ctrlbox.hxx:270
SvxBorderLineStyle GetSelectEntryStyle() const
Definition: ctrlbox.cxx:1329
ScopedVclPtr< VirtualDevice > aVirDev
Definition: ctrlbox.hxx:275
SvtLineListBox(std::unique_ptr< weld::MenuButton > pControl)
Definition: ctrlbox.cxx:1401
std::unique_ptr< weld::MenuButton > m_xControl
Definition: ctrlbox.hxx:268
std::unique_ptr< weld::Button > m_xNoneButton
Definition: ctrlbox.hxx:269
void UpdateEntries()
Definition: ctrlbox.cxx:1500
SVT_DLLPRIVATE void ImpGetLine(tools::Long nLine1, tools::Long nLine2, tools::Long nDistance, Color nColor1, Color nColor2, Color nColorDist, SvxBorderLineStyle nStyle, BitmapEx &rBmp)
Definition: ctrlbox.cxx:1345
static OUString GetLineStyleName(SvxBorderLineStyle eStyle)
Definition: ctrlbox.cxx:1469
std::vector< std::unique_ptr< ImpLineListData > > m_vLineList
Definition: ctrlbox.hxx:273
void SelectEntry(SvxBorderLineStyle nStyle)
Definition: ctrlbox.cxx:1483
void InsertEntry(const BorderWidthImpl &rWidthImpl, SvxBorderLineStyle nStyle, tools::Long nMinWidth=0, ColorFunc pColor1Fn=&sameColor, ColorFunc pColor2Fn=&sameColor, ColorDistFunc pColorDistFn=&sameDistColor)
Insert a listbox entry with all widths in Twips.
Definition: ctrlbox.cxx:1492
const LocaleDataWrapper & GetLocaleData() const
void SetPriority(TaskPriority ePriority)
void Stop()
void SetInvokeHandler(const Link< Timer *, void > &rLink)
reference_type * get() const
bool SetOutputSizePixel(const Size &rNewSize, bool bErase=true, bool bAlphaMaskTransparent=false)
std::unique_ptr< weld::Container > m_xTopLevel
Definition: toolbarmenu.hxx:41
B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
sal_uInt32 count() const
basegfx::B2DPoint const & getB2DPoint(sal_uInt32 nIndex) const
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
sal_uInt32 count() const
void setClosed(bool bNew)
B2DVector & normalize()
constexpr tools::Long GetWidth() const
constexpr tools::Long Top() const
constexpr tools::Long GetHeight() const
static OUString formatPercent(double dNumber, const LanguageTag &rLangTag)
static bool isSpace(const sal_uInt32 ch)
void SetFontSize(const Size &)
FontWidth GetWidthType()
FontItalic GetItalic()
const OUString & GetFamilyName() const
const Size & GetFontSize() const
FontWeight GetWeight()
std::tuple< vcl::RenderContext &, const tools::Rectangle &, bool, const OUString & > render_args
static OUString MetricToString(FieldUnit rUnit)
static unsigned int Power10(unsigned int n)
virtual int get_text_height() const=0
virtual float get_approximate_digit_width() const=0
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define SAL_CONFIGFILE(name)
#define IMGOUTERTEXTSPACE
Definition: ctrlbox.cxx:61
static double lcl_getGuessedWidth(tools::Long nTested, double nRate, bool bChanging)
Definition: ctrlbox.cxx:136
static std::vector< OUString > gRenderedFontNames
Definition: ctrlbox.cxx:335
static Size gUserItemSz
Definition: ctrlbox.cxx:331
#define GAPTOEXTRAPREVIEW
Definition: ctrlbox.cxx:63
double mfScale
Definition: ctrlbox.cxx:280
static int gFontNameBoxes
Definition: ctrlbox.cxx:332
IMPL_LINK(FontNameBox, SettingsChangedHdl, VclSimpleEvent &, rEvent, void)
Definition: ctrlbox.cxx:351
#define MINGAPWIDTH
Definition: ctrlbox.cxx:64
constexpr OUStringLiteral FONTNAMEBOXMRUENTRIESFILE
Definition: ctrlbox.cxx:66
static void lclDrawPolygon(OutputDevice &rDev, const basegfx::B2DPolygon &rPolygon, tools::Long nWidth, SvxBorderLineStyle nDashing)
Definition: ctrlbox.cxx:197
static void DrawPreview(const FontMetric &rFontMetric, const Point &rTopLeft, OutputDevice &rDevice, bool bSelected)
Definition: ctrlbox.cxx:574
static bool IsRunningUnitTest()
Definition: ctrlbox.cxx:507
static size_t gPreviewsPerDevice
Definition: ctrlbox.cxx:333
static std::vector< VclPtr< VirtualDevice > > gFontPreviewVirDevs
Definition: ctrlbox.cxx:334
IMPL_LINK_NOARG(FontNameBox, CustomGetSizeHdl, OutputDevice &, Size)
Definition: ctrlbox.cxx:531
#define EXTRAFONTSIZE
Definition: ctrlbox.cxx:62
::std::vector< FontMetric > ImplFontList
Definition: ctrlbox.hxx:98
int nCount
float u
ScXMLEditAttributeMap::Entry const aEntries[]
sal_Int32 m_nFlags
FieldUnit
sal_Int16 nValue
FontItalic
ITALIC_NONE
FontWidth
WIDTH_DONTKNOW
WEIGHT_NORMAL
WEIGHT_DONTKNOW
sal_Int32 nIndex
OUString aName
void * p
sal_Int64 n
LINEEND_LF
sal_uInt16 nPos
#define SAL_INFO(area, stream)
#define SAL_N_ELEMENTS(arr)
aStr
std::unique_ptr< sal_Int32[]> pData
int n2
int n1
void applyLineDashing(const B2DPolygon &rCandidate, const std::vector< double > &rDotDashArray, B2DPolyPolygon *pLineTarget, B2DPolyPolygon *pGapTarget, double fDotDashLength)
B2DVector getPerpendicular(const B2DVector &rNormalizedVec)
OString stripStart(const OString &rIn, char c)
Reference
int i
constexpr OUStringLiteral first
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
FontWeight
static std::vector< double > GetDashing(SvxBorderLineStyle nDashing)
Dashing array must start with a line width and end with a blank width.
Definition: ctrlbox.cxx:238
void DrawLine(OutputDevice &rDev, const Point &rP1, const Point &rP2, sal_uInt32 nWidth, SvxBorderLineStyle nDashing)
Definition: ctrlbox.cxx:313
std::vector< double > GetLineDashing(SvxBorderLineStyle nDashing, double fScale)
Definition: ctrlbox.cxx:291
basegfx::B2DPolyPolygon ApplyLineDashing(const basegfx::B2DPolygon &rPolygon, SvxBorderLineStyle nDashing, double fScale)
Definition: ctrlbox.cxx:298
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
long Long
bool TextToValue(const OUString &rStr, double &rValue, sal_Int64 nBaseValue, sal_uInt16 nDecDigits, const LocaleDataWrapper &rLocaleDataWrapper, FieldUnit eUnit)
sal_Int64 ConvertValue(sal_Int64 nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, FieldUnit eInUnit, FieldUnit eOutUnit)
void SetPointFont(OutputDevice &rDevice, const vcl::Font &rFont)
sal_Int16 nId
OUString makeShortRepresentativeTextForSelectedFont(OutputDevice const &rDevice)
bool canRenderNameOfSelectedFont(OutputDevice const &rDevice)
Definition: sampletext.cxx:143
OUString makeShortMinimalTextForScript(UScriptCode eScript)
Definition: sampletext.cxx:541
bool isSymbolFont(const vcl::Font &rFont)
Definition: sampletext.cxx:108
OUString makeShortRepresentativeTextForScript(UScriptCode eScript)
Definition: sampletext.cxx:220
OUString makeShortRepresentativeSymbolTextForSelectedFont(OutputDevice const &rDevice)
Definition: sampletext.cxx:149
sal_uIntPtr sal_uLong
OUString SvtResId(TranslateId aId)
Definition: svtresid.cxx:24
#define SAL_MAX_INT16
sal_uInt16 sal_Unicode
void * sal_Handle
Any result
OUString sId
#define WB_FLATVALUESET
Definition: valueset.hxx:177
#define WB_NO_DIRECTSELECT
Definition: valueset.hxx:178
Reference< XControl > m_xControl
sal_Int64 WinBits
WinBits const WB_TABSTOP