Bump for 3.6-28
[LibreOffice.git] / ucb / source / ucp / odma / odma_provider.hxx
blob7f99bbeccdb7dd4cb02193d4240b8a76c1efd5d2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef ODMA_PROVIDER_HXX
30 #define ODMA_PROVIDER_HXX
32 #include <ucbhelper/providerhelper.hxx>
33 #include "odma_lib.hxx"
35 #include "rtl/ref.hxx"
37 #include <map>
38 #include "odma_contentprops.hxx"
40 namespace odma {
42 //=========================================================================
44 // UNO service name for the provider. This name will be used by the UCB to
45 // create instances of the provider.
46 #define ODMA_CONTENT_PROVIDER_SERVICE_NAME \
47 "com.sun.star.ucb.ODMAContentProvider"
48 // #define ODMA_CONTENT_PROVIDER_SERVICE_NAME_LENGTH 34
50 // URL scheme. This is the scheme the provider will be able to create
51 // contents for. The UCB will select the provider ( i.e. in order to create
52 // contents ) according to this scheme.
53 #define ODMA_URL_ODMAID "::ODMA"
54 #define ODMA_URL_SCHEME "vnd.sun.star.odma"
55 #define ODMA_URL_SCHEME_SHORT "odma"
56 #define ODMA_URL_SHORT ":"
57 #define ODMA_URL_SHORT_LGTH 5
58 #define ODMA_URL_LGTH 18
59 #define ODMA_URL_ODMAID_LGTH 6
61 // UCB Content Type.
62 #define ODMA_CONTENT_TYPE "application/" ODMA_URL_SCHEME "-content"
63 #define ODMA_ODMA_REGNAME "sodma"
64 #define ODM_NAME_MAX 64 // Max length of a name document including
65 // the terminating NULL character.
67 //=========================================================================
68 class ContentProperties;
69 class ContentProvider : public ::ucbhelper::ContentProviderImplHelper
71 typedef ::std::map< ::rtl::OString, ::rtl::Reference<ContentProperties> > ContentsMap;
72 ContentsMap m_aContents; // contains all ContentProperties
73 static ODMHANDLE m_aOdmHandle; // the one and only ODMA handle to our DMS
75 /** fillDocumentProperties fills the given _rProp with ODMA properties
76 @param _rProp the ContentProperties
78 void fillDocumentProperties(const ::rtl::Reference<ContentProperties>& _rProp);
80 /**
82 ::rtl::Reference<ContentProperties> getContentProperty(const ::rtl::OUString& _sName,
83 const ContentPropertiesMemberFunctor& _aFunctor) const;
84 public:
85 ContentProvider( const ::com::sun::star::uno::Reference<
86 ::com::sun::star::lang::XMultiServiceFactory >& rSMgr );
87 virtual ~ContentProvider();
89 // XInterface
90 XINTERFACE_DECL()
92 // XTypeProvider
93 XTYPEPROVIDER_DECL()
95 // XServiceInfo
96 XSERVICEINFO_DECL()
98 // XContentProvider
99 virtual ::com::sun::star::uno::Reference<
100 ::com::sun::star::ucb::XContent > SAL_CALL
101 queryContent( const ::com::sun::star::uno::Reference<
102 ::com::sun::star::ucb::XContentIdentifier >& Identifier )
103 throw( ::com::sun::star::ucb::IllegalIdentifierException,
104 ::com::sun::star::uno::RuntimeException );
106 //////////////////////////////////////////////////////////////////////
107 // Additional interfaces
108 //////////////////////////////////////////////////////////////////////
110 //////////////////////////////////////////////////////////////////////
111 // Non-interface methods.
112 //////////////////////////////////////////////////////////////////////
113 static ODMHANDLE getHandle();
115 /** append add an entry to the internal map
116 @param _rProp the content properties
118 void append(const ::rtl::Reference<ContentProperties>& _rProp);
120 /** closeDocument closes the document
121 @param _sDocumentId the id of the document
123 void closeDocument(const ::rtl::OString& _sDocumentId);
125 /** saveDocument saves the document in DMS
126 @param _sDocumentId the id of the document
128 void saveDocument(const ::rtl::OString& _sDocumentId);
130 /** queryContentProperty query in the DMS for a content which document name is equal to _sDocumentName
131 @param _sDocumentName the document to query for
133 @return the content properties for this content or an empty refernce
135 ::rtl::Reference<ContentProperties> queryContentProperty(const ::rtl::OUString& _sDocumentName);
137 /** getContentPropertyWithTitle returns the ContentProperties for the first content with that title
138 @param _sTitle the title of the document
140 @return the content properties
142 ::rtl::Reference<ContentProperties> getContentPropertyWithTitle(const ::rtl::OUString& _sTitle) const;
144 /** getContentPropertyWithDocumentId returns the ContentProperties for the first content with that title
145 @param _sTitle the title of the document
147 @return the content properties
149 ::rtl::Reference<ContentProperties> getContentPropertyWithDocumentId(const ::rtl::OUString& _sDocumentId) const;
151 /** getContentPropertyWithSavedAsName returns the ContentProperties for the first content with that SavedAsName
152 @param _sSaveAsName the SavedAsName of the document
154 @return the content properties
156 ::rtl::Reference<ContentProperties> getContentPropertyWithSavedAsName(const ::rtl::OUString& _sSaveAsName) const;
158 /** openDoc returns the URL for the temporary file for the specific Content and opens it
159 @param _rProp used for check if already open, the member m_sFileURL will be set if is wan't opened yet
161 @return the URL of the temporary file
163 static ::rtl::OUString openDoc(const ::rtl::Reference<ContentProperties>& _rProp) throw (::com::sun::star::uno::Exception);
165 /** convertURL converts a normal URL into an ODMA understandable name
166 @param _sCanonicURL the URL from ContentIndentifier
168 @return the ODMA name
170 static ::rtl::OUString convertURL(const ::rtl::OUString& _sCanonicURL);
172 /** deleteDocument deletes the document inside the DMS and remove the content properties from inside list
173 @param _rProp the ContentProperties
175 @return true when successful
177 sal_Bool deleteDocument(const ::rtl::Reference<ContentProperties>& _rProp);
182 #endif
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */