Files
libreoffice/sd/source/ui/func/fuprlout.cxx

283 lines
10 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 16:07:07 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 16:07:07 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:07:07 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 16:07:07 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 16:07:07 +00:00
*
************************************************************************/
#include "fuprlout.hxx"
2000-09-18 16:07:07 +00:00
#include <vcl/wrkwin.hxx>
#include <sfx2/dispatch.hxx>
#include <svl/smplhint.hxx>
#include <svl/itempool.hxx>
#include <sot/storage.hxx>
2000-09-18 16:07:07 +00:00
#include <vcl/msgbox.hxx>
#include <svx/svdundo.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/request.hxx>
2000-09-18 16:07:07 +00:00
#include "drawdoc.hxx"
#include "sdpage.hxx"
#include "pres.hxx"
#include "DrawViewShell.hxx"
#include "FrameView.hxx"
2000-09-18 16:07:07 +00:00
#include "stlpool.hxx"
#include "View.hxx"
2000-09-18 16:07:07 +00:00
#include "glob.hrc"
#include "glob.hxx"
#include "strings.hrc"
#include "strmname.h"
#include "app.hrc"
#include "DrawDocShell.hxx"
2000-09-18 16:07:07 +00:00
#include "unprlout.hxx"
#include "unchss.hxx"
#include "unmovss.hxx"
#include "sdattr.hxx"
#include "sdresid.hxx"
#include "drawview.hxx"
#include "eetext.hxx"
#include <editeng/editdata.hxx>
#include "sdabstdlg.hxx"
namespace sd
{
2000-09-18 16:07:07 +00:00
#ifndef SO2_DECL_SVSTORAGE_DEFINED
#define SO2_DECL_SVSTORAGE_DEFINED
SO2_DECL_REF(SvStorage)
#endif
TYPEINIT1( FuPresentationLayout, FuPoor );
#define DOCUMENT_TOKEN (sal_Unicode('#'))
2000-09-18 16:07:07 +00:00
/*************************************************************************
|*
|* Konstruktor
|*
\************************************************************************/
FuPresentationLayout::FuPresentationLayout (
ViewShell* pViewSh,
::sd::Window* pWin,
::sd::View* pView,
SdDrawDocument* pDoc,
SfxRequest& rReq)
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
{
}
FunctionReference FuPresentationLayout::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
{
FunctionReference xFunc( new FuPresentationLayout( pViewSh, pWin, pView, pDoc, rReq ) );
xFunc->DoExecute(rReq);
return xFunc;
}
void FuPresentationLayout::DoExecute( SfxRequest& rReq )
2000-09-18 16:07:07 +00:00
{
// damit nicht Objekte, die gerade editiert werden oder selektiert
// sind , verschwinden
mpView->SdrEndTextEdit();
2000-09-18 16:07:07 +00:00
if(mpView->GetSdrPageView())
2000-09-18 16:07:07 +00:00
{
mpView->UnmarkAll();
2000-09-18 16:07:07 +00:00
}
sal_Bool bError = sal_False;
2000-09-18 16:07:07 +00:00
// die aktive Seite ermitteln
sal_uInt16 nSelectedPage = SDRPAGE_NOTFOUND;
for (sal_uInt16 nPage = 0; nPage < mpDoc->GetSdPageCount(PK_STANDARD); nPage++)
2000-09-18 16:07:07 +00:00
{
if (mpDoc->GetSdPage(nPage, PK_STANDARD)->IsSelected())
2000-09-18 16:07:07 +00:00
{
nSelectedPage = nPage;
break;
}
}
DBG_ASSERT(nSelectedPage != SDRPAGE_NOTFOUND, "keine selektierte Seite");
SdPage* pSelectedPage = mpDoc->GetSdPage(nSelectedPage, PK_STANDARD);
2000-09-18 16:07:07 +00:00
String aOldPageLayoutName(pSelectedPage->GetLayoutName());
String aOldLayoutName(aOldPageLayoutName);
aOldLayoutName.Erase(aOldLayoutName.SearchAscii(SD_LT_SEPARATOR));
// wenn wir auf einer Masterpage sind, gelten die Aenderungen fuer alle
// Seiten und Notizseiten, die das betreffende Layout benutzen
sal_Bool bOnMaster = sal_False;
if( mpViewShell && mpViewShell->ISA(DrawViewShell))
2000-09-18 16:07:07 +00:00
{
EditMode eEditMode =
static_cast<DrawViewShell*>(mpViewShell)->GetEditMode();
2000-09-18 16:07:07 +00:00
if (eEditMode == EM_MASTERPAGE)
bOnMaster = sal_True;
2000-09-18 16:07:07 +00:00
}
sal_Bool bMasterPage = bOnMaster;
sal_Bool bCheckMasters = sal_False;
2000-09-18 16:07:07 +00:00
// Dialog aufrufen
sal_Bool bLoad = sal_False; // tauchen neue Masterpages auf?
2000-09-18 16:07:07 +00:00
String aFile;
SfxItemSet aSet(mpDoc->GetPool(), ATTR_PRESLAYOUT_START, ATTR_PRESLAYOUT_END);
2000-09-18 16:07:07 +00:00
aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_LOAD, bLoad));
aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_MASTER_PAGE, bMasterPage ) );
aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_CHECK_MASTERS, bCheckMasters ) );
aSet.Put( SfxStringItem( ATTR_PRESLAYOUT_NAME, aOldLayoutName));
2000-09-18 16:07:07 +00:00
const SfxItemSet *pArgs = rReq.GetArgs ();
if (pArgs)
2000-09-18 16:07:07 +00:00
{
if (pArgs->GetItemState(ATTR_PRESLAYOUT_LOAD) == SFX_ITEM_SET)
bLoad = ((SfxBoolItem&)pArgs->Get(ATTR_PRESLAYOUT_LOAD)).GetValue();
if( pArgs->GetItemState( ATTR_PRESLAYOUT_MASTER_PAGE ) == SFX_ITEM_SET )
bMasterPage = ( (SfxBoolItem&) pArgs->Get( ATTR_PRESLAYOUT_MASTER_PAGE ) ).GetValue();
if( pArgs->GetItemState( ATTR_PRESLAYOUT_CHECK_MASTERS ) == SFX_ITEM_SET )
bCheckMasters = ( (SfxBoolItem&) pArgs->Get( ATTR_PRESLAYOUT_CHECK_MASTERS ) ).GetValue();
if (pArgs->GetItemState(ATTR_PRESLAYOUT_NAME) == SFX_ITEM_SET)
aFile = ((SfxStringItem&)pArgs->Get(ATTR_PRESLAYOUT_NAME)).GetValue();
}
else
{
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
AbstractSdPresLayoutDlg* pDlg = pFact ? pFact->CreateSdPresLayoutDlg(mpDocSh, mpViewShell, NULL, aSet ) : 0;
sal_uInt16 nResult = pDlg ? pDlg->Execute() : RET_CANCEL;
switch (nResult)
2000-09-18 16:07:07 +00:00
{
case RET_OK:
{
pDlg->GetAttr(aSet);
if (aSet.GetItemState(ATTR_PRESLAYOUT_LOAD) == SFX_ITEM_SET)
bLoad = ((SfxBoolItem&)aSet.Get(ATTR_PRESLAYOUT_LOAD)).GetValue();
if( aSet.GetItemState( ATTR_PRESLAYOUT_MASTER_PAGE ) == SFX_ITEM_SET )
bMasterPage = ( (SfxBoolItem&) aSet.Get( ATTR_PRESLAYOUT_MASTER_PAGE ) ).GetValue();
if( aSet.GetItemState( ATTR_PRESLAYOUT_CHECK_MASTERS ) == SFX_ITEM_SET )
bCheckMasters = ( (SfxBoolItem&) aSet.Get( ATTR_PRESLAYOUT_CHECK_MASTERS ) ).GetValue();
if (aSet.GetItemState(ATTR_PRESLAYOUT_NAME) == SFX_ITEM_SET)
aFile = ((SfxStringItem&)aSet.Get(ATTR_PRESLAYOUT_NAME)).GetValue();
}
break;
2000-09-18 16:07:07 +00:00
default:
bError = sal_True;
}
delete pDlg;
2000-09-18 16:07:07 +00:00
}
if (!bError)
{
mpDocSh->SetWaitCursor( sal_True );
2000-09-18 16:07:07 +00:00
// Hier werden nur Masterpages ausgewechselt, d.h. die aktuelle Seite
// bleibt aktuell. Damit beim Ein- und Ausfuegen der Masterpages nicht
// dauernd via PageOrderChangedHint die Methode ResetActualPage gerufen
// wird, wird jetzt blockiert.
// That isn't quitely right. If the masterpageview is active and you are
// removing a masterpage, it's possible that you are removing the
// current masterpage. So you have to call ResetActualPage !
if( mpViewShell->ISA(DrawViewShell) && !bCheckMasters )
static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(sal_True);
2000-09-18 16:07:07 +00:00
if (bLoad)
{
String aFileName = aFile.GetToken( 0, DOCUMENT_TOKEN );
SdDrawDocument* pTempDoc = mpDoc->OpenBookmarkDoc( aFileName );
2000-09-18 16:07:07 +00:00
// #69581: If I chosed the standard-template I got no filename and so I get no
// SdDrawDocument-Pointer. But the method SetMasterPage is able to handle
// a NULL-pointer as a Standard-template ( look at SdDrawDocument::SetMasterPage )
String aLayoutName;
if( pTempDoc )
aLayoutName = aFile.GetToken( 1, DOCUMENT_TOKEN );
2000-09-18 16:07:07 +00:00
mpDoc->SetMasterPage(nSelectedPage, aLayoutName, pTempDoc, bMasterPage, bCheckMasters);
mpDoc->CloseBookmarkDoc();
2000-09-18 16:07:07 +00:00
}
else
{
// MasterPage mit dem LayoutNamen aFile aus aktuellem Doc verwenden
mpDoc->SetMasterPage(nSelectedPage, aFile, mpDoc, bMasterPage, bCheckMasters);
2000-09-18 16:07:07 +00:00
}
// Blockade wieder aufheben
if (mpViewShell->ISA(DrawViewShell) && !bCheckMasters )
static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(sal_False);
2000-09-18 16:07:07 +00:00
/*************************************************************************
|* Falls dargestellte Masterpage sichtbar war, neu darstellen
\************************************************************************/
if (!bError && nSelectedPage != SDRPAGE_NOTFOUND)
{
if (bOnMaster)
{
if (mpViewShell->ISA(DrawViewShell))
2000-09-18 16:07:07 +00:00
{
::sd::View* pView =
static_cast<DrawViewShell*>(mpViewShell)->GetView();
sal_uInt16 nPgNum = pSelectedPage->TRG_GetMasterPage().GetPageNum();
2000-09-18 16:07:07 +00:00
if (static_cast<DrawViewShell*>(mpViewShell)->GetPageKind() == PK_NOTES)
2000-09-18 16:07:07 +00:00
nPgNum++;
pView->HideSdrPage();
pView->ShowSdrPage(pView->GetModel()->GetMasterPage(nPgNum));
2000-09-18 16:07:07 +00:00
}
// damit TabBar aktualisiert wird
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_MASTERPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
2000-09-18 16:07:07 +00:00
}
else
{
pSelectedPage->SetAutoLayout(pSelectedPage->GetAutoLayout());
2000-09-18 16:07:07 +00:00
}
}
// fake a mode change to repaint the page tab bar
if( mpViewShell && mpViewShell->ISA( DrawViewShell ) )
{
DrawViewShell* pDrawViewSh =
static_cast<DrawViewShell*>(mpViewShell);
EditMode eMode = pDrawViewSh->GetEditMode();
sal_Bool bLayer = pDrawViewSh->IsLayerModeActive();
pDrawViewSh->ChangeEditMode( eMode, !bLayer );
pDrawViewSh->ChangeEditMode( eMode, bLayer );
}
mpDocSh->SetWaitCursor( sal_False );
2000-09-18 16:07:07 +00:00
}
}
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */