LibreOffice Module vcl (master)  1
GraphicFormatDetector.hxx
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 #ifndef INCLUDED_VCL_INC_GRAPHICFORMATDETECTOR_HXX
21 #define INCLUDED_VCL_INC_GRAPHICFORMATDETECTOR_HXX
22 
23 #include <tools/stream.hxx>
24 #include <vector>
25 
26 namespace vcl
27 {
28 /***
29  * This function is has two modes:
30  * - determine the file format when bTest = false
31  * returns true, success
32  * out rFormatExtension - on success: file format string
33  * - verify file format when bTest = true
34  * returns false, if file type can't be verified
35  * true, if the format is verified or the format is not known
36  */
37 VCL_DLLPUBLIC bool peekGraphicFormat(SvStream& rStream, OUString& rFormatExtension, bool bTest);
38 
40 {
41 public:
43  OUString maExtension;
44 
45  std::vector<sal_uInt8> maFirstBytes;
46  sal_uInt32 mnFirstLong;
47  sal_uInt32 mnSecondLong;
48 
49  sal_uInt64 mnStreamPosition;
50  sal_uInt64 mnStreamLength;
51 
52  OUString msDetectedFormat;
53 
54  GraphicFormatDetector(SvStream& rStream, OUString const& rFormatExtension);
55 
56  bool detect();
57 
58  bool checkMET();
59  bool checkBMP();
60  bool checkWMForEMF();
61  bool checkPCX();
62  bool checkTIF();
63  bool checkGIF();
64  bool checkPNG();
65  bool checkJPG();
66  bool checkSVM();
67  bool checkPCD();
68  bool checkPSD();
69  bool checkEPS();
70  bool checkDXF();
71  bool checkPCT();
72  bool checkPBMorPGMorPPM();
73  bool checkRAS();
74  bool checkXPM();
75  bool checkXBM();
76  bool checkSVG();
77  bool checkTGA();
78  bool checkMOV();
79  bool checkPDF();
80 };
81 }
82 
83 #endif // INCLUDED_VCL_INC_GRAPHICFORMATDETECTOR_HXX
84 
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
std::vector< sal_uInt8 > maFirstBytes
bool peekGraphicFormat(SvStream &rStream, OUString &rFormatExtension, bool bTest)