Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include "MasterPagesPanel.hxx"
22 : #include "taskpane/ScrollPanel.hxx"
23 : #include "CurrentMasterPagesSelector.hxx"
24 : #include "RecentMasterPagesSelector.hxx"
25 : #include "AllMasterPagesSelector.hxx"
26 : #include "taskpane/ToolPanelViewShell.hxx"
27 : #include "taskpane/TaskPaneControlFactory.hxx"
28 : #include "taskpane/TitledControl.hxx"
29 : #include "../TaskPaneShellManager.hxx"
30 :
31 : #include "DrawViewShell.hxx"
32 : #include "ViewShellBase.hxx"
33 :
34 : #include "strings.hrc"
35 : #include "sdresid.hxx"
36 : #include "helpids.h"
37 : #include "app.hrc"
38 :
39 : namespace sd { namespace toolpanel { namespace controls {
40 :
41 :
42 0 : MasterPagesPanel::MasterPagesPanel (::Window& i_rParentWindow, ToolPanelViewShell& i_rPanelViewShell)
43 : :ScrollPanel (i_rParentWindow)
44 0 : ,m_pPanelViewShell( &i_rPanelViewShell )
45 : {
46 0 : impl_construct( m_pPanelViewShell->GetViewShellBase() );
47 0 : }
48 :
49 0 : void MasterPagesPanel::impl_construct( ViewShellBase& rBase )
50 : {
51 0 : SdDrawDocument* pDocument = rBase.GetDocument();
52 0 : ::std::auto_ptr<controls::MasterPagesSelector> pSelector;
53 :
54 0 : ::boost::shared_ptr<MasterPageContainer> pContainer (new MasterPageContainer());
55 :
56 : // Create a panel with the master pages that are in use by the currently
57 : // edited document.
58 0 : DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(rBase.GetMainViewShell().get());
59 : pSelector.reset(new controls::CurrentMasterPagesSelector (
60 : this,
61 : *pDocument,
62 : rBase,
63 0 : pContainer));
64 0 : pSelector->LateInit();
65 0 : pSelector->SetHelpId( HID_SD_TASK_PANE_PREVIEW_CURRENT );
66 0 : GetShellManager()->AddSubShell(
67 : SHELLID_SD_TASK_PANE_PREVIEW_CURRENT,
68 0 : pSelector.get(),
69 0 : pSelector->GetWindow());
70 : AddControl (
71 0 : ::std::auto_ptr<TreeNode>(pSelector.release()),
72 : SdResId(STR_TASKPANEL_CURRENT_MASTER_PAGES_TITLE),
73 0 : HID_SD_CURRENT_MASTERS);
74 :
75 : // Create a panel with the most recently used master pages.
76 : pSelector.reset(new controls::RecentMasterPagesSelector (
77 : this,
78 : *pDocument,
79 : rBase,
80 0 : pContainer));
81 0 : pSelector->LateInit();
82 0 : pSelector->SetHelpId( HID_SD_TASK_PANE_PREVIEW_RECENT );
83 0 : GetShellManager()->AddSubShell(
84 : SHELLID_SD_TASK_PANE_PREVIEW_RECENT,
85 0 : pSelector.get(),
86 0 : pSelector->GetWindow());
87 : AddControl (
88 0 : ::std::auto_ptr<TreeNode>(pSelector.release()),
89 : SdResId(STR_TASKPANEL_RECENT_MASTER_PAGES_TITLE),
90 0 : HID_SD_RECENT_MASTERS);
91 :
92 : // Create a panel with all available master pages.
93 : pSelector.reset(new controls::AllMasterPagesSelector (
94 : this,
95 : *pDocument,
96 : rBase,
97 : *pDrawViewShell,
98 0 : pContainer));
99 0 : pSelector->LateInit();
100 0 : pSelector->SetHelpId( HID_SD_TASK_PANE_PREVIEW_ALL );
101 0 : GetShellManager()->AddSubShell(
102 : SHELLID_SD_TASK_PANE_PREVIEW_ALL,
103 0 : pSelector.get(),
104 0 : pSelector->GetWindow());
105 : AddControl (
106 0 : ::std::auto_ptr<TreeNode>(pSelector.release()),
107 : SdResId(STR_TASKPANEL_ALL_MASTER_PAGES_TITLE),
108 0 : HID_SD_ALL_MASTERS);
109 0 : }
110 :
111 :
112 :
113 :
114 :
115 0 : MasterPagesPanel::~MasterPagesPanel (void)
116 : {
117 0 : TaskPaneShellManager* pShellManager( GetShellManager() );
118 : OSL_ENSURE( pShellManager, "MasterPagesPanel::~MasterPagesPanel: no shell manager anymore - cannot remove sub shells!" );
119 0 : if ( pShellManager )
120 : {
121 0 : pShellManager->RemoveSubShell( SHELLID_SD_TASK_PANE_PREVIEW_CURRENT );
122 0 : pShellManager->RemoveSubShell( SHELLID_SD_TASK_PANE_PREVIEW_RECENT );
123 0 : pShellManager->RemoveSubShell( SHELLID_SD_TASK_PANE_PREVIEW_ALL );
124 : }
125 0 : }
126 :
127 :
128 :
129 :
130 0 : TaskPaneShellManager* MasterPagesPanel::GetShellManager()
131 : {
132 0 : if ( m_pPanelViewShell )
133 0 : return &m_pPanelViewShell->GetSubShellManager();
134 0 : return TreeNode::GetShellManager();
135 : }
136 :
137 :
138 :
139 :
140 0 : std::auto_ptr< ControlFactory > MasterPagesPanel::CreateControlFactory( ToolPanelViewShell& i_rToolPanelShell )
141 : {
142 : return std::auto_ptr< ControlFactory >(
143 0 : new RootControlFactoryWithArg< MasterPagesPanel, ToolPanelViewShell >( i_rToolPanelShell ) );
144 : }
145 :
146 : } } } // end of namespace ::sd::toolpanel::controls
147 :
148 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|