1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef SD_SIDEBAR_PANELS_DCUMENT_HELPER_HXX
23 #define SD_SIDEBAR_PANELS_DCUMENT_HELPER_HXX
24 
25 #include <tools/solar.h>
26 #include <boost/shared_ptr.hpp>
27 #include <vector>
28 
29 class SdDrawDocument;
30 class SdPage;
31 class String;
32 
33 namespace sd { namespace sidebar {
34 
35 /** A collection of methods supporting the handling of master pages.
36 */
37 class DocumentHelper
38 {
39 public:
40     /** Return a copy of the given master page in the given document.
41     */
42     static SdPage* CopyMasterPageToLocalDocument (
43         SdDrawDocument& rTargetDocument,
44         SdPage* pMasterPage);
45 
46     /** Return and, when not yet present, create a slide that uses the given
47         masster page.
48     */
49     static SdPage* GetSlideForMasterPage (SdPage* pMasterPage);
50 
51     /** Copy the styles used by the given page from the source document to
52         the target document.
53     */
54     static void ProvideStyles (
55         SdDrawDocument& rSourceDocument,
56         SdDrawDocument& rTargetDocument,
57         SdPage* pPage);
58 
59     /** Assign the given master page to the list of pages.
60         @param rTargetDocument
61             The document that is the owner of the pages in rPageList.
62         @param pMasterPage
63             This master page will usually be a member of the list of all
64             available master pages as provided by the MasterPageContainer.
65         @param rPageList
66             The pages to which to assign the master page.  These pages may
67             be slides or master pages themselves.
68     */
69     static void AssignMasterPageToPageList (
70         SdDrawDocument& rTargetDocument,
71         SdPage* pMasterPage,
72         const ::boost::shared_ptr<std::vector<SdPage*> >& rPageList);
73 
74 private:
75     static SdPage* AddMasterPage (
76         SdDrawDocument& rTargetDocument,
77         SdPage* pMasterPage);
78     static SdPage* AddMasterPage (
79         SdDrawDocument& rTargetDocument,
80         SdPage* pMasterPage,
81         sal_uInt16 nInsertionIndex);
82     static SdPage* ProvideMasterPage (
83         SdDrawDocument& rTargetDocument,
84         SdPage* pMasterPage,
85         const ::boost::shared_ptr<std::vector<SdPage*> >& rpPageList);
86 
87     /** Assign the given master page to the given page.
88         @param pMasterPage
89             In contrast to AssignMasterPageToPageList() this page is assumed
90             to be in the target document, i.e. the same document that pPage
91             is in.  The caller will usually call AddMasterPage() to create a
92             clone of a master page in a another document to create it.
93         @param rsBaseLayoutName
94             The layout name of the given master page.  It is given so that
95             it has not to be created on every call.  It could be generated
96             from the given master page, though.
97         @param pPage
98             The page to which to assign the master page.  It can be a slide
99             or a master page itself.
100     */
101     static void AssignMasterPageToPage (
102         SdPage* pMasterPage,
103         const String& rsBaseLayoutName,
104         SdPage* pPage);
105 };
106 
107 
108 } } // end of namespace sd::sidebar
109 
110 #endif
111