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