Files
core/PdfWriter/Src/Destination.cpp
Alexander.Trofimov 01a3fd5efc to utf8
2016-06-23 16:47:17 +03:00

122 lines
2.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "Destination.h"
#include "Pages.h"
namespace PdfWriter
{
//----------------------------------------------------------------------------------------
// CDestination
//----------------------------------------------------------------------------------------
CDestination::CDestination(CPage* pPage, CXref* pXref)
{
pXref->Add(this);
// Первый элемент массива должен быть страницей, которой принадлежит объект
Add((CObjectBase*)pPage);
Add("Fit"); // Значение по умолчанию Fit
}
bool CDestination::IsValid() const
{
if (m_arrList.size() < 2)
return false;
CObjectBase* pObject = Get(0, false);
if (object_type_DICT != pObject->GetType() || dict_type_PAGE != ((CDictObject*)pObject)->GetDictType())
return false;
return true;
}
void CDestination::PrepareArray()
{
CPage* pPage = (CPage*)Get(0);
if (m_arrList.size() > 1)
{
Clear();
Add((CObjectBase*)pPage);
}
}
void CDestination::SetXYZ(float fLeft, float fTop, float fZoom)
{
if (!IsValid())
return;
// Если параметр приближения задан некорректно, тогда оставляем его нетронутым(что соответствует значению 0)
if (fZoom < 0.08 || fZoom > 32)
fZoom = 0;
fLeft = std::max(fLeft, 0.f);
fTop = std::max(fTop, 0.f);
PrepareArray();
Add("XYZ");
Add(fLeft);
Add(fTop);
Add(fZoom);
}
void CDestination::SetFit()
{
if (!IsValid())
return;
PrepareArray();
Add("Fit");
}
void CDestination::SetFitH(float fTop)
{
if (!IsValid())
return;
PrepareArray();
Add("FitH");
Add(fTop);
}
void CDestination::SetFitV(float fLeft)
{
if (!IsValid())
return;
PrepareArray();
Add("FitV");
Add(fLeft);
}
void CDestination::SetFitR(float fLeft, float fBottom, float fRight, float fTop)
{
if (!IsValid())
return;
PrepareArray();
Add("FitR");
Add(fLeft);
Add(fBottom);
Add(fRight);
Add(fTop);
}
void CDestination::SetFitB()
{
if (!IsValid())
return;
PrepareArray();
Add("FitB");
}
void CDestination::SetFitBH(float fTop)
{
if (!IsValid())
return;
PrepareArray();
Add("FitBH");
Add(fTop);
}
void CDestination::SetFitBV(float fLeft)
{
if (!IsValid())
return;
PrepareArray();
Add("FitBV");
Add(fLeft);
}
}