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 
23 
24 #ifndef SD_TOOLPANEL_CONTROLS_DCUMENT_HELPER_HXX
25 #define SD_TOOLPANEL_CONTROLS_DCUMENT_HELPER_HXX
26 
27 #include <tools/solar.h>
28 #include <boost/shared_ptr.hpp>
29 #include <vector>
30 
31 class SdDrawDocument;
32 class SdPage;
33 class String;
34 
35 namespace sd { namespace toolpanel { namespace controls {
36 
37 /** A collection of methods supporting the handling of master pages.
38 */
39 class DocumentHelper
40 {
41 public:
42     /** Return a copy of the given master page in the given document.
43     */
44     static SdPage* CopyMasterPageToLocalDocument (
45         SdDrawDocument& rTargetDocument,
46         SdPage* pMasterPage);
47 
48     /** Return and, when not yet present, create a slide that uses the given
49         masster page.
50     */
51     static SdPage* GetSlideForMasterPage (SdPage* pMasterPage);
52 
53     /** Copy the styles used by the given page from the source document to
54         the target document.
55     */
56     static void ProvideStyles (
57         SdDrawDocument& rSourceDocument,
58         SdDrawDocument& rTargetDocument,
59         SdPage* pPage);
60 
61     /** Assign the given master page to the list of pages.
62         @param rTargetDocument
63             The document that is the owner of the pages in rPageList.
64         @param pMasterPage
65             This master page will usually be a member of the list of all
66             available master pages as provided by the MasterPageContainer.
67         @param rPageList
68             The pages to which to assign the master page.  These pages may
69             be slides or master pages themselves.
70     */
71     static void AssignMasterPageToPageList (
72         SdDrawDocument& rTargetDocument,
73         SdPage* pMasterPage,
74         const ::boost::shared_ptr<std::vector<SdPage*> >& rPageList);
75 
76 private:
77     static SdPage* AddMasterPage (
78         SdDrawDocument& rTargetDocument,
79         SdPage* pMasterPage);
80     static SdPage* AddMasterPage (
81         SdDrawDocument& rTargetDocument,
82         SdPage* pMasterPage,
83         sal_uInt16 nInsertionIndex);
84     static SdPage* ProvideMasterPage (
85         SdDrawDocument& rTargetDocument,
86         SdPage* pMasterPage,
87         const ::boost::shared_ptr<std::vector<SdPage*> >& rpPageList);
88 
89     /** Assign the given master page to the given page.
90         @param pMasterPage
91             In contrast to AssignMasterPageToPageList() this page is assumed
92             to be in the target document, i.e. the same document that pPage
93             is in.  The caller will usually call AddMasterPage() to create a
94             clone of a master page in a another document to create it.
95         @param rsBaseLayoutName
96             The layout name of the given master page.  It is given so that
97             it has not to be created on every call.  It could be generated
98             from the given master page, though.
99         @param pPage
100             The page to which to assign the master page.  It can be a slide
101             or a master page itself.
102     */
103     static void AssignMasterPageToPage (
104         SdPage* pMasterPage,
105         const String& rsBaseLayoutName,
106         SdPage* pPage);
107 };
108 
109 
110 } } } // end of namespace ::sd::toolpanel::controls
111 
112 #endif
113