diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-03-20 00:21:17 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-03-20 16:11:57 -0500 |
commit | 7154b092a716d4d0041a8a563294511ec9e5dbc6 (patch) | |
tree | 2e2cbbd319a3ee008b536f584bf7a160f0f8ee01 /vcl/source | |
parent | 5971a040f974dcdd0b0d8491d720fa7ad74439b4 (diff) |
cosmetic: split PhysicalFontFace class it its own source/header
oudev,2,3,4,5,6 are a dumping ground for a lot of things
chipping at it one class at the time...
organize the #include of the impacted source while at it.
Change-Id: I57bbb1f9e3c6b2ac6b3ca127e5976bf16f3e3cf8
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/font/PhysicalFontFace.cxx | 231 | ||||
-rw-r--r-- | vcl/source/gdi/outdev3.cxx | 211 | ||||
-rw-r--r-- | vcl/source/gdi/pdffontcache.cxx | 9 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 67 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.hxx | 41 |
5 files changed, 286 insertions, 273 deletions
diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx new file mode 100644 index 000000000000..c454d3d09970 --- /dev/null +++ b/vcl/source/font/PhysicalFontFace.cxx @@ -0,0 +1,231 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/types.h> + +#include <tools/fontenum.hxx> + +#include "outfont.hxx" + +#include "PhysicalFontFace.hxx" + + +PhysicalFontFace::PhysicalFontFace( const ImplDevFontAttributes& rDFA, int nMagic ) + : ImplDevFontAttributes( rDFA ) + , mnWidth(0) + , mnHeight(0) + , mnMagic( nMagic ) + , mpNext( NULL ) +{ + // StarSymbol is a unicode font, but it still deserves the symbol flag + if( !IsSymbolFont() ) + if ( IsStarSymbol( GetFamilyName() ) ) + SetSymbolFlag( true ); +} + +sal_Int32 PhysicalFontFace::CompareIgnoreSize( const PhysicalFontFace& rOther ) const +{ + // compare their width, weight, italic, style name and family name + if( GetWidthType() < rOther.GetWidthType() ) + return -1; + else if( GetWidthType() > rOther.GetWidthType() ) + return 1; + + if( GetWeight() < rOther.GetWeight() ) + return -1; + else if( GetWeight() > rOther.GetWeight() ) + return 1; + + if( GetSlant() < rOther.GetSlant() ) + return -1; + else if( GetSlant() > rOther.GetSlant() ) + return 1; + + sal_Int32 nRet = GetFamilyName().compareTo( rOther.GetFamilyName() ); + + if (nRet == 0) + { + nRet = GetStyleName().compareTo( rOther.GetStyleName() ); + } + + return nRet; +} + +sal_Int32 PhysicalFontFace::CompareWithSize( const PhysicalFontFace& rOther ) const +{ + sal_Int32 nCompare = CompareIgnoreSize( rOther ); + if (nCompare != 0) + return nCompare; + + if( mnHeight < rOther.mnHeight ) + return -1; + else if( mnHeight > rOther.mnHeight ) + return 1; + + if( mnWidth < rOther.mnWidth ) + return -1; + else if( mnWidth > rOther.mnWidth ) + return 1; + + return 0; +} + +bool PhysicalFontFace::IsBetterMatch( const FontSelectPattern& rFSD, FontMatchStatus& rStatus ) const +{ + int nMatch = 0; + + const OUString& rFontName = rFSD.maTargetName; + if( rFontName.equalsIgnoreAsciiCase( GetFamilyName() ) ) + nMatch += 240000; + + if( rStatus.mpTargetStyleName + && GetStyleName().equalsIgnoreAsciiCase( *rStatus.mpTargetStyleName ) ) + nMatch += 120000; + + if( (rFSD.GetPitch() != PITCH_DONTKNOW) && (rFSD.GetPitch() == GetPitch()) ) + nMatch += 20000; + + // prefer NORMAL font width + // TODO: change when the upper layers can tell their width preference + if( GetWidthType() == WIDTH_NORMAL ) + nMatch += 400; + else if( (GetWidthType() == WIDTH_SEMI_EXPANDED) || (GetWidthType() == WIDTH_SEMI_CONDENSED) ) + nMatch += 300; + + if( rFSD.GetWeight() != WEIGHT_DONTKNOW ) + { + // if not bold or requiring emboldening prefer light fonts to bold fonts + FontWeight ePatternWeight = rFSD.mbEmbolden ? WEIGHT_NORMAL : rFSD.GetWeight(); + + int nReqWeight = (int)ePatternWeight; + if ( ePatternWeight > WEIGHT_MEDIUM ) + nReqWeight += 100; + + int nGivenWeight = (int)GetWeight(); + if( GetWeight() > WEIGHT_MEDIUM ) + nGivenWeight += 100; + + int nWeightDiff = nReqWeight - nGivenWeight; + + if ( nWeightDiff == 0 ) + nMatch += 1000; + else if ( nWeightDiff == +1 || nWeightDiff == -1 ) + nMatch += 700; + else if ( nWeightDiff < +50 && nWeightDiff > -50) + nMatch += 200; + } + else // requested weight == WEIGHT_DONTKNOW + { + // prefer NORMAL font weight + // TODO: change when the upper layers can tell their weight preference + if( GetWeight() == WEIGHT_NORMAL ) + nMatch += 450; + else if( GetWeight() == WEIGHT_MEDIUM ) + nMatch += 350; + else if( (GetWeight() == WEIGHT_SEMILIGHT) || (GetWeight() == WEIGHT_SEMIBOLD) ) + nMatch += 200; + else if( GetWeight() == WEIGHT_LIGHT ) + nMatch += 150; + } + + // if requiring custom matrix to fake italic, prefer upright font + FontItalic ePatternItalic = rFSD.maItalicMatrix != ItalicMatrix() ? ITALIC_NONE : rFSD.GetSlant(); + + if ( ePatternItalic == ITALIC_NONE ) + { + if( GetSlant() == ITALIC_NONE ) + nMatch += 900; + } + else + { + if( ePatternItalic == GetSlant() ) + nMatch += 900; + else if( GetSlant() != ITALIC_NONE ) + nMatch += 600; + } + + if( mbDevice ) + nMatch += 1; + + int nHeightMatch = 0; + int nWidthMatch = 0; + + if( IsScalable() ) + { + if( rFSD.mnOrientation != 0 ) + nMatch += 80; + else if( rFSD.mnWidth != 0 ) + nMatch += 25; + else + nMatch += 5; + } + else + { + if( rFSD.mnHeight == mnHeight ) + { + nMatch += 20; + if( rFSD.mnWidth == mnWidth ) + nMatch += 10; + } + else + { + // for non-scalable fonts the size difference is very important + // prefer the smaller font face because of clipping/overlapping issues + int nHeightDiff = (rFSD.mnHeight - mnHeight) * 1000; + nHeightMatch = (nHeightDiff >= 0) ? -nHeightDiff : 100+nHeightDiff; + if( rFSD.mnHeight ) + nHeightMatch /= rFSD.mnHeight; + + if( (rFSD.mnWidth != 0) && (mnWidth != 0) && (rFSD.mnWidth != mnWidth) ) + { + int nWidthDiff = (rFSD.mnWidth - mnWidth) * 100; + nWidthMatch = (nWidthDiff >= 0) ? -nWidthDiff : +nWidthDiff; + } + } + } + + if( rStatus.mnFaceMatch > nMatch ) + return false; + else if( rStatus.mnFaceMatch < nMatch ) + { + rStatus.mnFaceMatch = nMatch; + rStatus.mnHeightMatch = nHeightMatch; + rStatus.mnWidthMatch = nWidthMatch; + return true; + } + + // when two fonts are still competing prefer the + // one with the best matching height + if( rStatus.mnHeightMatch > nHeightMatch ) + return false; + else if( rStatus.mnHeightMatch < nHeightMatch ) + { + rStatus.mnHeightMatch = nHeightMatch; + rStatus.mnWidthMatch = nWidthMatch; + return true; + } + + if( rStatus.mnWidthMatch > nWidthMatch ) + return false; + + rStatus.mnWidthMatch = nWidthMatch; + return true; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index e624d0bf1e1c..8dd4b9206302 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -699,217 +699,6 @@ static void ImplCalcType( sal_uLong& rType, FontWeight& rWeight, FontWidth& rWid } } -PhysicalFontFace::PhysicalFontFace( const ImplDevFontAttributes& rDFA, int nMagic ) -: ImplDevFontAttributes( rDFA ), - mnWidth(0), - mnHeight(0), - mnMagic( nMagic ), - mpNext( NULL ) -{ - // StarSymbol is a unicode font, but it still deserves the symbol flag - if( !IsSymbolFont() ) - if ( IsStarSymbol( GetFamilyName() ) ) - SetSymbolFlag( true ); -} - -sal_Int32 PhysicalFontFace::CompareIgnoreSize( const PhysicalFontFace& rOther ) const -{ - // compare their width, weight, italic, style name and family name - if( GetWidthType() < rOther.GetWidthType() ) - return -1; - else if( GetWidthType() > rOther.GetWidthType() ) - return 1; - - if( GetWeight() < rOther.GetWeight() ) - return -1; - else if( GetWeight() > rOther.GetWeight() ) - return 1; - - if( GetSlant() < rOther.GetSlant() ) - return -1; - else if( GetSlant() > rOther.GetSlant() ) - return 1; - - sal_Int32 nRet = GetFamilyName().compareTo( rOther.GetFamilyName() ); - - if (nRet == 0) - { - nRet = GetStyleName().compareTo( rOther.GetStyleName() ); - } - - return nRet; -} - -sal_Int32 PhysicalFontFace::CompareWithSize( const PhysicalFontFace& rOther ) const -{ - sal_Int32 nCompare = CompareIgnoreSize( rOther ); - if (nCompare != 0) - return nCompare; - - if( mnHeight < rOther.mnHeight ) - return -1; - else if( mnHeight > rOther.mnHeight ) - return 1; - - if( mnWidth < rOther.mnWidth ) - return -1; - else if( mnWidth > rOther.mnWidth ) - return 1; - - return 0; -} - -struct FontMatchStatus -{ -public: - int mnFaceMatch; - int mnHeightMatch; - int mnWidthMatch; - const OUString* mpTargetStyleName; -}; - -bool PhysicalFontFace::IsBetterMatch( const FontSelectPattern& rFSD, FontMatchStatus& rStatus ) const -{ - int nMatch = 0; - - const OUString& rFontName = rFSD.maTargetName; - if( rFontName.equalsIgnoreAsciiCase( GetFamilyName() ) ) - nMatch += 240000; - - if( rStatus.mpTargetStyleName - && GetStyleName().equalsIgnoreAsciiCase( *rStatus.mpTargetStyleName ) ) - nMatch += 120000; - - if( (rFSD.GetPitch() != PITCH_DONTKNOW) && (rFSD.GetPitch() == GetPitch()) ) - nMatch += 20000; - - // prefer NORMAL font width - // TODO: change when the upper layers can tell their width preference - if( GetWidthType() == WIDTH_NORMAL ) - nMatch += 400; - else if( (GetWidthType() == WIDTH_SEMI_EXPANDED) || (GetWidthType() == WIDTH_SEMI_CONDENSED) ) - nMatch += 300; - - if( rFSD.GetWeight() != WEIGHT_DONTKNOW ) - { - // if not bold or requiring emboldening prefer light fonts to bold fonts - FontWeight ePatternWeight = rFSD.mbEmbolden ? WEIGHT_NORMAL : rFSD.GetWeight(); - - int nReqWeight = (int)ePatternWeight; - if ( ePatternWeight > WEIGHT_MEDIUM ) - nReqWeight += 100; - - int nGivenWeight = (int)GetWeight(); - if( GetWeight() > WEIGHT_MEDIUM ) - nGivenWeight += 100; - - int nWeightDiff = nReqWeight - nGivenWeight; - - if ( nWeightDiff == 0 ) - nMatch += 1000; - else if ( nWeightDiff == +1 || nWeightDiff == -1 ) - nMatch += 700; - else if ( nWeightDiff < +50 && nWeightDiff > -50) - nMatch += 200; - } - else // requested weight == WEIGHT_DONTKNOW - { - // prefer NORMAL font weight - // TODO: change when the upper layers can tell their weight preference - if( GetWeight() == WEIGHT_NORMAL ) - nMatch += 450; - else if( GetWeight() == WEIGHT_MEDIUM ) - nMatch += 350; - else if( (GetWeight() == WEIGHT_SEMILIGHT) || (GetWeight() == WEIGHT_SEMIBOLD) ) - nMatch += 200; - else if( GetWeight() == WEIGHT_LIGHT ) - nMatch += 150; - } - - // if requiring custom matrix to fake italic, prefer upright font - FontItalic ePatternItalic = rFSD.maItalicMatrix != ItalicMatrix() ? ITALIC_NONE : rFSD.GetSlant(); - - if ( ePatternItalic == ITALIC_NONE ) - { - if( GetSlant() == ITALIC_NONE ) - nMatch += 900; - } - else - { - if( ePatternItalic == GetSlant() ) - nMatch += 900; - else if( GetSlant() != ITALIC_NONE ) - nMatch += 600; - } - - if( mbDevice ) - nMatch += 1; - - int nHeightMatch = 0; - int nWidthMatch = 0; - - if( IsScalable() ) - { - if( rFSD.mnOrientation != 0 ) - nMatch += 80; - else if( rFSD.mnWidth != 0 ) - nMatch += 25; - else - nMatch += 5; - } - else - { - if( rFSD.mnHeight == mnHeight ) - { - nMatch += 20; - if( rFSD.mnWidth == mnWidth ) - nMatch += 10; - } - else - { - // for non-scalable fonts the size difference is very important - // prefer the smaller font face because of clipping/overlapping issues - int nHeightDiff = (rFSD.mnHeight - mnHeight) * 1000; - nHeightMatch = (nHeightDiff >= 0) ? -nHeightDiff : 100+nHeightDiff; - if( rFSD.mnHeight ) - nHeightMatch /= rFSD.mnHeight; - - if( (rFSD.mnWidth != 0) && (mnWidth != 0) && (rFSD.mnWidth != mnWidth) ) - { - int nWidthDiff = (rFSD.mnWidth - mnWidth) * 100; - nWidthMatch = (nWidthDiff >= 0) ? -nWidthDiff : +nWidthDiff; - } - } - } - - if( rStatus.mnFaceMatch > nMatch ) - return false; - else if( rStatus.mnFaceMatch < nMatch ) - { - rStatus.mnFaceMatch = nMatch; - rStatus.mnHeightMatch = nHeightMatch; - rStatus.mnWidthMatch = nWidthMatch; - return true; - } - - // when two fonts are still competing prefer the - // one with the best matching height - if( rStatus.mnHeightMatch > nHeightMatch ) - return false; - else if( rStatus.mnHeightMatch < nHeightMatch ) - { - rStatus.mnHeightMatch = nHeightMatch; - rStatus.mnWidthMatch = nWidthMatch; - return true; - } - - if( rStatus.mnWidthMatch > nWidthMatch ) - return false; - - rStatus.mnWidthMatch = nWidthMatch; - return true; -} - ImplFontEntry::ImplFontEntry( const FontSelectPattern& rFontSelData ) : maFontSelData( rFontSelData ) , maMetric( rFontSelData ) diff --git a/vcl/source/gdi/pdffontcache.cxx b/vcl/source/gdi/pdffontcache.cxx index 294cbfe00cfb..ccb131dd7cc9 100644 --- a/vcl/source/gdi/pdffontcache.cxx +++ b/vcl/source/gdi/pdffontcache.cxx @@ -17,11 +17,14 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/types.h> + +#include "outfont.hxx" +#include "PhysicalFontFace.hxx" +#include "salgdi.hxx" +#include "sallayout.hxx" #include "pdffontcache.hxx" -#include <salgdi.hxx> -#include <outfont.hxx> -#include <sallayout.hxx> using namespace vcl; diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 681c75448c39..bf8c70742db2 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -17,64 +17,55 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "sal/config.h" +#include <sal/types.h> #include <math.h> #include <algorithm> +#include <lcms2.h> -#include <tools/urlobj.hxx> - -#include <pdfwriter_impl.hxx> - +#include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolygon.hxx> -#include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> -#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolypolygoncutter.hxx> -#include <basegfx/matrix/b2dhommatrix.hxx> - -#include <osl/thread.h> +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <boost/scoped_array.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/util/URLTransformer.hpp> +#include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> +#include <cppuhelper/implbase1.hxx> +#include <i18nlangtag/languagetag.hxx> #include <osl/file.h> - +#include <osl/thread.h> #include <rtl/crc.h> #include <rtl/digest.h> #include <rtl/ustrbuf.hxx> - #include <tools/debug.hxx> -#include <tools/zcodec.hxx> #include <tools/stream.hxx> - -#include <i18nlangtag/languagetag.hxx> - -#include <vcl/virdev.hxx> -#include <vcl/bmpacc.hxx> +#include <tools/urlobj.hxx> +#include <tools/zcodec.hxx> #include <vcl/bitmapex.hxx> +#include <vcl/bmpacc.hxx> +#include <vcl/cvtgrf.hxx> #include <vcl/image.hxx> +#include <vcl/lineinfo.hxx> #include <vcl/metric.hxx> +#include <vcl/settings.hxx> +#include <vcl/strhelper.hxx> #include <vcl/svapp.hxx> -#include <vcl/lineinfo.hxx> -#include "vcl/cvtgrf.hxx" -#include "vcl/strhelper.hxx" -#include "vcl/settings.hxx" - -#include <fontsubset.hxx> -#include <outdev.h> -#include <sallayout.hxx> -#include <textlayout.hxx> -#include <salgdi.hxx> - -#include <lcms2.h> - -#include <comphelper/processfactory.hxx> -#include <comphelper/string.hxx> +#include <vcl/virdev.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/util/URLTransformer.hpp> -#include <com/sun/star/util/URL.hpp> +#include "fontsubset.hxx" +#include "outdev.h" +#include "PhysicalFontFace.hxx" +#include "salgdi.hxx" +#include "sallayout.hxx" +#include "textlayout.hxx" -#include "cppuhelper/implbase1.hxx" +#include "pdfwriter_impl.hxx" -#include <boost/scoped_array.hpp> #if !defined(ANDROID) && !defined(IOS) // NSS header files for PDF signing support diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index c4ae22e05467..4fe749ae9e71 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -19,33 +19,31 @@ #ifndef INCLUDED_VCL_SOURCE_GDI_PDFWRITER_IMPL_HXX #define INCLUDED_VCL_SOURCE_GDI_PDFWRITER_IMPL_HXX -#include "vcl/pdfwriter.hxx" -#include "rtl/ustring.hxx" -#include "osl/file.h" -#include "tools/gen.hxx" -#include "tools/stream.hxx" -#include "vcl/outdev.hxx" -#include "vcl/bitmapex.hxx" -#include "vcl/gradient.hxx" -#include "vcl/hatch.hxx" -#include "vcl/wall.hxx" -#include "outdata.hxx" -#include "rtl/strbuf.hxx" -#include "rtl/cipher.h" -#include "rtl/digest.h" -#include "com/sun/star/util/XURLTransformer.hpp" -#include "com/sun/star/lang/Locale.hpp" -#include <sal/macros.h> - -#include <sallayout.hxx> -#include "pdffontcache.hxx" - #include <vector> #include <map> #include <boost/unordered_map.hpp> #include <list> #include <boost/shared_array.hpp> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> +#include <osl/file.h> +#include <rtl/cipher.h> +#include <rtl/digest.h> +#include <rtl/strbuf.hxx> +#include <rtl/ustring.hxx> +#include <tools/gen.hxx> +#include <tools/stream.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/gradient.hxx> +#include <vcl/hatch.hxx> +#include <vcl/outdev.hxx> +#include <vcl/pdfwriter.hxx> +#include <vcl/wall.hxx> + +#include "sallayout.hxx" +#include "outdata.hxx" +#include "pdffontcache.hxx" class StyleSettings; class FontSelectPattern; @@ -54,6 +52,7 @@ class FontSubsetInfo; class ZCodec; class EncHashTransporter; struct BitStreamState; +class PhysicalFontFace; // the maximum password length #define ENCRYPTED_PWD_SIZE 32 |