LibreOffice Module xmlhelp (master) 1
urlparameter.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#pragma once
21
22#include <rtl/ustring.hxx>
23#include <rtl/string.hxx>
24#include <com/sun/star/io/XActiveDataSink.hpp>
25#include <com/sun/star/io/XOutputStream.hpp>
26
27namespace chelp {
28
29
30 class Databases;
31
32
34 {
35 public:
36
37 explicit DbtToStringConverter( const char* ptr )
38 : m_ptr( ptr )
39 {
40 }
41
42 OUString getHash() const
43 {
44 if( m_ptr )
45 {
46 sal_Int32 sizeOfFile = static_cast<sal_Int32>(m_ptr[0]);
47 OUString Hash( m_ptr+1,sizeOfFile,RTL_TEXTENCODING_UTF8 );
48 sal_Int32 idx;
49 if( ( idx = Hash.indexOf( u'#' ) ) != -1 )
50 return Hash.copy( 1+idx );
51 }
52 return OUString();
53 }
54
55
56 OUString getFile() const
57 {
58 if( ! m_ptr )
59 return OUString();
60
61 sal_Int32 sizeOfFile = static_cast<sal_Int32>(m_ptr[0]);
62 OUString File( m_ptr+1,sizeOfFile,RTL_TEXTENCODING_UTF8 );
63 sal_Int32 idx;
64 if( ( idx = File.indexOf( u'#' ) ) != -1 )
65 return File.copy( 0,idx );
66 else
67 return File;
68 }
69
70
71 OUString getDatabase() const
72 {
73 if( ! m_ptr )
74 return OUString();
75
76 sal_Int32 sizeOfDatabase = static_cast<int>(m_ptr[ 1+ static_cast<sal_Int32>(m_ptr[0]) ]);
77 return OUString( m_ptr + 2 + static_cast<sal_Int32>(m_ptr[0]),sizeOfDatabase,RTL_TEXTENCODING_UTF8 );
78 }
79
80
81 OUString getTitle() const
82 {
83 if( ! m_ptr )
84 return OUString();
85
86 //fdo#82025 - use strlen instead of stored length byte to determine string len
87 //There is a one byte length field at m_ptr[2 + m_ptr[0] + m_ptr[1
88 //+ m_ptr[0]]] but by default char is signed so anything larger
89 //than 127 defaults to a negative value, casting it would allow up
90 //to 255 but instead make use of the null termination to avoid
91 //running into a later problem with strings >= 255
92 const char* pTitle = m_ptr + 3 + m_ptr[0] + static_cast<sal_Int32>(m_ptr[ 1+ static_cast<sal_Int32>(m_ptr[0]) ]);
93
94 return OStringToOUString(pTitle, RTL_TEXTENCODING_UTF8);
95 }
96
97
98 private:
99
100 const char* m_ptr;
101
102 };
103
104
106 {
107 public:
109 URLParameter( const OUString& aURL,
110 Databases* pDatabases );
111
112 bool isActive() const { return !m_aActive.isEmpty() && m_aActive == "true"; }
113 bool isQuery() const { return m_aId.isEmpty() && !m_aQuery.isEmpty(); }
114 bool isFile() const { return !m_aId.isEmpty(); }
115 bool isModule() const { return m_aId.isEmpty() && !m_aModule.isEmpty(); }
116 bool isRoot() const { return m_aModule.isEmpty(); }
117 bool isErrorDocument();
118
119 OUString const & get_id();
120
121 OUString get_tag();
122
123 // Not called for a directory
124
125 OUString const & get_path();
126
127 const OUString& get_eid() const { return m_aEid; }
128
129 OUString get_title();
130
131 OUString get_jar();
132
133 const OUString& get_ExtensionRegistryPath() const { return m_aExtensionRegistryPath; }
134
135 const OUString& get_module() const { return m_aModule; }
136
137 OUString const & get_dbpar() const
138 {
139 if( !m_aDbPar.isEmpty() )
140 return m_aDbPar;
141 else
142 return m_aModule;
143 }
144
145 OUString const & get_language() const;
146
147 OUString const & get_program();
148
149 const OUString& get_query() const { return m_aQuery; }
150
151 const OUString& get_scope() const { return m_aScope; }
152
153 const OUString& get_system() const { return m_aSystem; }
154
155 sal_Int32 get_hitCount() const { return m_nHitCount; }
156
157 OString getByName( const char* par );
158
159 void open( const css::uno::Reference< css::io::XActiveDataSink >& xDataSink );
160
161 void open( const css::uno::Reference< css::io::XOutputStream >& xDataSink );
162
163 private:
164
166
169
170 OUString m_aURL;
171
172 OUString m_aTag;
173 OUString m_aId;
174 OUString m_aPath;
175 OUString m_aModule;
176 OUString m_aTitle;
177 OUString m_aJar;
179 OUString m_aEid;
180 OUString m_aDbPar;
181
182 OUString m_aLanguage;
183
184 OUString m_aPrefix;
185 OUString m_aProgram;
186 OUString m_aSystem;
187 OUString m_aActive;
188
189 OUString m_aQuery;
190 OUString m_aScope;
191
192 OUString m_aExpr;
193
194 sal_Int32 m_nHitCount; // The default maximum hitcount
195
196
197 // private methods
198
199 void init();
200
201 OUString get_the_tag();
202
203 OUString get_the_title();
204
205 void readHelpDataFile();
206
208 void parse();
209
210 bool scheme();
211
212 bool module();
213
214 bool name( bool modulePresent );
215
216 bool query();
217
218 }; // end class URLParameter
219
220
221} // end namespace chelp
222
223/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DbtToStringConverter(const char *ptr)
OUString getDatabase() const
URLParameter(const OUString &aURL, Databases *pDatabases)
void open(const css::uno::Reference< css::io::XOutputStream > &xDataSink)
OUString const & get_id()
bool isQuery() const
bool isModule() const
bool isActive() const
OUString get_the_title()
const OUString & get_ExtensionRegistryPath() const
OString getByName(const char *par)
OUString const & get_dbpar() const
OUString m_aExtensionRegistryPath
void open(const css::uno::Reference< css::io::XActiveDataSink > &xDataSink)
sal_Int32 get_hitCount() const
const OUString & get_eid() const
const OUString & get_module() const
const OUString & get_system() const
bool name(bool modulePresent)
Databases * m_pDatabases
OUString const & get_language() const
OUString const & get_path()
const OUString & get_query() const
const OUString & get_scope() const
OUString const & get_program()
URL aURL
float u
const sal_uInt16 idx[]