/* -*- 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 .
*/
SvtViewOptions::SvtViewOptions( EViewType eType, OUString sViewName )
: m_eViewType ( eType )
, m_sViewName (std::move( sViewName ))
{
(void)m_eViewType; // so the release build does not complain, since we only use it in assert // we must know, which view type we must support switch( eType )
{ case EViewType::Dialog: m_sListName = "Dialogs"; break; case EViewType::TabDialog: m_sListName = "TabDialogs"; break; case EViewType::TabPage: m_sListName = "TabPages"; break; case EViewType::Window: m_sListName = "Windows"; break; default: assert(false);
} if (comphelper::IsFuzzing()) return;
/*-************************************************************************************************************ @short checks for already existing entries @descr If user don't know, if an entry already exist - he can get this information by calling this method.
@seealso member m_aList
@param "sName", name of entry to check exist state @return true , if item exist false, otherwise
*/ bool SvtViewOptions::Exists() const
{ bool bExists = false;
/*-************************************************************************************************************ @short delete entry @descr Use it to delete set entry by given name.
@seealso member m_aList
@param "sName", name of entry to delete it
*/ void SvtViewOptions::Delete()
{ try
{
css::uno::Reference< css::container::XNameContainer > xSet(m_xSet, css::uno::UNO_QUERY_THROW);
xSet->removeByName(m_sViewName);
::comphelper::ConfigurationHelper::flush(m_xRoot);
} catch(const css::container::NoSuchElementException&)
{ } catch(const css::uno::Exception&)
{
TOOLS_WARN_EXCEPTION("unotools", "Unexpected exception");
}
}
// public method
/*-************************************************************************************************************ @short read/write access to cache view items and her properties @descr Follow methods support read/write access to all cache view items.
/*-************************************************************************************************************ @short ctor @descr We use it to open right configuration file and let configuration objects fill her caches. Then we read all existing entries from right list and cached it inside our object too. Normally we should enable notifications for changes on these values too ... but these feature isn't full implemented in the moment.
OUString SvtViewOptions::GetPageID() const
{ // Safe impossible cases. // These call isn't allowed for dialogs, tab-pages or windows!
assert( m_eViewType == EViewType::TabDialog && "SvtViewOptions::GetPageID()\nCall not allowed for Dialogs, TabPages or Windows! I do nothing!" );
void SvtViewOptions::SetPageID(const OUString& rID)
{ // Safe impossible cases. // These call isn't allowed for dialogs, tab-pages or windows!
assert( m_eViewType == EViewType::TabDialog && "SvtViewOptions::SetPageID()\nCall not allowed for Dialogs, TabPages or Windows! I do nothing!" );
bool SvtViewOptions::IsVisible() const
{ // Safe impossible cases. // These call isn't allowed for dialogs, tab-dialogs or tab-pages!
assert( m_eViewType == EViewType::Window && "SvtViewOptions::IsVisible()\nCall not allowed for Dialogs, TabDialogs or TabPages! I do nothing!" );
void SvtViewOptions::SetVisible( bool bVisible )
{ // Safe impossible cases. // These call isn't allowed for dialogs, tab-dialogs or tab-pages!
assert(m_eViewType == EViewType::Window && "SvtViewOptions::SetVisible()\nCall not allowed for Dialogs, TabDialogs or TabPages! I do nothing!" );
bool SvtViewOptions::HasVisible() const
{ // Safe impossible cases. // These call isn't allowed for dialogs, tab-dialogs or tab-pages!
assert( m_eViewType == EViewType::Window && "SvtViewOptions::IsVisible()\nCall not allowed for Dialogs, TabDialogs or TabPages! I do nothing!" );
return GetVisible() != STATE_NONE;
}
css::uno::Sequence< css::beans::NamedValue > SvtViewOptions::GetUserData() const
{ try
{
css::uno::Reference< css::container::XNameAccess > xNode(
impl_getSetNode(m_sViewName, false),
css::uno::UNO_QUERY); // no _THROW ! because we don't create missing items here. So we have to live with zero references .-)
css::uno::Reference< css::container::XNameAccess > xUserData; if (xNode.is())
xNode->getByName(PROPERTY_USERDATA) >>= xUserData; if (xUserData.is())
{ const css::uno::Sequence<OUString> lNames = xUserData->getElementNames();
sal_Int32 c = lNames.getLength();
css::uno::Sequence< css::beans::NamedValue > lUserData(c);
/*-************************************************************************************************************ @short create new set node with default values on disk @descr To create a new UserData item - the super node of these property must already exist! You can call this method to create these new entry with default values and change UserData then.
@seealso method impl_writeDirectProp()
@param "sNode", name of new entry
*/
css::uno::Reference< css::uno::XInterface > SvtViewOptions::impl_getSetNode( const OUString& sNode , bool bCreateIfMissing) const
{
css::uno::Reference< css::uno::XInterface > xNode;
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.