/* -*- 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 .
*/
bool lcl_SuffixIsUser(std::u16string_view rString)
{ // Interesting, why the rest must be longer than 1 character? It is so // since commit 4fbc9dd48b7cebb304010e7337b1bbc3936c7923 (2001-08-16) return rString.size() > 8 && o3tl::ends_with(rString, u" (user)");
}
switch ( eFlags )
{ case SwGetPoolIdFromName::TxtColl: return TablePair<GetParaMap>::getMap(bProgName); case SwGetPoolIdFromName::ChrFmt: return TablePair<GetCharMap>::getMap(bProgName); case SwGetPoolIdFromName::FrmFmt: return TablePair<GetFrameMap>::getMap(bProgName); case SwGetPoolIdFromName::PageDesc: return TablePair<GetPageMap>::getMap(bProgName); case SwGetPoolIdFromName::NumRule: return TablePair<GetNumRuleMap>::getMap(bProgName); case SwGetPoolIdFromName::TableStyle: return TablePair<GetTableStyleMap>::getMap(bProgName); case SwGetPoolIdFromName::CellStyle: return TablePair<GetCellStyleMap>::getMap(bProgName);
}
assert(false); // must not reach here
abort();
}
// This gets the UI name from the programmatic name
UIName SwStyleNameMapper::GetUIName(const ProgName& rName,
SwGetPoolIdFromName const eFlags)
{
sal_uInt16 nId = GetPoolIdFromProgName ( rName, eFlags ); return nId != USHRT_MAX ? GetUIName( nId, rName ) : UIName(rName.toString());
}
// Get the programmatic name from the UI name
ProgName SwStyleNameMapper::GetProgName( const UIName& rName, SwGetPoolIdFromName const eFlags)
{
sal_uInt16 nId = GetPoolIdFromUIName ( rName, eFlags ); return nId != USHRT_MAX ? GetProgName( nId, rName ) : ProgName(rName.toString());
}
// Get the programmatic name from the UI name in rName and put it into rFillName void SwStyleNameMapper::FillProgName( const UIName& rName, ProgName& rFillName,
SwGetPoolIdFromName const eFlags)
{
sal_uInt16 nId = GetPoolIdFromUIName ( rName, eFlags ); if ( nId == USHRT_MAX )
{ // rName isn't in our UI name table...check if it's in the programmatic one
nId = GetPoolIdFromProgName ( ProgName(rName.toString()), eFlags );
rFillName = ProgName(rName.toString()); if (nId == USHRT_MAX )
{ if (eFlags != SwGetPoolIdFromName::TableStyle)
{ // check if it has a " (user)" suffix, if so remove it
lcl_CheckSuffixAndDelete(rFillName);
} else// FIXME don't do this
{ // It isn't ...make sure the suffix isn't already " (user)"...if it is, // we need to add another one if (lcl_SuffixIsUser(rFillName.toString()))
rFillName = ProgName(rFillName.toString() + " (user)");
}
} else
{ // It's in the programmatic name table...append suffix
rFillName = ProgName(rFillName.toString() + " (user)");
}
} else
{ // If we aren't trying to disambiguate, then just do a normal fill
fillProgNameFromId(nId, rFillName);
}
// Get the UI name from the programmatic name in rName and put it into rFillName void SwStyleNameMapper::FillUIName( const ProgName& rName, UIName& rFillName,
SwGetPoolIdFromName const eFlags)
{
ProgName aName = rName; if (eFlags == SwGetPoolIdFromName::ChrFmt && rName == "Standard")
aName = ProgName(SwResId(STR_POOLCHR_STANDARD));
sal_uInt16 nId = GetPoolIdFromProgName ( aName, eFlags ); if ( nId == USHRT_MAX )
{
rFillName = UIName(aName.toString()); // TabStyle: unfortunately ODF documents with UIName table styles exist if (eFlags == SwGetPoolIdFromName::TableStyle || // see testTdf129568ui
GetPoolIdFromUIName(UIName(aName.toString()), eFlags) == USHRT_MAX)
{ // aName isn't in our Prog name table...check if it has a " (user)" suffix, if so remove it
lcl_CheckSuffixAndDelete(rFillName);
} else
{
rFillName = UIName(rFillName.toString() + " (user)");
}
} else
{ // If we aren't trying to disambiguate, then just do a normal fill
fillUINameFromId(nId, rFillName);
}
}
// Get the UI name from the pool ID void SwStyleNameMapper::FillUIName(sal_uInt16 const nId, UIName& rFillName)
{
fillUINameFromId(nId, rFillName);
}
// Get the UI name from the pool ID
UIName SwStyleNameMapper::GetUIName(
sal_uInt16 const nId, const ProgName& rName)
{ return UIName(getNameFromId(nId, rName.toString(), false));
}
// Get the programmatic name from the pool ID void SwStyleNameMapper::FillProgName(sal_uInt16 nId, ProgName& rFillName)
{
fillProgNameFromId(nId, rFillName);
}
// Get the programmatic name from the pool ID
ProgName
SwStyleNameMapper::GetProgName(sal_uInt16 const nId, const UIName& rName)
{ return ProgName(getNameFromId(nId, rName.toString(), true));
}
// This gets the PoolId from the UI Name
sal_uInt16 SwStyleNameMapper::GetPoolIdFromUIName( const UIName& rName, SwGetPoolIdFromName const eFlags)
{ const NameToIdHash & rHashMap = getHashTable ( eFlags, false );
NameToIdHash::const_iterator aIter = rHashMap.find(rName.toString()); return aIter != rHashMap.end() ? (*aIter).second : USHRT_MAX;
}
// Get the Pool ID from the programmatic name
sal_uInt16 SwStyleNameMapper::GetPoolIdFromProgName( const ProgName& rName, SwGetPoolIdFromName const eFlags)
{ const NameToIdHash & rHashMap = getHashTable ( eFlags, true );
NameToIdHash::const_iterator aIter = rHashMap.find(rName.toString()); return aIter != rHashMap.end() ? (*aIter).second : USHRT_MAX;
}
// Hard coded Programmatic Name tables
/// returns an empty array because Cell Names aren't translated const std::vector<OUString>& SwStyleNameMapper::GetCellStyleUINameArray()
{ staticconst std::vector<OUString> s_aCellStyleUINameArray; return s_aCellStyleUINameArray;
}
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.