/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// get DesignMode from model bool bInitDesignMode = pFormModel->GetOpenInDesignMode(); if ( pFormModel->OpenInDesignModeIsDefaulted( ) )
{ // this means that nobody ever explicitly set this on the model, and the model has never // been loaded from a stream. // This means this is a newly created document. This means, we want to have it in design // mode by default (though a newly created model returns true for GetOpenInDesignMode). // We _want_ to have this because it makes a lot of hacks following the original fix
DBG_ASSERT( !bInitDesignMode, "FmFormView::Init: doesn't the model default to FALSE anymore?" ); // if this asserts, either the on-construction default in the model has changed (then this here // may not be necessary anymore), or we're not dealing with a new document...
bInitDesignMode = true;
}
// look up the PageViewWindow for the newly inserted window, and care for it // #i39269# / 2004-12-20 / frank.schoenheit@sun.com const SdrPageWindow* pPageWindow = findPageWindow( this, &rNewDev ); if ( pPageWindow )
m_pImpl->addWindow( *pPageWindow );
}
void FmFormView::ChangeDesignMode(bool bDesign)
{ if (bDesign == IsDesignMode()) return;
FmFormModel* pModel = dynamic_cast<FmFormModel*>(&GetModel()); if (pModel)
{ // For the duration of the transition the Undo-Environment is disabled. This ensures that non-transient Properties can // also be changed (this should be done with care and also reversed before switching the mode back. An example is the // setting of the maximal length of the text by FmXEditModel on its control.)
pModel->GetUndoEnv().Lock();
}
// --- 1. deactivate all controls if we are switching to design mode if ( bDesign )
DeactivateControls( GetSdrPageView() );
// --- 2. simulate a deactivation (the shell will handle some things there ...?) if ( m_pFormShell && m_pFormShell->GetImpl() )
m_pFormShell->GetImpl()->viewDeactivated_Lock(*this); else
m_pImpl->Deactivate();
// --- 3. activate all controls, if we're switching to alive mode if ( !bDesign )
ActivateControls( GetSdrPageView() );
// --- 4. load resp. unload the forms
FmFormPage* pCurPage = GetCurPage(); if ( pCurPage )
{ if ( m_pFormShell && m_pFormShell->GetImpl() )
m_pFormShell->GetImpl()->loadForms_Lock(pCurPage, (bDesign ? LoadFormsFlags::Unload : LoadFormsFlags::Load));
}
// --- 5. base class functionality
SetDesignMode( bDesign );
// --- 6. simulate an activation (the shell will handle some things there ...?)
OSL_PRECOND( m_pFormShell && m_pFormShell->GetImpl(), "FmFormView::ChangeDesignMode: is this really allowed? No shell?" ); if ( m_pFormShell && m_pFormShell->GetImpl() )
m_pFormShell->GetImpl()->viewActivated_Lock(*this); else
m_pImpl->Activate();
if ( pCurPage )
{ if ( bDesign )
{ if ( GetActualOutDev() && GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW )
{ const vcl::Window* pWindow = GetActualOutDev()->GetOwnerWindow(); const_cast< vcl::Window* >( pWindow )->GrabFocus();
}
// redraw UNO objects if ( GetSdrPageView() )
{
SdrObjListIter aIter(pCurPage); while( aIter.IsMore() )
{
SdrObject* pObj = aIter.Next(); if (pObj && pObj->IsUnoObj())
{ // For redraw just use ActionChanged() // pObj->BroadcastObjectChange();
pObj->ActionChanged();
}
}
}
} else
{ // set the auto focus to the first control (if indicated by the model to do so) bool bForceControlFocus = pModel && pModel->GetAutoControlFocus(); if (bForceControlFocus)
m_pImpl->AutoFocus();
}
}
// Unlock Undo-Environment if (pModel)
pModel->GetUndoEnv().UnLock();
}
void FmFormView::GrabFirstControlFocus()
{ if ( !IsDesignMode() )
m_pImpl->AutoFocus();
}
// so that the form navigator can react to the pagechange
m_pFormShell->GetViewShell()->GetViewFrame().GetBindings().Invalidate(SID_FM_FMEXPLORER_CONTROL, true);
// notify our shell that we have been activated if ( m_pFormShell && m_pFormShell->GetImpl() )
m_pFormShell->GetImpl()->viewActivated_Lock(*this); else
m_pImpl->Activate();
// --- 2. tell the shell the view is (going to be) deactivated if ( m_pFormShell && m_pFormShell->GetImpl() )
m_pFormShell->GetImpl()->viewDeactivated_Lock(*this); else
m_pImpl->Deactivate();
// --- 3. base class behavior
E3dView::HideSdrPage();
}
void FmFormView::ActivateControls(SdrPageView const * pPageView)
{ if (!pPageView) return;
for (sal_uInt32 i = 0; i < pPageView->PageWindowCount(); ++i)
{ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i);
m_pImpl->addWindow(rPageWindow);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.