Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
37b8f4e0
Kaydet (Commit)
37b8f4e0
authored
May 12, 2015
tarafından
Tomaž Vajngerl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
refactor SvxFontPrevWindow to use RenderContext + clean-up
Change-Id: Ibbb23adff4c38b4c819894b6714de355f13219c3
üst
a7246759
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
426 additions
and
440 deletions
+426
-440
fntctrl.hxx
include/svx/fntctrl.hxx
+7
-8
fntctrl.cxx
svx/source/dialog/fntctrl.cxx
+419
-432
No files found.
include/svx/fntctrl.hxx
Dosyayı görüntüle @
37b8f4e0
...
...
@@ -27,26 +27,25 @@
#include <rtl/ustring.hxx>
// forward ---------------------------------------------------------------
class
SfxItemSet
;
class
FontPrevWin_Impl
;
// class SvxFontPrevWindow -----------------------------------------------
class
SVX_DLLPUBLIC
SAL_WARN_UNUSED
SvxFontPrevWindow
:
public
vcl
::
Window
{
using
OutputDevice
::
SetFont
;
private
:
FontPrevWin_Impl
*
pImpl
;
std
::
unique_ptr
<
FontPrevWin_Impl
>
pImpl
;
bool
mbResetForeground
:
1
;
bool
mbResetBackground
:
1
;
SVX_DLLPRIVATE
void
InitSettings
(
bool
bForeground
,
bool
bBackground
);
SVX_DLLPRIVATE
void
ResetSettings
(
bool
bForeground
,
bool
bBackground
);
SVX_DLLPRIVATE
void
ApplySettings
(
vcl
::
RenderContext
&
rRenderContext
);
SVX_DLLPRIVATE
void
Init
();
SVX_DLLPRIVATE
void
SetFontSize
(
const
SfxItemSet
&
rSet
,
sal_uInt16
nSlot
,
SvxFont
&
rFont
);
SVX_DLLPRIVATE
void
SetFontLang
(
const
SfxItemSet
&
rSet
,
sal_uInt16
nSlot
,
SvxFont
&
rFont
);
public
:
SvxFontPrevWindow
(
vcl
::
Window
*
pParent
,
const
ResId
&
rId
);
SvxFontPrevWindow
(
vcl
::
Window
*
pParent
,
const
ResId
&
rId
);
SvxFontPrevWindow
(
vcl
::
Window
*
pParent
,
WinBits
nStyle
);
virtual
~
SvxFontPrevWindow
();
virtual
void
dispose
()
SAL_OVERRIDE
;
...
...
@@ -68,7 +67,7 @@ public:
void
UseResourceText
(
bool
bUse
=
true
);
void
Paint
(
vcl
::
RenderContext
&
rRenderContext
,
const
Rectangle
&
)
SAL_OVERRIDE
;
bool
IsTwoLines
()
const
;
bool
IsTwoLines
()
const
;
void
SetTwoLines
(
bool
bSet
);
void
SetBrackets
(
sal_Unicode
cStart
,
sal_Unicode
cEnd
);
...
...
svx/source/dialog/fntctrl.cxx
Dosyayı görüntüle @
37b8f4e0
...
...
@@ -83,80 +83,80 @@ using ::com::sun::star::i18n::BreakIterator;
namespace
{
void
scaleFontWidth
(
vcl
::
Font
&
_rFont
,
const
OutputDevice
&
rOutDev
,
long
&
_n100PercentFont
)
{
_rFont
.
SetWidth
(
0
);
_n100PercentFont
=
rOutDev
.
GetFontMetric
(
_rFont
).
GetWidth
();
}
void
initFont
(
vcl
::
Font
&
_rFont
)
{
_rFont
.
SetTransparent
(
true
);
_rFont
.
SetAlign
(
ALIGN_BASELINE
);
}
void
scaleFontWidth
(
vcl
::
Font
&
rFont
,
vcl
::
RenderContext
&
rRenderContext
,
long
&
n100PercentFont
)
{
rFont
.
SetWidth
(
0
);
n100PercentFont
=
rRenderContext
.
GetFontMetric
(
rFont
).
GetWidth
();
}
void
setFontSize
(
vcl
::
Font
&
_rFont
)
{
Size
aSize
(
_rFont
.
GetSize
()
);
aSize
.
Height
()
=
(
aSize
.
Height
()
*
3
)
/
5
;
aSize
.
Width
()
=
(
aSize
.
Width
()
*
3
)
/
5
;
_rFont
.
SetSize
(
aSize
);
}
void
initFont
(
vcl
::
Font
&
rFont
)
{
rFont
.
SetTransparent
(
true
);
rFont
.
SetAlign
(
ALIGN_BASELINE
);
}
void
calcFontHeightAnyAscent
(
OutputDevice
*
_pWin
,
const
vcl
::
Font
&
_rFont
,
long
&
_nHeight
,
long
&
_nAscent
)
{
if
(
!
_nHeight
)
{
_pWin
->
SetFont
(
_rFont
);
FontMetric
aMetric
(
_pWin
->
GetFontMetric
()
);
_nHeight
=
aMetric
.
GetLineHeight
();
_nAscent
=
aMetric
.
GetAscent
();
}
}
void
setFontSize
(
vcl
::
Font
&
rFont
)
{
Size
aSize
(
rFont
.
GetSize
());
aSize
.
Height
()
=
(
aSize
.
Height
()
*
3
)
/
5
;
aSize
.
Width
()
=
(
aSize
.
Width
()
*
3
)
/
5
;
rFont
.
SetSize
(
aSize
);
}
void
setFont
(
const
SvxFont
&
rNewFont
,
SvxFont
&
rImplFont
)
void
calcFontHeightAnyAscent
(
vcl
::
RenderContext
&
rRenderContext
,
const
vcl
::
Font
&
rFont
,
long
&
nHeight
,
long
&
nAscent
)
{
if
(
!
nHeight
)
{
rImplFont
=
rNewFont
;
rImplFont
.
SetTransparent
(
true
);
rImplFont
.
SetAlign
(
ALIGN_BASELINE
);
rRenderContext
.
SetFont
(
rFont
);
FontMetric
aMetric
(
rRenderContext
.
GetFontMetric
());
nHeight
=
aMetric
.
GetLineHeight
();
nAscent
=
aMetric
.
GetAscent
();
}
}
void
setFont
(
const
SvxFont
&
rNewFont
,
SvxFont
&
rImplFont
)
{
rImplFont
=
rNewFont
;
rImplFont
.
SetTransparent
(
true
);
rImplFont
.
SetAlign
(
ALIGN_BASELINE
);
}
}
// end anonymous namespace
class
FontPrevWin_Impl
{
friend
class
SvxFontPrevWindow
;
SvxFont
aFont
;
VclPtr
<
Printer
>
pPrinter
;
bool
bDelPrinter
;
Reference
<
XBreakIterator
>
xBreak
;
std
::
vector
<
sal_uIntPtr
>
aTextWidth
;
std
::
deque
<
sal_Int32
>
aScriptChg
;
std
::
vector
<
sal_uInt16
>
aScriptType
;
SvxFont
aCJKFont
;
SvxFont
aCTLFont
;
OUString
aText
;
OUString
aScriptText
;
Color
*
pColor
;
Color
*
pBackColor
;
long
nAscent
;
sal_Unicode
cStartBracket
;
sal_Unicode
cEndBracket
;
long
n100PercentFontWidth
;
// initial -1 -> not set yet
long
n100PercentFontWidthCJK
;
long
n100PercentFontWidthCTL
;
sal_uInt16
nFontWidthScale
;
bool
bSelection
:
1
,
bGetSelection
:
1
,
bUseResText
:
1
,
bPreviewBackgroundToCharacter
:
1
,
bTwoLines
:
1
,
bUseFontNameAsText
:
1
,
bTextInited
:
1
;
SvxFont
m
aFont
;
VclPtr
<
Printer
>
m
pPrinter
;
bool
m
bDelPrinter
;
Reference
<
XBreakIterator
>
m
xBreak
;
std
::
vector
<
sal_uIntPtr
>
m
aTextWidth
;
std
::
deque
<
sal_Int32
>
m
aScriptChg
;
std
::
vector
<
sal_uInt16
>
m
aScriptType
;
SvxFont
m
aCJKFont
;
SvxFont
m
aCTLFont
;
OUString
m
aText
;
OUString
m
aScriptText
;
Color
*
m
pColor
;
Color
*
m
pBackColor
;
long
m
nAscent
;
sal_Unicode
m
cStartBracket
;
sal_Unicode
m
cEndBracket
;
long
mn100PercentFontWidth
;
// initial -1 -> not set yet
long
m
n100PercentFontWidthCJK
;
long
m
n100PercentFontWidthCTL
;
sal_uInt16
m
nFontWidthScale
;
bool
mbSelection
:
1
;
bool
mbGetSelection
:
1
;
bool
mbUseResText
:
1
;
bool
mbPreviewBackgroundToCharacter
:
1
;
bool
mbTwoLines
:
1
;
bool
mbUseFontNameAsText
:
1
;
bool
mbTextInited
:
1
;
bool
m_bCJKEnabled
;
bool
m_bCTLEnabled
;
...
...
@@ -164,12 +164,21 @@ class FontPrevWin_Impl
public
:
inline
FontPrevWin_Impl
()
:
pPrinter
(
NULL
),
bDelPrinter
(
false
),
pColor
(
NULL
),
pBackColor
(
0
),
nAscent
(
0
),
cStartBracket
(
0
),
cEndBracket
(
0
),
nFontWidthScale
(
100
),
bSelection
(
false
),
bGetSelection
(
false
),
bUseResText
(
false
),
bPreviewBackgroundToCharacter
(
false
),
bTwoLines
(
false
),
bUseFontNameAsText
(
false
),
bTextInited
(
false
)
mpPrinter
(
nullptr
),
mbDelPrinter
(
false
),
mpColor
(
nullptr
),
mpBackColor
(
0
),
mnAscent
(
0
),
mcStartBracket
(
0
),
mcEndBracket
(
0
),
mnFontWidthScale
(
100
),
mbSelection
(
false
),
mbGetSelection
(
false
),
mbUseResText
(
false
),
mbPreviewBackgroundToCharacter
(
false
),
mbTwoLines
(
false
),
mbUseFontNameAsText
(
false
),
mbTextInited
(
false
)
{
SvtLanguageOptions
aLanguageOptions
;
m_bCJKEnabled
=
aLanguageOptions
.
IsAnyEnabled
();
...
...
@@ -180,37 +189,37 @@ public:
inline
~
FontPrevWin_Impl
()
{
delete
pColor
;
delete
pBackColor
;
if
(
bDelPrinter
)
pPrinter
.
disposeAndClear
();
delete
m
pColor
;
delete
m
pBackColor
;
if
(
mbDelPrinter
)
m
pPrinter
.
disposeAndClear
();
}
void
CheckScript
();
Size
CalcTextSize
(
OutputDevice
*
pWin
,
OutputDevice
*
pPrt
,
const
SvxFont
&
rFont
);
void
DrawPrev
(
OutputDevice
*
pWin
,
Printer
*
pPrt
,
Point
&
rPt
,
const
SvxFont
&
rFont
);
void
CheckScript
();
Size
CalcTextSize
(
vcl
::
RenderContext
&
rRenderContext
,
OutputDevice
*
pPrinter
,
const
SvxFont
&
rFont
);
void
DrawPrev
(
vcl
::
RenderContext
&
rRenderContext
,
Printer
*
pPrinter
,
Point
&
rPt
,
const
SvxFont
&
rFont
);
bool
SetFontWidthScale
(
sal_uInt16
nScaleInPercent
);
inline
void
Invalidate100PercentFontWidth
();
inline
bool
Is100PercentFontWidthValid
()
const
;
void
ScaleFontWidth
(
const
OutputDevice
&
rOutDev
);
bool
SetFontWidthScale
(
sal_uInt16
nScaleInPercent
);
inline
void
Invalidate100PercentFontWidth
();
inline
bool
Is100PercentFontWidthValid
()
const
;
void
ScaleFontWidth
(
vcl
::
RenderContext
&
rRenderContext
);
// scales rNonCJKFont and aCJKFont depending on nFontWidthScale and
//
sets the 100%-Font-Widths
// sets the 100%-Font-Widths
};
inline
void
FontPrevWin_Impl
::
Invalidate100PercentFontWidth
()
{
n100PercentFontWidth
=
n100PercentFontWidthCJK
=
n100PercentFontWidthCTL
=
-
1
;
mn100PercentFontWidth
=
mn100PercentFontWidthCJK
=
m
n100PercentFontWidthCTL
=
-
1
;
}
inline
bool
FontPrevWin_Impl
::
Is100PercentFontWidthValid
()
const
{
DBG_ASSERT
(
(
n100PercentFontWidth
==
-
1
&&
n100PercentFontWidthCJK
==
-
1
)
||
(
n100PercentFontWidth
!=
-
1
&&
n100PercentFontWidthCJK
!=
-
1
)
||
(
n100PercentFontWidth
==
-
1
&&
n100PercentFontWidthCTL
==
-
1
)
||
(
n100PercentFontWidth
!=
-
1
&&
n100PercentFontWidthCTL
!=
-
1
),
DBG_ASSERT
(
(
mn100PercentFontWidth
==
-
1
&&
m
n100PercentFontWidthCJK
==
-
1
)
||
(
mn100PercentFontWidth
!=
-
1
&&
m
n100PercentFontWidthCJK
!=
-
1
)
||
(
mn100PercentFontWidth
==
-
1
&&
m
n100PercentFontWidthCTL
==
-
1
)
||
(
mn100PercentFontWidth
!=
-
1
&&
m
n100PercentFontWidthCTL
!=
-
1
),
"*FontPrevWin_Impl::Is100PercentFontWidthValid(): 100PercentFontWidth's not synchronous"
);
return
n100PercentFontWidth
!=
-
1
;
return
m
n100PercentFontWidth
!=
-
1
;
}
/*
...
...
@@ -221,52 +230,52 @@ inline bool FontPrevWin_Impl::Is100PercentFontWidthValid() const
*/
void
FontPrevWin_Impl
::
CheckScript
()
{
assert
(
!
aText
.
isEmpty
());
// must have a preview text here!
if
(
aText
==
aScriptText
)
assert
(
!
m
aText
.
isEmpty
());
// must have a preview text here!
if
(
maText
==
m
aScriptText
)
{
return
;
// already initialized
}
aScriptText
=
aText
;
maScriptText
=
m
aText
;
aScriptChg
.
clear
();
aScriptType
.
clear
();
aTextWidth
.
clear
();
m
aScriptChg
.
clear
();
m
aScriptType
.
clear
();
m
aTextWidth
.
clear
();
if
(
!
xBreak
.
is
()
)
if
(
!
mxBreak
.
is
()
)
{
Reference
<
XComponentContext
>
xContext
=
::
comphelper
::
getProcessComponentContext
();
xBreak
=
BreakIterator
::
create
(
xContext
);
Reference
<
XComponentContext
>
xContext
=
::
comphelper
::
getProcessComponentContext
();
m
xBreak
=
BreakIterator
::
create
(
xContext
);
}
sal_uInt16
nScript
=
0
;
sal_Int32
nChg
=
0
;
while
(
nChg
<
aText
.
getLength
()
)
while
(
nChg
<
maText
.
getLength
()
)
{
nScript
=
xBreak
->
getScriptType
(
aText
,
nChg
);
nChg
=
xBreak
->
endOfScript
(
aText
,
nChg
,
nScript
);
if
(
nChg
<
aText
.
getLength
()
&&
nChg
>
0
&&
(
c
om
::
sun
::
star
::
i18n
::
ScriptType
::
WEAK
==
xBreak
->
getScriptType
(
aText
,
nChg
-
1
)))
nScript
=
mxBreak
->
getScriptType
(
maText
,
nChg
);
nChg
=
mxBreak
->
endOfScript
(
maText
,
nChg
,
nScript
);
if
(
nChg
<
m
aText
.
getLength
()
&&
nChg
>
0
&&
(
c
ss
::
i18n
::
ScriptType
::
WEAK
==
mxBreak
->
getScriptType
(
m
aText
,
nChg
-
1
)))
{
int8_t
nType
=
u_charType
(
aText
[
nChg
]
);
int8_t
nType
=
u_charType
(
maText
[
nChg
]
);
if
(
nType
==
U_NON_SPACING_MARK
||
nType
==
U_ENCLOSING_MARK
||
nType
==
U_COMBINING_SPACING_MARK
)
nType
==
U_COMBINING_SPACING_MARK
)
{
aScriptChg
.
push_back
(
nChg
-
1
);
maScriptChg
.
push_back
(
nChg
-
1
);
}
else
{
aScriptChg
.
push_back
(
nChg
);
maScriptChg
.
push_back
(
nChg
);
}
}
else
{
aScriptChg
.
push_back
(
nChg
);
maScriptChg
.
push_back
(
nChg
);
}
aScriptType
.
push_back
(
nScript
);
aTextWidth
.
push_back
(
0
);
maScriptType
.
push_back
(
nScript
);
maTextWidth
.
push_back
(
0
);
}
}
...
...
@@ -280,77 +289,88 @@ void FontPrevWin_Impl::CheckScript()
* The member nAscent is calculated to the maximal ascent of all used fonts.
*/
Size
FontPrevWin_Impl
::
CalcTextSize
(
OutputDevice
*
pWin
,
OutputDevice
*
_pPrinter
,
const
SvxFont
&
rFont
)
Size
FontPrevWin_Impl
::
CalcTextSize
(
vcl
::
RenderContext
&
rRenderContext
,
OutputDevice
*
_pPrinter
,
const
SvxFont
&
rInFont
)
{
sal_uInt16
nScript
;
sal_uInt16
nIdx
=
0
;
sal_Int32
nStart
=
0
;
sal_Int32
nEnd
;
size_t
nCnt
=
aScriptChg
.
size
();
if
(
nCnt
)
size_t
nCnt
=
maScriptChg
.
size
();
if
(
nCnt
)
{
nEnd
=
aScriptChg
[
nIdx
];
nScript
=
aScriptType
[
nIdx
];
nEnd
=
maScriptChg
[
nIdx
];
nScript
=
maScriptType
[
nIdx
];
}
else
{
nEnd
=
aText
.
getLength
();
nScript
=
c
om
::
sun
::
star
::
i18n
::
ScriptType
::
LATIN
;
nEnd
=
m
aText
.
getLength
();
nScript
=
c
ss
::
i18n
::
ScriptType
::
LATIN
;
}
long
nTxtWidth
=
0
;
long
nCJKHeight
=
0
;
long
nCTLHeight
=
0
;
long
nHeight
=
0
;
nAscent
=
0
;
m
nAscent
=
0
;
long
nCJKAscent
=
0
;
long
nCTLAscent
=
0
;
do
{
const
SvxFont
&
rFnt
=
(
nScript
==
com
::
sun
::
star
::
i18n
::
ScriptType
::
ASIAN
)
?
aCJKFont
:
((
nScript
==
com
::
sun
::
star
::
i18n
::
ScriptType
::
COMPLEX
)
?
aCTLFont
:
rFont
);
sal_uIntPtr
nWidth
=
rFnt
.
GetTxtSize
(
_pPrinter
,
aText
,
nStart
,
nEnd
-
nStart
).
Width
();
if
(
nIdx
>=
aTextWidth
.
size
())
const
SvxFont
&
rFont
=
(
nScript
==
css
::
i18n
::
ScriptType
::
ASIAN
)
?
maCJKFont
:
((
nScript
==
css
::
i18n
::
ScriptType
::
COMPLEX
)
?
maCTLFont
:
rInFont
);
sal_uIntPtr
nWidth
=
rFont
.
GetTxtSize
(
_pPrinter
,
maText
,
nStart
,
nEnd
-
nStart
).
Width
();
if
(
nIdx
>=
maTextWidth
.
size
())
break
;
aTextWidth
[
nIdx
++
]
=
nWidth
;
maTextWidth
[
nIdx
++
]
=
nWidth
;
nTxtWidth
+=
nWidth
;
switch
(
nScript
)
switch
(
nScript
)
{
case
c
om
:
:
sun
::
star
::
i18n
::
ScriptType
::
ASIAN
:
calcFontHeightAnyAscent
(
pWin
,
aCJKFont
,
nCJKHeight
,
nCJKAscent
);
case
c
ss
:
:
i18n
::
ScriptType
::
ASIAN
:
calcFontHeightAnyAscent
(
rRenderContext
,
maCJKFont
,
nCJKHeight
,
nCJKAscent
);
break
;
case
c
om
:
:
sun
::
star
::
i18n
::
ScriptType
::
COMPLEX
:
calcFontHeightAnyAscent
(
pWin
,
aCTLFont
,
nCTLHeight
,
nCTLAscent
);
case
c
ss
:
:
i18n
::
ScriptType
::
COMPLEX
:
calcFontHeightAnyAscent
(
rRenderContext
,
maCTLFont
,
nCTLHeight
,
nCTLAscent
);
break
;
default
:
calcFontHeightAnyAscent
(
pWin
,
rFont
,
nHeight
,
nAscent
);
calcFontHeightAnyAscent
(
rRenderContext
,
rFont
,
nHeight
,
m
nAscent
);
}
if
(
nEnd
<
aText
.
getLength
()
&&
nIdx
<
nCnt
)
if
(
nEnd
<
maText
.
getLength
()
&&
nIdx
<
nCnt
)
{
nStart
=
nEnd
;
nEnd
=
aScriptChg
[
nIdx
];
nScript
=
aScriptType
[
nIdx
];
nEnd
=
maScriptChg
[
nIdx
];
nScript
=
maScriptType
[
nIdx
];
}
else
break
;
}
while
(
true
);
nHeight
-=
nAscent
;
while
(
true
);
nHeight
-=
mnAscent
;
nCJKHeight
-=
nCJKAscent
;
nCTLHeight
-=
nCTLAscent
;
if
(
nHeight
<
nCJKHeight
)
if
(
nHeight
<
nCJKHeight
)
nHeight
=
nCJKHeight
;
if
(
nAscent
<
nCJKAscent
)
nAscent
=
nCJKAscent
;
if
(
nHeight
<
nCTLHeight
)
if
(
mnAscent
<
nCJKAscent
)
mnAscent
=
nCJKAscent
;
if
(
nHeight
<
nCTLHeight
)
nHeight
=
nCTLHeight
;
if
(
nAscent
<
nCTLAscent
)
nAscent
=
nCTLAscent
;
nHeight
+=
nAscent
;
Size
aTxtSize
(
nTxtWidth
,
nHeight
);
if
(
mnAscent
<
nCTLAscent
)
mnAscent
=
nCTLAscent
;
nHeight
+=
mnAscent
;
Size
aTxtSize
(
nTxtWidth
,
nHeight
);
return
aTxtSize
;
}
...
...
@@ -361,131 +381,143 @@ Size FontPrevWin_Impl::CalcTextSize( OutputDevice* pWin, OutputDevice* _pPrinter
* given rFont.
*/
void
FontPrevWin_Impl
::
DrawPrev
(
OutputDevice
*
pWin
,
Printer
*
_pPrinter
,
Point
&
rPt
,
const
SvxFont
&
rFont
)
void
FontPrevWin_Impl
::
DrawPrev
(
vcl
::
RenderContext
&
rRenderContext
,
Printer
*
_pPrinter
,
Point
&
rPt
,
const
SvxFont
&
rInFont
)
{
vcl
::
Font
aOldFont
=
_pPrinter
->
GetFont
();
sal_uInt16
nScript
;
sal_uInt16
nIdx
=
0
;
sal_Int32
nStart
=
0
;
sal_Int32
nEnd
;
size_t
nCnt
=
aScriptChg
.
size
();
if
(
nCnt
)
size_t
nCnt
=
m
aScriptChg
.
size
();
if
(
nCnt
)
{
nEnd
=
aScriptChg
[
nIdx
];
nScript
=
aScriptType
[
nIdx
];
nEnd
=
maScriptChg
[
nIdx
];
nScript
=
maScriptType
[
nIdx
];
}
else
{
nEnd
=
aText
.
getLength
();
nScript
=
c
om
::
sun
::
star
::
i18n
::
ScriptType
::
LATIN
;
nEnd
=
m
aText
.
getLength
();
nScript
=
c
ss
::
i18n
::
ScriptType
::
LATIN
;
}
do
{
const
SvxFont
&
rFnt
=
(
nScript
==
com
::
sun
::
star
::
i18n
::
ScriptType
::
ASIAN
)
?
aCJKFont
:
((
nScript
==
com
::
sun
::
star
::
i18n
::
ScriptType
::
COMPLEX
)
?
aCTLFont
:
rFont
);
_pPrinter
->
SetFont
(
rFnt
);
const
SvxFont
&
rFont
=
(
nScript
==
css
::
i18n
::
ScriptType
::
ASIAN
)
?
maCJKFont
:
((
nScript
==
css
::
i18n
::
ScriptType
::
COMPLEX
)
?
maCTLFont
:
rInFont
);
_pPrinter
->
SetFont
(
rFont
);
rF
nt
.
DrawPrev
(
pWin
,
_pPrinter
,
rPt
,
aText
,
nStart
,
nEnd
-
nStart
);
rF
ont
.
DrawPrev
(
&
rRenderContext
,
_pPrinter
,
rPt
,
maText
,
nStart
,
nEnd
-
nStart
);
rPt
.
X
()
+=
aTextWidth
[
nIdx
++
];
if
(
nEnd
<
aText
.
getLength
()
&&
nIdx
<
nCnt
)
rPt
.
X
()
+=
maTextWidth
[
nIdx
++
];
if
(
nEnd
<
maText
.
getLength
()
&&
nIdx
<
nCnt
)
{
nStart
=
nEnd
;
nEnd
=
aScriptChg
[
nIdx
];
nScript
=
aScriptType
[
nIdx
];
nEnd
=
maScriptChg
[
nIdx
];
nScript
=
maScriptType
[
nIdx
];
}
else
break
;
}
while
(
true
);
_pPrinter
->
SetFont
(
aOldFont
);
while
(
true
);
_pPrinter
->
SetFont
(
aOldFont
);
}
bool
FontPrevWin_Impl
::
SetFontWidthScale
(
sal_uInt16
nScale
)
bool
FontPrevWin_Impl
::
SetFontWidthScale
(
sal_uInt16
nScale
)
{
if
(
nFontWidthScale
!=
nScale
)
if
(
mnFontWidthScale
!=
nScale
)
{
nFontWidthScale
=
nScale
;
m
nFontWidthScale
=
nScale
;
return
true
;
}
return
false
;
}
void
FontPrevWin_Impl
::
ScaleFontWidth
(
const
OutputDevice
&
rOutDev
)
void
FontPrevWin_Impl
::
ScaleFontWidth
(
vcl
::
RenderContext
&
rOutDev
)
{
if
(
!
Is100PercentFontWidthValid
()
)
if
(
!
Is100PercentFontWidthValid
()
)
{
scaleFontWidth
(
aFont
,
rOutDev
,
n100PercentFontWidth
);
scaleFontWidth
(
aCJKFont
,
rOutDev
,
n100PercentFontWidthCJK
);
scaleFontWidth
(
aCTLFont
,
rOutDev
,
n100PercentFontWidthCTL
);
scaleFontWidth
(
maFont
,
rOutDev
,
m
n100PercentFontWidth
);
scaleFontWidth
(
maCJKFont
,
rOutDev
,
m
n100PercentFontWidthCJK
);
scaleFontWidth
(
maCTLFont
,
rOutDev
,
m
n100PercentFontWidthCTL
);
}
aFont
.
SetWidth
(
n100PercentFontWidth
*
nFontWidthScale
/
100
);
aCJKFont
.
SetWidth
(
n100PercentFontWidthCJK
*
nFontWidthScale
/
100
);
aCTLFont
.
SetWidth
(
n100PercentFontWidthCTL
*
nFontWidthScale
/
100
);
maFont
.
SetWidth
(
mn100PercentFontWidth
*
mnFontWidthScale
/
100
);
maCJKFont
.
SetWidth
(
mn100PercentFontWidthCJK
*
mnFontWidthScale
/
100
);
maCTLFont
.
SetWidth
(
mn100PercentFontWidthCTL
*
mnFontWidthScale
/
100
);
}
void
SvxFontPrevWindow
::
ResetSettings
(
bool
bForeground
,
bool
bBackground
)
{
mbResetForeground
=
bForeground
;
mbResetBackground
=
bBackground
;
Invalidate
();
}
void
SvxFontPrevWindow
::
InitSettings
(
bool
bForeground
,
bool
bBackground
)
void
SvxFontPrevWindow
::
ApplySettings
(
vcl
::
RenderContext
&
rRenderContext
)
{
const
StyleSettings
&
rStyleSettings
=
Application
::
GetSettings
().
GetStyleSettings
();
if
(
bForeground
)
if
(
mbResetForeground
)
{
svtools
::
ColorConfig
aColorConfig
;
Color
aTextColor
(
aColorConfig
.
GetColorValue
(
svtools
::
FONTCOLOR
).
nColor
);
Color
aTextColor
(
aColorConfig
.
GetColorValue
(
svtools
::
FONTCOLOR
).
nColor
);
if
(
IsControlForeground
()
)
if
(
IsControlForeground
()
)
aTextColor
=
GetControlForeground
();
SetTextColor
(
aTextColor
);
rRenderContext
.
SetTextColor
(
aTextColor
);
mbResetForeground
=
false
;
}
if
(
bBackground
)
if
(
mbResetBackground
)
{
if
(
IsControlBackground
()
)
SetBackground
(
GetControlBackground
()
);
if
(
IsControlBackground
()
)
rRenderContext
.
SetBackground
(
GetControlBackground
()
);
else
SetBackground
(
rStyleSettings
.
GetWindowColor
()
);
rRenderContext
.
SetBackground
(
rStyleSettings
.
GetWindowColor
());
mbResetBackground
=
false
;
}
Invalidate
();
}
void
SvxFontPrevWindow
::
Init
()
{
pImpl
=
new
FontPrevWin_Impl
;
pImpl
.
reset
(
new
FontPrevWin_Impl
)
;
SfxViewShell
*
pSh
=
SfxViewShell
::
Current
();
if
(
pSh
)
pImpl
->
pPrinter
=
pSh
->
GetPrinter
();
if
(
pSh
)
pImpl
->
m
pPrinter
=
pSh
->
GetPrinter
();
if
(
!
pImpl
->
pPrinter
)
if
(
!
pImpl
->
mpPrinter
)
{
pImpl
->
pPrinter
=
new
Printer
;
pImpl
->
bDelPrinter
=
true
;
pImpl
->
m
pPrinter
=
new
Printer
;
pImpl
->
m
bDelPrinter
=
true
;
}
SetMapMode
(
MapMode
(
MAP_TWIP
)
);
initFont
(
pImpl
->
aFont
);
initFont
(
pImpl
->
aCJKFont
);
initFont
(
pImpl
->
aCTLFont
);
InitSettings
(
true
,
true
);
SetBorderStyle
(
WindowBorderStyle
::
MONO
);
SetMapMode
(
MapMode
(
MAP_TWIP
));
initFont
(
pImpl
->
maFont
);
initFont
(
pImpl
->
maCJKFont
);
initFont
(
pImpl
->
maCTLFont
);
ResetSettings
(
true
,
true
);
SetBorderStyle
(
WindowBorderStyle
::
MONO
);
}
SvxFontPrevWindow
::
SvxFontPrevWindow
(
vcl
::
Window
*
pParent
,
const
ResId
&
rId
)
:
Window
(
pParent
,
rId
)
SvxFontPrevWindow
::
SvxFontPrevWindow
(
vcl
::
Window
*
pParent
,
const
ResId
&
rId
)
:
Window
(
pParent
,
rId
)
,
mbResetForeground
(
true
)
,
mbResetBackground
(
true
)
{
Init
();
}
SvxFontPrevWindow
::
SvxFontPrevWindow
(
vcl
::
Window
*
pParent
,
WinBits
nStyle
)
:
Window
(
pParent
,
nStyle
)
,
mbResetForeground
(
true
)
,
mbResetBackground
(
true
)
{
Init
();
}
...
...
@@ -506,42 +538,35 @@ SvxFontPrevWindow::~SvxFontPrevWindow()
void
SvxFontPrevWindow
::
dispose
()
{
delete
pImpl
;
pImpl
.
reset
()
;
vcl
::
Window
::
dispose
();
}
SvxFont
&
SvxFontPrevWindow
::
GetCTLFont
()
{
return
pImpl
->
aCTLFont
;
return
pImpl
->
m
aCTLFont
;
}
SvxFont
&
SvxFontPrevWindow
::
GetCJKFont
()
{
return
pImpl
->
aCJKFont
;
return
pImpl
->
m
aCJKFont
;
}
void
SvxFontPrevWindow
::
StateChanged
(
StateChangedType
nType
)
{
if
(
nType
==
StateChangedType
::
ControlForeground
)
InitSettings
(
true
,
false
);
else
if
(
nType
==
StateChangedType
::
ControlBackground
)
InitSettings
(
false
,
true
);
if
(
nType
==
StateChangedType
::
ControlForeground
)
ResetSettings
(
true
,
false
);
else
if
(
nType
==
StateChangedType
::
ControlBackground
)
ResetSettings
(
false
,
true
);
Window
::
StateChanged
(
nType
);
Window
::
StateChanged
(
nType
);
Invalidate
();
}
void
SvxFontPrevWindow
::
DataChanged
(
const
DataChangedEvent
&
rDCEvt
)
{
if
(
(
rDCEvt
.
GetType
()
==
DataChangedEventType
::
SETTINGS
)
&&
(
rDCEvt
.
GetFlags
()
&
AllSettingsFlags
::
STYLE
)
)
InitSettings
(
true
,
true
);
if
(
(
rDCEvt
.
GetType
()
==
DataChangedEventType
::
SETTINGS
)
&&
(
rDCEvt
.
GetFlags
()
&
AllSettingsFlags
::
STYLE
)
)
ResetSettings
(
true
,
true
);
else
Window
::
DataChanged
(
rDCEvt
);
}
...
...
@@ -549,333 +574,312 @@ void SvxFontPrevWindow::DataChanged( const DataChangedEvent& rDCEvt )
SvxFont
&
SvxFontPrevWindow
::
GetFont
()
{
pImpl
->
Invalidate100PercentFontWidth
();
// because the user might change the size
return
pImpl
->
aFont
;
return
pImpl
->
m
aFont
;
}
const
SvxFont
&
SvxFontPrevWindow
::
GetFont
()
const
{
return
pImpl
->
aFont
;
return
pImpl
->
m
aFont
;
}
void
SvxFontPrevWindow
::
SetPreviewText
(
const
OUString
&
rString
)
{
pImpl
->
aText
=
rString
;
pImpl
->
bTextInited
=
true
;
pImpl
->
m
aText
=
rString
;
pImpl
->
m
bTextInited
=
true
;
}
void
SvxFontPrevWindow
::
SetFontNameAsPreviewText
()
{
pImpl
->
bUseFontNameAsText
=
true
;
pImpl
->
m
bUseFontNameAsText
=
true
;
}
void
SvxFontPrevWindow
::
SetFont
(
const
SvxFont
&
rNormalOutFont
,
const
SvxFont
&
rCJKOutFont
,
const
SvxFont
&
rCTLFont
)
{
setFont
(
rNormalOutFont
,
pImpl
->
aFont
);
setFont
(
rCJKOutFont
,
pImpl
->
aCJKFont
);
setFont
(
rCTLFont
,
pImpl
->
aCTLFont
);
setFont
(
rNormalOutFont
,
pImpl
->
maFont
);
setFont
(
rCJKOutFont
,
pImpl
->
maCJKFont
);
setFont
(
rCTLFont
,
pImpl
->
maCTLFont
);
pImpl
->
Invalidate100PercentFontWidth
();
Invalidate
();
}
void
SvxFontPrevWindow
::
SetColor
(
const
Color
&
rColor
)
{
delete
pImpl
->
pColor
;
pImpl
->
pColor
=
new
Color
(
rColor
);
delete
pImpl
->
m
pColor
;
pImpl
->
mpColor
=
new
Color
(
rColor
);
Invalidate
();
}
void
SvxFontPrevWindow
::
ResetColor
()
{
delete
pImpl
->
pColor
;
pImpl
->
pColor
=
0
;
delete
pImpl
->
m
pColor
;
pImpl
->
m
pColor
=
0
;
Invalidate
();
}
void
SvxFontPrevWindow
::
SetBackColor
(
const
Color
&
rColor
)
{
delete
pImpl
->
pBackColor
;
pImpl
->
pBackColor
=
new
Color
(
rColor
);
delete
pImpl
->
m
pBackColor
;
pImpl
->
mpBackColor
=
new
Color
(
rColor
);
Invalidate
();
}
void
SvxFontPrevWindow
::
UseResourceText
(
bool
bUse
)
void
SvxFontPrevWindow
::
UseResourceText
(
bool
bUse
)
{
pImpl
->
bUseResText
=
bUse
;
pImpl
->
m
bUseResText
=
bUse
;
}
void
SvxFontPrevWindow
::
Paint
(
vcl
::
RenderContext
&
/*rRenderContext*/
,
const
Rectangle
&
)
void
SvxFontPrevWindow
::
Paint
(
vcl
::
RenderContext
&
rRenderContext
,
const
Rectangle
&
)
{
Printer
*
pPrinter
=
pImpl
->
pPrinter
;
const
SvxFont
&
rFont
=
pImpl
->
aFont
;
const
SvxFont
&
rCJKFont
=
pImpl
->
aCJKFont
;
const
SvxFont
&
rCTLFont
=
pImpl
->
aCTLFont
;
ApplySettings
(
rRenderContext
);
if
(
!
IsEnabled
()
)
Printer
*
pPrinter
=
pImpl
->
mpPrinter
;
const
SvxFont
&
rFont
=
pImpl
->
maFont
;
const
SvxFont
&
rCJKFont
=
pImpl
->
maCJKFont
;
const
SvxFont
&
rCTLFont
=
pImpl
->
maCTLFont
;
if
(
!
IsEnabled
())
{
const
StyleSettings
&
rStyleSettings
=
Application
::
GetSettings
().
GetStyleSettings
();
const
Size
aLogSize
(
GetOutputSize
()
);
const
Size
aLogSize
(
rRenderContext
.
GetOutputSize
()
);
Rectangle
aRect
(
Point
(
0
,
0
),
aLogSize
);
SetLineColor
();
SetFillColor
(
rStyleSettings
.
GetWindowColor
()
);
DrawRect
(
aRect
);
Rectangle
aRect
(
Point
(
0
,
0
),
aLogSize
);
rRenderContext
.
SetLineColor
();
rRenderContext
.
SetFillColor
(
rStyleSettings
.
GetWindowColor
()
);
rRenderContext
.
DrawRect
(
aRect
);
}
else
{
if
(
pImpl
->
bUseResText
)
pImpl
->
aText
=
GetText
();
else
if
(
!
pImpl
->
bSelection
&&
!
pImpl
->
bTextInited
)
if
(
pImpl
->
mbUseResText
)
pImpl
->
m
aText
=
GetText
();
else
if
(
!
pImpl
->
mbSelection
&&
!
pImpl
->
mbTextInited
)
{
using
namespace
c
om
::
sun
::
star
::
i18n
::
ScriptType
;
using
namespace
c
ss
::
i18n
::
ScriptType
;
SfxViewShell
*
pSh
=
SfxViewShell
::
Current
();
if
(
pSh
&&
!
pImpl
->
bGetSelection
&&
!
pImpl
->
bUseFontNameAsText
)
if
(
pSh
&&
!
pImpl
->
mbGetSelection
&&
!
pImpl
->
mbUseFontNameAsText
)
{
pImpl
->
aText
=
pSh
->
GetSelectionText
();
pImpl
->
bGetSelection
=
true
;
pImpl
->
bSelection
=
!
pImpl
->
aText
.
isEmpty
();
pImpl
->
maText
=
pSh
->
GetSelectionText
();
pImpl
->
mbGetSelection
=
true
;
pImpl
->
mbSelection
=
!
pImpl
->
maText
.
isEmpty
();
}
if
(
!
pImpl
->
bSelection
||
pImpl
->
bUseFontNameAsText
)
if
(
!
pImpl
->
mbSelection
||
pImpl
->
mbUseFontNameAsText
)
{
//If we're showing multiple sample texts, then they're all
//sample texts. If only showing Latin, continue to use
//the fontname as the preview
if
((
pImpl
->
m_bCJKEnabled
)
||
(
pImpl
->
m_bCTLEnabled
))
pImpl
->
aText
=
makeRepresentativeTextForFont
(
LATIN
,
rFont
);
pImpl
->
m
aText
=
makeRepresentativeTextForFont
(
LATIN
,
rFont
);
else
pImpl
->
aText
=
rFont
.
GetName
();
pImpl
->
m
aText
=
rFont
.
GetName
();
if
(
pImpl
->
m_bCJKEnabled
)
{
if
(
!
pImpl
->
aText
.
isEmpty
())
pImpl
->
aText
+=
" "
;
pImpl
->
aText
+=
makeRepresentativeTextForFont
(
ASIAN
,
rCJKFont
);
if
(
!
pImpl
->
m
aText
.
isEmpty
())
pImpl
->
m
aText
+=
" "
;
pImpl
->
m
aText
+=
makeRepresentativeTextForFont
(
ASIAN
,
rCJKFont
);
}
if
(
pImpl
->
m_bCTLEnabled
)
{
if
(
!
pImpl
->
aText
.
isEmpty
())
pImpl
->
aText
+=
" "
;
pImpl
->
aText
+=
makeRepresentativeTextForFont
(
COMPLEX
,
rCTLFont
);
if
(
!
pImpl
->
m
aText
.
isEmpty
())
pImpl
->
m
aText
+=
" "
;
pImpl
->
m
aText
+=
makeRepresentativeTextForFont
(
COMPLEX
,
rCTLFont
);
}
}
if
(
pImpl
->
aText
.
isEmpty
()
)
pImpl
->
aText
=
GetText
();
if
(
pImpl
->
maText
.
isEmpty
()
)
pImpl
->
m
aText
=
GetText
();
if
(
pImpl
->
aText
.
isEmpty
())
if
(
pImpl
->
m
aText
.
isEmpty
())
{
// fdo#58427: still no text? let's try that one...
pImpl
->
aText
=
makeRepresentativeTextForFont
(
LATIN
,
rFont
);
pImpl
->
m
aText
=
makeRepresentativeTextForFont
(
LATIN
,
rFont
);
}
// remove line feeds and carriage returns from string
bool
bNotEmpty
=
false
;
for
(
sal_Int32
i
=
0
;
i
<
pImpl
->
aText
.
getLength
();
++
i
)
for
(
sal_Int32
i
=
0
;
i
<
pImpl
->
maText
.
getLength
();
++
i
)
{
if
(
0xa
==
pImpl
->
aText
[
i
]
||
0xd
==
pImpl
->
aText
[
i
]
)
pImpl
->
aText
=
pImpl
->
aText
.
replaceAt
(
i
,
1
,
" "
);
if
(
0xa
==
pImpl
->
maText
[
i
]
||
0xd
==
pImpl
->
maText
[
i
]
)
pImpl
->
maText
=
pImpl
->
maText
.
replaceAt
(
i
,
1
,
" "
);
else
bNotEmpty
=
true
;
}
if
(
!
bNotEmpty
)
pImpl
->
aText
=
GetText
();
if
(
!
bNotEmpty
)
pImpl
->
m
aText
=
GetText
();
if
(
pImpl
->
aText
.
getLength
()
>
(
TEXT_WIDTH
-
1
)
)
if
(
pImpl
->
maText
.
getLength
()
>
(
TEXT_WIDTH
-
1
)
)
{
sal_Int32
nSpaceIdx
=
pImpl
->
aText
.
indexOf
(
" "
,
TEXT_WIDTH
);
sal_Int32
nSpaceIdx
=
pImpl
->
m
aText
.
indexOf
(
" "
,
TEXT_WIDTH
);
if
(
nSpaceIdx
!=
-
1
)
pImpl
->
aText
=
pImpl
->
aText
.
copy
(
0
,
nSpaceIdx
);
pImpl
->
maText
=
pImpl
->
m
aText
.
copy
(
0
,
nSpaceIdx
);
}
}
// calculate text width scaling
pImpl
->
ScaleFontWidth
(
*
this
/*, rFont*/
);
pImpl
->
ScaleFontWidth
(
rRenderContext
);
pImpl
->
CheckScript
();
Size
aTxtSize
=
pImpl
->
CalcTextSize
(
this
,
pPrinter
,
rFont
);
Size
aTxtSize
=
pImpl
->
CalcTextSize
(
rRenderContext
,
pPrinter
,
rFont
);
const
Size
aLogSize
(
GetOutputSize
()
);
const
Size
aLogSize
(
rRenderContext
.
GetOutputSize
()
);
long
nX
=
aLogSize
.
Width
()
/
2
-
aTxtSize
.
Width
()
/
2
;
long
nY
=
aLogSize
.
Height
()
/
2
-
aTxtSize
.
Height
()
/
2
;
if
(
nY
+
pImpl
->
nAscent
>
aLogSize
.
Height
()
)
nY
=
aLogSize
.
Height
()
-
pImpl
->
nAscent
;
if
(
nY
+
pImpl
->
mnAscent
>
aLogSize
.
Height
()
)
nY
=
aLogSize
.
Height
()
-
pImpl
->
m
nAscent
;
if
(
pImpl
->
pBackColor
)
if
(
pImpl
->
mpBackColor
)
{
Rectangle
aRect
(
Point
(
0
,
0
),
aLogSize
);
Color
aLineCol
=
GetLineColor
();
Color
aFillCol
=
GetFillColor
();
SetLineColor
();
SetFillColor
(
*
pImpl
->
pBackColor
);
DrawRect
(
aRect
);
SetLineColor
(
aLineCol
);
SetFillColor
(
aFillCol
);
Rectangle
aRect
(
Point
(
0
,
0
),
aLogSize
);
Color
aLineCol
=
rRenderContext
.
GetLineColor
();
Color
aFillCol
=
rRenderContext
.
GetFillColor
();
rRenderContext
.
SetLineColor
();
rRenderContext
.
SetFillColor
(
*
pImpl
->
mpBackColor
);
rRenderContext
.
DrawRect
(
aRect
);
rRenderContext
.
SetLineColor
(
aLineCol
);
rRenderContext
.
SetFillColor
(
aFillCol
);
}
if
(
pImpl
->
pColor
)
if
(
pImpl
->
mpColor
)
{
Rectangle
aRect
(
Point
(
nX
,
nY
),
aTxtSize
);
Color
aLineCol
=
GetLineColor
();
Color
aFillCol
=
GetFillColor
();
SetLineColor
();
SetFillColor
(
*
pImpl
->
pColor
);
DrawRect
(
aRect
);
SetLineColor
(
aLineCol
);
SetFillColor
(
aFillCol
);
Rectangle
aRect
(
Point
(
nX
,
nY
),
aTxtSize
);
Color
aLineCol
=
rRenderContext
.
GetLineColor
();
Color
aFillCol
=
rRenderContext
.
GetFillColor
();
rRenderContext
.
SetLineColor
();
rRenderContext
.
SetFillColor
(
*
pImpl
->
mpColor
);
rRenderContext
.
DrawRect
(
aRect
);
rRenderContext
.
SetLineColor
(
aLineCol
);
rRenderContext
.
SetFillColor
(
aFillCol
);
}
long
nStdAscent
=
pImpl
->
nAscent
;
long
nStdAscent
=
pImpl
->
m
nAscent
;
nY
+=
nStdAscent
;
if
(
IsTwoLines
())
{
SvxFont
aSmallFont
(
rFont
);
Size
aOldSize
=
pImpl
->
aCJKFont
.
GetSize
();
SvxFont
aSmallFont
(
rFont
);
Size
aOldSize
=
pImpl
->
m
aCJKFont
.
GetSize
();
setFontSize
(
aSmallFont
);
setFontSize
(
pImpl
->
aCJKFont
);
setFontSize
(
pImpl
->
m
aCJKFont
);
long
nStartBracketWidth
=
0
;
long
nEndBracketWidth
=
0
;
long
nTextWidth
=
0
;
if
(
pImpl
->
cStartBracket
)
if
(
pImpl
->
m
cStartBracket
)
{
OUString
sBracket
(
pImpl
->
cStartBracket
);
nStartBracketWidth
=
rFont
.
GetTxtSize
(
pPrinter
,
sBracket
).
Width
();
OUString
sBracket
(
pImpl
->
m
cStartBracket
);
nStartBracketWidth
=
rFont
.
GetTxtSize
(
pPrinter
,
sBracket
).
Width
();
}
if
(
pImpl
->
cEndBracket
)
if
(
pImpl
->
m
cEndBracket
)
{
OUString
sBracket
(
pImpl
->
cEndBracket
);
nEndBracketWidth
=
rFont
.
GetTxtSize
(
pPrinter
,
sBracket
).
Width
();
OUString
sBracket
(
pImpl
->
m
cEndBracket
);
nEndBracketWidth
=
rFont
.
GetTxtSize
(
pPrinter
,
sBracket
).
Width
();
}
nTextWidth
=
pImpl
->
CalcTextSize
(
this
,
pPrinter
,
aSmallFont
).
Width
();
nTextWidth
=
pImpl
->
CalcTextSize
(
rRenderContext
,
pPrinter
,
aSmallFont
).
Width
();
long
nResultWidth
=
nStartBracketWidth
;
nResultWidth
+=
nEndBracketWidth
;
nResultWidth
+=
nTextWidth
;
long
_nX
=
(
aLogSize
.
Width
()
-
nResultWidth
)
/
2
;
DrawLine
(
Point
(
0
,
nY
),
Point
(
_nX
,
nY
)
);
DrawLine
(
Point
(
_nX
+
nResultWidth
,
nY
),
Point
(
aLogSize
.
Width
(),
nY
)
);
rRenderContext
.
DrawLine
(
Point
(
0
,
nY
),
Point
(
_nX
,
nY
)
);
rRenderContext
.
DrawLine
(
Point
(
_nX
+
nResultWidth
,
nY
),
Point
(
aLogSize
.
Width
(),
nY
)
);
long
nSmallAscent
=
pImpl
->
nAscent
;
long
nOffset
=
(
nStdAscent
-
nSmallAscent
)
/
2
;
long
nSmallAscent
=
pImpl
->
m
nAscent
;
long
nOffset
=
(
nStdAscent
-
nSmallAscent
)
/
2
;
if
(
pImpl
->
cStartBracket
)
if
(
pImpl
->
m
cStartBracket
)
{
OUString
sBracket
(
pImpl
->
cStartBracket
);
rFont
.
DrawPrev
(
this
,
pPrinter
,
Point
(
_nX
,
nY
-
nOffset
-
4
),
sBracket
);
OUString
sBracket
(
pImpl
->
m
cStartBracket
);
rFont
.
DrawPrev
(
&
rRenderContext
,
pPrinter
,
Point
(
_nX
,
nY
-
nOffset
-
4
),
sBracket
);
_nX
+=
nStartBracketWidth
;
}
Point
aTmpPoint1
(
_nX
,
nY
-
nSmallAscent
-
2
);
Point
aTmpPoint2
(
_nX
,
nY
);
pImpl
->
DrawPrev
(
this
,
pPrinter
,
aTmpPoint1
,
aSmallFont
);
pImpl
->
DrawPrev
(
this
,
pPrinter
,
aTmpPoint2
,
aSmallFont
);
Point
aTmpPoint1
(
_nX
,
nY
-
nSmallAscent
-
2
);
Point
aTmpPoint2
(
_nX
,
nY
);
pImpl
->
DrawPrev
(
rRenderContext
,
pPrinter
,
aTmpPoint1
,
aSmallFont
);
pImpl
->
DrawPrev
(
rRenderContext
,
pPrinter
,
aTmpPoint2
,
aSmallFont
);
_nX
+=
nTextWidth
;
if
(
pImpl
->
cEndBracket
)
if
(
pImpl
->
m
cEndBracket
)
{
Point
aTmpPoint
(
_nX
+
1
,
nY
-
nOffset
-
4
);
OUString
sBracket
(
pImpl
->
cEndBracket
);
rFont
.
DrawPrev
(
this
,
pPrinter
,
aTmpPoint
,
sBracket
);
OUString
sBracket
(
pImpl
->
m
cEndBracket
);
rFont
.
DrawPrev
(
&
rRenderContext
,
pPrinter
,
aTmpPoint
,
sBracket
);
}
pImpl
->
aCJKFont
.
SetSize
(
aOldSize
);
pImpl
->
maCJKFont
.
SetSize
(
aOldSize
);
}
else
{
Color
aLineCol
=
GetLineColor
();
Color
aLineCol
=
rRenderContext
.
GetLineColor
();
SetLineColor
(
rFont
.
GetColor
()
);
DrawLine
(
Point
(
0
,
nY
),
Point
(
nX
,
nY
)
);
DrawLine
(
Point
(
nX
+
aTxtSize
.
Width
(),
nY
),
Point
(
aLogSize
.
Width
(),
nY
)
);
SetLineColor
(
aLineCol
);
rRenderContext
.
SetLineColor
(
rFont
.
GetColor
()
);
rRenderContext
.
DrawLine
(
Point
(
0
,
nY
),
Point
(
nX
,
nY
)
);
rRenderContext
.
DrawLine
(
Point
(
nX
+
aTxtSize
.
Width
(),
nY
),
Point
(
aLogSize
.
Width
(),
nY
)
);
rRenderContext
.
SetLineColor
(
aLineCol
);
Point
aTmpPoint
(
nX
,
nY
);
pImpl
->
DrawPrev
(
this
,
pPrinter
,
aTmpPoint
,
rFont
);
Point
aTmpPoint
(
nX
,
nY
);
pImpl
->
DrawPrev
(
rRenderContext
,
pPrinter
,
aTmpPoint
,
rFont
);
}
}
}
bool
SvxFontPrevWindow
::
IsTwoLines
()
const
{
return
pImpl
->
bTwoLines
;
return
pImpl
->
m
bTwoLines
;
}
void
SvxFontPrevWindow
::
SetTwoLines
(
bool
bSet
)
{
pImpl
->
bTwoLines
=
bSet
;
pImpl
->
m
bTwoLines
=
bSet
;
}
void
SvxFontPrevWindow
::
SetBrackets
(
sal_Unicode
cStart
,
sal_Unicode
cEnd
)
{
pImpl
->
cStartBracket
=
cStart
;
pImpl
->
cEndBracket
=
cEnd
;
pImpl
->
m
cStartBracket
=
cStart
;
pImpl
->
m
cEndBracket
=
cEnd
;
}
void
SvxFontPrevWindow
::
SetFontWidthScale
(
sal_uInt16
n
)
{
if
(
pImpl
->
SetFontWidthScale
(
n
)
)
if
(
pImpl
->
SetFontWidthScale
(
n
)
)
Invalidate
();
}
void
SvxFontPrevWindow
::
AutoCorrectFontColor
()
{
Color
aFontColor
(
GetTextColor
()
);
if
(
COL_AUTO
==
pImpl
->
aFont
.
GetColor
().
GetColor
()
)
pImpl
->
aFont
.
SetColor
(
aFontColor
);
if
(
COL_AUTO
==
pImpl
->
maFont
.
GetColor
().
GetColor
()
)
pImpl
->
maFont
.
SetColor
(
aFontColor
);
if
(
COL_AUTO
==
pImpl
->
aCJKFont
.
GetColor
().
GetColor
()
)
pImpl
->
aCJKFont
.
SetColor
(
aFontColor
);
if
(
COL_AUTO
==
pImpl
->
maCJKFont
.
GetColor
().
GetColor
()
)
pImpl
->
maCJKFont
.
SetColor
(
aFontColor
);
if
(
COL_AUTO
==
pImpl
->
aCTLFont
.
GetColor
().
GetColor
()
)
pImpl
->
aCTLFont
.
SetColor
(
aFontColor
);
if
(
COL_AUTO
==
pImpl
->
maCTLFont
.
GetColor
().
GetColor
()
)
pImpl
->
maCTLFont
.
SetColor
(
aFontColor
);
}
static
bool
GetWhich
(
const
SfxItemSet
&
rSet
,
sal_uInt16
nSlot
,
sal_uInt16
&
rWhich
)
static
bool
GetWhich
(
const
SfxItemSet
&
rSet
,
sal_uInt16
nSlot
,
sal_uInt16
&
rWhich
)
{
rWhich
=
rSet
.
GetPool
()
->
GetWhich
(
nSlot
,
true
);
rWhich
=
rSet
.
GetPool
()
->
GetWhich
(
nSlot
,
true
);
return
rSet
.
GetItemState
(
rWhich
)
>=
SfxItemState
::
DEFAULT
;
}
static
void
SetPrevFont
(
const
SfxItemSet
&
rSet
,
sal_uInt16
nSlot
,
SvxFont
&
rFont
)
static
void
SetPrevFont
(
const
SfxItemSet
&
rSet
,
sal_uInt16
nSlot
,
SvxFont
&
rFont
)
{
sal_uInt16
nWhich
;
if
(
GetWhich
(
rSet
,
nSlot
,
nWhich
)
)
if
(
GetWhich
(
rSet
,
nSlot
,
nWhich
)
)
{
const
SvxFontItem
&
rFontItem
=
static_cast
<
const
SvxFontItem
&>
(
rSet
.
Get
(
nWhich
)
);
rFont
.
SetFamily
(
rFontItem
.
GetFamily
()
);
rFont
.
SetName
(
rFontItem
.
GetFamilyName
()
);
rFont
.
SetPitch
(
rFontItem
.
GetPitch
()
);
rFont
.
SetCharSet
(
rFontItem
.
GetCharSet
()
);
rFont
.
SetStyleName
(
rFontItem
.
GetStyleName
()
);
const
SvxFontItem
&
rFontItem
=
static_cast
<
const
SvxFontItem
&>
(
rSet
.
Get
(
nWhich
)
);
rFont
.
SetFamily
(
rFontItem
.
GetFamily
()
);
rFont
.
SetName
(
rFontItem
.
GetFamilyName
()
);
rFont
.
SetPitch
(
rFontItem
.
GetPitch
()
);
rFont
.
SetCharSet
(
rFontItem
.
GetCharSet
()
);
rFont
.
SetStyleName
(
rFontItem
.
GetStyleName
()
);
}
}
...
...
@@ -899,16 +903,16 @@ void SvxFontPrevWindow::SetFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, S
{
sal_uInt16
nWhich
;
long
nH
;
if
(
GetWhich
(
rSet
,
nSlot
,
nWhich
)
)
if
(
GetWhich
(
rSet
,
nSlot
,
nWhich
)
)
{
nH
=
LogicToLogic
(
static_cast
<
const
SvxFontHeightItem
&>
(
rSet
.
Get
(
nWhich
)
).
GetHeight
(),
(
MapUnit
)
rSet
.
GetPool
()
->
GetMetric
(
nWhich
),
MAP_TWIP
);
nH
=
LogicToLogic
(
static_cast
<
const
SvxFontHeightItem
&>
(
rSet
.
Get
(
nWhich
)
).
GetHeight
(),
(
MapUnit
)
rSet
.
GetPool
()
->
GetMetric
(
nWhich
),
MAP_TWIP
);
}
else
nH
=
240
;
// as default 12pt
nH
=
240
;
// as default 12pt
rFont
.
SetSize
(
Size
(
0
,
nH
)
);
rFont
.
SetSize
(
Size
(
0
,
nH
)
);
}
void
SvxFontPrevWindow
::
SetFontLang
(
const
SfxItemSet
&
rSet
,
sal_uInt16
nSlot
,
SvxFont
&
rFont
)
...
...
@@ -922,15 +926,14 @@ void SvxFontPrevWindow::SetFontLang(const SfxItemSet& rSet, sal_uInt16 nSlot, Sv
rFont
.
SetLanguage
(
nLang
);
}
static
void
SetPrevFontEscapement
(
SvxFont
&
_rFont
,
sal_uInt8
nProp
,
sal_uInt8
nEscProp
,
short
nEsc
)
static
void
SetPrevFontEscapement
(
SvxFont
&
rFont
,
sal_uInt8
nProp
,
sal_uInt8
nEscProp
,
short
nEsc
)
{
_rFont
.
SetPropr
(
nProp
);
_rFont
.
SetProprRel
(
nEscProp
);
_rFont
.
SetEscapement
(
nEsc
);
rFont
.
SetPropr
(
nProp
);
rFont
.
SetProprRel
(
nEscProp
);
rFont
.
SetEscapement
(
nEsc
);
}
void
SvxFontPrevWindow
::
SetFromItemSet
(
const
SfxItemSet
&
rSet
,
bool
bPreviewBackgroundToCharacter
)
void
SvxFontPrevWindow
::
SetFromItemSet
(
const
SfxItemSet
&
rSet
,
bool
bPreviewBackgroundToCharacter
)
{
sal_uInt16
nWhich
;
SvxFont
&
rFont
=
GetFont
();
...
...
@@ -1160,22 +1163,20 @@ void SvxFontPrevWindow::SetFromItemSet( const SfxItemSet &rSet,
Invalidate
();
}
void
SvxFontPrevWindow
::
Init
(
const
SfxItemSet
&
rSet
)
void
SvxFontPrevWindow
::
Init
(
const
SfxItemSet
&
rSet
)
{
SvxFont
&
rFont
=
GetFont
();
SvxFont
&
rCJKFont
=
GetCJKFont
();
SvxFont
&
rCTLFont
=
GetCTLFont
();
SvxFont
&
rFont
=
GetFont
();
SvxFont
&
rCJKFont
=
GetCJKFont
();
SvxFont
&
rCTLFont
=
GetCTLFont
();
initFont
(
rFont
);
initFont
(
rCJKFont
);
initFont
(
rCTLFont
);
InitSettings
(
true
,
true
);
ResetSettings
(
true
,
true
);
sal_uInt16
nWhich
;
nWhich
=
rSet
.
GetPool
()
->
GetWhich
(
SID_CHAR_DLG_PREVIEW_STRING
);
if
(
ISITEMSET
)
if
(
ISITEMSET
)
{
const
SfxStringItem
&
rItem
=
static_cast
<
const
SfxStringItem
&>
(
rSet
.
Get
(
nWhich
)
);
OUString
aString
=
rItem
.
GetValue
();
...
...
@@ -1300,15 +1301,15 @@ void SvxFontPrevWindow::Init( const SfxItemSet& rSet )
// Background
bool
bTransparent
;
nWhich
=
rSet
.
GetPool
()
->
GetWhich
(
pImpl
->
bPreviewBackgroundToCharacter
?
SID_ATTR_BRUSH
:
SID_ATTR_BRUSH_CHAR
);
if
(
ISITEMSET
)
nWhich
=
rSet
.
GetPool
()
->
GetWhich
(
pImpl
->
mbPreviewBackgroundToCharacter
?
SID_ATTR_BRUSH
:
SID_ATTR_BRUSH_CHAR
);
if
(
ISITEMSET
)
{
const
SvxBrushItem
&
rBrush
=
static_cast
<
const
SvxBrushItem
&>
(
rSet
.
Get
(
nWhich
)
);
const
Color
&
rColor
=
rBrush
.
GetColor
();
bTransparent
=
rColor
.
GetTransparency
()
>
0
;
rFont
.
SetFillColor
(
rColor
);
rCJKFont
.
SetFillColor
(
rColor
);
rCTLFont
.
SetFillColor
(
rColor
);
rFont
.
SetFillColor
(
rColor
);
rCJKFont
.
SetFillColor
(
rColor
);
rCTLFont
.
SetFillColor
(
rColor
);
}
else
bTransparent
=
true
;
...
...
@@ -1318,32 +1319,32 @@ void SvxFontPrevWindow::Init( const SfxItemSet& rSet )
rCTLFont
.
SetTransparent
(
bTransparent
);
Color
aBackCol
(
COL_TRANSPARENT
);
if
(
!
pImpl
->
bPreviewBackgroundToCharacter
)
if
(
!
pImpl
->
mbPreviewBackgroundToCharacter
)
{
nWhich
=
rSet
.
GetPool
()
->
GetWhich
(
SID_ATTR_BRUSH
);
if
(
ISITEMSET
)
if
(
ISITEMSET
)
{
const
SvxBrushItem
&
rBrush
=
static_cast
<
const
SvxBrushItem
&>
(
rSet
.
Get
(
nWhich
)
);
if
(
GPOS_NONE
==
rBrush
.
GetGraphicPos
()
)
const
SvxBrushItem
&
rBrush
=
static_cast
<
const
SvxBrushItem
&>
(
rSet
.
Get
(
nWhich
)
);
if
(
GPOS_NONE
==
rBrush
.
GetGraphicPos
()
)
aBackCol
=
rBrush
.
GetColor
();
}
}
SetBackColor
(
aBackCol
);
SetBackColor
(
aBackCol
);
// Font
SetFont
(
rSet
,
SID_ATTR_CHAR_FONT
,
rFont
);
SetFont
(
rSet
,
SID_ATTR_CHAR_CJK_FONT
,
rCJKFont
);
SetFont
(
rSet
,
SID_ATTR_CHAR_CTL_FONT
,
rCTLFont
);
SetFont
(
rSet
,
SID_ATTR_CHAR_FONT
,
rFont
);
SetFont
(
rSet
,
SID_ATTR_CHAR_CJK_FONT
,
rCJKFont
);
SetFont
(
rSet
,
SID_ATTR_CHAR_CTL_FONT
,
rCTLFont
);
// Style
SetFontStyle
(
rSet
,
SID_ATTR_CHAR_POSTURE
,
SID_ATTR_CHAR_WEIGHT
,
rFont
);
SetFontStyle
(
rSet
,
SID_ATTR_CHAR_CJK_POSTURE
,
SID_ATTR_CHAR_CJK_WEIGHT
,
rCJKFont
);
SetFontStyle
(
rSet
,
SID_ATTR_CHAR_CTL_POSTURE
,
SID_ATTR_CHAR_CTL_WEIGHT
,
rCTLFont
);
SetFontStyle
(
rSet
,
SID_ATTR_CHAR_POSTURE
,
SID_ATTR_CHAR_WEIGHT
,
rFont
);
SetFontStyle
(
rSet
,
SID_ATTR_CHAR_CJK_POSTURE
,
SID_ATTR_CHAR_CJK_WEIGHT
,
rCJKFont
);
SetFontStyle
(
rSet
,
SID_ATTR_CHAR_CTL_POSTURE
,
SID_ATTR_CHAR_CTL_WEIGHT
,
rCTLFont
);
// Size
SetFontSize
(
rSet
,
SID_ATTR_CHAR_FONTHEIGHT
,
rFont
);
SetFontSize
(
rSet
,
SID_ATTR_CHAR_CJK_FONTHEIGHT
,
rCJKFont
);
SetFontSize
(
rSet
,
SID_ATTR_CHAR_CTL_FONTHEIGHT
,
rCTLFont
);
SetFontSize
(
rSet
,
SID_ATTR_CHAR_FONTHEIGHT
,
rFont
);
SetFontSize
(
rSet
,
SID_ATTR_CHAR_CJK_FONTHEIGHT
,
rCJKFont
);
SetFontSize
(
rSet
,
SID_ATTR_CHAR_CTL_FONTHEIGHT
,
rCTLFont
);
// Language
SetFontLang
(
rSet
,
SID_ATTR_CHAR_LANGUAGE
,
rFont
);
...
...
@@ -1405,11 +1406,6 @@ void SvxFontPrevWindow::Init( const SfxItemSet& rSet )
Invalidate
();
}
void
SvxFontPrevWindow
::
SetFont
(
const
SfxItemSet
&
rSet
,
sal_uInt16
nSlot
,
SvxFont
&
rFont
)
{
sal_uInt16
nWhich
=
rSet
.
GetPool
()
->
GetWhich
(
nSlot
);
...
...
@@ -1424,8 +1420,6 @@ void SvxFontPrevWindow::SetFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFo
}
}
void
SvxFontPrevWindow
::
SetFontStyle
(
const
SfxItemSet
&
rSet
,
sal_uInt16
nPosture
,
sal_uInt16
nWeight
,
SvxFont
&
rFont
)
{
sal_uInt16
nWhich
=
rSet
.
GetPool
()
->
GetWhich
(
nPosture
);
...
...
@@ -1443,8 +1437,6 @@ void SvxFontPrevWindow::SetFontStyle( const SfxItemSet& rSet, sal_uInt16 nPostur
}
}
void
SvxFontPrevWindow
::
SetFontWidthScale
(
const
SfxItemSet
&
rSet
)
{
sal_uInt16
nWhich
=
rSet
.
GetPool
()
->
GetWhich
(
SID_ATTR_CHAR_SCALEWIDTH
);
...
...
@@ -1456,26 +1448,21 @@ void SvxFontPrevWindow::SetFontWidthScale( const SfxItemSet& rSet )
}
}
namespace
{
void
setFontEscapement
(
SvxFont
&
_rFont
,
sal_uInt8
nProp
,
sal_uInt8
nEscProp
,
short
nEsc
)
void
setFontEscapement
(
SvxFont
&
rFont
,
sal_uInt8
nProp
,
sal_uInt8
nEscProp
,
short
nEsc
)
{
_rFont
.
SetPropr
(
nProp
);
_rFont
.
SetProprRel
(
nEscProp
);
_rFont
.
SetEscapement
(
nEsc
);
rFont
.
SetPropr
(
nProp
);
rFont
.
SetProprRel
(
nEscProp
);
rFont
.
SetEscapement
(
nEsc
);
}
}
void
SvxFontPrevWindow
::
SetFontEscapement
(
sal_uInt8
nProp
,
sal_uInt8
nEscProp
,
short
nEsc
)
void
SvxFontPrevWindow
::
SetFontEscapement
(
sal_uInt8
nProp
,
sal_uInt8
nEscProp
,
short
nEsc
)
{
setFontEscapement
(
GetFont
(),
nProp
,
nEscProp
,
nEsc
);
setFontEscapement
(
GetCJKFont
(),
nProp
,
nEscProp
,
nEsc
);
setFontEscapement
(
GetCTLFont
(),
nProp
,
nEscProp
,
nEsc
);
setFontEscapement
(
GetFont
(),
nProp
,
nEscProp
,
nEsc
);
setFontEscapement
(
GetCJKFont
(),
nProp
,
nEscProp
,
nEsc
);
setFontEscapement
(
GetCTLFont
(),
nProp
,
nEscProp
,
nEsc
);
Invalidate
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment