Line data Source code
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 :
10 : #ifndef INCLUDED_FILTER_MSFILTER_UTIL_HXX
11 : #define INCLUDED_FILTER_MSFILTER_UTIL_HXX
12 :
13 : #include <rtl/textenc.h>
14 : #include <tools/datetime.hxx>
15 : #include <tools/color.hxx>
16 : #include <com/sun/star/lang/Locale.hpp>
17 : #include <filter/msfilter/msfilterdllapi.h>
18 : #include <svx/msdffdef.hxx>
19 : #include <com/sun/star/awt/Size.hpp>
20 :
21 : namespace msfilter {
22 : namespace util {
23 :
24 : /// Returns the best-fit default 8bit encoding for a given locale
25 : /// i.e. useful when dealing with legacy formats which use legacy text encodings without recording
26 : /// what the encoding is, but you know or can guess the language
27 : MSFILTER_DLLPUBLIC rtl_TextEncoding getBestTextEncodingFromLocale(const ::com::sun::star::lang::Locale &rLocale);
28 :
29 : /// Convert a color in BGR format to RGB.
30 : MSFILTER_DLLPUBLIC sal_uInt32 BGRToRGB(sal_uInt32 nColour);
31 :
32 : /** Convert from DTTM to Writer's DateTime
33 :
34 : @author
35 : <a href="mailto:mmaher@openoffice.org">Martin Maher</a
36 : */
37 : MSFILTER_DLLPUBLIC DateTime DTTM2DateTime( long lDTTM );
38 :
39 : /** Convert DateTime to xsd::dateTime string.
40 :
41 : I guess there must be an implementation of this somewhere in LO, but I failed
42 : to find it, unfortunately :-(
43 : */
44 :
45 : /// Given a cBullet in encoding r_ioChrSet and fontname r_ioFontName return a
46 : /// suitable new Bullet and change r_ioChrSet and r_ioFontName to form the
47 : /// best-fit replacement in terms of default available MSOffice symbol
48 : /// fonts.
49 : ///
50 : /// Set bDisableUnicodeSupport when exporting to 8bit encodings
51 : ///
52 : /// Used to map from [Open|Star]Symbol to some Windows font or other.
53 : MSFILTER_DLLPUBLIC sal_Unicode bestFitOpenSymbolToMSFont(sal_Unicode cBullet,
54 : rtl_TextEncoding& r_ioChrSet, OUString& r_ioFontName, bool bDisableUnicodeSupport = false);
55 :
56 :
57 : enum TextCategory
58 : {
59 : latin, //Latin
60 : cs, //Complex Script
61 : ea, //East Asian
62 : sym //Symbol
63 : };
64 :
65 : /** Categorize codepoints according to how MS seems to do it.
66 :
67 : It's been bugging me for ages as to what codepoint MS considers in
68 : what category. Tom Jebo has a post suggesting the criteria used here
69 : and indicating its been submitting to the standards working group
70 : as a proposed resolution.
71 : */
72 : MSFILTER_DLLPUBLIC TextCategory categorizeCodePoint(sal_uInt32 codePoint, const OUString &rBcp47LanguageTag);
73 :
74 : #define OOXML_COLOR_AUTO 0x0a
75 :
76 : /**
77 : * Converts tools Color to HTML color (without leading hashmark).
78 : *
79 : * @param rColor color to convert
80 : * @param bAutoColor if OOXML_COLOR_AUTO should be recognized as an auto color
81 : */
82 : MSFILTER_DLLPUBLIC OString ConvertColor( const Color &rColor, bool bAutoColor = false );
83 :
84 :
85 : /** Paper size in 1/100 millimeters. */
86 : struct MSFILTER_DLLPUBLIC ApiPaperSize
87 : {
88 : sal_Int32 mnWidth;
89 : sal_Int32 mnHeight;
90 : };
91 :
92 : class MSFILTER_DLLPUBLIC PaperSizeConv
93 : {
94 : public:
95 : static sal_Int32 getMSPaperSizeIndex( const com::sun::star::awt::Size& rSize );
96 : static const ApiPaperSize& getApiSizeForMSPaperSizeIndex( sal_Int32 nMSOPaperIndex );
97 : };
98 :
99 : /**
100 : * Finds the quoted text in a field instruction text.
101 : *
102 : * Example: SEQ "Figure" \someoption -> "Figure"
103 : */
104 : MSFILTER_DLLPUBLIC OUString findQuotedText( const OUString& rCommand, const sal_Char* cStartQuote, const sal_Unicode uEndQuote );
105 :
106 0 : class MSFILTER_DLLPUBLIC WW8ReadFieldParams
107 : {
108 : private:
109 : const OUString aData;
110 : sal_Int32 nFnd;
111 : sal_Int32 nNext;
112 : sal_Int32 nSavPtr;
113 : public:
114 : WW8ReadFieldParams( const OUString& rData );
115 : ~WW8ReadFieldParams();
116 :
117 : bool GoToTokenParam();
118 : sal_Int32 SkipToNextToken();
119 0 : sal_Int32 GetTokenSttPtr() const { return nFnd; }
120 :
121 : sal_Int32 FindNextStringPiece( sal_Int32 _nStart = -1 );
122 : bool GetTokenSttFromTo(sal_Int32* _pFrom, sal_Int32* _pTo, sal_Int32 _nMax);
123 :
124 : OUString GetResult() const;
125 : };
126 :
127 0 : struct MSFILTER_DLLPUBLIC EquationResult
128 : {
129 : OUString sResult;
130 : OUString sType;
131 : };
132 :
133 : MSFILTER_DLLPUBLIC EquationResult ParseCombinedChars(const OUString& rStr);
134 :
135 : /// Similar to EnhancedCustomShapeTypeNames::Get(), but it also supports OOXML types and returns a drawingML string.
136 : MSFILTER_DLLPUBLIC const char* GetOOXMLPresetGeometry( const char* sShapeType );
137 :
138 : /// Similar to EnhancedCustomShapeTypeNames::Get(), but returns an MSO_SPT (binary / VML type).
139 : MSFILTER_DLLPUBLIC MSO_SPT GETVMLShapeType(const OString& aType);
140 :
141 : }
142 :
143 : }
144 :
145 : #endif
146 :
147 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|