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