LibreOffice Module sd (master) 1
fuprobjs.cxx
Go to the documentation of this file.
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#include <fuprobjs.hxx>
21
22#include <svl/stritem.hxx>
23#include <svl/style.hxx>
24#include <editeng/outliner.hxx>
25#include <svl/hint.hxx>
26#include <tools/debug.hxx>
27
28#include <app.hrc>
29
30#include <strings.hxx>
31
32#include <drawdoc.hxx>
33#include <sfx2/sfxdlg.hxx>
34#include <DrawDocShell.hxx>
35#include <OutlineView.hxx>
36#include <OutlineViewShell.hxx>
37#include <ViewShell.hxx>
38#include <Window.hxx>
39#include <glob.hxx>
40#include <prlayout.hxx>
41#include <unchss.hxx>
42#include <sdabstdlg.hxx>
43#include <memory>
44
45namespace sd {
46
47
49 ViewShell* pViewSh,
50 ::sd::Window* pWin,
51 ::sd::View* pView,
52 SdDrawDocument* pDoc,
53 SfxRequest& rReq)
54 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
55{
56}
57
59{
60 rtl::Reference<FuPoor> xFunc( new FuPresentationObjects( pViewSh, pWin, pView, pDoc, rReq ) );
61 xFunc->DoExecute(rReq);
62 return xFunc;
63}
64
66{
67 OutlineViewShell* pOutlineViewShell = dynamic_cast< OutlineViewShell* >( mpViewShell );
68 DBG_ASSERT( pOutlineViewShell, "sd::FuPresentationObjects::DoExecute(), does not work without an OutlineViewShell!");
69 if( !pOutlineViewShell )
70 return;
71
72 /* does the selections end in a unique presentation layout?
73 if not, it is not allowed to edit the templates */
75 pOutlineViewShell->GetStatusBarState( aSet );
76 OUString aLayoutName = aSet.Get(SID_STATUS_LAYOUT).GetValue();
77 DBG_ASSERT(!aLayoutName.isEmpty(), "Layout not defined");
78
79 bool bUnique = false;
80 sal_Int16 nDepth, nTmp;
81 OutlineView* pOlView = static_cast<OutlineView*>(pOutlineViewShell->GetView());
82 OutlinerView* pOutlinerView = pOlView->GetViewByWindow( static_cast<Window*>(mpWindow) );
83 ::Outliner* pOutl = pOutlinerView->GetOutliner();
84
85 std::vector<Paragraph*> aSelList;
86 pOutlinerView->CreateSelectionList(aSelList);
87
88 Paragraph* pPara = aSelList.empty() ? nullptr : aSelList.front();
89
90 nDepth = pOutl->GetDepth(pOutl->GetAbsPos( pPara ) );
91 bool bPage = ::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE );
92
93 for( const auto& rpPara : aSelList )
94 {
95 nTmp = pOutl->GetDepth( pOutl->GetAbsPos( rpPara ) );
96
97 if( nDepth != nTmp )
98 {
99 bUnique = false;
100 break;
101 }
102
103 if( ::Outliner::HasParaFlag( rpPara, ParaFlag::ISPAGE ) != bPage )
104 {
105 bUnique = false;
106 break;
107 }
108 bUnique = true;
109 }
110
111 if( !bUnique )
112 return;
113
114 OUString aStyleName = aLayoutName + SD_LT_SEPARATOR;
116
117 if( bPage )
118 {
120 aStyleName += STR_LAYOUT_TITLE;
121 }
122 else
123 {
124 ePO = static_cast<PresentationObjects>( static_cast<int>(PresentationObjects::Outline_1) + nDepth - 1 );
125 aStyleName += STR_LAYOUT_OUTLINE + " " + OUString::number(nDepth);
126 }
127
128 SfxStyleSheetBasePool* pStyleSheetPool = mpDocSh->GetStyleSheetPool();
129 SfxStyleSheetBase* pStyleSheet = pStyleSheetPool->Find( aStyleName, SfxStyleFamily::Page );
130 DBG_ASSERT(pStyleSheet, "StyleSheet missing");
131
132 if( !pStyleSheet )
133 return;
134
135 SfxStyleSheetBase& rStyleSheet = *pStyleSheet;
136
139 false, rStyleSheet, ePO, pStyleSheetPool));
140 if( pDlg->Execute() == RET_OK )
141 {
142 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
143 // Undo-Action
145 std::make_unique<StyleSheetUndoAction>(mpDoc, static_cast<SfxStyleSheet*>(pStyleSheet), pOutSet));
146
147 pStyleSheet->GetItemSet().Put( *pOutSet );
148 static_cast<SfxStyleSheet*>( pStyleSheet )->Broadcast( SfxHint( SfxHintId::DataChanged ) );
149 }
150}
151
152} // end of namespace sd
153
154/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void CreateSelectionList(std::vector< Paragraph * > &aSelList)
Outliner * GetOutliner() const
static bool HasParaFlag(const Paragraph *pPara, ParaFlag nFlag)
sal_Int16 GetDepth(sal_Int32 nPara) const
sal_Int32 GetAbsPos(Paragraph const *pPara) const
virtual VclPtr< SfxAbstractTabDialog > CreateSdPresLayoutTemplateDlg(SfxObjectShell *pDocSh, weld::Window *pParent, bool bBackgroundDlg, SfxStyleSheetBase &rStyleBase, PresentationObjects ePO, SfxStyleSheetBasePool *pSSPool)=0
static SD_DLLPUBLIC SdAbstractDialogFactory * Create()
Definition: sdabstdlg.cxx:38
const SfxItemPool & GetItemPool() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
virtual SfxItemSet & GetItemSet()
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
virtual SfxStyleSheetBasePool * GetStyleSheetPool() override
Definition: docshel4.cxx:690
virtual SfxUndoManager * GetUndoManager() override
Definition: docshell.cxx:363
Base class for all functions.
Definition: fupoor.hxx:48
SdDrawDocument * mpDoc
Definition: fupoor.hxx:148
VclPtr< ::sd::Window > mpWindow
Definition: fupoor.hxx:146
ViewShell * mpViewShell
Definition: fupoor.hxx:145
DrawDocShell * mpDocSh
Definition: fupoor.hxx:147
FuPresentationObjects(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fuprobjs.cxx:48
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fuprobjs.cxx:58
virtual void DoExecute(SfxRequest &rReq) override
Definition: fuprobjs.cxx:65
Show a textual overview of the text contents of all slides.
void GetStatusBarState(SfxItemSet &rSet)
Definition: outlnvsh.cxx:1246
Derivative of sd::View for the outline mode |* .
Definition: OutlineView.hxx:55
OutlinerView * GetViewByWindow(vcl::Window const *pWin) const
Return a pointer to the OutlinerView corresponding to the window.
Definition: outlview.cxx:262
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
::sd::View * GetView() const
Definition: ViewShell.hxx:144
SD_DLLPUBLIC weld::Window * GetFrameWeld() const
Definition: viewshel.cxx:1582
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
#define DBG_ASSERT(sCon, aError)
constexpr OUStringLiteral SD_LT_SEPARATOR
Definition: glob.hxx:49
PresentationObjects
Definition: prlayout.hxx:29
constexpr OUStringLiteral STR_LAYOUT_TITLE
Definition: strings.hxx:15
constexpr OUStringLiteral STR_LAYOUT_OUTLINE
Definition: strings.hxx:16
RET_OK