1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: urlparameter.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _URLPARAMETER_HXX_
32 #define _URLPARAMETER_HXX_
34 #include <rtl/ustring.hxx>
35 #include <rtl/string.hxx>
36 #include <com/sun/star/ucb/IllegalIdentifierException.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
39 #include <com/sun/star/io/XActiveDataSink.hpp>
40 #include <com/sun/star/io/XOutputStream.hpp>
41 #include <com/sun/star/ucb/Command.hpp>
49 class DbtToStringConverter
53 DbtToStringConverter( const sal_Char
* ptr
,sal_Int32 len
)
60 rtl::OUString
getHash()
64 sal_Int32 sizeOfFile
= ( sal_Int32
) m_ptr
[0];
65 rtl::OUString
Hash( m_ptr
+1,sizeOfFile
,RTL_TEXTENCODING_UTF8
);
67 if( ( idx
= Hash
.indexOf( sal_Unicode( '#' ) ) ) != -1 )
68 return Hash
.copy( 1+idx
);
70 return rtl::OUString();
74 rtl::OUString
getFile()
77 return rtl::OUString();
79 sal_Int32 sizeOfFile
= ( sal_Int32
) m_ptr
[0];
80 rtl::OUString
File( m_ptr
+1,sizeOfFile
,RTL_TEXTENCODING_UTF8
);
82 if( ( idx
= File
.indexOf( sal_Unicode( '#' ) ) ) != -1 )
83 return File
.copy( 0,idx
);
89 rtl::OUString
getDatabase()
92 return rtl::OUString();
94 sal_Int32 sizeOfDatabase
= ( int ) m_ptr
[ 1+ ( sal_Int32
) m_ptr
[0] ];
95 return rtl::OUString( m_ptr
+ 2 + ( sal_Int32
) m_ptr
[0],sizeOfDatabase
,RTL_TEXTENCODING_UTF8
);
99 rtl::OUString
getTitle()
101 if( ! m_ptr
) // || getHash().getLength() )
102 return rtl::OUString();
104 sal_Int32 sizeOfTitle
=
105 ( sal_Int32
) m_ptr
[ 2 + m_ptr
[0] + ( sal_Int32
) m_ptr
[ 1+ ( sal_Int32
) m_ptr
[0] ] ];
106 return rtl::OUString( m_ptr
+ 3 + m_ptr
[0] + ( sal_Int32
) m_ptr
[ 1+ ( sal_Int32
) m_ptr
[0] ],
108 RTL_TEXTENCODING_UTF8
);
116 const sal_Char
* m_ptr
;
127 URLParameter( const rtl::OUString
& aURL
,
128 Databases
* pDatabases
)
129 throw( com::sun::star::ucb::IllegalIdentifierException
);
131 bool isPicture() { return m_aModule
.compareToAscii("picture") == 0; }
132 bool isActive() { return m_aActive
.getLength() > 0 && m_aActive
.compareToAscii( "true" ) == 0; }
133 bool isQuery() { return m_aId
.compareToAscii("") == 0 && m_aQuery
.compareToAscii("") != 0; }
134 bool isEntryForModule() { return m_aId
.compareToAscii("start") == 0 || m_bStart
; }
135 bool isFile() { return m_aId
.compareToAscii( "" ) != 0; }
136 bool isModule() { return m_aId
.compareToAscii("") == 0 && m_aModule
.compareToAscii("") != 0; }
137 bool isRoot() { return m_aModule
.compareToAscii("") == 0; }
138 bool isErrorDocument();
140 rtl::OUString
get_url() { return m_aURL
; }
142 rtl::OUString
get_id();
144 rtl::OUString
get_tag();
146 // Not called for an directory
148 rtl::OUString
get_path() { return get_the_path(); }
150 rtl::OUString
get_eid() { return m_aEid
; }
152 rtl::OUString
get_title();
154 rtl::OUString
get_jar() { return get_the_jar(); } // BerkeleyDb
156 rtl::OUString
get_module() { return m_aModule
; }
158 rtl::OUString
get_dbpar() {
159 if( m_aDbPar
.getLength() ) return m_aDbPar
;
160 else return m_aModule
;
163 rtl::OUString
get_prefix() { return m_aPrefix
; }
165 rtl::OUString
get_language();
167 rtl::OUString
get_device() { return m_aDevice
; }
169 rtl::OUString
get_program();
171 rtl::OUString
get_query() { return m_aQuery
; }
173 rtl::OUString
get_scope() { return m_aScope
; }
175 rtl::OUString
get_system() { return m_aSystem
; }
177 sal_Int32
get_hitCount() { return m_nHitCount
; }
179 rtl::OString
getByName( const char* par
);
181 void open( const com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& rxSMgr
,
182 const com::sun::star::ucb::Command
& aCommand
,
184 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& Environment
,
185 const com::sun::star::uno::Reference
< com::sun::star::io::XActiveDataSink
>& xDataSink
);
187 void open( const com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& rxSMgr
,
188 const com::sun::star::ucb::Command
& aCommand
,
190 const com::sun::star::uno::Reference
< com::sun::star::ucb::XCommandEnvironment
>& Environment
,
191 const com::sun::star::uno::Reference
< com::sun::star::io::XOutputStream
>& xDataSink
);
195 Databases
* m_pDatabases
;
197 bool m_bBerkeleyRead
;
201 rtl::OUString m_aURL
;
203 rtl::OUString m_aTag
;
205 rtl::OUString m_aPath
;
206 rtl::OUString m_aModule
;
207 rtl::OUString m_aTitle
;
208 rtl::OUString m_aJar
;
209 rtl::OUString m_aEid
;
210 rtl::OUString m_aDbPar
;
212 rtl::OUString m_aDefaultLanguage
;
213 rtl::OUString m_aLanguage
;
215 rtl::OUString m_aPrefix
;
216 rtl::OUString m_aDevice
;
217 rtl::OUString m_aProgram
;
218 rtl::OUString m_aSystem
;
219 rtl::OUString m_aActive
;
221 rtl::OUString m_aQuery
;
222 rtl::OUString m_aScope
;
224 rtl::OUString m_aExpr
;
226 sal_Int32 m_nHitCount
; // The default maximum hitcount
231 void init( bool bDefaultLanguageIsInitialized
);
233 rtl::OUString
get_the_tag();
235 rtl::OUString
get_the_path();
237 rtl::OUString
get_the_title();
239 rtl::OUString
get_the_jar();
243 void parse() throw( com::sun::star::ucb::IllegalIdentifierException
);
249 bool name( bool modulePresent
);
253 }; // end class URLParameter
256 } // end namespace chelp