phonebookui/Phonebook/View/src/CPbkPhoneNumberDefaultFormatter.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 25 May 2010 12:26:45 +0300
branchRCL_3
changeset 12 4ae315f230bc
parent 0 e686773b3f54
permissions -rw-r--r--
Revision: 201019 Kit: 2010121

/*
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*       Default Phonebook phone number formatter.
*
*/


// INCLUDE FILES
#include "CPbkPhoneNumberDefaultFormatter.h"
#include <AknUtils.h>


// ================= MEMBER FUNCTIONS =======================

inline CPbkPhoneNumberDefaultFormatter::CPbkPhoneNumberDefaultFormatter()
	{
	}

inline void CPbkPhoneNumberDefaultFormatter::ConstructL
        (TInt aMaxPhoneNumberDisplayLength)
    {
    iFormatterNumberBuffer = HBufC::NewL(aMaxPhoneNumberDisplayLength);
    }

CPbkPhoneNumberDefaultFormatter* CPbkPhoneNumberDefaultFormatter::NewL
        (TInt aMaxPhoneNumberDisplayLength)
    {
    CPbkPhoneNumberDefaultFormatter* self = new(ELeave) CPbkPhoneNumberDefaultFormatter;
    CleanupStack::PushL(self);
    self->ConstructL(aMaxPhoneNumberDisplayLength);
    CleanupStack::Pop(self);
    return self;
    }

CPbkPhoneNumberDefaultFormatter::~CPbkPhoneNumberDefaultFormatter()
	{
    delete iFormatterNumberBuffer;
	}

void CPbkPhoneNumberDefaultFormatter::SetMaxBufferLengthL
		(TInt aMaxLength)
	{
    if (aMaxLength > iFormatterNumberBuffer->Des().MaxLength())
        {
        iFormatterNumberBuffer = iFormatterNumberBuffer->ReAllocL(aMaxLength);
        }
	}

TPtrC CPbkPhoneNumberDefaultFormatter::FormatPhoneNumberForDisplay
		(const TDesC& aOriginalPhoneNumber)
	{
    // convert number according to active number setting
    if (aOriginalPhoneNumber.Length() <= iFormatterNumberBuffer->Des().MaxLength())
        {
        TPtr formatterNumber = iFormatterNumberBuffer->Des();
        formatterNumber.Copy(aOriginalPhoneNumber);
        AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formatterNumber);
        return formatterNumber;
        }
    else
        {
    	return aOriginalPhoneNumber;
        }
	}


// End of File