1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SFX2_DOCTEMPL_HXX
20 #define INCLUDED_SFX2_DOCTEMPL_HXX
22 #include <rtl/ustring.hxx>
23 #include <sal/config.h>
24 #include <sal/types.h>
25 #include <sfx2/dllapi.h>
26 #include <tools/ref.hxx>
28 // CLASS -----------------------------------------------------------------
32 #ifndef SFX_DECL_OBJECTSHELL_DEFINED
33 #define SFX_DECL_OBJECTSHELL_DEFINED
34 typedef tools::SvRef
<SfxObjectShell
> SfxObjectShellRef
;
37 class SfxDocTemplate_Impl
;
39 #ifndef SFX_DECL_DOCTEMPLATES_DEFINED
40 #define SFX_DECL_DOCTEMPLATES_DEFINED
41 typedef tools::SvRef
<SfxDocTemplate_Impl
> SfxDocTemplate_ImplRef
;
44 // class SfxDocumentTemplates --------------------------------------------
46 class SFX2_DLLPUBLIC SfxDocumentTemplates
49 SfxDocTemplate_ImplRef pImp
;
51 SAL_DLLPRIVATE
bool CopyOrMove( sal_uInt16 nTargetRegion
, sal_uInt16 nTargetIdx
,
52 sal_uInt16 nSourceRegion
, sal_uInt16 nSourceIdx
, bool bMove
);
54 SfxDocumentTemplates();
55 SfxDocumentTemplates(const SfxDocumentTemplates
&);
56 ~SfxDocumentTemplates();
58 bool IsConstructed() { return pImp
!= NULL
; }
60 const SfxDocumentTemplates
&operator=(const SfxDocumentTemplates
&);
62 void ReInitFromComponent();
64 sal_uInt16
GetRegionCount() const;
65 const OUString
& GetRegionName(sal_uInt16 nIdx
) const; //dv!
66 OUString
GetFullRegionName(sal_uInt16 nIdx
) const;
68 sal_uInt16
GetCount(sal_uInt16 nRegion
) const;
69 const OUString
& GetName(sal_uInt16 nRegion
, sal_uInt16 nIdx
) const; //dv!
70 OUString
GetPath(sal_uInt16 nRegion
, sal_uInt16 nIdx
) const;
72 // Allows to retrieve the target template URL from the UCB
73 OUString
GetTemplateTargetURLFromComponent( const OUString
& aGroupName
,
74 const OUString
& aTitle
);
76 // Convert a resource string - a template name - to its localised pair
77 // if it exists in templatelocnames.src
78 static OUString
ConvertResourceString(int nSourceResIds
,
81 const OUString
& rString
);
83 bool Copy(sal_uInt16 nTargetRegion
,
84 sal_uInt16 nTargetIdx
,
85 sal_uInt16 nSourceRegion
,
86 sal_uInt16 nSourceIdx
);
87 bool Move(sal_uInt16 nTargetRegion
,
88 sal_uInt16 nTargetIdx
,
89 sal_uInt16 nSourceRegion
,
90 sal_uInt16 nSourceIdx
);
91 bool Delete(sal_uInt16 nRegion
, sal_uInt16 nIdx
);
92 bool InsertDir(const OUString
&rText
, sal_uInt16 nRegion
);
94 bool InsertTemplate (sal_uInt16 nSourceRegion
, sal_uInt16 nIdx
, const OUString
&rName
, const OUString
&rPath
);
96 /** Change the name of an entry or a directory
101 The id of the region to rename or containing the template to rename
103 The id of the template to rename or USHRT_MAX to rename the region.
106 sal_True if the action could be performed, sal_False otherwise
109 bool SetName(const OUString
&rName
, sal_uInt16 nRegion
, sal_uInt16 nIdx
);
111 bool CopyTo(sal_uInt16 nRegion
, sal_uInt16 nIdx
, const OUString
&rName
) const;
112 bool CopyFrom(sal_uInt16 nRegion
, sal_uInt16 nIdx
, OUString
&rName
);
114 bool GetFull( const OUString
& rRegion
, const OUString
& rName
, OUString
& rPath
);
115 bool GetLogicNames( const OUString
& rPath
, OUString
& rRegion
, OUString
& rName
) const;
117 /** updates the configuration where the document templates structure is stored.
119 <p>The info about the document templates (which files, which groups etc.) is stored in the
120 configuration. This means that just by copying files into OOo's template directories, this
121 change is not reflected in the SfxDocumentTemplates - 'cause the configuration is not synchronous with
122 the file system. This can be enforced with this method.</p>
125 The update of the configuration is rather expensive - nothing you want to do regulary if you don't really
126 need it. So you have the possibility to do a smart update - it first checks if the update if necessary.
127 In case the update is needed, the additional check made it somewhat more expensive. In case it's not
128 necessary (which should be the usual case), the check alone is (much) less expensive than the real update.
130 So set <arg>_bSmart</arg> to <TRUE/> to do a check for necessity first.
132 void Update( bool _bSmart
= true );
135 #endif // INCLUDED_SFX2_DOCTEMPL_HXX
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */