/* -*- 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 .
*/
// set a default value if ( LOCALE_IDEFAULTCODEPAGE == lctype )
{
winCP = OUString::number( static_cast<sal_Int32>(GetOEMCP( )) );
} elseif ( LOCALE_IDEFAULTANSICODEPAGE == lctype )
{
winCP = OUString::number( static_cast<sal_Int32>(GetACP( )) );
} else
OSL_ASSERT( false );
// First, get required buffer size, in characters int nResult = GetLocaleInfoW(
lcid, lctype, nullptr, 0 );
OSL_ASSERT( nResult );
if ( nResult )
{
std::unique_ptr<wchar_t[]> buff( newwchar_t[nResult] ); // Now get the actual data
nResult = GetLocaleInfoW( lcid, lctype, buff.get(), nResult );
OSL_ASSERT(nResult);
if (nResult)
winCP = o3tl::toU( buff.get() );
}
return winCP;
}
// returns a mime charset parameter value appropriate // to the given codepage, optional a prefix can be // given, e.g. "windows-" or "cp"
// returns a mime charset parameter value appropriate // to the given locale id and locale type, optional a // prefix can be given, e.g. "windows-" or "cp"
// OleStdCopyTargetDevice() // // Purpose: // duplicate a TARGETDEVICE struct. this function allocates memory for // the copy. the caller MUST free the allocated copy when done with it // using the standard allocator returned from CoGetMalloc. // (OleStdFree can be used to free the copy). // // Parameters: // ptdSrc pointer to source TARGETDEVICE // // Return Value: // pointer to allocated copy of ptdSrc // if ptdSrc==NULL then returns NULL is returned. // if ptdSrc!=NULL and memory allocation fails, then NULL is returned
DVTARGETDEVICE* CopyTargetDevice( DVTARGETDEVICE* ptdSrc )
{
DVTARGETDEVICE* ptdDest = nullptr;
// OleStdCopyFormatEtc() // // Purpose: // Copies the contents of a FORMATETC structure. this function takes // special care to copy correctly copying the pointer to the TARGETDEVICE // contained within the source FORMATETC structure. // if the source FORMATETC has a non-NULL TARGETDEVICE, then a copy // of the TARGETDEVICE will be allocated for the destination of the // FORMATETC (petcDest). // // NOTE: the caller MUST free the allocated copy of the TARGETDEVICE // within the destination FORMATETC when done with it // using the standard allocator returned from CoGetMalloc. // (OleStdFree can be used to free the copy). // // Parameters: // petcDest pointer to destination FORMATETC // petcSrc pointer to source FORMATETC // // Return Value: // returns TRUE if copy was successful; // returns FALSE if not successful, e.g. one or both of the pointers // were invalid or the pointers were equal bool CopyFormatEtc( LPFORMATETC petcDest, LPFORMATETC petcSrc )
{ bool bRet = false;
// returns: // 1 for exact match, // 0 for no match, // -1 for partial match (which is defined to mean the left is a subset // of the right: fewer aspects, null target device, fewer medium).
elseif ( pFetcLhs->dwAspect == pFetcRhs->dwAspect ) // same aspects; equal
; elseif ( ( pFetcLhs->dwAspect & ~pFetcRhs->dwAspect ) != 0 )
{ // left not subset of aspects of right; not equal
nMatch = FORMATETC_NO_MATCH;
} else // left subset of right
nMatch = FORMATETC_PARTIAL_MATCH;
if ( nMatch == FORMATETC_EXACT_MATCH || nMatch == FORMATETC_PARTIAL_MATCH )
{ if ( pFetcLhs->tymed == pFetcRhs->tymed ) // same medium flags; equal
; elseif ( ( pFetcLhs->tymed & ~pFetcRhs->tymed ) != 0 )
{ // left not subset of medium flags of right; not equal
nMatch = FORMATETC_NO_MATCH;
} else // left subset of right
nMatch = FORMATETC_PARTIAL_MATCH;
}
}
}
__except( EXCEPTION_EXECUTE_HANDLER )
{
OSL_FAIL( "Error CompareFormatEtc" );
nMatch = FORMATETC_NO_MATCH;
}
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.